pass the version to all templates

This commit is contained in:
Karl 2025-07-30 09:22:28 +01:00
parent d40f6a95b0
commit fdd2893255
4 changed files with 9 additions and 4 deletions

View File

@ -18,6 +18,13 @@ user_config = load_config()
app = Flask(__name__)
app.secret_key = os.environ.get("SECRET_KEY")
# Make version available to all templates
from libs.generic import get_current_version
@app.context_processor
def inject_version():
version = get_current_version()
return dict(version=version)
# Inject config into routes that need it
create_routes.init_app(user_config)
auth_routes.init_app(user_config)

View File

@ -110,7 +110,7 @@ def get_current_version():
return version
except subprocess.CalledProcessError as e:
print("Error running bump-my-version:", e)
return None
return "unknown"
def load_models_from_config():
flux_models = load_config()["comfyui:flux"]["models"].split(",")

View File

@ -11,12 +11,10 @@ def index():
image_filename = "./image.png"
image_path = os.path.join(image_folder, image_filename)
prompt = get_details_from_png(image_path)["p"]
version = get_current_version()
return render_template(
"index.html",
image=image_filename,
prompt=prompt,
reload_interval=user_config["frame"]["reload_interval"],
version=version,
)

View File

@ -12,7 +12,7 @@
<!-- Version number at bottom right -->
<div class="version">
<a href="{{ url_for('settings_route.config_editor') }}">v{{ version }}</a>
<a href="{{ url_for('settings_route.config_editor') }}">{% if version and version != 'unknown' %}v{{ version }}{% else %}v?.?.?{% endif %}</a>
</div>
{% block scripts %}{% endblock %}