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" %} -
-

- So hey, you want to know more about me. Here u have! -

-
-

- A thing i need to say is that this page one day could be deprecated bc - of me just not remembering to change anything. -

-

- Index -

- -

- How to adress me -

-

- So first of all if you are not gonna adress me directly or you don't - know me yet just call me Bizcochito! -
-

-

- You can call me: -

- -

- Also if you are gonna "pronoun" me, please think before if u can just - use the name "Yari" that is literaly like "They" long. -

-

- If you insist in using pronouns you can use this - (in order of preference) : -

- -

- Who i am -

-

- Existential question i have yet not answered -

-

- What i am -

-

- A silly colection of bytes -

-

- Where to contact me -

-
- {# djlint: ignore D018 #} - XMPP - - - Personal Mail - - - Pleroma - -
-
-IDK return back -
diff --git a/templates/ad.njk b/templates/ad.njk index ab0090a..d077e7d 100644 --- a/templates/ad.njk +++ b/templates/ad.njk @@ -1,5 +1,7 @@ -
- - ad - -
+{% macro adimage(ad) %} +
+ + ad + +
+{% endmacro %} diff --git a/templates/imagelist.njk b/templates/imagelist.njk index 05cb8e0..ae77e15 100644 --- a/templates/imagelist.njk +++ b/templates/imagelist.njk @@ -1,10 +1,12 @@ -
- {% for image in image_list %} - - {{ image.url }} - - {% endfor %} -
+{% macro images_list(image_list) %} +
+ {% for image in image_list %} + + {{ image.url }} + + {% endfor %} +
+{% endmacro %} diff --git a/templates/index.njk b/templates/index.njk index 83792e7..1e287a9 100755 --- a/templates/index.njk +++ b/templates/index.njk @@ -4,27 +4,21 @@

I'm bizcochito, hey!

-

- Pages -

-

Banners

- + {% from "imagelist.njk" import images_list as il1 %} + {{ il1(image("banner") ) }}

Funni gifs

- + {% from "imagelist.njk" import images_list as il2 %} + {{ il2(image("gif") ) }}

Frens

- + {% from "imagelist.njk" import images_list as il3 %} + {{ il3(image("8831") ) }}

Another banner that is unused

@@ -48,5 +42,6 @@ - -{% endblock body %} \ No newline at end of file + {% from "ad.njk" import adimage %} + {{ adimage(ad() ) }} +{% endblock body %} diff --git a/templates/signbook.njk b/templates/signbook.njk deleted file mode 100755 index 354446c..0000000 --- a/templates/signbook.njk +++ /dev/null @@ -1,53 +0,0 @@ -{% extends "base.njk" %} -
-

- Cool signers: -

- {% if signer_list %} -

-

-

- {% else %} -

- No one signed here :( -

- {% endif %} -
-
-

- Be part of this cuties! -

-

-

-

- {% csrf_token %} - {% if error_message %} -

- {{ error_message }} -

- {% endif %} - - {{ form.as_table }} -
- -
-

-

-