Added consent page.

This commit is contained in:
DebaucheryLibrarian 2024-06-02 02:50:54 +02:00
parent 87dad222a1
commit 828f009696
6 changed files with 256 additions and 2 deletions

2
.nvmrc
View File

@ -1 +1 @@
20.10.0 20.14.0

198
assets/consent.html Normal file
View File

@ -0,0 +1,198 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>traxxx - consent</title>
<style>
:root {
--primary: #f65596;
--background: #fff;
--text: #222;
--text-light: #fff;
--text-shadow: rgba(0, 0, 0, .7);
--highlight: rgba(255, 255, 255, .75);
--shadow: rgba(0, 0, 0, .25);
}
html,
body {
height: 100%;
margin: 0;
color: var(--text);
font-family: sans-serif;
}
body {
display: flex;
align-items: center;
justify-content: center;
box-sizing: border-box;
padding: 1rem;
}
.content {
display: flex;
flex-direction: column;
}
.heading {
font-size: 1.5rem;
text-align: center;
}
.consent {
text-align: center;
}
.points {
margin: 0;
}
.points li {
margin-bottom: .5rem;
}
.logo {
fill: var(--primary);
height: 1.2rem;
}
.disclaimer {
color: var(--text-shadow);
margin: 0;
text-align: center;
font-size: .9rem;
}
.actions {
display: flex;
align-items: center;
justify-content: center;
gap: 1rem;
margin-top: 1rem;
}
.button {
width: 15rem;
position: relative;
padding: 1rem 2rem;
border: none;
background: none;
text-decoration: none;
border-radius: .5rem;
background: var(--background);
text-align: center;
transition: box-shadow .1s ease-in-out;
box-shadow: 0 0 3px var(--shadow);
}
.button.straight:hover {
box-shadow: 0 0 5px var(--primary);
}
.button.lgbt:before {
content: '';
width: calc(100% - 10px);
height: calc(100% - 10px);
border-radius: .5rem;
position: absolute;
top: 5px;
left: 5px;
z-index: -1;
filter: blur(3px);
background: linear-gradient(90deg, #f00, #f80, #ff0, #0f0, #00f, #a0f, #fff, #f8f, #0ff);
transition: all .1s ease;
}
.button.lgbt:hover {
box-shadow: 0;
}
.button.lgbt:hover:before {
width: 100%;
height: 100%;
top: 0;
left: 0;
}
.button-label {
margin-bottom: .25rem;
font-size: 1.5rem;
font-weight: bold;
color: var(--primary);
}
.button-prefer {
color: var(--text-shadow);
font-size: .9rem;
}
.leave {
color: inherit;
text-decoration: none;
font-size: 1.25rem;
margin-right: 2rem;
}
.leave:hover {
color: var(--primary);
text-decoration: underline;
}
@media(max-width: 800px) {
.actions {
flex-direction: column-reverse;
}
.leave {
margin: 0;
}
}
</style>
</head>
<body>
<div class="content">
<h2 class="heading">
<img
src="/img/logo.svg"
class="logo"
> contains sexually explicit content
</h2>
<p class="consent">
By entering this website, you agree that
<ul class="points">
<li>You are at least 18 years old, and legally permitted to view adult material in your jurisdiction.</li>
<li>You do not regard erotic and pornographic media as obscene or offensive.</li>
<li>You understand that most sexual scenarios depicted on this website are not representative of real-life interactions.</li>
</ul>
</p>
<div class="actions">
<a
href="https://google.com/"
class="leave"
>Leave</a>
<a
href="/?consent&straight"
class="button enter straight"
>
<div class="button-label">Enter</div>
<div class="button-prefer">I prefer straight content</div>
</a>
<a
href="/?consent&lgbt"
class="button enter lgbt"
>
<div class="button-label">Enter</div>
<div class="button-prefer">Include gay, bi and trans content</div>
</a>
</div>
</div>
</body>
</html>

View File

@ -234,7 +234,7 @@ function search() {
async function logout() { async function logout() {
await del('/session'); await del('/session');
navigate('/login', null, { redirect: true }); navigate('/login?consent', null, { redirect: true }); // pass consent variable to reinstate in new session
} }
function blurSearch(event) { function blurSearch(event) {

19
public/img/logo.svg Normal file
View File

@ -0,0 +1,19 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
width="100%"
height="100%"
viewBox="0 0 78.574379 17.664054"
version="1.1"
id="svg1"
xmlns="http://www.w3.org/2000/svg"
xmlns:svg="http://www.w3.org/2000/svg">
<defs
id="defs1" />
<path
d="m 64.140362,126.65896 q 0.08682,0.17364 0.08682,0.33487 0,0.16123 -0.03721,0.26045 -0.03721,0.0992 -0.161231,0.23564 -0.124023,0.12402 -0.186035,0.17363 -0.04961,0.0496 -0.21084,0.16123 -1.252636,0.89297 -3.224609,0.89297 -0.979785,0 -1.860352,-0.29765 -0.868164,-0.28526 -1.575097,-0.85577 -0.706934,-0.5705 -1.128613,-1.53789 -0.409278,-0.97978 -0.409278,-2.24482 v -5.02295 h -1.116211 q -0.558105,0 -0.868164,-0.31006 -0.310058,-0.31006 -0.310058,-0.85576 v -0.86816 q 0,-0.57051 0.297656,-0.86817 0.310058,-0.29765 0.880566,-0.29765 h 1.116211 v -2.95176 q 0,-0.5209 0.285254,-0.78135 0.297656,-0.26045 0.880566,-0.38447 l 2.033985,-0.35967 q 0.545703,-0.11162 0.855762,0.22324 0.310058,0.32246 0.310058,0.91778 v 3.33623 h 2.517676 q 0.558105,0 0.855762,0.31005 0.310058,0.29766 0.310058,0.85577 v 0.86816 q 0,0.5457 -0.310058,0.85576 -0.310059,0.31006 -0.855762,0.31006 h -2.517676 v 4.56406 q 0,0.86817 0.384473,1.26504 0.396875,0.39688 1.041797,0.39688 0.446484,0 1.041797,-0.35967 0.756542,-0.4961 1.16582,0.38447 z m 10.541993,-11.02568 q 0.409277,0.13643 0.58291,0.37207 0.186035,0.22324 0.04961,0.71934 l -0.483691,1.90996 q -0.285254,0.99218 -1.066602,0.68213 -0.855761,-0.26045 -1.32705,-0.26045 -1.103809,0 -1.711524,0.66972 -0.595312,0.66973 -0.595312,1.82315 v 5.66787 q 0,0.5457 -0.297657,0.85576 -0.297656,0.31006 -0.843359,0.31006 h -2.108398 q -0.545703,0 -0.84336,-0.31006 -0.297656,-0.31006 -0.297656,-0.85576 v -10.49238 q 0,-0.54571 0.297656,-0.85577 0.297657,-0.31005 0.84336,-0.31005 h 1.339453 q 0.545703,0 0.843359,0.31005 0.310059,0.31006 0.310059,0.85577 v 0.60771 q 1.426269,-1.98437 3.472656,-1.98437 0.95498,0 1.835547,0.28525 z m 7.218163,-0.28525 q 1.21543,0 2.257227,0.28525 1.041797,0.28525 1.922363,0.89297 0.880566,0.60771 1.389063,1.69912 0.508496,1.09141 0.508496,2.56728 v 6.42442 q 0,1.16582 -1.165821,1.16582 H 85.77005 q -0.545704,0 -0.855762,-0.31006 -0.297656,-0.31006 -0.297656,-0.85576 v -0.0992 q -1.761133,1.5999 -4.055567,1.5999 -2.269629,0 -3.646289,-1.10381 -1.364258,-1.11621 -1.364258,-2.93935 0,-1.95957 1.500684,-3.1502 1.500684,-1.19062 3.96875,-1.19062 1.314648,0 2.889746,0.5333 v -0.45889 q 0,-0.89297 -0.607715,-1.40146 -0.595312,-0.5085 -1.699121,-0.5085 -1.599902,0 -2.852539,0.74414 -0.95498,0.5333 -1.463476,-0.45889 l -0.285254,-0.58291 q -0.297657,-0.63251 -0.21084,-0.97978 0.08682,-0.34727 0.520898,-0.62012 0.917774,-0.58291 2.17041,-0.91777 1.252637,-0.33486 2.418457,-0.33486 z m -0.223242,10.64121 q 0.979785,0 1.649512,-0.4961 0.682129,-0.49609 0.682129,-1.04179 v -1.0418 q -1.203028,-0.55811 -2.282031,-0.55811 -0.930176,0 -1.500684,0.44649 -0.558106,0.44648 -0.558106,1.15342 0,0.70693 0.545704,1.12861 0.545703,0.40928 1.463476,0.40928 z m 17.264063,-3.98116 4.043161,5.20899 q 0.37207,0.5333 0.18604,0.85576 -0.17363,0.31006 -0.74414,0.31006 h -2.753323 q -0.508496,0 -0.855761,-0.26045 -0.334864,-0.26045 -0.744141,-0.85576 l -1.773535,-2.54248 -1.79834,2.54248 q -0.409277,0.59531 -0.756543,0.85576 -0.334863,0.26045 -0.868164,0.26045 h -2.294434 q -0.58291,0 -0.781347,-0.31006 -0.186035,-0.31006 0.198437,-0.85576 l 4.067969,-5.20899 -4.043164,-5.28339 q -0.384473,-0.54571 -0.21084,-0.85577 0.186035,-0.31005 0.768945,-0.31005 h 2.716114 q 0.520898,0 0.880566,0.27285 0.359668,0.26045 0.756543,0.84336 l 1.773535,2.59209 1.748731,-2.59209 q 0.421679,-0.59532 0.768945,-0.85577 0.347265,-0.26044 0.855757,-0.26044 h 2.31924 q 0.58291,0 0.76895,0.31005 0.19844,0.31006 -0.18604,0.85577 z m 14.237891,0 4.04316,5.20899 q 0.37207,0.5333 0.18604,0.85576 -0.17364,0.31006 -0.74414,0.31006 h -2.75332 q -0.5085,0 -0.85577,-0.26045 -0.33486,-0.26045 -0.74414,-0.85576 l -1.77353,-2.54248 -1.79834,2.54248 q -0.40928,0.59531 -0.75654,0.85576 -0.33487,0.26045 -0.86817,0.26045 h -2.29443 q -0.58291,0 -0.78135,-0.31006 -0.18604,-0.31006 0.19844,-0.85576 l 4.06797,-5.20899 -4.04317,-5.28339 q -0.38447,-0.54571 -0.21084,-0.85577 0.18604,-0.31005 0.76895,-0.31005 h 2.71611 q 0.5209,0 0.88057,0.27285 0.35967,0.26045 0.75654,0.84336 l 1.77354,2.59209 1.74873,-2.59209 q 0.42168,-0.59532 0.76894,-0.85577 0.34727,-0.26044 0.85576,-0.26044 h 2.31924 q 0.58291,0 0.76895,0.31005 0.19843,0.31006 -0.18604,0.85577 z m 14.23789,0 4.04316,5.20899 q 0.37207,0.5333 0.18603,0.85576 -0.17363,0.31006 -0.74414,0.31006 h -2.75332 q -0.50849,0 -0.85576,-0.26045 -0.33486,-0.26045 -0.74414,-0.85576 l -1.77353,-2.54248 -1.79834,2.54248 q -0.40928,0.59531 -0.75655,0.85576 -0.33486,0.26045 -0.86816,0.26045 h -2.29443 q -0.58291,0 -0.78135,-0.31006 -0.18604,-0.31006 0.19844,-0.85576 l 4.06796,-5.20899 -4.04316,-5.28339 q -0.38447,-0.54571 -0.21084,-0.85577 0.18604,-0.31005 0.76895,-0.31005 h 2.71611 q 0.5209,0 0.88057,0.27285 0.35966,0.26045 0.75654,0.84336 l 1.77353,2.59209 1.74873,-2.59209 q 0.42168,-0.59532 0.76895,-0.85577 0.34727,-0.26044 0.85576,-0.26044 h 2.31924 q 0.58291,0 0.76894,0.31005 0.19844,0.31006 -0.18603,0.85577 z"
transform="translate(-53.139484,-111.05371)"
id="path1"
style="stroke:none;stroke-opacity:1;fill:#f65596;fill-opacity:1" />
</svg>

After

Width:  |  Height:  |  Size: 5.3 KiB

29
src/web/consent.js Normal file
View File

@ -0,0 +1,29 @@
export default function consentHandler(req, res, next) {
if (Object.hasOwn(req.query, 'lgbt')) {
const lgbtFilters = (req.tagFilter || []).filter((tag) => !['gay', 'bisexual', 'transsexual'].includes(tag));
req.tagFilter = lgbtFilters; // eslint-disable-line no-param-reassign
res.cookie('tags', JSON.stringify(lgbtFilters));
}
if (Object.hasOwn(req.query, 'straight')) {
const straightFilters = Array.from(new Set([...(req.tagFilter || []), 'gay', 'bisexual', 'transsexual']));
req.tagFilter = straightFilters; // eslint-disable-line no-param-reassign
res.cookie('tags', JSON.stringify(straightFilters));
}
if (Object.hasOwn(req.query, 'consent')) {
req.session.hasConsent = true; // eslint-disable-line no-param-reassign
res.redirect(req.path);
return;
}
if (!req.path.includes('/consent') && !req.session?.hasConsent) {
res.redirect('/consent');
return;
}
next();
}

View File

@ -1,4 +1,5 @@
import config from 'config'; import config from 'config';
import path from 'path';
import express from 'express'; import express from 'express';
import boolParser from 'express-query-boolean'; import boolParser from 'express-query-boolean';
import Router from 'express-promise-router'; import Router from 'express-promise-router';
@ -13,6 +14,7 @@ import { renderPage } from 'vike/server'; // eslint-disable-line import/extensio
import redis from '../redis.js'; import redis from '../redis.js';
import errorHandler from './error.js'; import errorHandler from './error.js';
import consentHandler from './consent.js';
import { fetchScenesApi } from './scenes.js'; import { fetchScenesApi } from './scenes.js';
import { fetchActorsApi } from './actors.js'; import { fetchActorsApi } from './actors.js';
@ -122,6 +124,12 @@ export default async function initServer() {
router.use(viteDevMiddleware); router.use(viteDevMiddleware);
} }
router.use(consentHandler);
router.get('/consent', (req, res) => {
res.sendFile(path.join(import.meta.dirname, '../../assets/consent.html'));
});
// SESSION // SESSION
router.post('/api/session', loginApi); router.post('/api/session', loginApi);
router.delete('/api/session', logoutApi); router.delete('/api/session', logoutApi);