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, 'sequence_value': 1,
'pph': 1, 'pph': 1,
'ips': 1, 'ips': 1,
'settings.sfw': 1,
'settings.description': 1, 'settings.description': 1,
'settings.name': 1, 'settings.name': 1,
} }

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

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

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

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

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

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

@ -27,19 +27,22 @@ block content
tr tr
th Board th Board
th Description th Description
th(style='cursor:help' title='Posts in the last hour') PPH th.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='Unique posters in the last 24h') Active Users
th Total Posts th Total Posts
each board in boards each board in boards
tr 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.settings.description}
td #{board.pph} td #{board.pph}
td #{board.ips} td #{board.ips}
td #{board.sequence_value-1} td #{board.sequence_value-1}
.table-container.flex-center.mv-10.text-center .table-container.flex-center.mv-10.text-center
table table
tr(style='cursor:help' title='Stats include hidden boards') tr.help(title='Total stats including unlisted boards')
th Total Posts th Total Posts
th Total PPH th Total PPH
th Active Users th Active Users
@ -66,12 +69,15 @@ block content
tr tr
th Board th Board
th Description th Description
th(style='cursor:help' title='Posts in the last hour') PPH th.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='Unique posters in the last 24h') Active Users
th Total Posts th Total Posts
each board in webringBoards each board in webringBoards
tr 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.subtitle || '-'}
td #{board.postsPerHour || '-'} td #{board.postsPerHour || '-'}
td #{board.uniqueUsers || '-'} td #{board.uniqueUsers || '-'}

@ -140,6 +140,10 @@ block content
.label Unlisted .label Unlisted
label.postform-style.ph-5 label.postform-style.ph-5
input(type='checkbox', name='unlisted', value='true' checked=board.settings.unlisted) 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 .row
.label Theme .label Theme
select(name='theme') select(name='theme')

Loading…
Cancel
Save