mirror of https://gitgud.io/fatchan/jschan.git
Overboard catalog reference #286
parent
7e705b2ea9
commit
77b8ae5540
12 changed files with 102 additions and 20 deletions
@ -0,0 +1,26 @@ |
||||
'use strict'; |
||||
|
||||
const { Posts, Boards } = require(__dirname+'/../../db/') |
||||
, cache = require(__dirname+'/../../redis.js') |
||||
, { overboardCatalogLimit } = require(__dirname+'/../../configs/main.js'); |
||||
|
||||
module.exports = async (req, res, next) => { |
||||
|
||||
let threads = (await cache.get('catalog')) || []; |
||||
if (!threads || threads.length === 0) { |
||||
try { |
||||
const listedBoards = await Boards.getLocalListed(); |
||||
threads = await Posts.getCatalog(listedBoards, false, overboardCatalogLimit); |
||||
cache.set('catalog', threads, 60); |
||||
} catch (err) { |
||||
return next(err); |
||||
} |
||||
} |
||||
|
||||
res |
||||
.set('Cache-Control', 'public, max-age=60') |
||||
.render('overboardcatalog', { |
||||
threads, |
||||
}); |
||||
|
||||
} |
@ -0,0 +1,29 @@ |
||||
extends ../layout.pug |
||||
include ../mixins/catalogtile.pug |
||||
|
||||
block head |
||||
title Catalog |
||||
|
||||
|
||||
block content |
||||
.board-header |
||||
h1.board-title Overboard Catalog |
||||
h4.board-description Recently bumped threads from all listed boards |
||||
a(href='/overboard.html') Index View |
||||
include ../includes/stickynav.pug |
||||
.wrapbar |
||||
.pages.jsonly |
||||
input#catalogfilter(type='text' placeholder='Filter') |
||||
select.ml-5.right#catalogsort |
||||
option(value="" disabled selected hidden) Sort by |
||||
option(value="bump") Bump order |
||||
option(value="date") Creation date |
||||
option(value="replies") Reply count |
||||
hr(size=1) |
||||
if threads.length === 0 |
||||
p No posts. |
||||
else |
||||
.catalog |
||||
for thread, i in threads |
||||
+catalogtile(thread, false) |
||||
hr(size=1) |
Loading…
Reference in new issue