From 9f5510bc042ddb1589d10236d2982f5b7ba3ea6b Mon Sep 17 00:00:00 2001 From: Kibi Kelburton Date: Mon, 27 Jul 2026 00:12:51 +0200 Subject: [PATCH 1/2] add custom gate template for private society --- src/index.mjs | 26 ++++++++++++++------ views/_gate_template.html | 51 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 69 insertions(+), 8 deletions(-) create mode 100644 views/_gate_template.html diff --git a/src/index.mjs b/src/index.mjs index e30c00b..6695f6c 100644 --- a/src/index.mjs +++ b/src/index.mjs @@ -345,7 +345,14 @@ const nginx502 = (cfg.websrv.private_society && cfg.websrv.private_society_gate ? null : nginx502Fallback; +// Custom gate template — resolved once at boot from config +// Set private_society_gate: "custom" and private_society_gate_template: "your-template-name" (no .html) +const _customGateTemplate = (cfg.websrv.private_society && cfg.websrv.private_society_gate === 'custom' && cfg.websrv.private_society_gate_template) + ? String(cfg.websrv.private_society_gate_template).replace(/\.html$/i, '') + : null; + if (nginx502 === null) console.log('[BOOT] Private society gate: Cloudflare dynamic mode'); +if (_customGateTemplate) console.log(`[BOOT] Private society gate: Custom template → views/${_customGateTemplate}.html (flummpress resolves extension)`); // ───────────────────────────────────────────────────────────────────────────── @@ -839,18 +846,21 @@ process.on('uncaughtException', err => { req.url.pathname = '/private_society_bypass'; return; } - // For page requests, return 502 Bad Gateway for all paths except homepage (which shows the gate) - if (req.url.pathname !== '/') { + // For page requests, serve the gate for all paths (custom template or fallback) + if (_customGateTemplate) { + res.writeHead(200, { 'Content-Type': 'text/html' }).end(tpl.render(_customGateTemplate, {}, req)); + } else if (req.url.pathname !== '/') { + // Non-home paths: always show the static/cloudflare gate res.writeHead(200, { 'Content-Type': 'text/html' }).end(nginx502 ?? buildGatePage(req)); - req.url.pathname = '/private_society_bypass'; - return; - } - // Homepage: in cloudflare dynamic mode serve gate directly; otherwise fall through to template - if (nginx502 === null) { + } else if (nginx502 === null) { + // Homepage in cloudflare dynamic mode: serve the CF gate directly res.writeHead(200, { 'Content-Type': 'text/html' }).end(buildGatePage(req)); - req.url.pathname = '/private_society_bypass'; + } else { + // Homepage in plain nginx mode: fall through to index.html template return; } + req.url.pathname = '/private_society_bypass'; + return; } } }); diff --git a/views/_gate_template.html b/views/_gate_template.html new file mode 100644 index 0000000..b6e302b --- /dev/null +++ b/views/_gate_template.html @@ -0,0 +1,51 @@ +@if(private_society && !session) + + + + + + {{ domain }} + + + + + + + + + + + + + + +@else +@include(snippets/header) +
+
+ + penis :D +
+
+@include(snippets/footer) +@endif -- 2.50.1 From a7aabac9561f9e3043bacb382448c1f317db9848 Mon Sep 17 00:00:00 2001 From: Kibi Kelburton Date: Mon, 27 Jul 2026 00:22:13 +0200 Subject: [PATCH 2/2] update example gate --- views/_gate_template.html | 34 +++++++++------------------------- 1 file changed, 9 insertions(+), 25 deletions(-) diff --git a/views/_gate_template.html b/views/_gate_template.html index b6e302b..cfe5121 100644 --- a/views/_gate_template.html +++ b/views/_gate_template.html @@ -1,4 +1,3 @@ -@if(private_society && !session) @@ -9,20 +8,18 @@ - - -