From 35e4ae222cf3f50bcb9df7c196e9469dc3b673c4 Mon Sep 17 00:00:00 2001 From: Nathan Woodburn Date: Fri, 23 Feb 2024 17:27:38 +1100 Subject: [PATCH] feat: Add date to now page --- server.py | 14 ++++++++++++-- templates/now/24_02_18.html | 3 ++- templates/now/template.html | 3 ++- templates/sitemap.xml | 3 +++ 4 files changed, 19 insertions(+), 4 deletions(-) diff --git a/server.py b/server.py index 8858a28..f1d6938 100644 --- a/server.py +++ b/server.py @@ -3,6 +3,7 @@ import os import dotenv import requests import CloudFlare +import datetime app = Flask(__name__) dotenv.load_dotenv() @@ -129,6 +130,7 @@ def index(): return resp @app.route('/now') +@app.route('/now/') def now(): global handshake_scripts @@ -141,7 +143,13 @@ def now(): # Remove template files = [file for file in files if file != 'template.html'] files.sort(reverse=True) - return render_template('now/' + files[0], handshake_scripts=handshake_scripts) + date = files[0].strip('.html') + # Convert to date + date = datetime.datetime.strptime(date, '%y_%m_%d') + date = date.strftime('%A, %B %d, %Y') + + + return render_template('now/' + files[0], handshake_scripts=handshake_scripts, DATE=date) @app.route('/') @@ -158,13 +166,15 @@ def catch_all(path): if os.path.isfile('templates/' + path + '.html'): return render_template(path + '.html', handshake_scripts=handshake_scripts) + if os.path.isfile('templates/' + path.strip('/') + '.html'): + return render_template(path.strip('/') + '.html', handshake_scripts=handshake_scripts) + return render_template('404.html'), 404 def getAddress(): global address if address == '': address = 'hs1qv3uu4amv87g7p7h49xez2pmzwjf92am0wzpnh4' - # address = requests.get('http://hip02-server:3000').text? return address diff --git a/templates/now/24_02_18.html b/templates/now/24_02_18.html index ed30d62..252552b 100644 --- a/templates/now/24_02_18.html +++ b/templates/now/24_02_18.html @@ -72,7 +72,8 @@ Find out what I've been up to in the last week"> {{handshake_scripts | safe}}

Nathan.Woodburn/

-

WHat's Happening Now

+

WHat's Happening Now

+
{{DATE}}

HappeninG

diff --git a/templates/now/template.html b/templates/now/template.html index 6ac61f8..f6d83ea 100644 --- a/templates/now/template.html +++ b/templates/now/template.html @@ -72,7 +72,8 @@ Find out what I've been up to in the last week"> {{handshake_scripts | safe}}

Nathan.Woodburn/

-

WHat's Happening Now

+

WHat's Happening Now

+
{{DATE}}

Title

diff --git a/templates/sitemap.xml b/templates/sitemap.xml index 4d6f9ef..9680b93 100644 --- a/templates/sitemap.xml +++ b/templates/sitemap.xml @@ -3,6 +3,9 @@ https://nathan.woodburn.au/now/24_02_18 + + https://nathan.woodburn.au/now/24_02_25 + https://nathan.woodburn.au/now/template