From 16d28bc02ec784b488f526bcbe7d89c01abaa7ab Mon Sep 17 00:00:00 2001 From: Damien De Paoli Date: Sat, 11 Oct 2025 12:47:53 +1100 Subject: [PATCH] first pass of versioning, working for files.html only for now --- files.py | 26 +++++++++++--------- templates/files.html | 58 ++++++++++++++++++++++---------------------- 2 files changed, 44 insertions(+), 40 deletions(-) diff --git a/files.py b/files.py index e412dbe..1971a24 100644 --- a/files.py +++ b/files.py @@ -270,23 +270,12 @@ class EntrySchema(ma.SQLAlchemyAutoSchema): def get_full_path(self, obj): return obj.FullPathOnFS() -# quick helper func to return the timestampe of a (jscript) file. -# we use this as a quick/hacky way of versioning the jscript file -def get_version(fname): - mtime = os.path.getmtime(fname) - return int(mtime) # Use timestamp as version - # global - this will be use more than once below, so do it once for efficiency entries_schema = EntrySchema(many=True) FOT_Schema = FaceOverrideTypeSchema(many=True) path_Schema = PathSchema(many=True) person_Schema = PersonSchema(many=True) -js_vers={} -js_vers['fs'] = get_version( url_for( 'internal', filename='js/files_support.js') ) -js_vers['vs'] = get_version( url_for( 'internal', filename='js/view_support.js') ) -js_vers['ft'] = get_version( url_for( 'internal', filename='js/files_transform.js') ) - ################################################################################ # /get_entries_by_ids -> route where we supply list of entry ids (for next/prev # page of data we want to show). Returns json of all matching entries @@ -482,6 +471,7 @@ def file_list_ip(): def files_ip(): OPT=States( request ) query_data = GetQueryData( OPT ) + js_vers = getVersions() return render_template("files.html", page_title=f"View Files ({OPT.path_type} Path)", OPT=OPT, query_data=query_data, js_vers=js_vers ) ################################################################################ @@ -782,3 +772,17 @@ def get_existing_paths(dt): first_dir=0 ret+= ' ]' return make_response( ret ) + +# quick helper func to return timestamps of jscript files +# we use this as a quick/hacky way of versioning them +def getVersions(): + js_vers={} + js_vers['fs'] = int(os.path.getmtime( "."+url_for( 'internal', filename='js/files_support.js') )) + js_vers['vs'] = int(os.path.getmtime( "."+url_for( 'internal', filename='js/view_support.js') )) + js_vers['ft'] = int(os.path.getmtime( "."+url_for( 'internal', filename='js/files_transform.js') )) + js_vers['ic'] = int(os.path.getmtime( "."+url_for( 'internal', filename='icons.svg') )) + js_vers['r180'] = int(os.path.getmtime( "."+url_for( 'internal', filename='rot180.png') )) + js_vers['r270'] = int(os.path.getmtime( "."+url_for( 'internal', filename='rot270.png') )) + js_vers['r90'] = int(os.path.getmtime( "."+url_for( 'internal', filename='rot90.png') )) + js_vers['th'] = int(os.path.getmtime( "."+url_for( 'internal', filename='throbber.gif') )) + return js_vers diff --git a/templates/files.html b/templates/files.html index c684fcc..ed7c6d0 100644 --- a/templates/files.html +++ b/templates/files.html @@ -26,13 +26,13 @@
{% if "files_ip" in request.url %} - + {% set tmp_path=OPT.cwd | replace( "static/Import", "" ) + "/" %} {% elif "files_sp" in request.url %} - + {% set tmp_path=OPT.cwd | replace( "static/Storage", "" ) + "/" %} {% elif "files_rbp" in request.url %} - + {% set tmp_path=OPT.cwd | replace( "static/Bin", "" ) + "/" %} {% endif %} {{tmp_path}} @@ -58,21 +58,21 @@ {% endif %}
 {{OPT.how_many}} files  {% if "files_rbp" in request.url %} @@ -104,11 +104,11 @@
 {{OPT.how_many}} files 
@@ -129,12 +129,12 @@
- +