offline libs
This commit is contained in:
@@ -16,6 +16,7 @@ from .config import (
|
||||
SOCKETIO_CORS_ALLOWED_ORIGINS,
|
||||
)
|
||||
from .db import init_db
|
||||
from .services.frontend_assets import asset_path, bootstrap_css_path, validate_offline_assets
|
||||
from .utils import file_md5
|
||||
|
||||
socketio = SocketIO(cors_allowed_origins=SOCKETIO_CORS_ALLOWED_ORIGINS, ping_timeout=30, async_mode="threading")
|
||||
@@ -56,6 +57,7 @@ def register_error_pages(app: Flask) -> None:
|
||||
|
||||
|
||||
def create_app() -> Flask:
|
||||
validate_offline_assets()
|
||||
app = Flask(__name__)
|
||||
if PROXY_FIX_ENABLE:
|
||||
app.wsgi_app = ProxyFix(
|
||||
@@ -88,7 +90,21 @@ def create_app() -> Flask:
|
||||
return url_for("static", filename=filename, v=version)
|
||||
except OSError:
|
||||
return url_for("static", filename=filename)
|
||||
return {"static_url": static_url}
|
||||
|
||||
def frontend_asset_url(key: str) -> str:
|
||||
# Notatka: helper przełącza szablony między CDN i lokalnymi plikami bez duplikowania logiki.
|
||||
path = asset_path(key)
|
||||
return path if path.startswith("http") else static_url(path)
|
||||
|
||||
def bootstrap_theme_url(theme: str | None = None) -> str:
|
||||
path = bootstrap_css_path(theme)
|
||||
return path if path.startswith("http") else static_url(path)
|
||||
|
||||
return {
|
||||
"static_url": static_url,
|
||||
"frontend_asset_url": frontend_asset_url,
|
||||
"bootstrap_theme_url": bootstrap_theme_url,
|
||||
}
|
||||
|
||||
@app.after_request
|
||||
def cache_headers(response):
|
||||
|
||||
Reference in New Issue
Block a user