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
|
@ -24,8 +24,9 @@
|
|||
|
||||
/* Body */
|
||||
body {
|
||||
background-color: var(--bg-color);
|
||||
background-color: var(--bg-color);
|
||||
color: var(--font-color);
|
||||
/*overflow: hidden;*/
|
||||
}
|
||||
/* 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");
|
||||
});
|
||||
|
||||
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;
|
||||
let q = queries.random.main;
|
||||
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'));
|
||||
});
|
||||
|
||||
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 id = parseInt(req.url.split[2]) || 99999999;
|
||||
const eps = Math.min(parseInt(req.url.split[3]) || 100, 200);
|
||||
const id = parseInt(req.url.qs.id) || 99999999;
|
||||
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])
|
||||
.then(rows => {
|
||||
let items = {
|
||||
|
|
|
@ -14,7 +14,7 @@ router.get(/^\/$/, async (req, res) => {
|
|||
db.query(queries.items)
|
||||
.then(items => {
|
||||
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'));
|
||||
|
||||
/*const tpl = handlebars.compile(template);
|
||||
|
|
|
@ -1,14 +1,20 @@
|
|||
import http from "http";
|
||||
import url from "url";
|
||||
import querystring from "querystring";
|
||||
import cfg from "../config.json";
|
||||
|
||||
// routes
|
||||
import "./inc/routes/index";
|
||||
import "./inc/routes/api";
|
||||
|
||||
import { routes } from "./inc/router";
|
||||
|
||||
http.createServer((req, res, r, uri = url.parse(req.url)) => {
|
||||
req.url = uri;
|
||||
req.url.split = uri.pathname.split("/");
|
||||
req.url.split.shift();
|
||||
(!(r = routes.getRegex(req.url.pathname, req.method)) ? res.end(`404 - ${req.url.pathname}`) : r(req, res))
|
||||
}).listen(1499);
|
||||
http.createServer((req, res, r) => {
|
||||
req.url = url.parse(req.url.replace(/(?!^.)(\/+)?$/, ''));
|
||||
req.url.split = req.url.pathname.split("/").slice(1);
|
||||
req.url.qs = querystring.parse(req.url.query);
|
||||
|
||||
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>
|
||||
</div>
|
||||
<main class="f0ckgrid" id="posts">
|
||||
{{#each items}}
|
||||
<!--#each items}}
|
||||
<a href="/{{id}}" title="{{mime}}"><img class="thumb" src="//f0ck.me/t/{{id}}.png" /></a>
|
||||
{{/each}}
|
||||
/each}}-->
|
||||
</main>
|
||||
<footer>
|
||||
<section class="credits">Made with 666 souls in mind and 2 liters of fresh virgin blood</section>
|
||||
</footer>
|
||||
<!--<script src="f0ck.js"></script>-->
|
||||
<footer>
|
||||
<section class="credits">Made with 666 souls in mind, 2 liters of fresh virgin blood and a dozen cans of dog food</section>
|
||||
</footer>
|
||||
<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>
|
||||
</html>
|
||||
|
|
Loading…
Reference in New Issue
Block a user