diff --git a/bun.lockb b/bun.lockb index 218536a..8f030ec 100755 Binary files a/bun.lockb and b/bun.lockb differ diff --git a/src/app.ts b/src/app.ts index 8430c82..1f76cca 100644 --- a/src/app.ts +++ b/src/app.ts @@ -1,38 +1,34 @@ import fs from "fs"; import type { Response, Request } from "express"; +function ad() { + const ad_list = fs.readdirSync("static/ads/hor/"); + console.log(ad_list) + const ad = ad_list[Math.floor(Math.random() * ad_list.length)]; + return ad; +} + +function remove_extension(filename: string) { + return filename.substring(0, filename.lastIndexOf(".")) || filename; +} + +function image(type: string) { + const images_list = fs.readdirSync(`static/icons/${type}/`); + const image_list = images_list.map((image) => ({ + name: image, + url: remove_extension(image), + folder: type, + })); + return image_list; +} + class App { - ad(req: Request, res: Response) { - const ad_list = fs.readdirSync("../static/ads/hor/"); - const ad = ad_list[Math.floor(Math.random() * ad_list.length)]; - res.render("ad.njk", { ad }); - } - - remove_extension(filename: string) { - return filename.substring(0, filename.lastIndexOf(".")) || filename; - } - - image(req: Request, res: Response) { - const images_list = fs.readdirSync(`/static/icons/${req.url}/`); - const image_list = images_list.map((image) => ({ - name: image, - url: this.remove_extension(image), - folder: req.url, - })); - res.render("ad.njk", { image_list }); - } - - index(req: Request, res: Response) { + index(_req: Request, res: Response) { res.render("index.njk", { page: "index", title: "THE INDEX", - }); - } - - about(req: Request, res: Response) { - res.render("about.njk", { - page: "about", - title: "About Me", + image, + ad }); } } diff --git a/src/index.ts b/src/index.ts index 10fb0af..a15d33d 100644 --- a/src/index.ts +++ b/src/index.ts @@ -4,7 +4,7 @@ import app from "src/app"; const site = express(); -nunjucks.configure( "templates", { +nunjucks.configure("templates", { autoescape: true, express: site, }); @@ -12,11 +12,5 @@ nunjucks.configure( "templates", { site.use(express.static(".")); site.get("/", app.index); -site.get("/about", app.about); -site.get("/ads", app.ad); -site.get("/8811", app.image); -site.get("/banner", app.image); -site.get("/gif", app.image); -site.get("/signbook", app.index); site.listen(8080, () => console.log("app listening on 8080")); diff --git a/templates/about.njk b/templates/about.njk deleted file mode 100755 index 1caa787..0000000 --- a/templates/about.njk +++ /dev/null @@ -1,109 +0,0 @@ -{% extends "base.njk" %} -
- A thing i need to say is that this page one day could be deprecated bc - of me just not remembering to change anything. -
-
- So first of all if you are not gonna adress me directly or you don't
- know me yet just call me Bizcochito!
-
-
- Also if you are gonna "pronoun" me, please think before if u can just - use the name "Yari" that is literaly like "They" long. -
-- Existential question i have yet not answered -
-- A silly colection of bytes -
--
- No one signed here :( -
- {% endif %} --
-
- - -