diff --git a/controllers/pages.js b/controllers/pages.js index e862b216..f4eb217e 100644 --- a/controllers/pages.js +++ b/controllers/pages.js @@ -11,6 +11,7 @@ const express = require('express') , paramConverter = require(__dirname+'/../helpers/paramconverter.js') , sessionRefresh = require(__dirname+'/../helpers/sessionrefresh.js') , csrf = require(__dirname+'/../helpers/checks/csrfmiddleware.js') + , setMinimal = require(__dirname+'/../helpers/setminimal.js') //page models , { manageReports, manageBanners, manageSettings, manageBans, manageBoard, manageThread } = require(__dirname+'/../models/pages/manage/') , { globalManageSettings, globalManageReports, globalManageBans, @@ -60,6 +61,7 @@ router.get('/globalmanage/settings.html', sessionRefresh, isLoggedIn, calcPerms, router.get('/captcha', 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 //accounts router.get('/account.html', sessionRefresh, isLoggedIn, account); //page showing boards you are mod/owner of, links to password rese, logout, etc diff --git a/gulp/res/css/style.css b/gulp/res/css/style.css index 7b849932..7d953390 100644 --- a/gulp/res/css/style.css +++ b/gulp/res/css/style.css @@ -13,6 +13,9 @@ body { main { margin: 3em 0 0 0; } +main.minimal { + margin: 0; +} .row { display: flex; @@ -884,11 +887,15 @@ input[type="file"] { box-sizing: border-box; } -iframe.captcha { +iframe.captcha, iframe.bypass { /*dumb hack cos of noscript wrapping in unstyleable span*/ margin-bottom: -2px; } +iframe.bypass { + height: 215px; +} + .captcha { border: 1px solid var(--input-borders); background: white; diff --git a/helpers/checks/blockbypass.js b/helpers/checks/blockbypass.js index c4dc5533..76027eec 100644 --- a/helpers/checks/blockbypass.js +++ b/helpers/checks/blockbypass.js @@ -18,6 +18,7 @@ module.exports = async (req, res, next) => { return dynamicResponse(req, res, 403, 'message', { 'title': 'Forbidden', 'message': 'Missing or invalid block bypass', + 'frame': '/bypass_minimal.html', 'link': { 'href': '/bypass.html', 'text': 'Get block bypass', @@ -57,6 +58,7 @@ module.exports = async (req, res, next) => { return dynamicResponse(req, res, 403, 'message', { 'title': 'Forbidden', 'message': 'Block bypass expired or exceeded max uses', + 'frame': '/bypass_minimal.html', 'link': { 'href': '/bypass.html', 'text': 'Get block bypass', diff --git a/helpers/dynamic.js b/helpers/dynamic.js index f43d0d65..d0d5278e 100644 --- a/helpers/dynamic.js +++ b/helpers/dynamic.js @@ -1,6 +1,9 @@ 'use strict'; module.exports = (req, res, code, page, data) => { + if (req.body.minimal) { + data.minimal = true; + } res.status(code); if (req.headers['x-using-xhr'] != null) { return res.json(data); diff --git a/helpers/setminimal.js b/helpers/setminimal.js new file mode 100644 index 00000000..53180ed6 --- /dev/null +++ b/helpers/setminimal.js @@ -0,0 +1,6 @@ +'use strict'; + +module.exports = (req, res, next) => { + res.locals.minimal = true; + next(); +} diff --git a/helpers/tasks.js b/helpers/tasks.js index e1bc867e..a119e104 100644 --- a/helpers/tasks.js +++ b/helpers/tasks.js @@ -230,8 +230,10 @@ module.exports = { return render('register.html', 'register.pug'); }, - buildBypass: () => { - return render('bypass.html', 'bypass.pug'); + buildBypass: (minimal=false) => { + return render(`bypass${minimal ? '_minimal' : ''}.html`, 'bypass.pug', { + minimal, + }); }, buildCreate: () => { diff --git a/models/forms/blockbypass.js b/models/forms/blockbypass.js index 3d954429..595f3fbd 100644 --- a/models/forms/blockbypass.js +++ b/models/forms/blockbypass.js @@ -17,6 +17,7 @@ module.exports = async (req, res, next) => { 'sameSite': 'strict' }) .render('message', { + 'minimal': req.body.minimal, //todo: make use x- header for ajax once implm. 'title': 'Success', 'message': 'Completed block bypass, you may go back and make your post.', }); diff --git a/models/pages/blockbypass.js b/models/pages/blockbypass.js index ed456d8b..978d491d 100644 --- a/models/pages/blockbypass.js +++ b/models/pages/blockbypass.js @@ -6,7 +6,7 @@ module.exports = async (req, res, next) => { let html; try { - html = await buildBypass(); + html = await buildBypass(res.locals.minimal); } catch (err) { return next(err); } diff --git a/views/includes/footer.pug b/views/includes/footer.pug index bd18fa06..f24700c4 100644 --- a/views/includes/footer.pug +++ b/views/includes/footer.pug @@ -1,9 +1,10 @@ -small.footer#bottom - | - - a(href='/rules.html') rules - | - - a(href='/faq.html') faq - | - - a(href='https://github.com/fatchan/jschan/') source code - | - +unless minimal + small.footer#bottom + | - + a(href='/rules.html') rules + | - + a(href='/faq.html') faq + | - + a(href='https://github.com/fatchan/jschan/') source code + | - script(src='/js/render.js') diff --git a/views/includes/navbar.pug b/views/includes/navbar.pug index 914e000f..3fbbc6c8 100644 --- a/views/includes/navbar.pug +++ b/views/includes/navbar.pug @@ -1,8 +1,9 @@ -nav.navbar - a.nav-item(href='/index.html') Home - a.nav-item(href='/news.html') News - a.nav-item(href='/boards.html') Boards - a.nav-item(href='/account.html') Account - if board - a.nav-item(href=`/${board._id}/manage/reports.html`) Manage - a.jsonly.nav-item.right#settings +unless minimal + nav.navbar + a.nav-item(href='/index.html') Home + a.nav-item(href='/news.html') News + a.nav-item(href='/boards.html') Boards + a.nav-item(href='/account.html') Account + if board + a.nav-item(href=`/${board._id}/manage/reports.html`) Manage + a.jsonly.nav-item.right#settings diff --git a/views/layout.pug b/views/layout.pug index a67bb1d7..c707ec7d 100644 --- a/views/layout.pug +++ b/views/layout.pug @@ -5,7 +5,7 @@ html block head body#top include includes/navbar.pug - main + main(class=(minimal?'minimal':'')) .container block content include includes/footer.pug diff --git a/views/mixins/modal.pug b/views/mixins/modal.pug index 06036ccb..ca26023f 100644 --- a/views/mixins/modal.pug +++ b/views/mixins/modal.pug @@ -17,7 +17,10 @@ mixin modal(data) if data.errors each error in data.errors li #{error} - if data.link + if data.frame + .row + iframe.bypass(src=data.frame frameborder='0' scrolling='no') + else if data.link .row a.button.mv-0(href=data.link.href target='_blank') #{data.link.text} else if data.settings diff --git a/views/pages/bypass.pug b/views/pages/bypass.pug index c856b8ba..8f3f6681 100644 --- a/views/pages/bypass.pug +++ b/views/pages/bypass.pug @@ -12,4 +12,6 @@ block content .label Captcha span.col include ../includes/captcha.pug + if minimal + input(type='hidden' name='minimal' value='1') input(type='submit', value='Submit')