From af29b0f3f542b792103a3870df1d22980c123669 Mon Sep 17 00:00:00 2001 From: Kumi Date: Wed, 24 Jul 2024 21:29:58 +0200 Subject: [PATCH] feat: add onion location meta tag for Tor accessibility Included a `meta` tag in the base HTML template to provide the onion location for improved access through the Tor network. Enhanced context parameters to support this feature by adding the path generation logic. Updated argument parsing for better readability and consistency. This change aims to enhance the privacy and accessibility of the site for users connecting via Tor. --- main.py | 14 +++++++++++--- templates/base.html | 1 + 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/main.py b/main.py index 0590463..f00338f 100644 --- a/main.py +++ b/main.py @@ -16,10 +16,12 @@ from helpers.finances import ( get_latest_month, ) + class StaticPageHandler(SimpleHTTPRequestHandler): def __init__(self, *args, **kwargs): super().__init__(*args, directory="build", **kwargs) + # Configure Jinja2 environment env = Environment(loader=FileSystemLoader("templates")) @@ -91,6 +93,8 @@ def generate_static_site(development_mode=False): template_name = template_file.stem context = kwargs.copy() + context["path"] = f"{template_name}.html" if template_name != "index" else "" + if template_name in ["index", "simple"]: context.update({"services": services}) @@ -158,8 +162,12 @@ def generate_static_site(development_mode=False): if __name__ == "__main__": parser = ArgumentParser(description="Generate the private.coffee static site.") parser.add_argument("--dev", action="store_true", help="Enable development mode") - parser.add_argument("--serve", action="store_true", help="Serve the site after building") - parser.add_argument("--port", type=int, default=8000, help="Port to serve the site on") + parser.add_argument( + "--serve", action="store_true", help="Serve the site after building" + ) + parser.add_argument( + "--port", type=int, default=8000, help="Port to serve the site on" + ) args = parser.parse_args() @@ -170,4 +178,4 @@ if __name__ == "__main__": print(f"Serving on http://localhost:{args.port}") thread = Thread(target=server.serve_forever) thread.start() - thread.join() \ No newline at end of file + thread.join() diff --git a/templates/base.html b/templates/base.html index f70e61d..eb5dba9 100644 --- a/templates/base.html +++ b/templates/base.html @@ -44,6 +44,7 @@ name="twitter:image" content="https://private.coffee/assets/img/logo-inv_grad.png" /> + {% block title %}{% endblock %} - Private.coffee