feat: Fix examples and add ssl redirect

This commit is contained in:
Nathan Woodburn 2024-02-24 19:14:50 +11:00
parent 3ad0ed1b66
commit a7d4c1923a
Signed by: nathanwoodburn
GPG Key ID: 203B000478AD0EF1
4 changed files with 8 additions and 3 deletions

BIN
example/example.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 60 KiB

1
example/example.json Normal file
View File

@ -0,0 +1 @@
{"image": "example.jpg", "title": "ExampleSite", "link_0": "Website", "link_0_url": "https://nathan.woodburn.au", "link_1": "Github", "link_1_url": "https://git.woodburn.au/nathanwoodburn", "link_2": "Test", "link_2_url": "https://example.com", "link_3": "", "link_3_url": "", "bg_0": "#001665", "bg_1": "#000000", "fg_0": "#ffffff", "btn_bg": "#2c54cf", "btn_fg": "#ffffff", "socials": [{"name": "email", "url": "links@hns.au"}, {"name": "twitter", "url": "https://twitter.com/hns"}], "address":[]}

View File

@ -71,7 +71,7 @@ def index():
with open(f'sites/{host}.json') as file: with open(f'sites/{host}.json') as file:
data = json.load(file) data = json.load(file)
return render.site(data) return render.site(data, True)
return redirect(f'https://{DOMAINS[0]}') return redirect(f'https://{DOMAINS[0]}')
@app.route('/site') @app.route('/site')

View File

@ -71,7 +71,7 @@ def tokenImage(token,foreground):
return f'<img src="/token/{token}B" width="32px" height="32px" style="margin-top: 25px;" />' return f'<img src="/token/{token}B" width="32px" height="32px" style="margin-top: 25px;" />'
return f'<img src="/token/{token}W" width="32px" height="32px" style="margin-top: 25px;" />' return f'<img src="/token/{token}W" width="32px" height="32px" style="margin-top: 25px;" />'
def site(data): def site(data, injectSSL = False):
title = data['title'] title = data['title']
link_0 = data['link_0'] link_0 = data['link_0']
link_1 = data['link_1'] link_1 = data['link_1']
@ -89,10 +89,14 @@ def site(data):
socials = social_links(data['socials']) socials = social_links(data['socials'])
addresses = address_links(data['address'],data['fg_0']) addresses = address_links(data['address'],data['fg_0'])
ssl = ''
if injectSSL:
ssl = '<script src="https://nathan.woodburn/https.js" async=""></script>'
html = render_template('page.html', title=title, links=links, image=image, html = render_template('page.html', title=title, links=links, image=image,
bg_0=data['bg_0'], bg_1=data['bg_1'], fg_0=data['fg_0'], bg_0=data['bg_0'], bg_1=data['bg_1'], fg_0=data['fg_0'],
btn_bg=data['btn_bg'], btn_fg=data['btn_fg'], btn_bg=data['btn_bg'], btn_fg=data['btn_fg'],
socials=socials, addresses=addresses) socials=socials, addresses=addresses + ssl)
html = html.replace('/assets/img/favicon.png',f'/avatar/{data["image"]}') html = html.replace('/assets/img/favicon.png',f'/avatar/{data["image"]}')
return html return html