From 2229f32dd33f51605666633ecdc9c5817fc5c2cc Mon Sep 17 00:00:00 2001 From: x Date: Sat, 24 Jan 2026 10:58:22 +0100 Subject: [PATCH] potential fix for the last fucked up commits xd --- src/inc/routes/ajax.mjs | 1 + src/inc/routes/apiv2/index.mjs | 2 +- src/inc/routes/index.mjs | 25 ++++++++++++++----------- views/snippets/navbar.html | 4 ++-- 4 files changed, 18 insertions(+), 14 deletions(-) diff --git a/src/inc/routes/ajax.mjs b/src/inc/routes/ajax.mjs index f1f781a..90cacae 100644 --- a/src/inc/routes/ajax.mjs +++ b/src/inc/routes/ajax.mjs @@ -56,6 +56,7 @@ export default (router, tpl) => { // Inject missing variables normally provided by req or middleware data.url = { pathname: `/${req.params.itemid}` }; // Template expects url.pathname data.fullscreen = req.cookies.fullscreen || 0; // Index.mjs uses req.cookies.fullscreen + data.hidePagination = true; // Render both the item content and the pagination const itemHtml = tpl.render('ajax-item', data); diff --git a/src/inc/routes/apiv2/index.mjs b/src/inc/routes/apiv2/index.mjs index 682dc62..7ecedca 100644 --- a/src/inc/routes/apiv2/index.mjs +++ b/src/inc/routes/apiv2/index.mjs @@ -39,7 +39,7 @@ export default router => { mime ilike ${mime} and active = 'true' ${isFav ? db`and fu."user" = ${user}` : db`and items.username ilike ${user}`} - ${tag ? db`and tags.normalized ilike ${'%' + tag + '%'}` : db``} + ${tag ? db`and tags.normalized ilike '%' || slugify(${tag}) || '%'` : db``} ${!hasSession && globalfilter ? db`and items.id not in (select item_id from tags_assign where item_id = items.id and (${db.unsafe(globalfilter)}))` : db``} order by random() limit 1 diff --git a/src/inc/routes/index.mjs b/src/inc/routes/index.mjs index 2cec80a..545b77e 100644 --- a/src/inc/routes/index.mjs +++ b/src/inc/routes/index.mjs @@ -4,7 +4,7 @@ import lib from "../lib.mjs"; import f0cklib from "../routeinc/f0cklib.mjs"; const auth = async (req, res, next) => { - if(!req.session) + if (!req.session) return res.redirect("/login"); return next(); }; @@ -21,7 +21,7 @@ export default (router, tpl) => { limit 1 `; - if(!query.length) { + if (!query.length) { return res.reply({ code: 404, body: tpl.render('error', { @@ -44,11 +44,11 @@ export default (router, tpl) => { session: !!req.session, limit: 99999999 }); - if('items' in f0cks) { + if ('items' in f0cks) { count.f0cks = f0cks.items.length; f0cks.items = f0cks.items.slice(0, 50); } - } catch(err) { + } catch (err) { f0cks = false; count.f0cks = 0; } @@ -60,11 +60,11 @@ export default (router, tpl) => { session: !!req.session, limit: 99999999 }); - if('items' in favs) { + if ('items' in favs) { count.favs = favs.items.length; favs.items = favs.items.slice(0, 50); } - } catch(err) { + } catch (err) { favs = false; count.favs = 0; } @@ -93,7 +93,7 @@ export default (router, tpl) => { session: !!req.session, url: req.url.pathname }); - if(!data.success) { + if (!data.success) { return res.reply({ code: 404, body: tpl.render('error', { @@ -103,6 +103,10 @@ export default (router, tpl) => { }); } + if (mode === 'item') { + data.hidePagination = true; + } + return res.reply({ body: tpl.render(mode, data, req) }); }); @@ -123,10 +127,10 @@ export default (router, tpl) => { let referertmp = req.headers.referer; let referer = ""; - if(referertmp?.match(/f0ck\.me/)) + if (referertmp?.match(/f0ck\.me/)) referer = referertmp.split("/").slice(3).join("/"); - if(cfg.allowedModes[mode]) { + if (cfg.allowedModes[mode]) { const blah = { user_id: req.session.id, mode: mode, @@ -134,8 +138,7 @@ export default (router, tpl) => { }; await db` - insert into "user_options" ${ - db(blah, 'user_id', 'mode', 'theme') + insert into "user_options" ${db(blah, 'user_id', 'mode', 'theme') } on conflict ("user_id") do update set mode = excluded.mode, diff --git a/views/snippets/navbar.html b/views/snippets/navbar.html index 1782003..4154bf9 100644 --- a/views/snippets/navbar.html +++ b/views/snippets/navbar.html @@ -39,7 +39,7 @@ - @if(!/^\/\d+$/.test(url.pathname)) + @if(typeof hidePagination === 'undefined' || !hidePagination)