From fe2cd99df71271d0e7588c64646ad62ae599d24e Mon Sep 17 00:00:00 2001 From: farshad68 Date: Tue, 14 Apr 2026 11:20:02 +0200 Subject: [PATCH 1/7] show version from pyproject.toml file and show in in footer , the git hash is also available and show as tooltip --- learn2rag/ui/__init__.py | 22 ++++++++++++++++++++++ learn2rag/ui/templates/base.html | 5 +++++ learn2rag/ui/templates/footer.html | 5 +++++ 3 files changed, 32 insertions(+) diff --git a/learn2rag/ui/__init__.py b/learn2rag/ui/__init__.py index 0678800..300f3f4 100644 --- a/learn2rag/ui/__init__.py +++ b/learn2rag/ui/__init__.py @@ -13,6 +13,7 @@ import subprocess import threading import time +import tomllib from typing import Any import urllib @@ -218,6 +219,27 @@ def inject_current_year() -> dict[str, Any]: app.logger.exception(e) app.logger.warning('Ollama is already running or failed to start') + @app.context_processor + def inject_version(): + return { + "app_version": get_version(), + "git_hash": get_git_hash() + } + + def get_version(): + try: + with open("pyproject.toml", "rb") as f: + data = tomllib.load(f) + return data.get("project", {}).get("version", "0.0.0") + except Exception: + return "0.0.0" + + def get_git_hash(): + try: + return subprocess.check_output(['git', 'rev-parse', '--short', 'HEAD']).decode('ascii').strip() + except Exception: + return "unknown" + @app.get('/') def start() -> 'str | werkzeug.wrappers.response.Response': pipelines = learn2rag.data.get_all(app.instance_path, 'pipelines') diff --git a/learn2rag/ui/templates/base.html b/learn2rag/ui/templates/base.html index 63a3b9c..7f44245 100644 --- a/learn2rag/ui/templates/base.html +++ b/learn2rag/ui/templates/base.html @@ -101,6 +101,11 @@ }; document.body.addEventListener('htmx:sendError', errorHandler); document.body.addEventListener('htmx:responseError', errorHandler); + + document.addEventListener('DOMContentLoaded', function () { + const tooltipTriggerList = document.querySelectorAll('[data-bs-toggle="tooltip"]'); + const tooltipList = [...tooltipTriggerList].map(el => new bootstrap.Tooltip(el)); + }); diff --git a/learn2rag/ui/templates/footer.html b/learn2rag/ui/templates/footer.html index 8f22995..b416a59 100644 --- a/learn2rag/ui/templates/footer.html +++ b/learn2rag/ui/templates/footer.html @@ -12,6 +12,11 @@
© {{ current_year }} Learn2RAG. + + v{{ app_version }} +
From cebc2377a9a8f2ae98388cee1b2fe71f86d79eb0 Mon Sep 17 00:00:00 2001 From: farshad68 Date: Wed, 15 Apr 2026 11:53:31 +0200 Subject: [PATCH 2/7] now we just fetch version once not by each hook call also rewove font icons from the footer to get ride of Fix fa-brands-400.woff2 --- learn2rag/ui/__init__.py | 37 ++++++++++++++++++++----------------- 1 file changed, 20 insertions(+), 17 deletions(-) diff --git a/learn2rag/ui/__init__.py b/learn2rag/ui/__init__.py index 300f3f4..996edc1 100644 --- a/learn2rag/ui/__init__.py +++ b/learn2rag/ui/__init__.py @@ -204,7 +204,7 @@ def inject_data() -> dict[str, Any]: 'sources': learn2rag.data.get_all(app.instance_path, 'sources'), 'pipelines': learn2rag.data.get_all(app.instance_path, 'pipelines'), } - +# TODO : check if we dont need this delete @app.context_processor def inject_current_year() -> dict[str, Any]: return {'current_year': datetime.now().year} @@ -219,27 +219,17 @@ def inject_current_year() -> dict[str, Any]: app.logger.exception(e) app.logger.warning('Ollama is already running or failed to start') + + cached_version = get_version() + cached_hash = get_git_hash() + @app.context_processor def inject_version(): return { - "app_version": get_version(), - "git_hash": get_git_hash() + "app_version": cached_version, + "git_hash": cached_hash } - def get_version(): - try: - with open("pyproject.toml", "rb") as f: - data = tomllib.load(f) - return data.get("project", {}).get("version", "0.0.0") - except Exception: - return "0.0.0" - - def get_git_hash(): - try: - return subprocess.check_output(['git', 'rev-parse', '--short', 'HEAD']).decode('ascii').strip() - except Exception: - return "unknown" - @app.get('/') def start() -> 'str | werkzeug.wrappers.response.Response': pipelines = learn2rag.data.get_all(app.instance_path, 'pipelines') @@ -536,6 +526,19 @@ def shutdown_request() -> 'str | werkzeug.wrappers.response.Response': app.logger.info('App creation complete') return app +def get_version(): + try: + with open("pyproject.toml", "rb") as f: + data = tomllib.load(f) + return data.get("project", {}).get("version", "0.0.0") + except Exception: + return "0.0.0" + +def get_git_hash(): + try: + return subprocess.check_output(['git', 'rev-parse', '--short', 'HEAD']).decode('ascii').strip() + except Exception: + return "unknown" def atexit_handler() -> None: logging.debug('Exit handler') From a7c9c1807d745e8a357a9bacd0b0f7719f7a3a7a Mon Sep 17 00:00:00 2001 From: farshad68 Date: Wed, 15 Apr 2026 13:02:31 +0200 Subject: [PATCH 3/7] add type annotations --- learn2rag/ui/__init__.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/learn2rag/ui/__init__.py b/learn2rag/ui/__init__.py index 996edc1..8c2172f 100644 --- a/learn2rag/ui/__init__.py +++ b/learn2rag/ui/__init__.py @@ -526,7 +526,7 @@ def shutdown_request() -> 'str | werkzeug.wrappers.response.Response': app.logger.info('App creation complete') return app -def get_version(): +def get_version() -> str: try: with open("pyproject.toml", "rb") as f: data = tomllib.load(f) @@ -534,7 +534,7 @@ def get_version(): except Exception: return "0.0.0" -def get_git_hash(): +def get_git_hash() -> str: try: return subprocess.check_output(['git', 'rev-parse', '--short', 'HEAD']).decode('ascii').strip() except Exception: From 82237384e2d4ac5dc2ff3bc4127da004a1232515 Mon Sep 17 00:00:00 2001 From: farshad68 Date: Wed, 15 Apr 2026 13:13:35 +0200 Subject: [PATCH 4/7] resolve mypy any-return and untyped-def errors --- learn2rag/ui/__init__.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/learn2rag/ui/__init__.py b/learn2rag/ui/__init__.py index 8c2172f..0825cad 100644 --- a/learn2rag/ui/__init__.py +++ b/learn2rag/ui/__init__.py @@ -224,7 +224,7 @@ def inject_current_year() -> dict[str, Any]: cached_hash = get_git_hash() @app.context_processor - def inject_version(): + def inject_version() -> dict[str, str]: return { "app_version": cached_version, "git_hash": cached_hash @@ -530,7 +530,7 @@ def get_version() -> str: try: with open("pyproject.toml", "rb") as f: data = tomllib.load(f) - return data.get("project", {}).get("version", "0.0.0") + return str(data.get("project", {}).get("version", "0.0.0")) except Exception: return "0.0.0" From 127cea74be4eb9120f6f2fdb8cb34544850625be Mon Sep 17 00:00:00 2001 From: farshad68 Date: Thu, 16 Apr 2026 12:03:14 +0200 Subject: [PATCH 5/7] remove social links from footer --- learn2rag/ui/templates/footer.html | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/learn2rag/ui/templates/footer.html b/learn2rag/ui/templates/footer.html index b416a59..058d763 100644 --- a/learn2rag/ui/templates/footer.html +++ b/learn2rag/ui/templates/footer.html @@ -2,16 +2,8 @@
-
- © {{ current_year }} Learn2RAG. + Learn2RAG. From fefab32670e8ea193b575012b3fcb300134f3fbf Mon Sep 17 00:00:00 2001 From: denkv Date: Thu, 16 Apr 2026 12:07:05 +0200 Subject: [PATCH 6/7] Change wording --- learn2rag/ui/templates/footer.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/learn2rag/ui/templates/footer.html b/learn2rag/ui/templates/footer.html index 058d763..c744342 100644 --- a/learn2rag/ui/templates/footer.html +++ b/learn2rag/ui/templates/footer.html @@ -3,10 +3,10 @@
- Learn2RAG. + Learn2RAG + data-bs-title="git commit: {{ git_hash }}"> v{{ app_version }}
From dfd7b5960156fb994c9b28d1f5d15486f887258a Mon Sep 17 00:00:00 2001 From: denkv Date: Thu, 16 Apr 2026 12:08:15 +0200 Subject: [PATCH 7/7] Remove unused function --- learn2rag/ui/__init__.py | 4 ---- 1 file changed, 4 deletions(-) diff --git a/learn2rag/ui/__init__.py b/learn2rag/ui/__init__.py index 0825cad..4132dd3 100644 --- a/learn2rag/ui/__init__.py +++ b/learn2rag/ui/__init__.py @@ -204,10 +204,6 @@ def inject_data() -> dict[str, Any]: 'sources': learn2rag.data.get_all(app.instance_path, 'sources'), 'pipelines': learn2rag.data.get_all(app.instance_path, 'pipelines'), } -# TODO : check if we dont need this delete - @app.context_processor - def inject_current_year() -> dict[str, Any]: - return {'current_year': datetime.now().year} atexit.register(atexit_handler)