Monorepo: consolidate 7 repos into one
All checks were successful
Build and Deploy / build-and-deploy (push) Successful in 1m5s
All checks were successful
Build and Deploy / build-and-deploy (push) Successful in 1m5s
Combines shared, blog, market, cart, events, federation, and account into a single repository. Eliminates submodule sync, sibling model copying at build time, and per-app CI orchestration. Changes: - Remove per-app .git, .gitmodules, .gitea, submodule shared/ dirs - Remove stale sibling model copies from each app - Update all 6 Dockerfiles for monorepo build context (root = .) - Add build directives to docker-compose.yml - Add single .gitea/workflows/ci.yml with change detection - Add .dockerignore for monorepo build context - Create __init__.py for federation and account (cross-app imports)
This commit is contained in:
67
blog/bp/admin/routes.py
Normal file
67
blog/bp/admin/routes.py
Normal file
@@ -0,0 +1,67 @@
|
||||
from __future__ import annotations
|
||||
|
||||
#from quart import Blueprint, g
|
||||
|
||||
from quart import (
|
||||
render_template,
|
||||
make_response,
|
||||
Blueprint,
|
||||
redirect,
|
||||
url_for,
|
||||
request,
|
||||
jsonify
|
||||
)
|
||||
from shared.browser.app.redis_cacher import clear_all_cache
|
||||
from shared.browser.app.authz import require_admin
|
||||
from shared.browser.app.utils.htmx import is_htmx_request
|
||||
from shared.config import config
|
||||
from datetime import datetime
|
||||
|
||||
def register(url_prefix):
|
||||
bp = Blueprint("settings", __name__, url_prefix = url_prefix)
|
||||
|
||||
@bp.context_processor
|
||||
async def inject_root():
|
||||
return {
|
||||
"base_title": f"{config()['title']} settings",
|
||||
}
|
||||
|
||||
@bp.get("/")
|
||||
@require_admin
|
||||
async def home():
|
||||
|
||||
# Determine which template to use based on request type and pagination
|
||||
if not is_htmx_request():
|
||||
# Normal browser request: full page with layout
|
||||
html = await render_template(
|
||||
"_types/root/settings/index.html",
|
||||
)
|
||||
|
||||
else:
|
||||
html = await render_template("_types/root/settings/_oob_elements.html")
|
||||
|
||||
|
||||
return await make_response(html)
|
||||
|
||||
@bp.get("/cache/")
|
||||
@require_admin
|
||||
async def cache():
|
||||
if not is_htmx_request():
|
||||
html = await render_template("_types/root/settings/cache/index.html")
|
||||
else:
|
||||
html = await render_template("_types/root/settings/cache/_oob_elements.html")
|
||||
return await make_response(html)
|
||||
|
||||
@bp.post("/cache_clear/")
|
||||
@require_admin
|
||||
async def cache_clear():
|
||||
await clear_all_cache()
|
||||
if is_htmx_request():
|
||||
now = datetime.now()
|
||||
html = f'<span class="text-green-600 font-bold">Cache cleared at {now.strftime("%H:%M:%S")}</span>'
|
||||
return html
|
||||
|
||||
return redirect(url_for("settings.cache"))
|
||||
return bp
|
||||
|
||||
|
||||
Reference in New Issue
Block a user