donation page with monero

This commit is contained in:
JMARyA 2022-08-25 01:24:43 +02:00
parent 7bf48daab5
commit fa78fbff0f
Signed by: jmarya
GPG key ID: 901B2ADDF27C2263
3 changed files with 111 additions and 38 deletions

View file

@ -5,7 +5,8 @@ fmt:
clean: clean:
fd pycache -I -x rm -rv {} fd pycache -I -x rm -rv {}
restart: debug:
docker-compose down docker-compose -f docker-compose-debug.yml up -d
docker-compose build
docker-compose up -d debug-stop:
docker-compose -f docker-compose-debug.yml down

12
docker-compose-debug.yml Normal file
View file

@ -0,0 +1,12 @@
version: '3'
services:
app:
build: "."
environment:
TZ: Europe/Berlin
ports:
- 1030:1030
volumes:
- ./config:/config
- ./src:/app

View file

@ -23,7 +23,13 @@ BOOTSTRAP = [
def buildSite(content): def buildSite(content):
return Document( return Document(
head=Head( 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( body=Body(
content, content,
@ -41,7 +47,33 @@ def public_key():
ua = request.user_agent.string.lower() ua = request.user_agent.string.lower()
if "chrome" in ua or "safari" in ua or "firefox" in ua: if "chrome" in ua or "safari" in ua or "firefox" in ua:
return buildSite(Paragraph(ret.replace("\n", "<br>"))).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", "<br>")),
global_attr=GlobalAttributes(
css_class="container card bg-primary"
),
),
]
).to_code()
resp = Response(response=ret, status=200, mimetype="application/pgp-keys") resp = Response(response=ret, status=200, mimetype="application/pgp-keys")
return resp return resp
@ -49,40 +81,68 @@ def public_key():
return Response(response="", status=502) 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
@main_pages.route("/", methods=["GET"]) @main_pages.route("/", methods=["GET"])
def index(): def index():
return buildSite( return buildSite(
[ [build_information_block(), build_contact_block(), build_donation_block()]
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"),
),
]
).to_code() ).to_code()