add sfw boards, update homepage and webring to support and show this

merge-requests/208/head
fatchan 5 years ago
parent 05dc5c8459
commit dd495b0e6d
  1. 1
      db/boards.js
  2. 4
      gulp/res/css/style.css
  3. 1
      models/forms/changeboardsettings.js
  4. 17
      schedules.js
  5. 4
      schedules/webring.js
  6. 12
      server.js
  7. 1
      socketio.js
  8. 20
      views/pages/home.pug
  9. 4
      views/pages/managesettings.pug

@ -115,6 +115,7 @@ module.exports = {
'sequence_value': 1,
'pph': 1,
'ips': 1,
'settings.sfw': 1,
'settings.description': 1,
'settings.name': 1,
}

@ -356,6 +356,10 @@ td, th {
cursor: pointer;
}
.help {
cursor: help;
}
#postform:target + .toggle-summary {
visibility: hidden;
}

@ -40,6 +40,7 @@ module.exports = async (req, res, next) => {
moderators,
'name': req.body.name && req.body.name.trim().length > 0 ? req.body.name : oldSettings.name,
'description': req.body.description && req.body.description.trim().length > 0 ? req.body.description : oldSettings.description,
'sfw': req.body.sfw ? true : false,
'unlisted': req.body.unlisted ? true : false,
'locked': req.body.locked ? true : false,
'early404': req.body.early404 ? true : false,

@ -16,16 +16,18 @@ const msTime = require(__dirname+'/helpers/mstime.js')
//delete files for expired captchas
const deleteCaptchas = require(__dirname+'/schedules/deletecaptchas.js');
setInterval(async () => {
await deleteCaptchas().catch(e => console.error);
deleteCaptchas().catch(e => console.error);
setInterval(() => {
deleteCaptchas().catch(e => console.error);
}, msTime.minute*5);
//update webring
if (enableWebring) {
const updateWebring = require(__dirname+'/schedules/webring.js');
setInterval(async () => {
await updateWebring().catch(e => console.error);
}, msTime.day);
updateWebring().catch(e => console.error);
setInterval(() => {
updateWebring().catch(e => console.error);
}, msTime.hour);
}
//update board stats and homepage
@ -41,8 +43,9 @@ const msTime = require(__dirname+'/helpers/mstime.js')
//file pruning
const pruneFiles = require(__dirname+'/schedules/prune.js');
setInterval(async () => {
await pruneFiles().catch(e => console.error);
pruneFiles().catch(e => console.error);
setInterval(() => {
pruneFiles().catch(e => console.error);
}, msTime.day);
})();

@ -2,7 +2,7 @@
const fetch = require('node-fetch')
, { meta } = require(__dirname+'/../configs/main.json')
, { following, blacklist } = require(__dirname+'/../configs/webring.json')
, { logos, following, blacklist } = require(__dirname+'/../configs/webring.json')
, { Boards } = require(__dirname+'/../db/')
, { outputFile } = require('fs-extra')
, cache = require(__dirname+'/../redis.js')
@ -44,6 +44,7 @@ module.exports = async () => {
name: meta.siteName,
url: meta.url,
endpoint: `${meta.url}/webring.json`,
logos,
following,
blacklist,
known,
@ -56,6 +57,7 @@ module.exports = async () => {
postsPerHour: b.pph,
totalPosts: b.sequence_value-1,
uniqueUsers: b.ips,
nsfw: !b.settings.sfw
};
}),
}

@ -32,7 +32,7 @@ const express = require('express')
const { redisClient } = require(__dirname+'/redis.js');
// connect socketio
console.log('CONNECTING TO SOCKETIO');
console.log('STARTING WEBSOCKET');
Socketio.connect(server);
// disable useless express header
@ -102,28 +102,28 @@ const express = require('express')
//listen
server.listen(configs.port, '127.0.0.1', () => {
new CachePugTemplates({ app, views }).start();
console.log(`listening on port ${configs.port}`);
console.log(`LISTENING ON :${configs.port}`);
//let PM2 know that this is ready for graceful reloads and to serialise startup
if (typeof process.send === 'function') {
//make sure we are a child process of PM2 i.e. not in dev
console.info('sending ready signal to PM2');
console.log('SENT READY SIGNAL TO PM2');
process.send('ready');
}
});
//listen for sigint from PM2
process.on('SIGINT', () => {
console.info('SIGINT SIGNAL RECEIVED');
console.log('SIGINT SIGNAL RECEIVED');
// Stops the server from accepting new connections and finishes existing connections.
server.close((err) => {
// if error, log and exit with error (1 code)
console.info('CLOSING SERVER');
console.log('CLOSING SERVER');
if (err) {
console.error(err);
process.exit(1);
}
// close database connection
console.info('DISCONNECTING MONGODB');
console.log('DISCONNECTING MONGODB');
Mongo.client.close();
//close redis connection
console.log('DISCONNECTING REDIS')

@ -17,6 +17,7 @@ module.exports = {
startRooms: () => {
module.exports.io.on('connection', socket => {
socket.on('room', room => {
//TODO: add some validation here that rooms exist or AT LEAST a regex for valid thread rooms
socket.join(room);
});
});

@ -27,19 +27,22 @@ block content
tr
th Board
th Description
th(style='cursor:help' title='Posts in the last hour') PPH
th(style='cursor:help' title='Unique IPs that have posted in the last 24h') Active Users
th.help(title='Posts in the last hour') PPH
th.help(title='Unique posters in the last 24h') Active Users
th Total Posts
each board in boards
tr
td: a(href=`/${board._id}/`) /#{board._id}/ - #{board.settings.name}
td
if board.settings.sfw
span.help(title='Safe for work') 💼
a(href=`/${board._id}/`) /#{board._id}/ - #{board.settings.name}
td #{board.settings.description}
td #{board.pph}
td #{board.ips}
td #{board.sequence_value-1}
.table-container.flex-center.mv-10.text-center
table
tr(style='cursor:help' title='Stats include hidden boards')
tr.help(title='Total stats including unlisted boards')
th Total Posts
th Total PPH
th Active Users
@ -66,12 +69,15 @@ block content
tr
th Board
th Description
th(style='cursor:help' title='Posts in the last hour') PPH
th(style='cursor:help' title='Unique IPs that have posted in the last 24h') Active Users
th.help(title='Posts in the last hour') PPH
th.help(title='Unique posters in the last 24h') Active Users
th Total Posts
each board in webringBoards
tr
td: a(href=board.path) #{board.siteName} /#{board.uri}/ - #{board.title}
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 || '-'}

@ -140,6 +140,10 @@ block content
.label Unlisted
label.postform-style.ph-5
input(type='checkbox', name='unlisted', value='true' checked=board.settings.unlisted)
.row
.label SFW
label.postform-style.ph-5
input(type='checkbox', name='sfw', value='true' checked=board.settings.sfw)
.row
.label Theme
select(name='theme')

Loading…
Cancel
Save