feat: Add home page info
All checks were successful
Build Docker / Build Main Image (push) Successful in 37s
Build Docker / Build SLDs Image (push) Successful in 37s

This commit is contained in:
Nathan Woodburn 2023-11-15 22:51:30 +11:00
parent 5be0abeccd
commit bbb47144f4
Signed by: nathanwoodburn
GPG Key ID: 203B000478AD0EF1
7 changed files with 60 additions and 12 deletions

21
db.py
View File

@ -2,6 +2,7 @@ import mysql.connector
import os
import dotenv
import json
import random
dotenv.load_dotenv()
@ -200,3 +201,23 @@ def update_website_wallet(domain,token,address):
connection.commit()
cursor.close()
connection.close()
def get_random_sites():
connection = mysql.connector.connect(**dbargs)
cursor = connection.cursor()
cursor.execute("""
SELECT * FROM site
""")
data = cursor.fetchall()
cursor.close()
connection.close()
# Randomly pick 5
if len(data) > 5:
data = random.sample(data,5)
names = []
for site in data:
names.append(site[1])
return names

22
main.py
View File

@ -24,6 +24,8 @@ CITY_DOMAIN = os.getenv('CITY_DOMAIN')
if CITY_DOMAIN == None:
CITY_DOMAIN = "exampledomainnathan1"
random_sites = ""
#Assets routes
@app.route('/assets/<path:path>')
def assets(path):
@ -35,6 +37,15 @@ def error(message):
@app.route('/')
def index():
global random_sites
if random_sites == "":
random_sites_names = db.get_random_sites()
for site in random_sites_names:
random_sites += "<a href='https://" + site + "." + CITY_DOMAIN + "' target='_blank'>" + site + "." +CITY_DOMAIN+ "</a><br>"
if 'token' in request.cookies:
token = request.cookies['token']
# Verify token
@ -44,8 +55,8 @@ def index():
resp = make_response(redirect('/'))
resp.set_cookie('token', '', expires=0)
return resp
return render_template('index.html',account=user['email'],account_link="account",account_link_name="Account",CITY_DOMAIN=CITY_DOMAIN)
return render_template('index.html',account="Login",account_link="login",account_link_name="Login",CITY_DOMAIN=CITY_DOMAIN)
return render_template('index.html',account=user['email'],account_link="account",account_link_name="Account",CITY_DOMAIN=CITY_DOMAIN,random_sites=random_sites)
return render_template('index.html',account="Login",account_link="login",account_link_name="Login",CITY_DOMAIN=CITY_DOMAIN,random_sites=random_sites)
@app.route('/signup', methods=['POST'])
def signup():
@ -229,7 +240,12 @@ def catch_all(path):
def not_found(e):
return redirect('/')
def update_random_sites():
global random_sites
random_sites_names = db.get_random_sites()
random_sites = ""
for site in random_sites_names:
random_sites += "<a href='https://" + site + "." + CITY_DOMAIN + "' target='_blank'>" + site + "." +CITY_DOMAIN+ "</a><br>"
if __name__ == '__main__':
db.check_tables()

View File

@ -10,3 +10,4 @@ passlib
argon2-cffi
mysql-connector-python
beautifulsoup4
apscheduler

View File

@ -8,8 +8,13 @@ import dotenv
import sys
import json
import db
from apscheduler.schedulers.background import BackgroundScheduler
def update_sites_job():
print("Updating random sites", flush=True)
main.update_random_sites()
class GunicornApp(BaseApplication):
def __init__(self, app, options=None):
self.options = options or {}
@ -26,6 +31,12 @@ class GunicornApp(BaseApplication):
if __name__ == '__main__':
db.check_tables()
scheduler = BackgroundScheduler()
scheduler.add_job(update_sites_job, 'interval', minutes=15)
scheduler.start()
workers = os.getenv('WORKERS')
threads = os.getenv('THREADS')
if workers is None:

View File

@ -1 +1 @@
.bs-icon{--bs-icon-size:.75rem;display:flex;flex-shrink:0;justify-content:center;align-items:center;font-size:var(--bs-icon-size);width:calc(var(--bs-icon-size) * 2);height:calc(var(--bs-icon-size) * 2);color:var(--bs-primary)}.bs-icon-xs{--bs-icon-size:1rem;width:calc(var(--bs-icon-size) * 1.5);height:calc(var(--bs-icon-size) * 1.5)}.bs-icon-sm{--bs-icon-size:1rem}.bs-icon-md{--bs-icon-size:1.5rem}.bs-icon-lg{--bs-icon-size:2rem}.bs-icon-xl{--bs-icon-size:2.5rem}.bs-icon.bs-icon-primary{color:var(--bs-white);background:var(--bs-primary)}.bs-icon.bs-icon-primary-light{color:var(--bs-primary);background:rgba(var(--bs-primary-rgb),.2)}.bs-icon.bs-icon-semi-white{color:var(--bs-primary);background:rgba(255,255,255,.5)}.bs-icon.bs-icon-rounded{border-radius:.5rem}.bs-icon.bs-icon-circle{border-radius:50%}.right-align{right:0;margin-right:1%}.top-align{top:0;margin-top:1%}.sticky-bottom{width:100%;bottom:1%;left:0}
a{color:inherit}.bs-icon{--bs-icon-size:.75rem;display:flex;flex-shrink:0;justify-content:center;align-items:center;font-size:var(--bs-icon-size);width:calc(var(--bs-icon-size) * 2);height:calc(var(--bs-icon-size) * 2);color:var(--bs-primary)}.bs-icon-xs{--bs-icon-size:1rem;width:calc(var(--bs-icon-size) * 1.5);height:calc(var(--bs-icon-size) * 1.5)}.bs-icon-sm{--bs-icon-size:1rem}.bs-icon-md{--bs-icon-size:1.5rem}.bs-icon-lg{--bs-icon-size:2rem}.bs-icon-xl{--bs-icon-size:2.5rem}.bs-icon.bs-icon-primary{color:var(--bs-white);background:var(--bs-primary)}.bs-icon.bs-icon-primary-light{color:var(--bs-primary);background:rgba(var(--bs-primary-rgb),.2)}.bs-icon.bs-icon-semi-white{color:var(--bs-primary);background:rgba(255,255,255,.5)}.bs-icon.bs-icon-rounded{border-radius:.5rem}.bs-icon.bs-icon-circle{border-radius:50%}.right-align{right:0;margin-right:1%}.top-align{top:0;margin-top:1%}.sticky-bottom{width:100%;bottom:1%;left:0}

View File

@ -14,7 +14,6 @@
<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">
<link rel="stylesheet" href="assets/css/city.min.css">
</head>
<body style="height: 99vh;width: 100vw;color: #1fffff;background: #000000;overflow-x: hidden;">

View File

@ -32,12 +32,12 @@
<section style="margin-top: 10px;">
<div class="row" style="margin: 0px;">
<div class="col" style="background: var(--bs-body-color);margin-right: 10px;border-radius: 10px;">
<h1 style="margin: 10px;">Heading</h1>
<p style="margin: 10px;">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Mauris vivamus urna nisi dapibus nascetur convallis sollicitudin tempus lorem condimentum. Aptent dictumst montes id mattis molestie parturient morbi lobortis cubilia pharetra. Natoque adipiscing mollis parturient odio elit eu varius vulputate phasellus gravida. Et eget donec fringilla viverra id eu tempor ullamcorper aliquet vehicula. Et euismod magnis interdum mollis tellus lacinia at sollicitudin morbi inceptos.<br><br>Dictumst natoque imperdiet per praesent nisl morbi fermentum ultrices vivamus eu. Dictum venenatis netus orci himenaeos dictumst mattis pulvinar mattis laoreet tempor. Vulputate consequat in duis convallis mus mattis suspendisse semper netus varius. Magna placerat lectus eleifend nisi nunc laoreet lorem ipsum primis pellentesque. Fusce inceptos ante orci habitasse dui torquent dictum habitant iaculis sit. Interdum sociis eu porta inceptos parturient neque tortor lectus vivamus nunc.</p>
<h1 style="margin: 10px;">Introducing ShakeCities</h1>
<p style="margin: 10px;">ShakeCities is a site offering free personalizable&nbsp;websites. This is a perfect way to start your journey into Handshake domains! Step into a new experience where Handshake domains become instant sites, and where everyone can create their own unique decentralized page.<br>Secured with HTTPS powered by DANE (DNS-based Authentication of Named Entities).<br>But that's not all ShakeCities goes beyond, allowing you to seamlessly integrate crypto addresses into your site, providing an easy way to get paid. Simply send crypto to <code>@yourname.{{CITY_DOMAIN}}</code><br>Join us in building a decentralized, secure, and innovative internet landscape. Embrace the future with ShakeCities where Handshake domains meet simplicity.</p>
</div>
<div class="col" style="background: var(--bs-body-color);margin-left: 10px;border-radius: 10px;">
<h1 style="margin: 10px;">Heading</h1>
<p style="margin: 10px;">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Conubia semper malesuada lobortis blandit ac leo leo potenti vel rutrum volutpat. Orci taciti arcu ipsum arcu rhoncus tortor aliquet id magna malesuada amet. Diam inceptos tempor gravida mattis mollis at imperdiet eros per cras sagittis.<br><br>Aliquet faucibus elit lacus elementum sed malesuada a vestibulum lacinia bibendum eleifend. Viverra mattis eleifend cum nulla nascetur parturient lectus vitae nostra a sem. Vel proin ullamcorper platea aenean vivamus volutpat lacus velit rutrum mi consequat. Ac gravida risus purus ligula mollis potenti duis ultricies eleifend tellus adipiscing.<br><br>Congue aenean lobortis fermentum lectus vel justo scelerisque id vitae mauris lacus. Gravida porta dolor tellus sem iaculis dictumst a mus in lorem ipsum. Dapibus pulvinar pretium ornare mauris duis sagittis non ullamcorper orci vestibulum venenatis. Imperdiet posuere penatibus sed senectus enim sollicitudin semper justo lorem aptent cras.</p>
<h1 style="margin: 10px;">Find a site</h1>
<p style="margin: 10px;font-size: 20px;">{{random_sites|safe}}</p>
</div>
</div>
</section>
@ -55,7 +55,7 @@
<section class="d-none d-print-block d-md-block d-lg-block d-xl-block d-xxl-block" style="background: var(--bs-body-color);text-align: center;padding-top: 10px;padding-bottom: 10px;margin-bottom: 25px;margin-top: 40px;border-radius: 10px;">
<div style="margin: 20px;">
<h1>Contact</h1>
<div class="list-group list-group-horizontal" data-bs-theme="dark" style="margin: auto;width: 50%;"><button class="list-group-item list-group-item-action" style="width: 33%;padding: 0px;margin: 10px;"><a class="btn btn-primary" role="button" style="width: 100%;" target="_blank" href="https://discord.com">Discord</a></button><button class="list-group-item list-group-item-action" style="width: 33%;padding: 0px;margin: 10px;"><a class="btn btn-primary" role="button" style="width: 100%;" target="_blank" href="mailto:email@example.com">Email</a></button><button class="list-group-item list-group-item-action" style="width: 33%;padding: 0px;margin: 10px;"><a class="btn btn-primary" role="button" style="width: 100%;" target="_blank" href="https://twitter.com">Twitter</a></button></div>
<div class="list-group list-group-horizontal" data-bs-theme="dark" style="margin: auto;width: 50%;"><button class="list-group-item list-group-item-action" style="width: 33%;padding: 0px;margin: 10px;"><a class="btn btn-primary" role="button" style="width: 100%;" target="_blank" href="https://l.woodburn.au/discord">Discord</a></button><button class="list-group-item list-group-item-action" style="width: 33%;padding: 0px;margin: 10px;"><a class="btn btn-primary" role="button" style="width: 100%;" target="_blank" href="mailto:shakecities@woodburn.au">Email</a></button><button class="list-group-item list-group-item-action" style="width: 33%;padding: 0px;margin: 10px;"><a class="btn btn-primary" role="button" style="width: 100%;" target="_blank" href="https://hnschat#channel:woodburn">HNSChat</a></button></div>
</div>
<div style="margin: 20px;">
<h1>Donate</h1>