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

View File

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

View File

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

View File

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

View File

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

@ -2,53 +2,55 @@
<nav class="navbar navbar-expand-lg">
<a class="navbar-brand" href="/"><span class="f0ck" width="" height="">F0CK</span></a>
<div class="navigation-links">
<ul class="navbar-nav">
<li class="nav-item dropdown">
<a class="nav-link user" href="#" content="{{ session.user }}" data-toggle="dropdown">
<img src="@if(session.avatar)/t/{{ session.avatar }}.webp@else/s/img/ava/default.png@endif" class="avatar" /><span>{{ session.user }}</span>
</a>
<ul class="dropdown-menu">
<li><a href="/admin">adminpanel</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="/settings">settings</a></li>
<li><a href="/search">search</a></li>
<li><a href="/about">About</a></li>
<li><a href="/ranking">Ranking</a></li>
<li><a href="/logout">logout</a></li>
</ul>
</li>
<li class="nav-item dropdown" id="themes">
<a class="nav-link ddcontent" href="#" content="{{ theme }}" data-toggle="dropdown">Themes</a>
<ul class="dropdown-menu">
@each(themes as t)
<li><a href="/theme/{{ t }}">{{ t }}</a></li>
@endeach
</ul>
</li>
<li class="nav-item dropdown">
<a class="nav-link ddcontent" href="#"@if(tmp?.mime) content="{{ tmp?.mime }}" data-toggle="dropdown"@endif>Filter@if(!tmp?.mime)&nbsp;&#9660;@endif</a>
<ul class="dropdown-menu">
<li><a class="dropdown-item" href="/@if(tmp?.user)user/{{ tmp?.user }}/@endif">All</a></li>
<li><a class="dropdown-item" href="/@if(tmp?.user)user/{{ tmp?.user }}/@endifaudio">Audio</a></li>
<li><a class="dropdown-item" href="/@if(tmp?.user)user/{{ tmp?.user }}/@endifvideo">Video</a></li>
<li><a class="dropdown-item" href="/@if(tmp?.user)user/{{ tmp?.user }}/@endifimage">Image</a></li>
</ul>
</li>
<li class="nav-item @if(session)dropdown@endif">
<a class="nav-link ddcontent" href="#"@if(typeof session.mode !== "undefined") content="{{ modes[session.mode] ?? 'sfw' }}" data-toggle="dropdown"@endif>Mode</a>
<ul class="dropdown-menu">
@for(let i = 0; i < modes.length; i++)
<li><a class="dropdown-item" href="/mode/{{ i }}">{{ modes[i] }}</a></li>
@endfor
</ul>
</li>
<li class="nav-item">
<a id="random" class="nav-link" href="/random">
<span class="nav-link-identifier">Random</span>
</a>
</li>
</ul>
<ul class="navbar-nav">
<li class="nav-item dropdown">
<a class="nav-link user" href="#" content="{{ session.user }}" data-toggle="dropdown">
<img src="@if(session.avatar)/t/{{ session.avatar }}.webp@else/s/img/ava/default.png@endif" class="avatar" /><span>{{ session.user }}</span>
</a>
<ul class="dropdown-menu">
<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() }}/favs">my favs</a></li>
<li><a href="/settings">settings</a></li>
<li><a href="/search">search</a></li>
<li><a href="/about">About</a></li>
<li><a href="/ranking">Ranking</a></li>
<li><a href="/logout">logout</a></li>
</ul>
</li>
<li class="nav-item dropdown" id="themes">
<a class="nav-link ddcontent" href="#" content="{{ theme }}" data-toggle="dropdown">Themes</a>
<ul class="dropdown-menu">
@each(themes as t)
<li><a href="/theme/{{ t }}">{{ t }}</a></li>
@endeach
</ul>
</li>
<li class="nav-item dropdown">
<a class="nav-link ddcontent" href="#"@if(tmp?.mime) content="{{ tmp?.mime }}" data-toggle="dropdown"@endif>Filter@if(!tmp?.mime)&nbsp;&#9660;@endif</a>
<ul class="dropdown-menu">
<li><a class="dropdown-item" href="/@if(tmp?.user)user/{{ tmp?.user }}/@endif">All</a></li>
<li><a class="dropdown-item" href="/@if(tmp?.user)user/{{ tmp?.user }}/@endifaudio">Audio</a></li>
<li><a class="dropdown-item" href="/@if(tmp?.user)user/{{ tmp?.user }}/@endifvideo">Video</a></li>
<li><a class="dropdown-item" href="/@if(tmp?.user)user/{{ tmp?.user }}/@endifimage">Image</a></li>
</ul>
</li>
<li class="nav-item @if(session)dropdown@endif">
<a class="nav-link ddcontent" href="#"@if(typeof session.mode !== "undefined") content="{{ modes[session.mode] ?? 'sfw' }}" data-toggle="dropdown"@endif>Mode</a>
<ul class="dropdown-menu">
@for(let i = 0; i < modes.length; i++)
<li><a class="dropdown-item" href="/mode/{{ i }}">{{ modes[i] }}</a></li>
@endfor
</ul>
</li>
<li class="nav-item">
<a id="random" class="nav-link" href="/random">
<span class="nav-link-identifier">Random</span>
</a>
</li>
</ul>
</div>
<div class="collapse navbar-collapse show" id="navbarSupportedContent">
<div class="pagination-container-fluid">

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>