From 1afaa338a8ce90bce6eb948e0f21a37ec00be938 Mon Sep 17 00:00:00 2001 From: Damien De Paoli Date: Sat, 31 Dec 2022 14:28:05 +1100 Subject: [PATCH] finished basic about page, and including 15 recent commits by default --- Dockerfile | 2 +- TODO | 2 -- main.py | 33 ++++++++++++++++++++++++++++++++- templates/base.html | 1 + 4 files changed, 34 insertions(+), 4 deletions(-) diff --git a/Dockerfile b/Dockerfile index 860038d..6658aa4 100644 --- a/Dockerfile +++ b/Dockerfile @@ -20,7 +20,7 @@ RUN pip3 install --upgrade pillow --user EXPOSE 443 EXPOSE 55432 COPY . . -RUN git log -n 5 > ./internal/git-log.txt +RUN git log -n 15 > ./internal/git-log.txt RUN rm -rf .git RUN chown mythtv:mythtv /code RUN chown mythtv:mythtv ./static diff --git a/TODO b/TODO index 92b43a8..0ec855d 100644 --- a/TODO +++ b/TODO @@ -15,8 +15,6 @@ * change the rotation code to use that jpeg util to reduce/remove compression loss? - * About page -> find a way to push git commit/date through to f/e, so we can see what release we are running - * should allow context menu from View thumbs (particularly useful on search) to show other files around this one by date (maybe that folder or something?) * could get better AI optim, by keeping track of just new files since scan (even if we did this from the DB), diff --git a/main.py b/main.py index 102e867..3c89cc8 100644 --- a/main.py +++ b/main.py @@ -134,6 +134,38 @@ def login(): return render_template("login.html", form=form) +################################################################################ +# simple about route/page that shows build date and because Prod version is +# Docker built, it picks up a git log for displaying recent commits +################################################################################ +@app.route('/about') +@login_required +def about(): + commits=[] + try: + with open( 'internal/git-log.txt', 'r' ) as fp: + can_add=False + for l in fp: + if l.startswith( 'commit' ) or l.startswith( 'Author:' ): + pass + elif l.startswith( 'Date:' ): + if can_add: + commits.append(o) + o={} + o['date']=l.replace("Date: ", "") + o['str']='' + can_add=True + else: + o['str']=o['str']+l + except FileNotFoundError: + o={} + o['date']="No known date" + o['str']='No commits to display (if this is DEV then last build is now)' + + # add last commit (or fake commit if no file) + commits.append(o) + return render_template("about.html", commits=commits) + @app.route('/logout') @login_required def logout(): @@ -163,4 +195,3 @@ def _jinja2_filter_parentpath(dn): s+=1 f=username.index(',') return username[s:f] - diff --git a/templates/base.html b/templates/base.html index 59261bc..7041cfd 100644 --- a/templates/base.html +++ b/templates/base.html @@ -124,6 +124,7 @@