Revert "Merge branch 'f0ckdev' into 'master'"
This reverts merge request !61
This commit is contained in:
parent
d897d0a22f
commit
f29164d959
@ -231,7 +231,7 @@ function Websrv(tlib) {
|
|||||||
var query = "select * from `f0ck`.`items`";
|
var query = "select * from `f0ck`.`items`";
|
||||||
lib.sql.query(query, (err, rows, fields) => {
|
lib.sql.query(query, (err, rows, fields) => {
|
||||||
var items = [];
|
var items = [];
|
||||||
rows.forEach(e => {
|
rows.forEach((e,i,a) => {
|
||||||
items.push({
|
items.push({
|
||||||
'id': e.id,
|
'id': e.id,
|
||||||
'mime': e.mime
|
'mime': e.mime
|
||||||
@ -241,34 +241,7 @@ function Websrv(tlib) {
|
|||||||
res.end(JSON.stringify(items), 'utf-8');
|
res.end(JSON.stringify(items), 'utf-8');
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
else if(url[2] == "latest") {
|
else if(url[2] == "p" && Number.isInteger(parseInt(url[3]))) { // pagination
|
||||||
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
|
|
||||||
var eps = 50;
|
var eps = 50;
|
||||||
var id = url[3];
|
var id = url[3];
|
||||||
lib.sql.query("select * from `f0ck`.`items` where `id` < ? order by `id` desc limit ?", [id, eps], (err, rows, fields) => {
|
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.writeHead(200, { 'Content-Type': 'text/html' });
|
||||||
res.end(JSON.stringify(items), 'utf-8');
|
res.end(JSON.stringify(items), 'utf-8');
|
||||||
});
|
});
|
||||||
}*/
|
}
|
||||||
else if(Number.isInteger(parseInt(url[2]))) { // Item
|
else if(Number.isInteger(parseInt(url[2]))) { // Item
|
||||||
var query = "select * from `f0ck`.`items` where `id` = ? limit 1; " // get 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
|
+ "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"),
|
"how": fs.readFileSync("./s/how.tpl.html", "utf-8"),
|
||||||
"contact": fs.readFileSync("./s/contact.tpl.html", "utf-8")
|
"contact": fs.readFileSync("./s/contact.tpl.html", "utf-8")
|
||||||
};
|
};
|
||||||
};
|
};
|
Loading…
Reference in New Issue
Block a user