diff --git a/Makefile b/Makefile index 92bae95..c156e64 100644 --- a/Makefile +++ b/Makefile @@ -5,7 +5,8 @@ fmt: clean: fd pycache -I -x rm -rv {} -restart: - docker-compose down - docker-compose build - docker-compose up -d +debug: + docker-compose -f docker-compose-debug.yml up -d + +debug-stop: + docker-compose -f docker-compose-debug.yml down diff --git a/docker-compose-debug.yml b/docker-compose-debug.yml new file mode 100644 index 0000000..79677f8 --- /dev/null +++ b/docker-compose-debug.yml @@ -0,0 +1,12 @@ +version: '3' + +services: + app: + build: "." + environment: + TZ: Europe/Berlin + ports: + - 1030:1030 + volumes: + - ./config:/config + - ./src:/app \ No newline at end of file diff --git a/src/index.py b/src/index.py index 089f619..419d25f 100644 --- a/src/index.py +++ b/src/index.py @@ -23,7 +23,13 @@ BOOTSTRAP = [ def buildSite(content): return Document( head=Head( - [Meta(name="viewport", content="width=350, user-scalable=0;"), BOOTSTRAP] + [ + Meta( + name="viewport", + content="user-scalable=no, width=device-width, initial-scale=1.0", + ), + BOOTSTRAP, + ] ), body=Body( content, @@ -41,7 +47,33 @@ def public_key(): ua = request.user_agent.string.lower() if "chrome" in ua or "safari" in ua or "firefox" in ua: - return buildSite(Paragraph(ret.replace("\n", "
"))).to_code() + return buildSite( + [ + Div( + Div( + [ + Bold("To Import: "), + Span( + f'curl "{request.base_url}"|gpg --import', + global_attr=GlobalAttributes( + style="display: block;font-family: monospace,monospace;margin-top: 10px; font-size: 20px;overflow-wrap: break-word;" + ), + ), + ], + global_attr=GlobalAttributes(css_class="alert alert-info"), + ), + global_attr=GlobalAttributes( + css_class="container", style="margin-top: 25px" + ), + ), + Div( + Paragraph(ret.replace("\n", "
")), + global_attr=GlobalAttributes( + css_class="container card bg-primary" + ), + ), + ] + ).to_code() resp = Response(response=ret, status=200, mimetype="application/pgp-keys") return resp @@ -49,40 +81,68 @@ def public_key(): return Response(response="", status=502) +def build_contact_block(): + return Div( + [ + Heading(1, "Contact"), + ThematicBreak(), + [Link("/public_key", "My PGP Key"), LineBreak()] + if exists("/config/pub.key") + else None, + Link(f"mailto:{CONFIG['email']}", CONFIG["email"]), + LineBreak(), + ], + global_attr=GlobalAttributes(css_class="container border-dark"), + ) + + +def build_donation_block(): + return Div( + [ + Heading(1, "Donation"), + ThematicBreak(), + Paragraph( + [ + Bold("Monero: "), + Span( + CONFIG["xmr_address"], + global_attr=GlobalAttributes( + style="color: orange;overflow-wrap: break-word;" + ), + ), + ] + ) + if "xmr_address" in CONFIG + else None, + ], + global_attr=GlobalAttributes(css_class="container", style="margin-top: 20px"), + ) + + +def build_information_block(): + return Div( + [ + Image( + "/assets/me", + 200, + 200, + "Me", + global_attr=GlobalAttributes(css_class="rounded"), + ), + LineBreak(), + LineBreak(), + Heading(1, CONFIG["name"]), + ThematicBreak(), + ], + global_attr=GlobalAttributes( + css_class="container border-dark", style="margin-top: 20px" + ), + ) + + # Main @main_pages.route("/", methods=["GET"]) def index(): return buildSite( - [ - Div( - [ - Image( - "/assets/me", - 200, - 200, - "Me", - global_attr=GlobalAttributes(css_class="rounded"), - ), - LineBreak(), - LineBreak(), - Heading(1, CONFIG["name"]), - ThematicBreak(), - ], - global_attr=GlobalAttributes( - css_class="container border-dark", style="margin-top: 20px" - ), - ), - Div( - [ - Heading(1, "Contact"), - ThematicBreak(), - [Link("/public_key", "My PGP Key"), LineBreak()] - if exists("/config/pub.key") - else None, - Link(f"mailto:{CONFIG['email']}", CONFIG["email"]), - LineBreak(), - ], - global_attr=GlobalAttributes(css_class="container border-dark"), - ), - ] + [build_information_block(), build_contact_block(), build_donation_block()] ).to_code()