From dc2a9657b78064fb1f3b4edb89a4b9b6b74b4b84 Mon Sep 17 00:00:00 2001 From: alex Date: Sun, 8 Oct 2023 22:05:42 +0200 Subject: Add laspelis --- blog_experiment/blog/__init__.py | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) (limited to 'blog_experiment/blog/__init__.py') diff --git a/blog_experiment/blog/__init__.py b/blog_experiment/blog/__init__.py index c16c2a23..81332ddd 100644 --- a/blog_experiment/blog/__init__.py +++ b/blog_experiment/blog/__init__.py @@ -8,12 +8,17 @@ import htmlgenerator as h from blog import blog_pages, page, html, pretty, gemtext -class AboutPage(page.BasePage): +class SimplePage(page.BasePage): + def __init__(self, request, url, title): + super().__init__(request) + self.url = url + self.title = title + def get_gemini_content(self): return ( bicephalus.Status.OK, "text/gemini", - pathlib.Path("static/about/index.gmi").read_text(), + pathlib.Path(f"static{self.url}index.gmi").read_text(), ) def get_http_content(self): @@ -23,7 +28,7 @@ class AboutPage(page.BasePage): pretty.pretty_html(h.render( h.HTML( h.HEAD( - h.TITLE("About Álex Córcoles"), + h.TITLE(self.title), ), h.BODY(*html.gemini_to_html(gemtext.parse(self.get_gemini_content()[2]))) ), {})), @@ -40,6 +45,10 @@ def handler(request: bicephalus.Request) -> bicephalus.Response: if request.path == "/feed/" and request.proto == bicephalus.Proto.HTTP: return blog_pages.Root(request).feed() if request.path == "/about/": - return AboutPage(request).response() + return SimplePage(request, request.path, "About Álex Córcoles").response() + if request.path == "/laspelis/": + return SimplePage(request, request.path, "laspelis").response() + if re.match(r"/laspelis/\d+/?", request.path): + return SimplePage(request, request.path.removesuffix("/") + "/", request.path).response() return page.NotFound(request).response() -- cgit v1.2.3