Overboard catalog reference #286

merge-requests/208/head
Thomas Lynch 4 years ago
parent 7e705b2ea9
commit 77b8ae5540
  1. 4
      configs/main.js.example
  2. 5
      controllers/pages.js
  3. 37
      db/posts.js
  4. 2
      gulpfile.js
  5. 1
      models/pages/index.js
  6. 26
      models/pages/overboardcatalog.js
  7. 2
      views/includes/navbar.pug
  8. 9
      views/mixins/catalogtile.pug
  9. 2
      views/pages/boardlist.pug
  10. 2
      views/pages/catalog.pug
  11. 3
      views/pages/overboard.pug
  12. 29
      views/pages/overboardcatalog.pug

@ -101,8 +101,10 @@ module.exports = {
editPost: 30,
},
//how many threads to show on overboard
//how many threads to show on overboard index view
overboardLimit: 20,
//how many threads to show on overboard catalog view
overboardCatalogLimit: 50,
//cache templates in memory. disable only if editing templates and doing dev work
cacheTemplates: true,

@ -22,7 +22,7 @@ const express = require('express')
, { globalManageSettings, globalManageReports, globalManageBans, globalManageBoards,
globalManageRecent, globalManageAccounts, globalManageNews, globalManageLogs } = require(__dirname+'/../models/pages/globalmanage/')
, { changePassword, blockBypass, home, register, login, create,
board, catalog, banners, randombanner, news, captchaPage, overboard,
board, catalog, banners, randombanner, news, captchaPage, overboard, overboardCatalog,
captcha, thread, modlog, modloglist, account, boardlist } = require(__dirname+'/../models/pages/');
//homepage
@ -41,7 +41,8 @@ router.get('/:board/catalog.(html|json)', Boards.exists, catalog); //catalog
router.get('/:board/logs.html', Boards.exists, modloglist);//modlog list
router.get('/:board/logs/:date(\\d{2}-\\d{2}-\\d{4}).html', Boards.exists, paramConverter, modlog); //daily log
router.get('/:board/banners.html', Boards.exists, banners); //banners
router.get('/all.html', overboard); //overboard
router.get('/overboard.html', overboard); //overboard
router.get('/catalog.html', overboardCatalog); //overboard catalog view
router.get('/create.html', useSession, sessionRefresh, isLoggedIn, create); //create new board
router.get('/randombanner', randombanner); //random banner

@ -250,13 +250,32 @@ module.exports = {
}).toArray();
},
getCatalog: (board) => {
getCatalog: (board, sortSticky=true, catalogLimit=0) => {
const threadsQuery = {
thread: null,
}
if (board) {
if (Array.isArray(board)) {
//array for overboard catalog
threadsQuery['board'] = {
'$in': board
}
} else {
threadsQuery['board'] = board;
}
}
let threadsSort = {
'bumped': -1,
};
if (sortSticky === true) {
threadsSort = {
'sticky': -1,
'bumped': -1
}
}
// get all threads for catalog
return db.find({
'thread': null,
'board': board
}, {
return db.find(threadsQuery, {
'projection': {
'salt': 0,
'password': 0,
@ -264,10 +283,10 @@ module.exports = {
'reports': 0,
'globalreports': 0,
}
}).sort({
'sticky': -1,
'bumped': -1,
}).toArray();
})
.limit(catalogLimit)
.sort(threadsSort)
.toArray();
},

@ -218,6 +218,8 @@ async function cache() {
Redis.deletePattern('banners:*'),
Redis.deletePattern('users:*'),
Redis.deletePattern('blacklisted:*'),
Redis.deletePattern('overboard'),
Redis.deletePattern('catalog'),
]);
Redis.redisClient.quit();
}

@ -20,4 +20,5 @@ module.exports = {
modloglist: require(__dirname+'/modloglist.js'),
boardlist: require(__dirname+'/boardlist.js'),
overboard: require(__dirname+'/overboard.js'),
overboardCatalog: require(__dirname+'/overboardcatalog.js'),
}

@ -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,
});
}

@ -1,11 +1,11 @@
unless minimal
nav.navbar
a.nav-item(href='/index.html') Home
//a.nav-item(href='/all.html') Overboard
a.nav-item(href='/boards.html' style=(enableWebring ? 'line-height: 1.5em' : null))
| Boards
if enableWebring
.rainbow +Webring
a.nav-item(href='/overboard.html') Overboard
a.nav-item(href='/account.html') Account
if board
a.nav-item(href=`/${board._id}/manage/reports.html`) Manage

@ -1,4 +1,4 @@
mixin catalogtile(board, post, index)
mixin catalogtile(post, index)
.catalog-tile(data-board=post.board
data-post-id=post.postId
data-user-id=post.userId
@ -9,7 +9,7 @@ mixin catalogtile(board, post, index)
data-date=post.date
data-replies=post.replyposts
data-bump=post.bumped)
- const postURL = `/${board._id}/${modview ? 'manage/' : ''}thread/${post.postId}.html#${post.postId}`
- const postURL = `/${post.board}/${modview ? 'manage/' : ''}thread/${post.postId}.html#${post.postId}`
.post-info
input.left.post-check(type='checkbox', name='checkedposts' value=post.postId)
if modview
@ -20,8 +20,9 @@ mixin catalogtile(board, post, index)
span(title='Replies') R: #{post.replyposts}
| /
span(title='Files') F: #{post.replyfiles}
| /
span(title='Page') P: #{Math.ceil(index/10)}
if index
| /
span(title='Page') P: #{Math.ceil(index/10)}
if post.files.length > 0
.post-file-src
a(href=postURL)

@ -7,7 +7,7 @@ block content
h1.board-title Board List
h4.board-description
| or try the
a(href='/all.html') overboard
a(href='/overboard.html') overboard
.flexcenter.mv-10
form.form-post(action='/boards.html' method='GET')
input(type='hidden' value=page)

@ -36,7 +36,7 @@ block content
else
.catalog
for thread, i in threads
+catalogtile(board, thread, i+1)
+catalogtile(thread, i+1)
hr(size=1)
if modview
+managenav('catalog')

@ -6,8 +6,9 @@ block head
block content
.board-header
h1.board-title Overboard
h1.board-title Overboard Index
h4.board-description Recently bumped threads from all listed boards
a(href='/catalog.html') Catalog View
hr(size=1)
if threads.length === 0
p No posts.

@ -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…
Cancel
Save