Add setQueryLanguage mw, Make bypass_minimal language aware, TODO make form submissions know language and redirect to blockbypass for board with language query string

merge-requests/341/head
Thomas Lynch 1 year ago
parent 21a181d3fa
commit 7c9f6257f8
  1. 4
      controllers/pages.js
  2. 6
      lib/build/tasks.js
  3. 11
      lib/middleware/locale/locale.js
  4. 6
      locales/en.json
  5. 4
      locales/pt.json
  6. 8
      models/pages/blockbypass.js
  7. 6
      views/pages/bypass.pug

@ -16,7 +16,7 @@ const express = require('express')
, sessionRefresh = require(__dirname+'/../lib/middleware/permission/sessionrefresh.js')
, csrf = require(__dirname+'/../lib/middleware/misc/csrfmiddleware.js')
, setMinimal = require(__dirname+'/../lib/middleware/misc/setminimal.js')
, { setBoardLanguage } = require(__dirname+'/../lib/middleware/locale/locale.js')
, { setBoardLanguage, setQueryLanguage } = require(__dirname+'/../lib/middleware/locale/locale.js')
//page models
, { manageRecent, manageReports, manageAssets, manageSettings, manageBans, editCustomPage, manageMyPermissions,
manageBoard, manageThread, manageLogs, manageCatalog, manageCustomPages, manageStaff, editStaff, editPost } = require(__dirname+'/../models/pages/manage/')
@ -119,7 +119,7 @@ router.get('/globalmanage/editrole/:roleid([a-f0-9]{24}).html', useSession, sess
router.get('/captcha', geoIp, processIp, captcha); //get captcha image and cookie
router.get('/captcha.html', captchaPage); //iframed for noscript users
router.get('/bypass.html', blockBypass); //block bypass page
router.get('/bypass_minimal.html', setMinimal, blockBypass); //block bypass page
router.get('/bypass_minimal.html', setMinimal, setQueryLanguage, blockBypass); //block bypass page
//accounts
router.get('/account.html', useSession, sessionRefresh, isLoggedIn, calcPerms, csrf, account); //page showing boards you are mod/owner of, links to password rese, logout, etc

@ -420,10 +420,8 @@ module.exports = {
return html;
},
buildBypass: async (minimal=false) => {
const { html } = await render(`bypass${minimal ? '_minimal' : ''}.html`, 'bypass.pug', {
minimal,
});
buildBypass: async () => {
const { html } = await render('bypass.html', 'bypass.pug');
return html;
},

@ -19,4 +19,15 @@ module.exports = {
next();
},
setQueryLanguage: (req, res, next) => {
if (req.query.language
&& typeof req.query.language === 'string'
&& i18n.getLocales().includes(req.query.language)) {
res.locals.setLocale(res.locals, req.query.language);
}
next();
},
//TODO set param language? set body language? surely not...
};

@ -19,5 +19,7 @@
"New Reply": "New Reply",
"Name": "Name",
"You": "You",
"Index": "Index"
}
"Index": "Index",
"Submit": "Submit",
"Block Bypass": "Block Bypass"
}

@ -19,5 +19,7 @@
"New Reply": "Nova Resposta",
"Name": "Nome",
"You": "You",
"Index": "Index"
"Index": "Index",
"Submit": "Enviar",
"Block Bypass": "Bypass"
}

@ -4,6 +4,14 @@ const { buildBypass } = require(__dirname+'/../../lib/build/tasks.js');
module.exports = async (req, res, next) => {
if (res.locals.minimal === true) {
return res
.set('Cache-Control', 'public, max-age=60')
.render('bypass', {
minimal: true
});
}
let html;
try {
html = await buildBypass(res.locals.minimal);

@ -1,10 +1,10 @@
extends ../layout.pug
block head
title Block Bypass
title #{__('Block Bypass')}
block content
h1.board-title Block Bypass
h1.board-title #{__('Block Bypass')}
.form-wrapper.flex-center.mv-10
form.form-post(action='/forms/blockbypass' method='POST' data-captcha-preload='true')
.row
@ -12,6 +12,6 @@ block content
include ../includes/captcha.pug
if minimal
input(type='hidden' name='minimal' value='1')
input(type='submit', value='Submit')
input(type='submit', value=__('Submit'))
if message
p.title #{message}

Loading…
Cancel
Save