show build on website footer

This commit is contained in:
2026-07-07 16:12:12 +02:00
parent ffa34815cd
commit 8f64760add
7 changed files with 106 additions and 0 deletions
+21
View File
@@ -20,6 +20,7 @@ Backend:
- `/api/health` returns health/version information. - `/api/health` returns health/version information.
- `/api/user` returns the authenticated user. - `/api/user` returns the authenticated user.
- Access events are appended to `access_log.json`. - Access events are appended to `access_log.json`.
- `build_info.json` is loaded at startup and exposed to all templates as `build_info`.
Frontend: Frontend:
@@ -28,6 +29,26 @@ Frontend:
- `window.ARTICLE_DATA` is loaded from `/static/article-data.json`. - `window.ARTICLE_DATA` is loaded from `/static/article-data.json`.
- `window.APP_CONFIG` is currently defined inline for forklift rules. - `window.APP_CONFIG` is currently defined inline for forklift rules.
- A disclaimer modal blocks use until the user checks the confirmation checkbox. - A disclaimer modal blocks use until the user checks the confirmation checkbox.
- The footer displays build metadata: version, branch, commit, and timestamp.
## Build Info
Build/deployment metadata is read from:
```text
build_info.json
```
Expected fields:
- `version`
- `branch`
- `commit`
- `timestamp`
If `build_info.json` is missing, malformed, or does not contain a usable value, RollCalc falls back to `unknown` for that value and continues serving the site.
The data is loaded centrally in `app.py` and made available to every template as `build_info`.
## Roll Geometry ## Roll Geometry
+15
View File
@@ -51,6 +51,7 @@ The app uses HTTP Basic Auth. Current credentials are defined in `BETA_USERS` in
├── app.py ├── app.py
├── requirements.txt ├── requirements.txt
├── README.md ├── README.md
├── build_info.json
├── access_log.json ├── access_log.json
├── config.json ├── config.json
├── article-data_.json ├── article-data_.json
@@ -101,6 +102,7 @@ The template contains:
- Page layout and all main CSS. - Page layout and all main CSS.
- A disclaimer modal shown after Basic Auth login and before calculator use. - A disclaimer modal shown after Basic Auth login and before calculator use.
- Footer build metadata from `build_info`.
- Global state: - Global state:
- `window.ARTICLE_DATA` - `window.ARTICLE_DATA`
- `window.APP_CONFIG` - `window.APP_CONFIG`
@@ -261,6 +263,19 @@ JSON audit log written by `app.py`.
Important implementation detail: each logged access reads and rewrites the entire JSON file. This is simple but not concurrency-safe and can become inefficient as the file grows. Important implementation detail: each logged access reads and rewrites the entire JSON file. This is simple but not concurrency-safe and can become inefficient as the file grows.
### `build_info.json`
Deployment/build metadata displayed in the site footer.
Expected fields:
- `version`
- `branch`
- `commit`
- `timestamp`
`app.py` loads this file centrally at startup and exposes it to all templates as `build_info`. If the file is missing, invalid, or a field is empty, the affected values fall back to `unknown` and the website continues to work.
### `fix_article_data.py` ### `fix_article_data.py`
Utility script that updates relative frontend fetch/register paths to Flask-style `/static/...` paths and checks that key static files exist. Utility script that updates relative frontend fetch/register paths to Flask-style `/static/...` paths and checks that key static files exist.
+7
View File
@@ -621,5 +621,12 @@
"endpoint": "/", "endpoint": "/",
"method": "GET", "method": "GET",
"status": 200 "status": 200
},
{
"timestamp": "2026-07-07T14:46:22.335316",
"username": "mtazl",
"endpoint": "/",
"method": "GET",
"status": 200
} }
] ]
+37
View File
@@ -29,6 +29,43 @@ BETA_USERS = {
# Logging für Auditing # Logging für Auditing
LOG_FILE = "access_log.json" LOG_FILE = "access_log.json"
BUILD_INFO_FILE = "build_info.json"
UNKNOWN_BUILD_INFO = {
"version": "unknown",
"branch": "unknown",
"commit": "unknown",
"timestamp": "unknown"
}
# ============================================================================
# BUILD INFO
# ============================================================================
def load_build_info():
"""Load deployment/build metadata for templates."""
try:
with open(BUILD_INFO_FILE, "r") as f:
data = json.load(f)
except Exception as e:
print(f"[Build Info Error] {e}")
return UNKNOWN_BUILD_INFO.copy()
if not isinstance(data, dict):
return UNKNOWN_BUILD_INFO.copy()
build_info = UNKNOWN_BUILD_INFO.copy()
for key in build_info:
value = data.get(key)
if isinstance(value, str) and value.strip():
build_info[key] = value.strip()
return build_info
BUILD_INFO = load_build_info()
@app.context_processor
def inject_build_info():
"""Make build metadata available in all templates."""
return {"build_info": BUILD_INFO}
# ============================================================================ # ============================================================================
# AUTHENTICATION # AUTHENTICATION
+6
View File
@@ -0,0 +1,6 @@
{
"version": "0.4",
"branch": "develop/v0.4",
"commit": "ffa3481",
"timestamp": "2026-07-07T10:26:13Z"
}
+16
View File
@@ -0,0 +1,16 @@
#!/bin/bash
set -e
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
PROJECT_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)"
cd "$PROJECT_ROOT"
cat > build_info.json <<EOF
{
"version": "v0.4-dev",
"branch": "$(git branch --show-current)",
"commit": "$(git rev-parse --short HEAD)",
"timestamp": "$(date -Iseconds)"
}
EOF
+4
View File
@@ -60,6 +60,7 @@
.fc-req-nok { color: #dc3545; font-weight: 600; } .fc-req-nok { color: #dc3545; font-weight: 600; }
.formula-box { background: #f8f9fa; border: 1px solid #e0e0e0; border-radius: 6px; padding: 10px 14px; font-size: 12px; color: #666; margin-top: 18px; font-family: 'Courier New', monospace; } .formula-box { background: #f8f9fa; border: 1px solid #e0e0e0; border-radius: 6px; padding: 10px 14px; font-size: 12px; color: #666; margin-top: 18px; font-family: 'Courier New', monospace; }
.footer { text-align: center; font-size: 11px; color: #aaa; padding: 18px; margin-top: 30px; } .footer { text-align: center; font-size: 11px; color: #aaa; padding: 18px; margin-top: 30px; }
.footer-build-info { margin-top: 6px; color: #bbb; }
.disclaimer-overlay { .disclaimer-overlay {
position: fixed; position: fixed;
inset: 0; inset: 0;
@@ -844,6 +845,9 @@
<div class="footer"> <div class="footer">
Naue GmbH & Co. KG · Roll Diameter Calculator · Internal Application Naue GmbH & Co. KG · Roll Diameter Calculator · Internal Application
<div class="footer-build-info">
Version {{ build_info.version }} · Branch {{ build_info.branch }} · Commit {{ build_info.commit }} · Built {{ build_info.timestamp }}
</div>
</div> </div>
<script> <script>