potential fix for the last fucked up commits xd
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -39,7 +39,7 @@
|
||||
</div>
|
||||
</div>
|
||||
<!-- show pagination only for tags and main page -->
|
||||
@if(!/^\/\d+$/.test(url.pathname))
|
||||
@if(typeof hidePagination === 'undefined' || !hidePagination)
|
||||
<div class="collapse navbar-collapse show" id="navbarSupportedContent">
|
||||
<div class="pagination-container-fluid">
|
||||
<div class="pagination-wrapper">
|
||||
@@ -74,7 +74,7 @@
|
||||
</ol>
|
||||
</div>
|
||||
<!-- show pagination only for tags and main page -->
|
||||
@if(!(/\/\d+$/.test(url.pathname) && !/\/p\/\d+$/.test(url.pathname)))
|
||||
@if(typeof hidePagination === 'undefined' || !hidePagination)
|
||||
<div class="collapse navbar-collapse show" id="navbarSupportedContent">
|
||||
<div class="pagination-container-fluid">
|
||||
<div class="pagination-wrapper">
|
||||
|
||||
Reference in New Issue
Block a user