From 3e9ff9d916ba5096a805e72f188390e096bca605 Mon Sep 17 00:00:00 2001 From: Nathan Woodburn Date: Sat, 18 Nov 2023 18:36:18 +1100 Subject: [PATCH] feat: Add HIP2 Display toggle --- main.py | 12 ++++++++++-- sites/website.py | 5 +++++ templates/edit.html | 15 ++++++++++++--- 3 files changed, 27 insertions(+), 5 deletions(-) diff --git a/main.py b/main.py index 9a69b95..debe077 100644 --- a/main.py +++ b/main.py @@ -137,7 +137,7 @@ def edit(): fg_colour = "" text_colour = "" email = "" - template = "" + hip2_display = False if 'data' in data: html = data['data'].encode('utf-8').decode('unicode-escape') @@ -174,11 +174,14 @@ def edit(): else: selected_template = templates[0] + if 'hip2_display' in data: + hip2_display = data['hip2_display'] + return render_template('edit.html',account=user['email'],account_link="account",account_link_name="Account",data=html, hns=hns,btc=btc,eth=eth,hnschat=hnschat,email=email,location=location,avatar=avatar, bg_colour=bg_colour,fg_colour=fg_colour,text_colour=text_colour,templates=templates, - selected_template=selected_template,CITY_DOMAIN=CITY_DOMAIN,domain=user['domain']) + selected_template=selected_template,CITY_DOMAIN=CITY_DOMAIN,domain=user['domain'],hip2_display=hip2_display) @app.route('/edit', methods=['POST']) @@ -208,6 +211,11 @@ def send_edit(): data['email'] = request.form['email'] data['template'] = request.form['template'] + if 'hip2_display' in request.form: + data['hip2_display'] = True + else: + data['hip2_display'] = False + # Convert to json data = json.dumps(data) db.update_website_data_raw(user['domain'],data) diff --git a/sites/website.py b/sites/website.py index 6b9986b..427f466 100644 --- a/sites/website.py +++ b/sites/website.py @@ -41,6 +41,11 @@ def render(data,db_object): location = db_object['location'] email = db_object['email'] hns = db_object['HNS'] + + if 'hip2_display' in db_object: + if db_object['hip2_display'] == True: + hns = "@"+request.host + btc = db_object['BTC'] eth = db_object['ETH'] bg_colour = db_object['bg_colour'] diff --git a/templates/edit.html b/templates/edit.html index 7e00c43..9c57db7 100644 --- a/templates/edit.html +++ b/templates/edit.html @@ -45,11 +45,20 @@
{{avatar|safe}}
Clear
-
+
-
-
+
+
+ + +
+
+
+
+
+