cleaned up
All checks were successful
fetch npm modules / f0ck the f0cker (push) Successful in 37s

This commit is contained in:
Flummi 2023-05-03 05:13:48 +02:00
parent fbf03bfbb4
commit 2301d15abd
8 changed files with 147 additions and 176 deletions

View File

@ -16,8 +16,14 @@ const auth = async (req, res, next) => {
export default (router, tpl) => { export default (router, tpl) => {
router.get(/^\/login(\/)?$/, async (req, res) => { router.get(/^\/login(\/)?$/, async (req, res) => {
if(req.cookies.session) if(req.cookies.session) {
return res.reply({ body: "du bist schon eingeloggt lol" }); return res.reply({
body: tpl.render('error', {
message: "you're already logged in lol",
tmp: null
}, req)
});
}
res.reply({ res.reply({
body: tpl.render("login", { theme: req.cookies.theme ?? "f0ck" }) body: tpl.render("login", { theme: req.cookies.theme ?? "f0ck" })
}); });
@ -100,7 +106,11 @@ export default (router, tpl) => {
router.get(/^\/admin(\/)?$/, auth, async (req, res) => { // frontpage router.get(/^\/admin(\/)?$/, auth, async (req, res) => { // frontpage
res.reply({ res.reply({
body: tpl.render("admin", { totals: await lib.countf0cks(), session: req.session }, req) body: tpl.render("admin", {
totals: await lib.countf0cks(),
session: req.session,
tmp: null
}, req)
}); });
}); });
@ -116,7 +126,8 @@ export default (router, tpl) => {
body: tpl.render("admin/sessions", { body: tpl.render("admin/sessions", {
session: req.session, session: req.session,
sessions: rows, sessions: rows,
totals: await lib.countf0cks() totals: await lib.countf0cks(),
tmp: null
}, req) }, req)
}); });
}); });
@ -125,7 +136,8 @@ export default (router, tpl) => {
exec("journalctl -qeu f0ck --no-pager", (err, stdout) => { exec("journalctl -qeu f0ck --no-pager", (err, stdout) => {
res.reply({ res.reply({
body: tpl.render("admin/log", { body: tpl.render("admin/log", {
log: stdout.split("\n").slice(0, -1) log: stdout.split("\n").slice(0, -1),
tmp: null
}, req) }, req)
}); });
}); });
@ -182,7 +194,8 @@ export default (router, tpl) => {
res.reply({ res.reply({
body: tpl.render('admin/recover', { body: tpl.render('admin/recover', {
posts posts,
tmp: null
}, req) }, req)
}); });
}); });

View File

@ -1,10 +1,12 @@
@include(snippets/header_admin) @include(snippets/header)
<div class="container"> <div id="main">
<div class="container">
<h1>Henlo, {{ session.user }}</h1> <h1>Henlo, {{ session.user }}</h1>
<p>Hier entsteht eine Internetpräsenz!</p> <p>Hier entsteht eine Internetpräsenz!</p>
<img src="/s/img/favicon.gif" alt="f0ck bash"> <img src="/s/img/favicon.gif" alt="f0ck bash">
<p>@if(typeof totals !== "undefined") <p>@if(typeof totals !== "undefined")
total: {{ totals.total }} | tagged: {{ totals.tagged }} | untagged: {{ totals.untagged }} | sfw: {{ totals.sfw }} | nsfw: {{ totals.nsfw }} total: {{ totals.total }} | tagged: {{ totals.tagged }} | untagged: {{ totals.untagged }} | sfw: {{ totals.sfw }} | nsfw: {{ totals.nsfw }}
@endif</p> @endif</p>
</div>
</div> </div>
@include(snippets/footer) @include(snippets/footer)

View File

@ -1,16 +1,18 @@
@include(snippets/header_admin) @include(snippets/header)
@if(log) <div id="main">
<h1>last {{ log.length }} entries:</h1> @if(log)
<div class="logwrap"> <h1>last {{ log.length }} entries:</h1>
@each(log as line) <div class="logwrap">
@each(log as line)
<p>{{ line }}</p> <p>{{ line }}</p>
@endeach @endeach
</div> </div>
<script> <script>
(() => { (() => {
const d = document.querySelector("div.logwrap"); const d = document.querySelector("div.logwrap");
d.scrollTop = d.scrollHeight; d.scrollTop = d.scrollHeight;
})(); })();
</script> </script>
@endif @endif
</div>
@include(snippets/footer) @include(snippets/footer)

View File

@ -1,24 +1,26 @@
@include(snippets/header_admin) @include(snippets/header)
<table class="table" style="width: 100%"> <div id="main">
<thead> <table class="table" style="width: 100%">
<tr> <thead>
<tr>
<td></td> <td></td>
<td>ID</td> <td>ID</td>
<td>f0cker</td> <td>f0cker</td>
<td>mime</td> <td>mime</td>
<td></td> <td></td>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
@each(posts as post) @each(posts as post)
<tr> <tr>
<td><img src="data:image/webp;base64,{{ post.thumbnail }}" /></td> <td><img src="data:image/webp;base64,{{ post.thumbnail }}" /></td>
<td>{{ post.id }}</td> <td>{{ post.id }}</td>
<td>{{ post.username }}</td> <td>{{ post.username }}</td>
<td>{{ post.mime }}</td> <td>{{ post.mime }}</td>
<td><a href="/admin/recover/?id={{ post.id }}">recover</a></td> <td><a href="/admin/recover/?id={{ post.id }}">recover</a></td>
</tr> </tr>
@endeach @endeach
</tbody> </tbody>
</table> </table>
</div>
@include(snippets/footer) @include(snippets/footer)

View File

@ -1,7 +1,8 @@
@include(snippets/header_admin) @include(snippets/header)
<table class="table" style="width: 100%"> <div id="main">
<thead> <table class="table" style="width: 100%">
<tr> <thead>
<tr>
<td></td> <td></td>
<td>ID</td> <td>ID</td>
<td>userid</td> <td>userid</td>
@ -10,11 +11,11 @@
<td>created_at</td> <td>created_at</td>
<td>last_used</td> <td>last_used</td>
<td>last_action</td> <td>last_action</td>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
@each(sessions as session) @each(sessions as session)
<tr> <tr>
<td>{{ session.kmsi ? '&#9875;' : '' }}</td> <td>{{ session.kmsi ? '&#9875;' : '' }}</td>
<td>{{ session.id }}</td> <td>{{ session.id }}</td>
<td>{{ session.user_id }}</td> <td>{{ session.user_id }}</td>
@ -23,8 +24,9 @@
<td>{{ new Date(session.created_at * 1e3).toLocaleString("de-DE") }}</td> <td>{{ new Date(session.created_at * 1e3).toLocaleString("de-DE") }}</td>
<td>{{ new Date(session.last_used * 1e3).toLocaleString("de-DE") }}</td> <td>{{ new Date(session.last_used * 1e3).toLocaleString("de-DE") }}</td>
<td>{{ session.last_action }}</td> <td>{{ session.last_action }}</td>
</tr> </tr>
@endeach @endeach
</tbody> </tbody>
</table> </table>
</div>
@include(snippets/footer) @include(snippets/footer)

View File

@ -1,19 +0,0 @@
<!doctype html>
<html lang="en" theme="@if(typeof theme !== "undefined"){{ theme }}@endif">
<head>
<title>@if(typeof data !== "undefined" && data.title){{ data.title }}@elsef0ck!@endif</title>
<link rel="icon" type="image/gif" href="/s/img/favicon.gif" />
<link rel="stylesheet" href="/s/css/f0ck.css">
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="description" content="f0ck.me is the place where internet purists gather to celebrate content of all kinds">
@if(typeof data !== "undefined" && data.item)
<meta property="og:site_name" content="f0ck.me" />
<meta property="og:description"/>
<meta name="Description"/>
<meta property="og:image" content="{{ item.thumbnail }}" />
@endif
</head>
<body>
@include(snippets/navbar_admin)
<div id="main">

View File

@ -8,7 +8,9 @@
<img src="@if(session.avatar)/t/{{ session.avatar }}.webp@else/s/img/ava/default.png@endif" class="avatar" /><span>{{ session.user }}</span> <img src="@if(session.avatar)/t/{{ session.avatar }}.webp@else/s/img/ava/default.png@endif" class="avatar" /><span>{{ session.user }}</span>
</a> </a>
<ul class="dropdown-menu"> <ul class="dropdown-menu">
<li><a href="/admin">adminpanel</a></li> <li><a href="/admin/log">logfile</a></li>
<li><a href="/admin/sessions">all sessions</a></li>
<li><a href="/admin/recover">recover</a></li>
<li><a href="/user/{{ session.user.toLowerCase() }}/f0cks">my f0cks</a></li> <li><a href="/user/{{ session.user.toLowerCase() }}/f0cks">my f0cks</a></li>
<li><a href="/user/{{ session.user.toLowerCase() }}/favs">my favs</a></li> <li><a href="/user/{{ session.user.toLowerCase() }}/favs">my favs</a></li>
<li><a href="/settings">settings</a></li> <li><a href="/settings">settings</a></li>

View File

@ -1,33 +0,0 @@
<nav class="navbar navbar-expand-lg">
<a class="navbar-brand" href="/"><span class="f0ck">F0CK</span></a>
<div class="navigation-links">
<ul class="navbar-nav">
<li class="nav-item dropdown" id="themes">
<a class="nav-link" href="#" content="{{ theme }}" data-toggle="dropdown">Theme</a>
<ul class="dropdown-menu">
@each(themes as t)
<li><a href="/theme/{{ t }}">{{ t }}</a></li>
@endeach
</ul>
</li>
<li class="nav-item">
<a class="nav-link" href="/admin/sessions">
<span class="nav-link-identifier">sessions</span>
</a>
</li>
<li class="nav-item">
<a class="nav-link" href="/admin/log">
<span class="nav-link-identifier">Log</span>
</a>
</li>
<li class="nav-item">
<a class="nav-link" href="/admin/recover">
<span class="nav-link-identifier">Recover</span>
</a>
</li>
<li class="nav-item">
<a class="nav-link" href="/logout">Logout</a>
</li>
</ul>
</div>
</nav>