error pages
This commit is contained in:
parent
0f8ab86966
commit
ba8a0c6b68
@ -29,11 +29,24 @@ export default (router, tpl) => {
|
|||||||
let data;
|
let data;
|
||||||
|
|
||||||
if(user && (await sql("items").where("username", "like", user).count("* as total"))[0].total === 0)
|
if(user && (await sql("items").where("username", "like", user).count("* as total"))[0].total === 0)
|
||||||
return res.end("200 - user not found lol");
|
return res.reply({
|
||||||
|
code: 404,
|
||||||
|
body: tpl.render('error', {
|
||||||
|
message: "404 - user not found",
|
||||||
|
tmp: null
|
||||||
|
}, req)
|
||||||
|
});
|
||||||
|
|
||||||
if(mode === "item") { // item!
|
if(mode === "item") { // item!
|
||||||
if(itemid === 404)
|
if(itemid === 404) {
|
||||||
return res.end("404 - lol");
|
return res.reply({
|
||||||
|
code: 404,
|
||||||
|
body: tpl.render('error', {
|
||||||
|
message: "404 - f0ck not found",
|
||||||
|
tmp: null
|
||||||
|
}, req)
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
let items = sql("items").select("*").orderBy("items.id", "desc").whereRaw(modequery);
|
let items = sql("items").select("*").orderBy("items.id", "desc").whereRaw(modequery);
|
||||||
if(tag) {
|
if(tag) {
|
||||||
@ -57,8 +70,15 @@ export default (router, tpl) => {
|
|||||||
const item = items.findIndex(i => i.id === itemid);
|
const item = items.findIndex(i => i.id === itemid);
|
||||||
const actitem = items[item];
|
const actitem = items[item];
|
||||||
|
|
||||||
if(!actitem) // sfw-check!
|
if(!actitem) { // sfw-check!
|
||||||
return res.end("Sorry, this f0ck either doesn't exist (yet) or hasn't been tagged yet, please remain patient, a support assistant will be shortly with you.");
|
return res.reply({
|
||||||
|
code: 404,
|
||||||
|
body: tpl.render('error', {
|
||||||
|
message: "Sorry, this f0ck either doesn't exist (yet) or hasn't been tagged yet.<br />Please remain patient, a support assistant will be shortly with you.",
|
||||||
|
tmp: null
|
||||||
|
}, req)
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
const tags = await lib.getTags(itemid);
|
const tags = await lib.getTags(itemid);
|
||||||
const cheat = items.slice(Math.max(0, item - 3), item + 4).map(i => i.id);
|
const cheat = items.slice(Math.max(0, item - 3), item + 4).map(i => i.id);
|
||||||
@ -104,7 +124,14 @@ export default (router, tpl) => {
|
|||||||
|
|
||||||
if(tag) {
|
if(tag) {
|
||||||
if(tag.match(/sfw/) || tag.length <= 2)
|
if(tag.match(/sfw/) || tag.length <= 2)
|
||||||
return res.end("f0ck you!");
|
return res.reply({
|
||||||
|
code: 404,
|
||||||
|
body: tpl.render('error', {
|
||||||
|
message: "nope.",
|
||||||
|
tmp: null
|
||||||
|
}, req)
|
||||||
|
});
|
||||||
|
|
||||||
total = (await sql("items")
|
total = (await sql("items")
|
||||||
.select("items.id", "items.mime", "st.tag")
|
.select("items.id", "items.mime", "st.tag")
|
||||||
.innerJoin(
|
.innerJoin(
|
||||||
@ -130,7 +157,13 @@ export default (router, tpl) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(!total || total.length === 0)
|
if(!total || total.length === 0)
|
||||||
return res.end("no f0cks given lol");
|
return res.reply({
|
||||||
|
code: 404,
|
||||||
|
body: tpl.render('error', {
|
||||||
|
message: "404 - no f0cks given",
|
||||||
|
tmp: null
|
||||||
|
}, req)
|
||||||
|
});
|
||||||
|
|
||||||
const pages = +Math.ceil(total / cfg.websrv.eps);
|
const pages = +Math.ceil(total / cfg.websrv.eps);
|
||||||
const act_page = Math.min(pages, page || 1);
|
const act_page = Math.min(pages, page || 1);
|
||||||
@ -167,7 +200,13 @@ export default (router, tpl) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(rows.length === 0)
|
if(rows.length === 0)
|
||||||
return res.end("oops");
|
return res.reply({
|
||||||
|
code: 404,
|
||||||
|
body: tpl.render('error', {
|
||||||
|
message: "oopsi woopsi",
|
||||||
|
tmp: null
|
||||||
|
}, req)
|
||||||
|
});
|
||||||
|
|
||||||
rows.forEach(e => {
|
rows.forEach(e => {
|
||||||
if(!fs.existsSync(`public/t/${e.id}.png`))
|
if(!fs.existsSync(`public/t/${e.id}.png`))
|
||||||
|
3
views/error.html
Normal file
3
views/error.html
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
@include(main/header)
|
||||||
|
<h1>{{ message }}</h1>
|
||||||
|
@include(main/footer)
|
Loading…
Reference in New Issue
Block a user