Revert "Merge branch 'f0ckdev' into 'master'"

This reverts merge request !61
This commit is contained in:
noxy 2017-01-23 14:04:56 +00:00
parent d897d0a22f
commit f29164d959

View File

@ -231,7 +231,7 @@ function Websrv(tlib) {
var query = "select * from `f0ck`.`items`";
lib.sql.query(query, (err, rows, fields) => {
var items = [];
rows.forEach(e => {
rows.forEach((e,i,a) => {
items.push({
'id': e.id,
'mime': e.mime
@ -241,34 +241,7 @@ function Websrv(tlib) {
res.end(JSON.stringify(items), 'utf-8');
});
}
else if(url[2] == "latest") {
lib.sql.query("select * from `f0ck`.`items` order by `stamp` desc limit 1", (err, rows) => {
res.writeHead(200, { 'Content-Type': 'text/html' });
res.end(JSON.stringify({'latest': rows[0].stamp}), 'utf-8');
});
}
else if(url[2] == "p" && Number.isInteger(parseInt(url[3])) && Number.isInteger(parseInt(url[4]))) { // pagination
// /api/p/stamp/eps
var eps = parseInt(url[4]);
var stamp = parseInt(url[3]);
lib.sql.query("select * from `f0ck`.`items` where `stamp` < ? order by `stamp` desc limit ?", [stamp, eps], (err, rows) => {
var items = {
"items": [],
"first": stamp,
"latest": 0
};
rows.forEach(e => {
items.items.push({
id: e.id,
mime: e.mime
});
items.latest = e.stamp;
});
res.writeHead(200, { 'Content-Type': 'text/html' });
res.end(JSON.stringify(items), 'utf-8');
});
}
/*else if(url[2] == "p" && Number.isInteger(parseInt(url[3]))) { // pagination
else if(url[2] == "p" && Number.isInteger(parseInt(url[3]))) { // pagination
var eps = 50;
var id = url[3];
lib.sql.query("select * from `f0ck`.`items` where `id` < ? order by `id` desc limit ?", [id, eps], (err, rows, fields) => {
@ -286,7 +259,7 @@ function Websrv(tlib) {
res.writeHead(200, { 'Content-Type': 'text/html' });
res.end(JSON.stringify(items), 'utf-8');
});
}*/
}
else if(Number.isInteger(parseInt(url[2]))) { // Item
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
@ -339,4 +312,4 @@ Websrv.prototype.getTpls = () => {
"how": fs.readFileSync("./s/how.tpl.html", "utf-8"),
"contact": fs.readFileSync("./s/contact.tpl.html", "utf-8")
};
};
};