From fb54e9eb714d499a9f5fd58e57359ae059c8ce5a Mon Sep 17 00:00:00 2001 From: Thomas Rosnet Date: Mon, 4 Apr 2022 16:00:33 +0200 Subject: [PATCH 1/2] adding version in page + making jsonld available globally in templates --- app.py | 15 +++++++++++---- templates/footer.html | 6 +++++- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/app.py b/app.py index 48571420..d6859f0a 100644 --- a/app.py +++ b/app.py @@ -143,6 +143,17 @@ DICT_TEMP_RES = {} +@app.context_processor +def inject_app_version(): + repo = git.Repo(".") + tags = sorted(repo.tags, key=lambda t: t.commit.committed_datetime) + latest_tag = tags[-1] + return dict(version_tag=latest_tag) + +@app.context_processor +def inject_jsonld(): + return dict(jld=buildJSONLD()) + @app.route("/favicon.ico") def favicon(): return send_from_directory( @@ -158,7 +169,6 @@ def home(): "index.html", title="FAIR-Checker", subtitle="Improve the FAIRness of your web resources", - jld=buildJSONLD(), ) @@ -175,7 +185,6 @@ def about(): "about.html", title="About", subtitle="More about FAIR-Checker", - jld=buildJSONLD(), ) @@ -185,7 +194,6 @@ def statistics(): "statistics.html", title="Statistics", subtitle="Visualize usage statistics of FAIR-Checker", - jld=buildJSONLD(), evals=stats.evaluations_this_week(), success=stats.success_this_week(), success_weekly=stats.success_weekly_one_year(), @@ -1232,7 +1240,6 @@ def kg_metrics_2(): sample_data=sample_resources, title="Inspect", subtitle="to enhance metadata quality", - jld=buildJSONLD(), ) diff --git a/templates/footer.html b/templates/footer.html index 3fe1ebb0..b032c9c8 100644 --- a/templates/footer.html +++ b/templates/footer.html @@ -31,9 +31,13 @@
+

+ Software version: + {{ version_tag }} +

The source code is licensed - MIT. + MIT.

From a96688a40c71dbf4823b9f2515da849af0bf298c Mon Sep 17 00:00:00 2001 From: Thomas Rosnet Date: Wed, 6 Apr 2022 10:04:54 +0200 Subject: [PATCH 2/2] fix black --- app.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app.py b/app.py index d6859f0a..d6599cae 100644 --- a/app.py +++ b/app.py @@ -150,10 +150,12 @@ def inject_app_version(): latest_tag = tags[-1] return dict(version_tag=latest_tag) + @app.context_processor def inject_jsonld(): return dict(jld=buildJSONLD()) + @app.route("/favicon.ico") def favicon(): return send_from_directory(