working rewrute
This commit is contained in:
parent
f899c18f0a
commit
86d194841c
52
src/app.ts
52
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
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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"));
|
||||
|
|
|
@ -1,109 +0,0 @@
|
|||
{% extends "base.njk" %}
|
||||
<div class="centercubeplease">
|
||||
<h1>
|
||||
So hey, you want to know more about me. Here u have!
|
||||
</h1>
|
||||
<div class="centerade">
|
||||
<p>
|
||||
A thing i need to say is that this page one day could be deprecated bc
|
||||
of me just not remembering to change anything.
|
||||
</p>
|
||||
<h2>
|
||||
Index
|
||||
</h2>
|
||||
<ul class="disclosure-closed">
|
||||
<li>
|
||||
<a href="#how">How to adress me</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="#who">Who i am</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="#what">What i am</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="#where">Where to contact me</a>
|
||||
</li>
|
||||
</ul>
|
||||
<h2 id="how">
|
||||
How to adress me
|
||||
</h2>
|
||||
<p>
|
||||
So first of all if you are not gonna adress me directly or you don't
|
||||
know me yet just call me Bizcochito!
|
||||
<br />
|
||||
</p>
|
||||
<h3>
|
||||
You can call me:
|
||||
</h3>
|
||||
<ul class="disclosure-closed">
|
||||
<li>
|
||||
Yari
|
||||
</li>
|
||||
<li>
|
||||
Alicia
|
||||
</li>
|
||||
<li>
|
||||
Maria
|
||||
</li>
|
||||
<li>
|
||||
Bizcochito
|
||||
</li>
|
||||
</ul>
|
||||
<p>
|
||||
Also if you are gonna "pronoun" me, please think before if u can just
|
||||
use the name "Yari" that is literaly like "They" long.
|
||||
</p>
|
||||
<h3>
|
||||
If you insist in using pronouns you can use this
|
||||
<b> (in order of preference) </b> :
|
||||
</h3>
|
||||
<ul class="disclosure-closed">
|
||||
<li>
|
||||
<b>My names</b>
|
||||
</li>
|
||||
<li>
|
||||
Literally anything but he
|
||||
</li>
|
||||
</ul>
|
||||
<h2 id="who">
|
||||
Who i am
|
||||
</h2>
|
||||
<p>
|
||||
Existential question i have yet not answered
|
||||
</p>
|
||||
<h2 id="what">
|
||||
What i am
|
||||
</h2>
|
||||
<p>
|
||||
A silly colection of bytes
|
||||
</p>
|
||||
<h2 id="where">
|
||||
Where to contact me
|
||||
</h2>
|
||||
<div class="centerade">
|
||||
{# djlint: ignore D018 #}<a href="xmpp:bizcochito@fai.st">
|
||||
<img style="border: 0px;
|
||||
height: 36px;
|
||||
width: auto"
|
||||
src="https://xmpp.org/images/logos/xmpp-logo.svg"
|
||||
alt="XMPP" />
|
||||
</a>
|
||||
<a href="mailto:bizcochito@anartist.org">
|
||||
<img style="border: 0px;
|
||||
height: 36px;
|
||||
width: auto"
|
||||
src="https://upload.wikimedia.org/wikipedia/commons/thumb/e/ee/%28at%29.svg/170px-%28at%29.svg.png"
|
||||
alt="Personal Mail" />
|
||||
</a>
|
||||
<a href="https://awoo.fai.st/MeDueleLaTeta">
|
||||
<img style="border: 0px;
|
||||
height: 36px;
|
||||
width: auto"
|
||||
src="https://upload.wikimedia.org/wikipedia/commons/9/93/Fediverse_logo_proposal.svg"
|
||||
alt="Pleroma" />
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
<a href="{% url "webpage:index" %}">IDK return back</a>
|
||||
</div>
|
|
@ -1,5 +1,7 @@
|
|||
<div class="centerade">
|
||||
<a>
|
||||
<img src="/static/ads/hor/{{ ad }}" alt="ad" />
|
||||
</a>
|
||||
</div>
|
||||
{% macro adimage(ad) %}
|
||||
<div class="centerade">
|
||||
<a>
|
||||
<img src="/static/ads/hor/{{ ad }}" alt="ad" />
|
||||
</a>
|
||||
</div>
|
||||
{% endmacro %}
|
||||
|
|
|
@ -1,10 +1,12 @@
|
|||
<div class="img">
|
||||
{% for image in image_list %}
|
||||
<a href="https://{{ image.url }}">
|
||||
<img style="height:31px;
|
||||
width:auto"
|
||||
src="/static/icons/{{ image.folder }}/}{{ image.name }}"
|
||||
alt="{{ image.url }}" />
|
||||
</a>
|
||||
{% endfor %}
|
||||
</div>
|
||||
{% macro images_list(image_list) %}
|
||||
<div class="img">
|
||||
{% for image in image_list %}
|
||||
<a href="https://{{ image.url }}">
|
||||
<img style="height:31px;
|
||||
width:auto"
|
||||
src="static/icons/{{ image.folder }}/{{ image.name }}"
|
||||
alt="{{ image.url }}" />
|
||||
</a>
|
||||
{% endfor %}
|
||||
</div>
|
||||
{% endmacro %}
|
||||
|
|
|
@ -4,27 +4,21 @@
|
|||
<h1>
|
||||
I'm bizcochito, hey!
|
||||
</h1>
|
||||
<h2>
|
||||
Pages
|
||||
</h2>
|
||||
<ul class="disclosure-closed">
|
||||
<li>
|
||||
<a href="/about">About</a>
|
||||
<a href="/signbook">Signbook</a>
|
||||
</li>
|
||||
</ul>
|
||||
<h2>
|
||||
Banners
|
||||
</h2>
|
||||
<!-- Add htmx request on load for banner list -->
|
||||
{% from "imagelist.njk" import images_list as il1 %}
|
||||
{{ il1(image("banner") ) }}
|
||||
<h2>
|
||||
Funni gifs
|
||||
</h2>
|
||||
<!-- Add htmx request on load for gif list -->
|
||||
{% from "imagelist.njk" import images_list as il2 %}
|
||||
{{ il2(image("gif") ) }}
|
||||
<h2>
|
||||
Frens
|
||||
</h2>
|
||||
<!-- Add htmx request on load for 8831 list -->
|
||||
{% from "imagelist.njk" import images_list as il3 %}
|
||||
{{ il3(image("8831") ) }}
|
||||
<h2>
|
||||
Another banner that is unused
|
||||
</h2>
|
||||
|
@ -48,5 +42,6 @@
|
|||
</a>
|
||||
</div>
|
||||
</div>
|
||||
<!-- Add htmx request on load for ad -->
|
||||
{% endblock body %}
|
||||
{% from "ad.njk" import adimage %}
|
||||
{{ adimage(ad() ) }}
|
||||
{% endblock body %}
|
||||
|
|
|
@ -1,53 +0,0 @@
|
|||
{% extends "base.njk" %}
|
||||
<div class="centercubeplease">
|
||||
<h1>
|
||||
Cool signers:
|
||||
</h1>
|
||||
{% if signer_list %}
|
||||
<p>
|
||||
<ul>
|
||||
{% for signer in signer_list %}
|
||||
<li>
|
||||
<a href="https://{{ signer.website }}">
|
||||
<b>
|
||||
{{ signer.name }}
|
||||
</b>
|
||||
</a> said:
|
||||
<b>
|
||||
{{ signer.comment }}.
|
||||
</b>
|
||||
{% if signer.email %}
|
||||
Pester on:
|
||||
<a href="mailto:{{ signer.email }}">{{ signer.email }}</a>
|
||||
{% endif %}
|
||||
</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
</p>
|
||||
{% else %}
|
||||
<p>
|
||||
No one signed here :(
|
||||
</p>
|
||||
{% endif %}
|
||||
</div>
|
||||
<div class="centerade">
|
||||
<h2>
|
||||
Be part of this cuties!
|
||||
</h2>
|
||||
<p>
|
||||
<p>
|
||||
<form method="post" action="">
|
||||
{% csrf_token %}
|
||||
{% if error_message %}
|
||||
<p>
|
||||
<strong>{{ error_message }}</strong>
|
||||
</p>
|
||||
{% endif %}
|
||||
<table>
|
||||
{{ form.as_table }}
|
||||
</table>
|
||||
<input type="submit" />
|
||||
</form>
|
||||
</p>
|
||||
</p>
|
||||
</div>
|
Loading…
Reference in New Issue