From c0669602dd6258ae2ea4d8a76e2d2519ea09ff0d Mon Sep 17 00:00:00 2001 From: Flummi Date: Fri, 6 May 2022 14:20:11 +0200 Subject: [PATCH] search shmearch --- public/s/css/f0ck.css | 56 ++++++++++++++++++++++++++++++-- src/inc/routes/admin.mjs | 38 ---------------------- src/inc/routes/search.mjs | 44 +++++++++++++++++++++++++ views/admin/search.html | 27 --------------- views/search.html | 31 ++++++++++++++++++ views/snippets/navbar.html | 1 + views/snippets/navbar_admin.html | 5 --- 7 files changed, 130 insertions(+), 72 deletions(-) create mode 100644 src/inc/routes/search.mjs delete mode 100644 views/admin/search.html create mode 100644 views/search.html diff --git a/public/s/css/f0ck.css b/public/s/css/f0ck.css index 881bc1a..6d47944 100644 --- a/public/s/css/f0ck.css +++ b/public/s/css/f0ck.css @@ -40,6 +40,10 @@ html[theme='f0ck'] { --scroller-bg: #424242; } +html[theme="f0ck"] .admin-search button { + color: var(--black)!important; +} + html[theme='p1nk'] { --accent: #ff00d0; --bg: #171717; @@ -146,6 +150,23 @@ html[theme='amoled'] { --scroller-bg: #424242; } +html[theme="amoled"] .admin-search button { + color: var(--black)!important; +} + +html[theme="amoled"] table.table tbody tr:nth-of-type(2n+1) a { + color: var(--white) !important; + text-decoration: underline; +} + +html[theme="amoled"] table.table tbody tr:nth-of-type(2n+1) { + color: var(--white) !important; +} + +html[theme="amoled"] table.table a { + text-decoration: underline; +} + html[theme="paper"] { --accent: #000; --bg: #fff; @@ -265,6 +286,28 @@ html[theme="paper"] span#favs { border: 1px solid var(--white); } +html[theme="paper"] .admin-search button { + color: var(--white)!important; + opacity: 0.9; +} + +html[theme="paper"] table.table tbody tr:nth-of-type(2n+1) a { + color: var(--white) !important; + text-decoration: underline; +} + +html[theme="paper"] table.table tbody tr:nth-of-type(2n+1) { + color: var(--white) !important; +} + +html[theme="paper"] table.table a { + text-decoration: underline; +} + +html[theme="paper"] a { + color: var(--black); +} + html[theme="atmos"] { --accent: #1fb2b0; --bg: #161618; @@ -438,7 +481,7 @@ html, body { } a { - color: var(--accent) !important; + color: var(--accent) /* !important */; cursor: pointer; text-decoration: none; } @@ -616,7 +659,7 @@ span.f0ck { border-radius: 3px; background-image: linear-gradient(to bottom,var(--nav-link-background-linear-gradient)); box-shadow: var(--nav-link-box-shadow); - color: transparent; + /* color: transparent; */ } .navbar-expand-lg .navbar-nav .nav-link, .pagination > a, .pagination > span { @@ -1729,4 +1772,13 @@ a[data-mime^="audio"] { .admin-search input { padding: 15px; + border: 1px solid var(--accent); +} + +table img { + border: 1px solid; +} + +.results { + padding: 5px; } diff --git a/src/inc/routes/admin.mjs b/src/inc/routes/admin.mjs index e2ff4aa..139504b 100644 --- a/src/inc/routes/admin.mjs +++ b/src/inc/routes/admin.mjs @@ -1,7 +1,6 @@ import db from "../sql.mjs"; import lib from "../lib.mjs"; import { exec } from "child_process"; -import search from "../routeinc/search.mjs"; const auth = async (req, res, next) => { if(!req.session) { @@ -120,43 +119,6 @@ export default (router, tpl) => { }, req) }); }); - - router.get(/^\/admin\/test(\/)?$/, auth, async (req, res) => { - let ret; - if(Object.keys(req.url.qs).length > 0) { - let tag = req.url.qs.tag; - let rows; - - if(tag.startsWith('src:')) { - tag = tag.substring(4); - ret = await db` - select * - from "items" - where src ilike ${'%' + tag + '%'} - limit 500 - `; - } - else { - rows = await db` - select "items".id, "items".username, "tags".tag - from "tags" - left join "tags_assign" on "tags_assign".tag_id = "tags".id - left join "items" on "items".id = "tags_assign".item_id - where "tags".tag ilike ${'%' + tag + '%'} - limit 500 - `; - ret = search(rows, tag); - } - } - - res.reply({ - body: tpl.render("admin/search", { - result: ret, - totals: await lib.countf0cks(), - session: req.session - }, req) - }); - }); router.get(/^\/admin\/log(\/)?$/, auth, async (req, res) => { exec("journalctl -qeu f0ck --no-pager", (err, stdout) => { diff --git a/src/inc/routes/search.mjs b/src/inc/routes/search.mjs new file mode 100644 index 0000000..28f52fd --- /dev/null +++ b/src/inc/routes/search.mjs @@ -0,0 +1,44 @@ +import db from "../sql.mjs"; +import lib from "../lib.mjs"; +import search from "../routeinc/search.mjs"; + +export default (router, tpl) => { + router.get(/^\/search(\/)?$/, lib.auth, async (req, res) => { + let ret; + let tag = req.url.qs?.tag; + if(Object.keys(req.url.qs).length > 0) { + let rows; + + if(tag.startsWith('src:')) { + tag = tag.substring(4); + ret = await db` + select * + from "items" + where src ilike ${'%' + tag + '%'} + limit 500 + `; + } + else { + rows = await db` + select "items".id, "items".username, "items".mime, "tags".tag + from "tags" + left join "tags_assign" on "tags_assign".tag_id = "tags".id + left join "items" on "items".id = "tags_assign".item_id + where "tags".tag ilike ${'%' + tag + '%'} + limit 500 + `; + ret = search(rows, tag); + } + } + + res.reply({ + body: tpl.render("search", { + result: ret, + totals: await lib.countf0cks(), + searchstring: tag, + session: req.session, + tmp: null + }, req) + }); + }); +}; diff --git a/views/admin/search.html b/views/admin/search.html deleted file mode 100644 index 4545972..0000000 --- a/views/admin/search.html +++ /dev/null @@ -1,27 +0,0 @@ -@include(snippets/header_admin) -
- -
-
-@if(result) -

{{ result.length }} f0cks given

- - - - - - - - -@each(result as line) - - - - - - - -@endeach -
ThumbnailIDTagUsernameScore
{{ line.id }}{{ line.tag }}{{ line.username }}{{ line.score }}
-@endif -@include(snippets/footer) \ No newline at end of file diff --git a/views/search.html b/views/search.html new file mode 100644 index 0000000..f3e3297 --- /dev/null +++ b/views/search.html @@ -0,0 +1,31 @@ +@include(snippets/header) +

f0ckgle

+ +
+ @if(result) +

{{ result.length }} f0cks given:

+ + + + + + + + + + @each(result as line) + + + + + + + + + @endeach +
ThumbnailIDTagMimeUsernameScore
{{ line.id }}{!! line.tag !!}{{ line.mime }}{!! line.username !!}{{ line.score.toFixed(2) }}
+ @endif +
+@include(snippets/footer) \ No newline at end of file diff --git a/views/snippets/navbar.html b/views/snippets/navbar.html index da67e28..cea349d 100644 --- a/views/snippets/navbar.html +++ b/views/snippets/navbar.html @@ -12,6 +12,7 @@
  • my f0cks
  • my favs
  • settings
  • +
  • search
  • About
  • Ranking
  • logout
  • diff --git a/views/snippets/navbar_admin.html b/views/snippets/navbar_admin.html index 01d0649..62b140b 100644 --- a/views/snippets/navbar_admin.html +++ b/views/snippets/navbar_admin.html @@ -15,11 +15,6 @@ sessions -