From 2301d15abd14ef8262018c6d4499627406d3c56b Mon Sep 17 00:00:00 2001 From: Flummi Date: Wed, 3 May 2023 05:13:48 +0200 Subject: [PATCH] cleaned up --- src/inc/routes/admin.mjs | 25 +++++++-- views/admin.html | 8 ++- views/admin/log.html | 30 +++++----- views/admin/recover.html | 50 +++++++++-------- views/admin/sessions.html | 62 +++++++++++---------- views/snippets/header_admin.html | 19 ------- views/snippets/navbar.html | 96 ++++++++++++++++---------------- views/snippets/navbar_admin.html | 33 ----------- 8 files changed, 147 insertions(+), 176 deletions(-) delete mode 100644 views/snippets/header_admin.html delete mode 100644 views/snippets/navbar_admin.html diff --git a/src/inc/routes/admin.mjs b/src/inc/routes/admin.mjs index 490f8f0..25e0cb3 100644 --- a/src/inc/routes/admin.mjs +++ b/src/inc/routes/admin.mjs @@ -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) }); }); diff --git a/views/admin.html b/views/admin.html index 607fbe1..b1fddab 100644 --- a/views/admin.html +++ b/views/admin.html @@ -1,10 +1,12 @@ -@include(snippets/header_admin) -
+@include(snippets/header) +
+

Henlo, {{ session.user }}

Hier entsteht eine Internetpräsenz!

f0ck bash

@if(typeof totals !== "undefined") total: {{ totals.total }} | tagged: {{ totals.tagged }} | untagged: {{ totals.untagged }} | sfw: {{ totals.sfw }} | nsfw: {{ totals.nsfw }} @endif

+
-@include(snippets/footer) \ No newline at end of file +@include(snippets/footer) diff --git a/views/admin/log.html b/views/admin/log.html index f8066fa..13d6bb4 100644 --- a/views/admin/log.html +++ b/views/admin/log.html @@ -1,16 +1,18 @@ -@include(snippets/header_admin) -@if(log) -

last {{ log.length }} entries:

-
-@each(log as line) -

{{ line }}

-@endeach +@include(snippets/header) +
+ @if(log) +

last {{ log.length }} entries:

+
+ @each(log as line) +

{{ line }}

+ @endeach +
+ + @endif
- -@endif @include(snippets/footer) diff --git a/views/admin/recover.html b/views/admin/recover.html index 6ef1f0b..bc10099 100644 --- a/views/admin/recover.html +++ b/views/admin/recover.html @@ -1,24 +1,26 @@ -@include(snippets/header_admin) - - - - - - - - - - - -@each(posts as post) - - - - - - - -@endeach - -
IDf0ckermime
{{ post.id }}{{ post.username }}{{ post.mime }}recover
-@include(snippets/footer) \ No newline at end of file +@include(snippets/header) +
+ + + + + + + + + + + + @each(posts as post) + + + + + + + + @endeach + +
IDf0ckermime
{{ post.id }}{{ post.username }}{{ post.mime }}recover
+
+@include(snippets/footer) diff --git a/views/admin/sessions.html b/views/admin/sessions.html index 54fc61e..65c6642 100644 --- a/views/admin/sessions.html +++ b/views/admin/sessions.html @@ -1,30 +1,32 @@ -@include(snippets/header_admin) - - - - - - - - - - - - - - -@each(sessions as session) - - - - - - - - - - -@endeach - -
IDuseriduserbrowsercreated_atlast_usedlast_action
{{ session.kmsi ? '⚓' : '' }}{{ session.id }}{{ session.user_id }}{{ session.user }}{{ session.browser }}{{ new Date(session.created_at * 1e3).toLocaleString("de-DE") }}{{ new Date(session.last_used * 1e3).toLocaleString("de-DE") }}{{ session.last_action }}
-@include(snippets/footer) \ No newline at end of file +@include(snippets/header) +
+ + + + + + + + + + + + + + + @each(sessions as session) + + + + + + + + + + + @endeach + +
IDuseriduserbrowsercreated_atlast_usedlast_action
{{ session.kmsi ? '⚓' : '' }}{{ session.id }}{{ session.user_id }}{{ session.user }}{{ session.browser }}{{ new Date(session.created_at * 1e3).toLocaleString("de-DE") }}{{ new Date(session.last_used * 1e3).toLocaleString("de-DE") }}{{ session.last_action }}
+
+@include(snippets/footer) diff --git a/views/snippets/header_admin.html b/views/snippets/header_admin.html deleted file mode 100644 index a2e3147..0000000 --- a/views/snippets/header_admin.html +++ /dev/null @@ -1,19 +0,0 @@ - - - - @if(typeof data !== "undefined" && data.title){{ data.title }}@elsef0ck!@endif - - - - - - @if(typeof data !== "undefined" && data.item) - - - - - @endif - - - @include(snippets/navbar_admin) -
\ No newline at end of file diff --git a/views/snippets/navbar.html b/views/snippets/navbar.html index 348ca61..a4d5451 100644 --- a/views/snippets/navbar.html +++ b/views/snippets/navbar.html @@ -2,53 +2,55 @@