feat: differentiate between commit and html-formatted commit

This commit is contained in:
2025-04-16 12:07:04 +02:00
parent c35da4a043
commit 5f13949cd4
4 changed files with 14 additions and 8 deletions

View File

@@ -17,7 +17,7 @@ def index():
}
return render_template('index.html', goals=stats['goals'], assists=stats['assists'],
matches=stats['matches'], matches_list=stats['matches_list'],
commit=lewy_globals.getCommit())
commit_in_html=lewy_globals.getCommitInFormattedHTML())
@app.route('/mecze')
def mecze():

View File

@@ -1,10 +1,16 @@
from git import Repo # hash ostatniego commitu
def getCommit():
repo = "<p>Brak informacji o wersji skryptu</p>"
try:
repo = Repo(search_parent_directories=True).head.object.hexsha
repo = f"<p>Commit: <a href='https://gitea.7o7.cx/roberteam/lewangoalski/commit/{repo}'>{repo[:11]}</a></p>"
return Repo(search_parent_directories=True).head.object.hexsha
except:
pass
return None
def getCommitInFormattedHTML():
repo = "<p>Brak informacji o wersji skryptu</p>"
commit = getCommit()
if commit is not None:
repo = f"<p>Commit: <a href='https://gitea.7o7.cx/roberteam/lewangoalski/commit/{commit}'>{commit[:11]}</a></p>"
return repo

View File

@@ -3,13 +3,13 @@ from FlaskWebProject import app
@app.route('/')
def index():
# Odczyt ciasteczka "darkMode" <EFBFBD> domy<EFBFBD>lnie "disabled"
# Odczyt ciasteczka "darkMode" domyślnie "disabled"
dark_mode = request.cookies.get('darkMode', 'disabled')
return render_template('index.html', dark_mode=dark_mode)
@app.route('/toggle_dark_mode')
def toggle_dark_mode():
# Prze<EFBFBD><EFBFBD>cz tryb i zapisz w ciasteczku
# Przełącz tryb i zapisz w ciasteczku
dark_mode = request.cookies.get('darkMode', 'disabled')
new_mode = 'enabled' if dark_mode == 'disabled' else 'disabled'
response = make_response("OK")

View File

@@ -14,5 +14,5 @@
{% endblock %}
{% block footer %}
{{ commit | safe }}
{{ commit_in_html | safe }}
{% endblock %}