fix random & search
This commit is contained in:
parent
f5737e6f49
commit
155d496592
|
@ -1,3 +1,4 @@
|
|||
import cfg from "../../inc/config.mjs";
|
||||
import f0cklib from "../routeinc/f0cklib.mjs";
|
||||
|
||||
export default (router, tpl) => {
|
||||
|
@ -5,8 +6,8 @@ export default (router, tpl) => {
|
|||
let referer = req.headers.referer ?? '';
|
||||
let opts = {};
|
||||
|
||||
if(referer.match(/f0ck\.me/)) { // parse referer
|
||||
referer = referer.split("f0ck.me")[1];
|
||||
if(referer.match(new RegExp(cfg.main.url.regex))) { // parse referer
|
||||
referer = referer.split(cfg.main.url.domain)[1];
|
||||
const tmp = referer.match(/^\/?(?:\/tag\/(?<tag>.+?))?(?:\/user\/(?<user>.+?)\/(?<mode>f0cks|favs))?(?:\/(?<mime>image|audio|video))?(?:\/p\/(?<page>\d+))?(?:\/(?<itemid>\d+))?$/);
|
||||
if(tmp)
|
||||
opts = tmp.groups;
|
||||
|
@ -31,7 +32,7 @@ export default (router, tpl) => {
|
|||
});
|
||||
}
|
||||
|
||||
res.redirect(`/${data.link}${data.link.length != 0 ? "/" : ""}${data.itemid}`);
|
||||
res.redirect(`${data.link.main}${data.link.path}${data.itemid}`);
|
||||
});
|
||||
return router;
|
||||
};
|
||||
|
|
|
@ -18,7 +18,7 @@ export default (router, tpl) => {
|
|||
select count(*) as total
|
||||
from "items"
|
||||
where src ilike ${'%' + tag.substring(4) + '%'}
|
||||
group by "items".id, "tags".tag
|
||||
group by "items".id
|
||||
`).length;
|
||||
}
|
||||
else {
|
||||
|
@ -41,7 +41,8 @@ export default (router, tpl) => {
|
|||
select *
|
||||
from "items"
|
||||
where src ilike ${'%' + tag.substring(4) + '%'}
|
||||
group by "items".id, "tags".tag
|
||||
group by "items".id
|
||||
order by "items".id desc
|
||||
offset ${offset}
|
||||
limit ${_eps}
|
||||
`;
|
||||
|
|
|
@ -25,7 +25,7 @@ export default async bot => {
|
|||
return e.reply("no f0cks given! lol D:");
|
||||
|
||||
e.reply([
|
||||
`${cfg.main.url}/${rows[0].id}`,
|
||||
`${cfg.main.url.full}/${rows[0].id}`,
|
||||
`user: ${rows[0].username} @ ${rows[0].usernetwork} ${rows[0].userchannel}`,
|
||||
`~${lib.formatSize(rows[0].size)}`,
|
||||
rows[0].mime,
|
||||
|
|
|
@ -24,7 +24,7 @@ export default async bot => {
|
|||
if(rows.length === 0)
|
||||
return e.reply("nothing found, f0cker");
|
||||
|
||||
return e.reply(`f0ckrnd: ${cfg.main.url}/${rows[0].id} by: ${rows[0].username} (${rows[0].mime}, ~${lib.formatSize(rows[0].size)})`);
|
||||
return e.reply(`f0ckrnd: ${cfg.main.url.full}/${rows[0].id} by: ${rows[0].username} (${rows[0].mime}, ~${lib.formatSize(rows[0].size)})`);
|
||||
}
|
||||
}];
|
||||
};
|
||||
|
|
|
@ -51,7 +51,7 @@ export default async bot => {
|
|||
where src = ${link}
|
||||
`;
|
||||
if(q_repost.length > 0)
|
||||
return e.reply(`repost motherf0cker (link): ${cfg.main.url}/${q_repost[0].id}`);
|
||||
return e.reply(`repost motherf0cker (link): ${cfg.main.url.full}/${q_repost[0].id}`);
|
||||
|
||||
// generate uuid
|
||||
const uuid = (await db`
|
||||
|
@ -120,7 +120,7 @@ export default async bot => {
|
|||
where checksum = ${checksum}
|
||||
`;
|
||||
if(q_repostc.length > 0)
|
||||
return e.reply(`repost motherf0cker (checksum): ${cfg.main.url}/${q_repostc[0].id}`);
|
||||
return e.reply(`repost motherf0cker (checksum): ${cfg.main.url.full}/${q_repostc[0].id}`);
|
||||
|
||||
await fs.promises.copyFile(`./tmp/${filename}`, `./public/b/${filename}`);
|
||||
await fs.promises.unlink(`./tmp/${filename}`).catch(_=>{});
|
||||
|
@ -241,7 +241,7 @@ export default async bot => {
|
|||
}
|
||||
|
||||
e.reply([
|
||||
`[f0cked] link: ${cfg.main.url}/${itemid} | size: ${lib.formatSize(size)} | speed: ${speed}` + (tags.length > 0 ? ` | tags: ${tags.join(', ')}` : '')
|
||||
`[f0cked] link: ${cfg.main.url.full}/${itemid} | size: ${lib.formatSize(size)} | speed: ${speed}` + (tags.length > 0 ? ` | tags: ${tags.join(', ')}` : '')
|
||||
]);
|
||||
|
||||
});
|
||||
|
|
|
@ -15,8 +15,8 @@ export default async bot => {
|
|||
return e.reply("lol no");
|
||||
const tags = (await lib.getTags(id)).map(t => t.tag);
|
||||
if(tags.length === 0)
|
||||
return e.reply(`item ${cfg.main.url}/${id} has no tags!`);
|
||||
return e.reply(`item ${cfg.main.url}/${id} is tagged as: ${tags.join(', ')}`);
|
||||
return e.reply(`item ${cfg.main.url.full}/${id} has no tags!`);
|
||||
return e.reply(`item ${cfg.main.url.full}/${id} is tagged as: ${tags.join(', ')}`);
|
||||
}
|
||||
}, {
|
||||
name: "tags add",
|
||||
|
@ -73,8 +73,8 @@ export default async bot => {
|
|||
|
||||
const ntags = (await lib.getTags(id)).map(t => t.tag);
|
||||
if(ntags.length === 0)
|
||||
return e.reply(`item ${cfg.main.url}/${id} has no tags!`);
|
||||
return e.reply(`item ${cfg.main.url}/${id} is now tagged as: ${ntags.join(', ')}`);
|
||||
return e.reply(`item ${cfg.main.url.full}/${id} has no tags!`);
|
||||
return e.reply(`item ${cfg.main.url.full}/${id} is now tagged as: ${ntags.join(', ')}`);
|
||||
}
|
||||
}, {
|
||||
name: "tags remove",
|
||||
|
@ -126,8 +126,8 @@ export default async bot => {
|
|||
|
||||
const ntags = (await lib.getTags(id)).map(t => t.tag);
|
||||
if(ntags.length === 0)
|
||||
return e.reply(`item ${cfg.main.url}/${id} has no tags!`);
|
||||
return e.reply(`item ${cfg.main.url}/${id} is now tagged as: ${ntags.join(', ')}`);
|
||||
return e.reply(`item ${cfg.main.url.full}/${id} has no tags!`);
|
||||
return e.reply(`item ${cfg.main.url.full}/${id} is now tagged as: ${ntags.join(', ')}`);
|
||||
}
|
||||
}]
|
||||
};
|
||||
|
|
|
@ -25,7 +25,7 @@
|
|||
<td><a href="/tag/{!! line.tag !!}">{!! line.tag !!}</a></td>
|
||||
<td>{{ line.mime }}</td>
|
||||
<td><a href="/user/{!! line.username !!}/f0cks/{{ line.id }}">{!! line.username !!}</a></td>
|
||||
<td>{{ line.score.toFixed(2) }}</td>
|
||||
<td>{{ line.score?.toFixed(2) }}</td>
|
||||
</tr>
|
||||
@endeach
|
||||
</tbody>
|
||||
|
|
Loading…
Reference in New Issue
Block a user