modified: public/css/f0ck.css
new file: public/js/f0ck.js modified: src/inc/routes/api.mjs modified: src/inc/routes/index.mjs modified: src/websrv.mjs modified: views/index.html.tpl
This commit is contained in:
parent
b9adbffc81
commit
c95e0d82f1
|
@ -26,6 +26,7 @@
|
||||||
body {
|
body {
|
||||||
background-color: var(--bg-color);
|
background-color: var(--bg-color);
|
||||||
color: var(--font-color);
|
color: var(--font-color);
|
||||||
|
/*overflow: hidden;*/
|
||||||
}
|
}
|
||||||
/* End of Body */
|
/* End of Body */
|
||||||
|
|
||||||
|
|
0
public/js/f0ck.js
Normal file
0
public/js/f0ck.js
Normal file
|
@ -8,7 +8,7 @@ router.get(/^\/api$/, (req, res) => {
|
||||||
res.end("api lol");
|
res.end("api lol");
|
||||||
});
|
});
|
||||||
|
|
||||||
router.get(/^\/api\/random(\/user\/.+|\/image|\/video|\/audio|\/)?$/, async (req, res) => {
|
router.get(/^\/api\/random(\/user\/.+|\/image|\/video|\/audio)?$/, async (req, res) => {
|
||||||
const db = await sql;
|
const db = await sql;
|
||||||
let q = queries.random.main;
|
let q = queries.random.main;
|
||||||
let args = [];
|
let args = [];
|
||||||
|
@ -28,10 +28,11 @@ router.get(/^\/api\/random(\/user\/.+|\/image|\/video|\/audio|\/)?$/, async (req
|
||||||
}).catch(err => res.end(JSON.stringify( err ), 'utf-8'));
|
}).catch(err => res.end(JSON.stringify( err ), 'utf-8'));
|
||||||
});
|
});
|
||||||
|
|
||||||
router.get(/^\/api\/p(\/[0-9]+|\/)?(\/[0-9]+)?\/?$/, async (req, res) => {
|
//router.get(/^\/api\/p(\/[0-9]+|\/)?(\/[0-9]+)?$/, async (req, res) => {
|
||||||
|
router.get(/^\/api\/p$/, async (req, res) => {
|
||||||
const db = await sql;
|
const db = await sql;
|
||||||
const id = parseInt(req.url.split[2]) || 99999999;
|
const id = parseInt(req.url.qs.id) || 99999999;
|
||||||
const eps = Math.min(parseInt(req.url.split[3]) || 100, 200);
|
const eps = Math.min(parseInt(req.url.qs.eps) || 100, 200);
|
||||||
db.query("select * from f0ck.items where id < ? order by id desc limit ?", [id, eps])
|
db.query("select * from f0ck.items where id < ? order by id desc limit ?", [id, eps])
|
||||||
.then(rows => {
|
.then(rows => {
|
||||||
let items = {
|
let items = {
|
||||||
|
|
|
@ -14,7 +14,7 @@ router.get(/^\/$/, async (req, res) => {
|
||||||
db.query(queries.items)
|
db.query(queries.items)
|
||||||
.then(items => {
|
.then(items => {
|
||||||
const tpl = handlebars.compile(template);
|
const tpl = handlebars.compile(template);
|
||||||
res.end(tpl({ items: items }));
|
res.end(tpl({ items: items, debug: JSON.stringify(req.url, null, 2) }));
|
||||||
}).catch(err => res.end(JSON.stringify( err ), 'utf-8'));
|
}).catch(err => res.end(JSON.stringify( err ), 'utf-8'));
|
||||||
|
|
||||||
/*const tpl = handlebars.compile(template);
|
/*const tpl = handlebars.compile(template);
|
||||||
|
|
|
@ -1,14 +1,20 @@
|
||||||
import http from "http";
|
import http from "http";
|
||||||
import url from "url";
|
import url from "url";
|
||||||
|
import querystring from "querystring";
|
||||||
|
import cfg from "../config.json";
|
||||||
|
|
||||||
|
// routes
|
||||||
import "./inc/routes/index";
|
import "./inc/routes/index";
|
||||||
import "./inc/routes/api";
|
import "./inc/routes/api";
|
||||||
|
|
||||||
import { routes } from "./inc/router";
|
import { routes } from "./inc/router";
|
||||||
|
|
||||||
http.createServer((req, res, r, uri = url.parse(req.url)) => {
|
http.createServer((req, res, r) => {
|
||||||
req.url = uri;
|
req.url = url.parse(req.url.replace(/(?!^.)(\/+)?$/, ''));
|
||||||
req.url.split = uri.pathname.split("/");
|
req.url.split = req.url.pathname.split("/").slice(1);
|
||||||
req.url.split.shift();
|
req.url.qs = querystring.parse(req.url.query);
|
||||||
(!(r = routes.getRegex(req.url.pathname, req.method)) ? res.end(`404 - ${req.url.pathname}`) : r(req, res))
|
|
||||||
}).listen(1499);
|
console.log(`[${(new Date()).toLocaleTimeString()}] ${req.method} ${req.url.pathname}`);
|
||||||
|
|
||||||
|
!(r = routes.getRegex(req.url.pathname, req.method)) ? res.end(`404 - ${req.url.pathname}`) : r(req, res);
|
||||||
|
}).listen(cfg.websrv.port, () => console.log(`f0ck is listening on port ${cfg.websrv.port}.`));
|
||||||
|
|
|
@ -17,13 +17,14 @@
|
||||||
<button class="contact">Contact</button>
|
<button class="contact">Contact</button>
|
||||||
</div>
|
</div>
|
||||||
<main class="f0ckgrid" id="posts">
|
<main class="f0ckgrid" id="posts">
|
||||||
{{#each items}}
|
<!--#each items}}
|
||||||
<a href="/{{id}}" title="{{mime}}"><img class="thumb" src="//f0ck.me/t/{{id}}.png" /></a>
|
<a href="/{{id}}" title="{{mime}}"><img class="thumb" src="//f0ck.me/t/{{id}}.png" /></a>
|
||||||
{{/each}}
|
/each}}-->
|
||||||
</main>
|
</main>
|
||||||
<footer>
|
<footer>
|
||||||
<section class="credits">Made with 666 souls in mind and 2 liters of fresh virgin blood</section>
|
<section class="credits">Made with 666 souls in mind, 2 liters of fresh virgin blood and a dozen cans of dog food</section>
|
||||||
</footer>
|
</footer>
|
||||||
<!--<script src="f0ck.js"></script>-->
|
<div style="background-color: #fff; color: #000; white-space: pre; position: fixed; bottom: 0; right: 0">{{debug}}</div>
|
||||||
|
<script src="/js/f0ck.js" defer></script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
Loading…
Reference in New Issue
Block a user