From c0f1dd2ad40118f95b54a06ec8b37bc4a00164bb Mon Sep 17 00:00:00 2001 From: abneeeees Date: Sun, 18 Jan 2026 02:30:18 +0530 Subject: [PATCH] feat(template): add version and Current Year via template - Create python method that returns Current year in json - footer.html fetch year by {{ year }} - Add PROJECT_VERSION in .env and .env.example file - base.html and footer.html fetch current version by {{ config["PROJECT_VERSION"] }} --- .env.example | 1 + aperisolve/app.py | 9 ++++++++- aperisolve/templates/base.html | 2 +- aperisolve/templates/footer.html | 2 +- 4 files changed, 11 insertions(+), 3 deletions(-) diff --git a/.env.example b/.env.example index df712a3..21128ef 100644 --- a/.env.example +++ b/.env.example @@ -2,6 +2,7 @@ WEB_APP_PORT=5000 # Application configuration +PROJECT_VERSION=3.1.2 MAX_CONTENT_LENGTH=3145728 MAX_PENDING_TIME=600 MAX_STORE_TIME=259200 diff --git a/aperisolve/app.py b/aperisolve/app.py index 92852ef..dbfc39f 100644 --- a/aperisolve/app.py +++ b/aperisolve/app.py @@ -36,6 +36,7 @@ def create_app() -> Flask: app = Flask(__name__) app.json.sort_keys = False # type: ignore app.config["SQLALCHEMY_DATABASE_URI"] = os.environ.get("DB_URI") + app.config["PROJECT_VERSION"] = os.getenv("PROJECT_VERSION") app.config["SQLALCHEMY_TRACK_MODIFICATIONS"] = False app.config["MAX_CONTENT_LENGTH"] = int(os.environ.get("MAX_CONTENT_LENGTH", 1024 * 1024)) app.config["REDIS_QUEUE"] = Queue(connection=Redis(host="redis", port=6379)) @@ -426,7 +427,13 @@ def create_app() -> Flask: return abort(404, description="Image not found or unsupported format") return send_file(output_file, as_attachment=True) - + + # Returns Current Year + @app.context_processor + def return_curr_year(): + year = datetime.today().year + return{"year":year} + return app diff --git a/aperisolve/templates/base.html b/aperisolve/templates/base.html index 256251d..673e77b 100644 --- a/aperisolve/templates/base.html +++ b/aperisolve/templates/base.html @@ -18,7 +18,7 @@ Aperi'Solve - v3.1.2 + (v.{{ config["PROJECT_VERSION"] }})

{% block body_content %} {% endblock %} diff --git a/aperisolve/templates/footer.html b/aperisolve/templates/footer.html index 04a6b1d..0fbd048 100644 --- a/aperisolve/templates/footer.html +++ b/aperisolve/templates/footer.html @@ -2,7 +2,7 @@
Aperi'Solve - (v.3.1.2) © 2026 + (v.{{ config["PROJECT_VERSION"] }}) © {{ year }}