master #30
@@ -345,7 +345,14 @@ const nginx502 = (cfg.websrv.private_society && cfg.websrv.private_society_gate
|
|||||||
? null
|
? null
|
||||||
: nginx502Fallback;
|
: 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 (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';
|
req.url.pathname = '/private_society_bypass';
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// For page requests, return 502 Bad Gateway for all paths except homepage (which shows the gate)
|
// For page requests, serve the gate for all paths (custom template or fallback)
|
||||||
if (req.url.pathname !== '/') {
|
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));
|
res.writeHead(200, { 'Content-Type': 'text/html' }).end(nginx502 ?? buildGatePage(req));
|
||||||
req.url.pathname = '/private_society_bypass';
|
} else if (nginx502 === null) {
|
||||||
return;
|
// Homepage in cloudflare dynamic mode: serve the CF gate directly
|
||||||
}
|
|
||||||
// Homepage: in cloudflare dynamic mode serve gate directly; otherwise fall through to template
|
|
||||||
if (nginx502 === null) {
|
|
||||||
res.writeHead(200, { 'Content-Type': 'text/html' }).end(buildGatePage(req));
|
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;
|
return;
|
||||||
}
|
}
|
||||||
|
req.url.pathname = '/private_society_bypass';
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
35
views/_gate_template.html
Normal file
35
views/_gate_template.html
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
<!doctype html>
|
||||||
|
<html theme="@if(typeof theme !== 'undefined'){{ theme }}@else{{ default_theme || 'amoled' }}@endif">
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8" />
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||||
|
<title>{{ domain }}</title>
|
||||||
|
<link rel="icon" type="image/gif" href="/s/img/favicon.gif" />
|
||||||
|
<link rel="stylesheet" id="injected-gate-styles" href="/s/css/f0ckm.css?v={{ ts }}">
|
||||||
|
</head>
|
||||||
|
<body class="{{ default_layout === 'legacy' ? 'layout-legacy' : 'layout-modern' }}">
|
||||||
|
|
||||||
|
<div class="wrapper" style="text-align: center;">
|
||||||
|
<h2>Example Gate</h2>
|
||||||
|
<button type="button" onclick="openLoginGate();">Login</button>
|
||||||
|
|
||||||
|
<div id="gate-container" style="display:none;">
|
||||||
|
@include(snippets/navbar)
|
||||||
|
@include(snippets/footer)
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
function openLoginGate() {
|
||||||
|
document.getElementById('gate-container').style.display = 'block';
|
||||||
|
const tryOpen = () => {
|
||||||
|
const m = document.getElementById('login-modal');
|
||||||
|
if (m) { m.style.display = 'flex'; }
|
||||||
|
else { setTimeout(tryOpen, 50); }
|
||||||
|
};
|
||||||
|
tryOpen();
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
Reference in New Issue
Block a user