diff --git a/src/inc/routes/index.mjs b/src/inc/routes/index.mjs
index ebb074b..d8f308a 100644
--- a/src/inc/routes/index.mjs
+++ b/src/inc/routes/index.mjs
@@ -29,11 +29,24 @@ export default (router, tpl) => {
let data;
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(itemid === 404)
- return res.end("404 - lol");
+ if(itemid === 404) {
+ 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);
if(tag) {
@@ -57,8 +70,15 @@ export default (router, tpl) => {
const item = items.findIndex(i => i.id === itemid);
const actitem = items[item];
- 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.");
+ if(!actitem) { // sfw-check!
+ return res.reply({
+ code: 404,
+ body: tpl.render('error', {
+ message: "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.",
+ tmp: null
+ }, req)
+ });
+ }
const tags = await lib.getTags(itemid);
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.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")
.select("items.id", "items.mime", "st.tag")
.innerJoin(
@@ -130,7 +157,13 @@ export default (router, tpl) => {
}
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 act_page = Math.min(pages, page || 1);
@@ -167,7 +200,13 @@ export default (router, tpl) => {
}
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 => {
if(!fs.existsSync(`public/t/${e.id}.png`))
diff --git a/views/error.html b/views/error.html
new file mode 100644
index 0000000..53b05d5
--- /dev/null
+++ b/views/error.html
@@ -0,0 +1,3 @@
+@include(main/header)
+