fix the webring and the rest of the options to the new panel

merge-requests/218/head
Thomas Lynch 3 years ago
parent 06bac65200
commit 1b1883be1e
  1. 9
      configs/template.js.example
  2. 15
      configs/webring.json.example
  3. 3
      controllers/forms/globalsettings.js
  4. 11
      migrations/0.0.22.js
  5. 7
      models/forms/changeglobalsettings.js
  6. 2
      package.json
  7. 12
      schedules/index.js
  8. 7
      schedules/tasks/webring.js
  9. 16
      views/pages/globalmanagesettings.pug

@ -376,4 +376,13 @@ module.exports = {
}
},
following: [],
blacklist: [],
logo: [],
proxy: {
enabled: false,
address: ''
}
};

@ -1,15 +0,0 @@
{
"following": [
"https://example.com/webring.json"
],
"blacklist": [
"badwebsite.com"
],
"logo": [
"https://yourdomain.com/favicon.ico"
],
"proxy": {
"enabled": false,
"address": "socks5h://localhost:9050"
}
}

@ -134,6 +134,9 @@ module.exports = async (req, res, next) => {
{ result: minmaxBody(req.body.board_defaults_min_reply_message_length, req.body.board_defaults_max_reply_message_length), expected: true, error: 'Board defaults reply message length min must be less than max' },
{ result: numberBody(req.body.board_defaults_filter_mode, 0, 2), expected: false, error: 'Board defaults filter most must be a number from 0-2' },
{ result: numberBody(req.body.board_defaults_filter_ban_duration), expected: false, error: 'Board defaults filter ban duration must be a number' },
{ result: lengthBody(req.body.webring_following, 0, 10000), expected: false, error: 'Webring following list must not exceed 10000 characters' },
{ result: lengthBody(req.body.webring_blacklist, 0, 10000), expected: false, error: 'Webring blacklist must not exceed 10000 characters' },
{ result: lengthBody(req.body.webring_logos, 0, 10000), expected: false, error: 'Webring logos list must not exceed 10000 characters' },
];
const errors = await checkSchema(schema);

@ -0,0 +1,11 @@
'use strict';
const fs = require('fs-extra');
module.exports = async(db, redis) => {
console.log('remove need for configs/webring');
const webring = require(__dirname+'/../configs/template.js.example');
const settings = await redis.get('globalsetings');
const newSettings = { ...settings, ...webring };
redis.set('globalsettings', newSettings);
};

@ -89,6 +89,13 @@ module.exports = async (req, res, next) => {
pruneModlogs: numberSetting(req.body.prune_modlogs, oldSettings.pruneModlogs),
pruneIps: numberSetting(req.body.prune_ips, oldSettings.pruneIps),
enableWebring: booleanSetting(req.body.enable_webring, oldSettings.enableWebring),
following: arraySetting(req.body.webring_following, oldSettings.following),
blacklist: arraySetting(req.body.webring_blacklist, oldSettings.blacklist),
logo: arraySetting(req.body.webring_logos, oldSettings.logo),
proxy: {
enabled: booleanSetting(req.body.webring_proxy_enabled, oldSettings.proxy.enabled),
address: trimSetting(req.body.webring_proxy_address, oldSettings.proxy.address),
},
enableUserBoardCreation: booleanSetting(req.body.enable_user_board_creation, oldSettings.enableUserBoardCreation),
enableUserAccountCreation: booleanSetting(req.body.enable_user_account_creation, oldSettings.enableUserAccountCreation),
thumbExtension: trimSetting(req.body.thumb_extension, oldSettings.thumbExtension),

@ -1,7 +1,7 @@
{
"name": "jschan",
"version": "0.0.1",
"migrateVersion": "0.0.21",
"migrateVersion": "0.0.22",
"description": "",
"main": "server.js",
"dependencies": {

@ -5,7 +5,8 @@ process
.on('unhandledRejection', console.error);
const Mongo = require(__dirname+'/../db/db.js')
, config = require(__dirname+'/../config.js');
, config = require(__dirname+'/../config.js')
, { addCallback } = require(__dirname+'/../redis.js');
(async () => {
@ -14,7 +15,14 @@ const Mongo = require(__dirname+'/../db/db.js')
await config.load();
//start all the scheduled tasks
require(__dirname+'/tasks/index.js');
const schedules = require(__dirname+'/tasks/index.js');
//update the schedules to start/stop timer after config change
addCallback('config', () => {
Object.values(schedules).forEach(sc => {
sc.update();
});
})
//update board stats and homepage task, use cron and bull for proper timing
require(__dirname+'/../queue.js').push({

@ -7,21 +7,20 @@ const fetch = require('node-fetch')
, Mongo = require(__dirname+'/../../db/db.js')
, { Boards, Webring } = require(__dirname+'/../../db/')
, { outputFile } = require('fs-extra')
, SocksProxyAgent = require('socks-proxy-agent')
, uploadDirectory = require(__dirname+'/../../helpers/files/uploadDirectory.js')
, timeDiffString = require(__dirname+'/../../helpers/timediffstring.js')
, SocksProxyAgent = proxy.enabled && require('socks-proxy-agent')
, agent = SocksProxyAgent ? new SocksProxyAgent(require('url').parse(proxy.address)) : null
, timeUtils = require(__dirname+'/../../helpers/timeutils.js');
module.exports = {
func: async () => {
return
const { meta } = config.get;
const { meta, logo, following, blacklist, proxy } = config.get;
const label = `updating webring`;
const start = process.hrtime();
const agent = proxy.enabled ? new SocksProxyAgent(require('url').parse(proxy.address)) : null;
const visited = new Map();
let known = new Set(following);
let webringBoards = []; //list of webring boards

@ -528,7 +528,21 @@ block content
label.postform-style.ph-5
input(type='checkbox', name='enable_webring' value='true' checked=settings.enableWebring)
.row
p other webring options coming soon
.label Use Socks Proxy
label.postform-style.ph-5
input(type='checkbox', name='webring_proxy_enabled', value='true' checked=settings.proxy.enabled)
.row
.label Proxy Address
input(type='text', name='webring_proxy_address', value=settings.proxy.address)
.row
.label Following
textarea(name='webring_following' placeholder='Newline separated') #{settings.following.join('\n')}
.row
.label Logo URLs
textarea(name='webring_logos' placeholder='Newline separated') #{settings.logo.join('\n')}
.row
.label Blacklist
textarea(name='webring_blacklist' placeholder='Newline separated') #{settings.blacklist.join('\n')}
.col.mr-5

Loading…
Cancel
Save