From 2d5eb86776c928b2ec9008fa6ab5970f68dc192c Mon Sep 17 00:00:00 2001 From: holger krekel Date: Sat, 2 Dec 2023 00:18:54 +0100 Subject: [PATCH] make QR code clickable, verified it works on android and desktop --- .../src/deploy_chatmail/__init__.py | 30 ++++++++++++------- .../src/deploy_chatmail/nginx/index.html.j2 | 10 ++++--- 2 files changed, 26 insertions(+), 14 deletions(-) rename www/default/index.html => deploy-chatmail/src/deploy_chatmail/nginx/index.html.j2 (70%) diff --git a/deploy-chatmail/src/deploy_chatmail/__init__.py b/deploy-chatmail/src/deploy_chatmail/__init__.py index 072d0d53..6f42794e 100644 --- a/deploy-chatmail/src/deploy_chatmail/__init__.py +++ b/deploy-chatmail/src/deploy_chatmail/__init__.py @@ -156,7 +156,8 @@ def _install_mta_sts_daemon() -> bool: name="install postfix-mta-sts-resolver with pip", commands=[ "python3 -m venv /usr/local/lib/postfix-mta-sts-resolver", - "/usr/local/lib/postfix-mta-sts-resolver/bin/pip install postfix-mta-sts-resolver", + "/usr/local/lib/postfix-mta-sts-resolver/bin/pip " + "install postfix-mta-sts-resolver", ], ) @@ -294,18 +295,20 @@ def _configure_nginx(domain: str, debug: bool = False) -> bool: ) files.put( - name=f"Upload cgi newemail.py script", - src=importlib.resources.files("chatmaild").joinpath(f"newemail.py").open("rb"), + name="Upload cgi newemail.py script", + src=importlib.resources.files("chatmaild").joinpath("newemail.py").open("rb"), dest=f"{cgi_dir}/newemail.py", user="root", group="root", mode="755", ) + qr_data = gen_qr_png_data(domain) + files.put( - name=f"Upload QR code for account creation", - src=gen_qr_png_data(domain), - dest=f"/var/www/html/qrcode.png", + name="Upload QR code for account creation", + src=qr_data, + dest="/var/www/html/qrcode.png", user="root", group="root", mode="644", @@ -376,10 +379,17 @@ def deploy_chatmail(mail_domain: str, mail_server: str, dkim_selector: str) -> N # deploy web pages and info if we have them pkg_root = importlib.resources.files(__package__) www_path = pkg_root.joinpath(f"../../../www/{mail_domain}").resolve() - if not www_path.is_dir(): - www_path = pkg_root.joinpath(f"../../../www/default").resolve() - - files.rsync(f"{www_path}/", "/var/www/html", flags=["-avz"]) + if www_path.is_dir(): + files.rsync(f"{www_path}/", "/var/www/html", flags=["-avz"]) + else: + files.template( + src=importlib.resources.files(__package__).joinpath("nginx/index.html.j2"), + dest="/var/www/html/index.html", + user="root", + group="root", + mode="644", + config={"mail_domain": mail_domain}, + ) systemd.service( name="Start and enable OpenDKIM", diff --git a/www/default/index.html b/deploy-chatmail/src/deploy_chatmail/nginx/index.html.j2 similarity index 70% rename from www/default/index.html rename to deploy-chatmail/src/deploy_chatmail/nginx/index.html.j2 index de66cbbe..3bd998d6 100644 --- a/www/default/index.html +++ b/deploy-chatmail/src/deploy_chatmail/nginx/index.html.j2 @@ -1,3 +1,4 @@ + @@ -6,10 +7,11 @@ -

Welcome to Chatmail!

-

Scan this invite QR code from any Delta Chat app

- - +

Welcome to {{ config.mail_domain }}!

+

Tap or Scan this invite code to setup an account for Delta Chat app

+ + +

Properties / Constraints