From bd77fad9c6486dfeace8d1f90a5817808db02f53 Mon Sep 17 00:00:00 2001 From: jkhsjdhjs Date: Thu, 18 Aug 2016 03:33:10 +0200 Subject: [PATCH] removes first and last --- s/item.tpl.html | 2 +- src/main.js | 10 ++-------- 2 files changed, 3 insertions(+), 9 deletions(-) diff --git a/s/item.tpl.html b/s/item.tpl.html index 3db7e0a..34dcfc5 100644 --- a/s/item.tpl.html +++ b/s/item.tpl.html @@ -19,7 +19,7 @@

404 - Not f0cked

{% endif %} -
{% if last != null %}<- newest{% endif %} {% if next != null %} | {% endif %} random {% if prev != null %} | {% endif %} {% if first != null %}oldest ->{% endif %}

+
{% if next != null %} | {% endif %} random {% if prev != null %} | {% endif %}

src: {{ src }}
dest: {{ dest }}
diff --git a/src/main.js b/src/main.js index 750e781..9a761be 100644 --- a/src/main.js +++ b/src/main.js @@ -219,7 +219,7 @@ http.createServer((req, res) => { }); } else if(Number.isInteger(parseInt(url))) { // itempage - sql.query("select * from `f0ck`.`items` where `id` = ? limit 1; select `id` from `f0ck`.`items` where `id` = (select min(`id`) from `f0ck`.`items` where `id` > ?); select `id` from `f0ck`.`items` where `id` = (select max(`id`) from `f0ck`.`items` where `id` < ?); select `id` from `f0ck`.`items` order by `id` asc limit 1; select `id` from `f0ck`.`items` order by `id` desc limit 1", [url, url, url], (err, rows, fields) => { + sql.query("select * from `f0ck`.`items` where `id` = ? limit 1; select `id` from `f0ck`.`items` where `id` = (select min(`id`) from `f0ck`.`items` where `id` > ?); select `id` from `f0ck`.`items` where `id` = (select max(`id`) from `f0ck`.`items` where `id` < ?)", [url, url, url], (err, rows, fields) => { var tpl = swig.compile(templates.item); var data = { id: '', @@ -232,9 +232,7 @@ http.createServer((req, res) => { userchannel: '', usernetwork: '', next: null, - prev: null, - first: null, - last: null + prev: null }; if(rows[0].length) { var e = rows[0][0]; @@ -266,10 +264,6 @@ http.createServer((req, res) => { data.next = rows[1][0].id; if(rows[2].length) data.prev = rows[2][0].id; - if(rows[3].length && data.id != rows[3][0].id) - data.first = rows[3][0].id; - if(rows[4].length && data.id != rows[4][0].id) - data.last = rows[4][0].id; } res.writeHead(200, { 'Content-Type': 'text/html' }); res.end(tpl(data), 'utf-8');