feat: add onion location meta tag for Tor accessibility
All checks were successful
Build and Deploy Static Site / build (push) Successful in 57s

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.
This commit is contained in:
Kumi 2024-07-24 21:29:58 +02:00
parent 1d7f9ca10c
commit af29b0f3f5
Signed by: kumi
GPG key ID: ECBCC9082395383F
2 changed files with 12 additions and 3 deletions

14
main.py
View file

@ -16,10 +16,12 @@ from helpers.finances import (
get_latest_month, get_latest_month,
) )
class StaticPageHandler(SimpleHTTPRequestHandler): class StaticPageHandler(SimpleHTTPRequestHandler):
def __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):
super().__init__(*args, directory="build", **kwargs) super().__init__(*args, directory="build", **kwargs)
# Configure Jinja2 environment # Configure Jinja2 environment
env = Environment(loader=FileSystemLoader("templates")) env = Environment(loader=FileSystemLoader("templates"))
@ -91,6 +93,8 @@ def generate_static_site(development_mode=False):
template_name = template_file.stem template_name = template_file.stem
context = kwargs.copy() context = kwargs.copy()
context["path"] = f"{template_name}.html" if template_name != "index" else ""
if template_name in ["index", "simple"]: if template_name in ["index", "simple"]:
context.update({"services": services}) context.update({"services": services})
@ -158,8 +162,12 @@ def generate_static_site(development_mode=False):
if __name__ == "__main__": if __name__ == "__main__":
parser = ArgumentParser(description="Generate the private.coffee static site.") parser = ArgumentParser(description="Generate the private.coffee static site.")
parser.add_argument("--dev", action="store_true", help="Enable development mode") 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(
parser.add_argument("--port", type=int, default=8000, help="Port to serve the site on") "--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() args = parser.parse_args()
@ -170,4 +178,4 @@ if __name__ == "__main__":
print(f"Serving on http://localhost:{args.port}") print(f"Serving on http://localhost:{args.port}")
thread = Thread(target=server.serve_forever) thread = Thread(target=server.serve_forever)
thread.start() thread.start()
thread.join() thread.join()

View file

@ -44,6 +44,7 @@
name="twitter:image" name="twitter:image"
content="https://private.coffee/assets/img/logo-inv_grad.png" content="https://private.coffee/assets/img/logo-inv_grad.png"
/> />
<meta http-equiv="onion-location" content="http://coffee2m3bjsrrqqycx6ghkxrnejl2q6nl7pjw2j4clchjj6uk5zozad.onion/{{ path }}">
<link rel="icon" type="image/png" href="assets/img/logo_inv_grad.png" /> <link rel="icon" type="image/png" href="assets/img/logo_inv_grad.png" />
<title>{% block title %}{% endblock %} - Private.coffee</title> <title>{% block title %}{% endblock %} - Private.coffee</title>
<link rel="stylesheet" href="assets/dist/css/bootstrap.min.css" /> <link rel="stylesheet" href="assets/dist/css/bootstrap.min.css" />