finished basic about page, and including 15 recent commits by default

This commit is contained in:
2022-12-31 14:28:05 +11:00
parent 70c449d859
commit 1afaa338a8
4 changed files with 34 additions and 4 deletions

View File

@@ -20,7 +20,7 @@ RUN pip3 install --upgrade pillow --user
EXPOSE 443 EXPOSE 443
EXPOSE 55432 EXPOSE 55432
COPY . . COPY . .
RUN git log -n 5 > ./internal/git-log.txt RUN git log -n 15 > ./internal/git-log.txt
RUN rm -rf .git RUN rm -rf .git
RUN chown mythtv:mythtv /code RUN chown mythtv:mythtv /code
RUN chown mythtv:mythtv ./static RUN chown mythtv:mythtv ./static

2
TODO
View File

@@ -15,8 +15,6 @@
* change the rotation code to use that jpeg util to reduce/remove compression loss? * 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?) * 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), * could get better AI optim, by keeping track of just new files since scan (even if we did this from the DB),

33
main.py
View File

@@ -134,6 +134,38 @@ def login():
return render_template("login.html", form=form) 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') @app.route('/logout')
@login_required @login_required
def logout(): def logout():
@@ -163,4 +195,3 @@ def _jinja2_filter_parentpath(dn):
s+=1 s+=1
f=username.index(',') f=username.index(',')
return username[s:f] return username[s:f]

View File

@@ -124,6 +124,7 @@
</a> </a>
<div class="dropdown-menu dropdown-menu-end" aria-labelledby="navbarDropdownMenuLink"> <div class="dropdown-menu dropdown-menu-end" aria-labelledby="navbarDropdownMenuLink">
<div><a class="dropdown-item" href="{{url_for('states')}}">{{current_user.dn|Username}}</a></div> <div><a class="dropdown-item" href="{{url_for('states')}}">{{current_user.dn|Username}}</a></div>
<div><a class="dropdown-item" href="{{url_for('about')}}">About</a></div>
<div><a class="dropdown-item" href="{{url_for('logout')}}">Logout</a></div> <div><a class="dropdown-item" href="{{url_for('logout')}}">Logout</a></div>
</div> </div>
</div> </div>