replace index with test

This commit is contained in:
Flummi
2016-08-30 12:26:57 +00:00
parent da08de7b79
commit 03c9bb9a48
6 changed files with 62 additions and 124 deletions

View File

@ -38,18 +38,6 @@ function Websrv(tbot, tsql, tlib) {
};
if(filePath == "./index.html") { // mainpage
var tpl = swig.compile(templates.index);
var data = { items: [] };
sql.query("select `id`,`mime` from `f0ck`.`items` order by `id` desc", (err, rows, fields) => {
rows.forEach((e,i,a) => {
data.items.push({ "id": e.id, "mime": e.mime });
});
res.writeHead(200, { 'Content-Type': 'text/html' });
res.end(tpl(data), 'utf-8');
});
}
else if(filePath == "./test") { // (test)mainpage
var tpl = swig.compile(templates.test);
var data = {
items: [],
last: 10000
@ -63,7 +51,6 @@ function Websrv(tbot, tsql, tlib) {
res.end(tpl(data), 'utf-8');
});
}
else if(Number.isInteger(parseInt(url))) { // itempage
var query = "select * from `f0ck`.`items` where `id` = ? limit 1; " // get item
+ "select `id` from `f0ck`.`items` where `id` = (select min(`id`) from `f0ck`.`items` where `id` > ?); " // get previous item
@ -288,7 +275,6 @@ Websrv.prototype.getTpls = () => {
"item": fs.readFileSync("./s/item.tpl.html", "utf-8"),
"how": fs.readFileSync("./s/how.tpl.html", "utf-8"),
"contact": fs.readFileSync("./s/contact.tpl.html", "utf-8"),
"scripts": fs.readFileSync("./s/scripts.tpl.html", "utf-8"),
"test": fs.readFileSync("./s/test.tpl.html", "utf-8")
"scripts": fs.readFileSync("./s/scripts.tpl.html", "utf-8")
};
};