feat: Add blank template and footer part
This commit is contained in:
parent
d5e9100634
commit
743a8d6916
2
main.py
2
main.py
@ -34,7 +34,7 @@ if IMAGE_LOCATION == None:
|
|||||||
random_sites = ""
|
random_sites = ""
|
||||||
|
|
||||||
# Templates available for user
|
# Templates available for user
|
||||||
templates = ['Standard', 'Original', 'No card around data', 'No card around data (2)']
|
templates = ['Standard', 'Original', 'No card around data', 'No card around data (2)','Blank']
|
||||||
|
|
||||||
#Assets routes
|
#Assets routes
|
||||||
@app.route('/assets/<path:path>')
|
@app.route('/assets/<path:path>')
|
||||||
|
6
sites/parts/footer.html
Normal file
6
sites/parts/footer.html
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
<div style="position: absolute;bottom: 10px;width: 100%;left:25px;">
|
||||||
|
<div style="display: inline-block; background: {{fg_colour}};border-radius: 50%;padding: 10px;">
|
||||||
|
<img src="{{hns_icon}}" width="50px" height="50px">
|
||||||
|
</div>
|
||||||
|
<p style="margin-left: 25px; display:inline; color:{{fg_colour}};">Powered by <a href="https://{{main_domain}}" target="_blank">ShakeCities</a></p>
|
||||||
|
</div>
|
@ -1,4 +1,4 @@
|
|||||||
from flask import Flask, make_response, redirect, render_template_string, request, jsonify, render_template, send_from_directory
|
from flask import Flask, redirect, render_template_string, request
|
||||||
from bs4 import BeautifulSoup
|
from bs4 import BeautifulSoup
|
||||||
import os
|
import os
|
||||||
import dotenv
|
import dotenv
|
||||||
@ -7,6 +7,11 @@ main_domain = "cities.hnshosting.au"
|
|||||||
if os.getenv('MAIN_DOMAIN') != None:
|
if os.getenv('MAIN_DOMAIN') != None:
|
||||||
main_domain = os.getenv('MAIN_DOMAIN')
|
main_domain = os.getenv('MAIN_DOMAIN')
|
||||||
|
|
||||||
|
FOOTER=""
|
||||||
|
if os.path.exists("parts/footer.html"):
|
||||||
|
with open("parts/footer.html") as f:
|
||||||
|
FOOTER = f.read()
|
||||||
|
|
||||||
def render(data,db_object):
|
def render(data,db_object):
|
||||||
if data == False:
|
if data == False:
|
||||||
return redirect("https://" + main_domain + '/claim?domain=' + request.host.split('.')[0])
|
return redirect("https://" + main_domain + '/claim?domain=' + request.host.split('.')[0])
|
||||||
@ -19,8 +24,9 @@ def render(data,db_object):
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
soup = BeautifulSoup(data, 'html.parser')
|
soup = BeautifulSoup(data, 'html.parser')
|
||||||
for script in soup.find_all('script'):
|
|
||||||
script.extract()
|
# for script in soup.find_all('script'):
|
||||||
|
# script.extract()
|
||||||
|
|
||||||
# Inject SSL
|
# Inject SSL
|
||||||
soup.append(BeautifulSoup(ssl, 'html.parser'))
|
soup.append(BeautifulSoup(ssl, 'html.parser'))
|
||||||
@ -82,23 +88,22 @@ def render(data,db_object):
|
|||||||
if db_object['template'] != "":
|
if db_object['template'] != "":
|
||||||
template = db_object['template']
|
template = db_object['template']
|
||||||
|
|
||||||
|
footer = render_template_string(FOOTER,main_domain=main_domain,fg_colour=fg_colour,hns_icon=hns_icon)
|
||||||
if hide_addresses:
|
if hide_addresses:
|
||||||
return render_template_string(get_template_without_address(template),bg_colour=bg_colour,text_colour=text_colour,
|
return render_template_string(get_template(template,True),bg_colour=bg_colour,text_colour=text_colour,
|
||||||
fg_colour=fg_colour, avatar=avatar,main_domain=main_domain,
|
fg_colour=fg_colour, avatar=avatar,main_domain=main_domain,
|
||||||
hnschat=hnschat,email=email,location=location, hns_icon=hns_icon,
|
hnschat=hnschat,email=email,location=location, hns_icon=hns_icon,
|
||||||
hns=hns,btc=btc,eth=eth, data=html)
|
hns=hns,btc=btc,eth=eth, data=html,footer=footer)
|
||||||
else:
|
else:
|
||||||
return render_template(get_template_file(template),bg_colour=bg_colour,text_colour=text_colour,
|
return render_template_string(get_template(template),bg_colour=bg_colour,text_colour=text_colour,
|
||||||
fg_colour=fg_colour, avatar=avatar,main_domain=main_domain,
|
fg_colour=fg_colour, avatar=avatar,main_domain=main_domain,
|
||||||
hnschat=hnschat,email=email,location=location, hns_icon=hns_icon,
|
hnschat=hnschat,email=email,location=location, hns_icon=hns_icon,
|
||||||
hns=hns,btc=btc,eth=eth, data=html)
|
hns=hns,btc=btc,eth=eth, data=html,footer=footer)
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
return "<h1>Nothing here yet</h1>" + "<script>console.log('" + str(e).replace('\'','') + "');</script>"
|
return "<h1>Nothing here yet</h1>" + "<script>console.log('" + str(e).replace('\'','') + "');</script>"
|
||||||
|
|
||||||
|
def get_template(template,hide_addresses=False):
|
||||||
|
|
||||||
def get_template_without_address(template):
|
|
||||||
file = "templates/" +get_template_file(template)
|
file = "templates/" +get_template_file(template)
|
||||||
with open(file) as f:
|
with open(file) as f:
|
||||||
data = f.read()
|
data = f.read()
|
||||||
@ -106,13 +111,14 @@ def get_template_without_address(template):
|
|||||||
# Read template
|
# Read template
|
||||||
soup = BeautifulSoup(data, 'html.parser')
|
soup = BeautifulSoup(data, 'html.parser')
|
||||||
# Remove addresses div
|
# Remove addresses div
|
||||||
|
if hide_addresses:
|
||||||
try:
|
try:
|
||||||
addresses = soup.find(id="addresses")
|
addresses = soup.find(id="addresses")
|
||||||
addresses.decompose()
|
addresses.decompose()
|
||||||
finally:
|
except:
|
||||||
# Return template without addresses
|
pass
|
||||||
return str(soup)
|
|
||||||
|
|
||||||
|
return str(soup)
|
||||||
|
|
||||||
def calculate_contrast_ratio(color1, color2):
|
def calculate_contrast_ratio(color1, color2):
|
||||||
def calculate_luminance(color):
|
def calculate_luminance(color):
|
||||||
@ -156,11 +162,17 @@ def rgb_to_hex(rgb_color):
|
|||||||
|
|
||||||
|
|
||||||
def get_template_file(template):
|
def get_template_file(template):
|
||||||
if template == "Original":
|
template = template.lower()
|
||||||
return "city_old.html"
|
templates = {
|
||||||
elif template == "No card around data":
|
"standard": "city.html",
|
||||||
return "city_no_card.html"
|
"original": "city_old.html",
|
||||||
elif template == "No card around data (2)":
|
"no card around data": "city_no_card.html",
|
||||||
return "city_no_card_2.html"
|
"no card around data (2)": "city_no_card_2.html",
|
||||||
|
"blank": "city_blank.html"
|
||||||
|
}
|
||||||
|
|
||||||
|
if template in templates:
|
||||||
|
return templates[template]
|
||||||
|
|
||||||
|
|
||||||
return "city.html"
|
return "city.html"
|
@ -56,14 +56,7 @@
|
|||||||
<p style="font-size: 24px;margin-bottom: 0px;"><a href="/.well-known/wallets/ETH" target="_blank">{{eth|safe}}</a></p>
|
<p style="font-size: 24px;margin-bottom: 0px;"><a href="/.well-known/wallets/ETH" target="_blank">{{eth|safe}}</a></p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>{{footer | safe}}
|
||||||
<div class="d-flex justify-content-xl-start align-items-xl-center" style="margin-right: 1%;margin-left: 1%;height: 6%;margin-top: 0.5%;">
|
|
||||||
<div class="d-inline-block d-print-inline-block d-sm-none d-md-none d-lg-none d-xl-inline-block d-xxl-inline-block" style="display: inline-flex;width: 3vw;height: 3vw;background: #f1ffff;padding: 4px;border-radius: 50%;"><img src="{{hns_icon}}" width="100%" height="100%"></div>
|
|
||||||
<div class="d-xl-flex align-items-xl-center" style="display: inline-flex;padding: 1%;height: 100%;margin-left: 2%;">
|
|
||||||
<p class="align-self-baseline" style="color: #f1ffff;">Powered by <a href="https://{{main_domain}}" target="_blank">ShakeCities</a></p>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div style="height: 10px;"></div>
|
|
||||||
<script src="assets/bootstrap/js/bootstrap.min.js"></script>
|
<script src="assets/bootstrap/js/bootstrap.min.js"></script>
|
||||||
<script src="assets/js/script.min.js"></script>
|
<script src="assets/js/script.min.js"></script>
|
||||||
</body>
|
</body>
|
||||||
|
58
templates/city_blank.html
Normal file
58
templates/city_blank.html
Normal file
@ -0,0 +1,58 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html style="width: 100vw;height: 99vh;">
|
||||||
|
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0, shrink-to-fit=no">
|
||||||
|
<title>ShakeCities</title>
|
||||||
|
<meta name="twitter:description" content="Unlock web ownership's future with ShakeCities! Create your free, secure Handshake domain site. Integrate crypto payments, explore HNSChat, and join us in shaping the decentralized web!">
|
||||||
|
<meta name="description" content="Unlock web ownership's future with ShakeCities! Create your free, secure Handshake domain site. Integrate crypto payments, explore HNSChat, and join us in shaping the decentralized web!">
|
||||||
|
<meta name="twitter:card" content="summary">
|
||||||
|
<meta property="og:type" content="website">
|
||||||
|
<meta property="og:image" content="https://shakecities.com/assets/img/alexander-slattery-LI748t0BK8w-unsplash.webp">
|
||||||
|
<meta property="og:title" content="ShakeCities">
|
||||||
|
<meta name="twitter:title" content="ShakeCities">
|
||||||
|
<meta name="twitter:image" content="https://shakecities.com/assets/img/alexander-slattery-LI748t0BK8w-unsplash.webp">
|
||||||
|
<meta property="og:description" content="Unlock web ownership's future with ShakeCities! Create your free, secure Handshake domain site. Integrate crypto payments, explore HNSChat, and join us in shaping the decentralized web!">
|
||||||
|
<link rel="icon" type="image/png" sizes="670x700" href="assets/img/HNS.png">
|
||||||
|
<link rel="icon" type="image/png" sizes="670x700" href="assets/img/HNSW.png" media="(prefers-color-scheme: dark)">
|
||||||
|
<link rel="icon" type="image/png" sizes="670x700" href="assets/img/HNS.png">
|
||||||
|
<link rel="icon" type="image/png" sizes="670x700" href="assets/img/HNSW.png" media="(prefers-color-scheme: dark)">
|
||||||
|
<link rel="icon" type="image/png" sizes="670x700" href="assets/img/HNS.png">
|
||||||
|
<link rel="icon" type="image/png" sizes="670x700" href="assets/img/HNS.png">
|
||||||
|
<link rel="icon" type="image/png" sizes="670x700" href="assets/img/HNS.png">
|
||||||
|
<link rel="stylesheet" href="assets/bootstrap/css/bootstrap.min.css">
|
||||||
|
<link rel="stylesheet" href="assets/css/styles.min.css">
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<!-- Template colours
|
||||||
|
#f1ffff foreground colour
|
||||||
|
#1fffff text colour
|
||||||
|
#000000 background colour
|
||||||
|
|
||||||
|
These colours will be overriden with the user's colour scheme
|
||||||
|
-->
|
||||||
|
|
||||||
|
<body style="height: 99vh;width: 100vw;color: #1fffff;background: #000000;overflow-x: hidden;">
|
||||||
|
<!-- <div class="text-center" style="margin: 10px;">
|
||||||
|
<div>{{avatar|safe}}</div> This needs the safe filter to allow HTML to be rendered
|
||||||
|
<div style="color: #f1ffff;">
|
||||||
|
<p style="font-size: 24px;">{{hnschat|safe}}</p>
|
||||||
|
<p style="font-size: 24px;">{{email|safe}}</p>
|
||||||
|
<p style="font-size: 24px;">{{location|safe}}</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div style="padding: 2%;margin: 22px;">
|
||||||
|
<p style="font-size: 24px;">
|
||||||
|
|
||||||
|
</p>
|
||||||
|
</div> -->
|
||||||
|
|
||||||
|
{{data|safe}} <!-- This needs the safe filter to allow HTML to be rendered -->
|
||||||
|
<!-- Footer to display the powered by ShakeCities. -->
|
||||||
|
{{footer|safe}}
|
||||||
|
<script src="assets/bootstrap/js/bootstrap.min.js"></script>
|
||||||
|
<script src="assets/js/script.min.js"></script>
|
||||||
|
</body>
|
||||||
|
|
||||||
|
</html>
|
@ -56,14 +56,8 @@ These colours will be overriden with the user's colour scheme
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Footer to display the powered by ShakeCities. Probs best to leave as is -->
|
<!-- Footer to display the powered by ShakeCities. -->
|
||||||
<div class="d-flex justify-content-xl-start align-items-xl-center" style="margin-right: 1%;margin-left: 1%;height: 6%;margin-top: 0.5%;">
|
{{footer|safe}}
|
||||||
<div class="d-inline-block d-print-inline-block d-sm-none d-md-none d-lg-none d-xl-inline-block d-xxl-inline-block" style="display: inline-flex;width: 3vw;height: 3vw;background: #f1ffff;padding: 4px;border-radius: 50%;"><img src="{{hns_icon}}" width="100%" height="100%"></div>
|
|
||||||
<div class="d-xl-flex align-items-xl-center" style="display: inline-flex;padding: 1%;height: 100%;margin-left: 2%;">
|
|
||||||
<p class="align-self-baseline" style="color: #f1ffff;">Powered by <a href="https://{{main_domain}}" target="_blank">ShakeCities</a></p>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div style="height: 10px;"></div> <!-- This is here to give a bit more room at the bottom -->
|
|
||||||
<script src="assets/bootstrap/js/bootstrap.min.js"></script>
|
<script src="assets/bootstrap/js/bootstrap.min.js"></script>
|
||||||
<script src="assets/js/script.min.js"></script>
|
<script src="assets/js/script.min.js"></script>
|
||||||
</body>
|
</body>
|
||||||
|
@ -56,14 +56,8 @@ These colours will be overriden with the user's colour scheme
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Footer to display the powered by ShakeCities. Probs best to leave as is -->
|
<!-- Footer to display the powered by ShakeCities. -->
|
||||||
<div class="d-flex justify-content-xl-start align-items-xl-center" style="margin-right: 1%;margin-left: 1%;height: 6%;margin-top: 0.5%;">
|
{{footer|safe}}
|
||||||
<div class="d-inline-block d-print-inline-block d-sm-none d-md-none d-lg-none d-xl-inline-block d-xxl-inline-block" style="display: inline-flex;width: 3vw;height: 3vw;background: #f1ffff;padding: 4px;border-radius: 50%;"><img src="{{hns_icon}}" width="100%" height="100%"></div>
|
|
||||||
<div class="d-xl-flex align-items-xl-center" style="display: inline-flex;padding: 1%;height: 100%;margin-left: 2%;">
|
|
||||||
<p class="align-self-baseline" style="color: #f1ffff;">Powered by <a href="https://{{main_domain}}" target="_blank">ShakeCities</a></p>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div style="height: 10px;"></div> <!-- This is here to give a bit more room at the bottom -->
|
|
||||||
<script src="assets/bootstrap/js/bootstrap.min.js"></script>
|
<script src="assets/bootstrap/js/bootstrap.min.js"></script>
|
||||||
<script src="assets/js/script.min.js"></script>
|
<script src="assets/js/script.min.js"></script>
|
||||||
</body>
|
</body>
|
||||||
|
@ -64,14 +64,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<div style="background: #f1ffff;border-radius: 10px;padding-top: 2%;padding-left: 2%;padding-right: 2%;padding-bottom: 2%;margin: 22px;">
|
<div style="background: #f1ffff;border-radius: 10px;padding-top: 2%;padding-left: 2%;padding-right: 2%;padding-bottom: 2%;margin: 22px;">
|
||||||
<p style="font-size: 24px;">{{data|safe}}</p>
|
<p style="font-size: 24px;">{{data|safe}}</p>
|
||||||
</div>
|
</div>{{footer | safe}}
|
||||||
<div class="d-flex justify-content-xl-start align-items-xl-center" style="margin-right: 1%;margin-left: 1%;height: 6%;margin-top: 0.5%;">
|
|
||||||
<div class="d-inline-block d-print-inline-block d-sm-none d-md-none d-lg-none d-xl-inline-block d-xxl-inline-block" style="display: inline-flex;width: 3vw;height: 3vw;background: #f1ffff;padding: 4px;border-radius: 50%;"><img src="{{hns_icon}}" width="100%" height="100%"></div>
|
|
||||||
<div class="d-xl-flex align-items-xl-center" style="display: inline-flex;padding: 1%;height: 100%;margin-left: 2%;">
|
|
||||||
<p class="align-self-baseline" style="color: #f1ffff;">Powered by <a href="https://{{main_domain}}" target="_blank">ShakeCities</a></p>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div style="height: 10px;"></div>
|
|
||||||
<script src="assets/bootstrap/js/bootstrap.min.js"></script>
|
<script src="assets/bootstrap/js/bootstrap.min.js"></script>
|
||||||
<script src="assets/js/script.min.js"></script>
|
<script src="assets/js/script.min.js"></script>
|
||||||
</body>
|
</body>
|
||||||
|
@ -56,14 +56,8 @@ These colours will be overriden with the user's colour scheme
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Footer to display the powered by ShakeCities. Probs best to leave as is -->
|
<!-- Footer to display the powered by ShakeCities. -->
|
||||||
<div class="d-flex justify-content-xl-start align-items-xl-center" style="margin-right: 1%;margin-left: 1%;height: 6%;margin-top: 0.5%;">
|
{{footer|safe}}
|
||||||
<div class="d-inline-block d-print-inline-block d-sm-none d-md-none d-lg-none d-xl-inline-block d-xxl-inline-block" style="display: inline-flex;width: 3vw;height: 3vw;background: #f1ffff;padding: 4px;border-radius: 50%;"><img src="{{hns_icon}}" width="100%" height="100%"></div>
|
|
||||||
<div class="d-xl-flex align-items-xl-center" style="display: inline-flex;padding: 1%;height: 100%;margin-left: 2%;">
|
|
||||||
<p class="align-self-baseline" style="color: #f1ffff;">Powered by <a href="https://{{main_domain}}" target="_blank">ShakeCities</a></p>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div style="height: 10px;"></div> <!-- This is here to give a bit more room at the bottom -->
|
|
||||||
<script src="assets/bootstrap/js/bootstrap.min.js"></script>
|
<script src="assets/bootstrap/js/bootstrap.min.js"></script>
|
||||||
<script src="assets/js/script.min.js"></script>
|
<script src="assets/js/script.min.js"></script>
|
||||||
</body>
|
</body>
|
||||||
|
Loading…
Reference in New Issue
Block a user