feat: show year range of copyright

This commit is contained in:
Ayo Ayco 2024-04-26 12:21:21 +02:00
parent 5767e2738d
commit 5cd45f7cf2
2 changed files with 21 additions and 2 deletions

View file

@ -237,7 +237,15 @@
</ul> </ul>
</main> </main>
<footer> <footer>
&copy; {{ attribution.year }} {{ attribution.owner }} <p>
Copyright &copy;
{% if attribution.current_year %}
{{ attribution.year }}-{{ attribution.current_year }}
{%else%}
{{ attribution.year }}
{% endif %}
{{ attribution.owner }}
</p>
<p>Powered by <a href="https://ayco.io/sh/threads">/threads</a></p> <p>Powered by <a href="https://ayco.io/sh/threads">/threads</a></p>
</footer> </footer>
</body> </body>

View file

@ -1,5 +1,6 @@
from flask import Blueprint, render_template from flask import Blueprint, render_template
import requests import requests
import datetime
threads = Blueprint('threads', __name__, template_folder='template') threads = Blueprint('threads', __name__, template_folder='template')
@ -12,10 +13,20 @@ app = {
} }
attribution = { attribution = {
"owner": "Ayo Ayco", "owner": "Ayo Ayco",
"year": "2024" "year": "2022" # earliest year in featured posts
} }
########################################################### ###########################################################
@threads.before_request
def middleware():
# check current year and put ange as attribution
currentDateTime = datetime.datetime.now()
date = currentDateTime.date()
year = date.strftime("%Y")
if year != attribution['year']:
attribution['current_year'] = year
@threads.route('/') @threads.route('/')
def home(): def home():
statuses = fetch_statuses() statuses = fetch_statuses()