mirror of https://gitgud.io/fatchan/jschan.git
parent
339a743b1b
commit
8d82cad62d
17 changed files with 133 additions and 49 deletions
@ -0,0 +1,40 @@ |
||||
'use strict'; |
||||
|
||||
const cache = require(__dirname+'/../../redis.js') |
||||
, { enableWebring } = require(__dirname+'/../../configs/main.json') |
||||
, { Boards } = require(__dirname+'/../../db/') |
||||
, limit = 20; |
||||
|
||||
module.exports = async (req, res, next) => { |
||||
|
||||
let page; |
||||
if (req.query.page && !isNaN(parseInt(req.query.page))) { |
||||
page = parseInt(req.query.page) || 1; //or 1 prevent 0 page
|
||||
} else { |
||||
page = 1; |
||||
} |
||||
const offset = (page-1) * limit; |
||||
let boards, webringBoards, localPages, webringPages; |
||||
try { |
||||
[ boards, webringBoards, localPages ] = await Promise.all([ |
||||
Boards.boardSort(offset, limit), |
||||
enableWebring ? cache.get('webring:boards') : null, |
||||
Boards.count(), |
||||
]); |
||||
} catch (err) { |
||||
return next(err); |
||||
} |
||||
localPages = Math.ceil(localPages / limit); |
||||
if (enableWebring && webringBoards) { //sort webring boards
|
||||
webringPages = Math.ceil(webringBoards.length / limit); |
||||
webringBoards = webringBoards.sort((a, b) => { return b.uniqueUsers - a.uniqueUsers }).splice(offset, limit); |
||||
} |
||||
const maxPage = Math.max(localPages, webringPages); |
||||
return res.render('boardlist', { |
||||
boards, |
||||
webringBoards, |
||||
page, |
||||
maxPage |
||||
}); |
||||
|
||||
} |
@ -0,0 +1,9 @@ |
||||
| Page: |
||||
if maxPage === 0 |
||||
a.bold(href='?page=1') [1] |
||||
- for(let i = 1; i <= maxPage; i++) |
||||
if page === i |
||||
a.bold(href=`?page=${i}`) [#{i}] |
||||
else |
||||
a(href=`?page=${i}`) [#{i}] |
||||
| |
@ -0,0 +1,10 @@ |
||||
| Page: |
||||
if maxPage === 0 |
||||
a.bold(href=`index.html`) [1] |
||||
- for(let i = 1; i <= maxPage; i++) |
||||
if page === i |
||||
a.bold(href=`${i === 1 ? 'index' : i}.html`) [#{i}] |
||||
else |
||||
a(href=`${i === 1 ? 'index' : i}.html`) [#{i}] |
||||
| |
||||
| | |
@ -0,0 +1,8 @@ |
||||
.table-container.flex-center.mv-10.text-center |
||||
table.boardtable |
||||
tr |
||||
th Board |
||||
th Description |
||||
th.help(title='Posts in the last hour') PPH |
||||
th.help(title='Unique posters in the last 24h') Users |
||||
th Posts |
@ -1,10 +0,0 @@ |
||||
| Page: |
||||
if maxPage === 0 |
||||
a.bold(href=`/${board._id}/index.html`) [1] |
||||
- for(let i = 1; i <= maxPage; i++) |
||||
if page === i |
||||
a.bold(href=`/${board._id}/${i === 1 ? 'index' : i}.html`) [#{i}] |
||||
else |
||||
a(href=`/${board._id}/${i === 1 ? 'index' : i}.html`) #{i} |
||||
| |
||||
| | |
@ -1,13 +1,13 @@ |
||||
mixin globalmanagenav(selected) |
||||
nav.pages |
||||
a(href=`/globalmanage/reports.html` class=(selected === 'reports' ? 'bold' : '')) [Reports] |
||||
a(href='reports.html' class=(selected === 'reports' ? 'bold' : '')) [Reports] |
||||
| |
||||
a(href=`/globalmanage/bans.html` class=(selected === 'bans' ? 'bold' : '')) [Bans] |
||||
a(href='bans.html' class=(selected === 'bans' ? 'bold' : '')) [Bans] |
||||
| |
||||
a(href=`/globalmanage/recent.html` class=(selected === 'recent' ? 'bold' : '')) [Recent] |
||||
a(href='recent.html' class=(selected === 'recent' ? 'bold' : '')) [Recent] |
||||
if permLevel === 0 |
||||
| |
||||
a(href=`/globalmanage/accounts.html` class=(selected === 'accounts' ? 'bold' : '')) [Accounts] |
||||
a(href='accounts.html' class=(selected === 'accounts' ? 'bold' : '')) [Accounts] |
||||
| |
||||
a(href=`/globalmanage/news.html` class=(selected === 'news' ? 'bold' : '')) [News] |
||||
a(href='news.html' class=(selected === 'news' ? 'bold' : '')) [News] |
||||
|
||||
|
@ -1,10 +1,10 @@ |
||||
mixin managenav(selected) |
||||
nav.pages |
||||
a(href=`/${board._id}/manage/reports.html` class=(selected === 'reports' ? 'bold' : '')) [Reports] |
||||
a(href='reports.html' class=(selected === 'reports' ? 'bold' : '')) [Reports] |
||||
| |
||||
a(href=`/${board._id}/manage/bans.html` class=(selected === 'bans' ? 'bold' : '')) [Bans] |
||||
a(href='bans.html' class=(selected === 'bans' ? 'bold' : '')) [Bans] |
||||
| |
||||
if permLevel < 3 |
||||
a(href=`/${board._id}/manage/settings.html` class=(selected === 'settings' ? 'bold' : '')) [Settings] |
||||
a(href='settings.html' class=(selected === 'settings' ? 'bold' : '')) [Settings] |
||||
| |
||||
a(href=`/${board._id}/manage/banners.html` class=(selected === 'banners' ? 'bold' : '')) [Banners] |
||||
a(href='banners.html' class=(selected === 'banners' ? 'bold' : '')) [Banners] |
||||
|
@ -0,0 +1,36 @@ |
||||
extends ../layout.pug |
||||
|
||||
block head |
||||
script(src='/js/theme.js') |
||||
title #{meta.siteName} |
||||
|
||||
block content |
||||
h1.board-title Board List |
||||
if boards && boards.length > 0 |
||||
h4.board-description Local Boards |
||||
include ../includes/boardtable.pug |
||||
each board in boards |
||||
tr |
||||
td |
||||
if board.settings.sfw |
||||
span.help(title='Safe for work') 💼 |
||||
a(href=`/${board._id}/index.html`) /#{board._id}/ - #{board.settings.name} |
||||
td #{board.settings.description} |
||||
td #{board.pph} |
||||
td #{board.ips} |
||||
td #{board.sequence_value-1} |
||||
if webringBoards && webringBoards.length > 0 |
||||
h4.board-description Webring Boards |
||||
include ../includes/boardtable.pug |
||||
each board in webringBoards |
||||
tr |
||||
td |
||||
if !board.nsfw |
||||
span.help(title='Safe for work') 💼 |
||||
a(href=board.path) #{board.siteName} /#{board.uri}/ - #{board.title} |
||||
td #{board.subtitle || '-'} |
||||
td #{board.postsPerHour || '-'} |
||||
td #{board.uniqueUsers || '-'} |
||||
td #{board.totalPosts || '-'} |
||||
nav.pages.text-center |
||||
include ../includes/boardlistpages.pug |
Loading…
Reference in new issue