Skip to content

Commit 8ec8827

Browse files
committed
Branding
1 parent 0114baa commit 8ec8827

File tree

4 files changed

+15
-11
lines changed

4 files changed

+15
-11
lines changed

caterva2/services/sub.py

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -501,19 +501,16 @@ def url(path: str) -> str:
501501

502502

503503
def brand_logo():
504-
path = "media/brand/logo.webp"
505-
if (BASE_DIR / path).exists():
506-
return url(path)
504+
path = "media/logo.webp"
505+
if not (settings.statedir / path).exists():
506+
path = "static/logo-caterva2-horizontal-small.webp"
507507

508-
return url("static/logo-caterva2-horizontal-small.webp")
508+
return url(path)
509509

510510

511511
templates = Jinja2Templates(directory=BASE_DIR / "templates")
512512
templates.env.filters["filesizeformat"] = custom_filesizeformat
513513
templates.env.globals["url"] = url
514-
templates.env.globals["brand"] = {
515-
"logo": brand_logo(),
516-
}
517514

518515

519516
# Add CSS/JS to templates namespace
@@ -2503,7 +2500,6 @@ async def jupyter_heartbeat():
25032500
#
25042501

25052502
app.mount("/static", StaticFiles(directory=BASE_DIR / "static"), name="static")
2506-
app.mount("/media", StaticFiles(directory=BASE_DIR / "media"), name="media")
25072503

25082504

25092505
#
@@ -2567,6 +2563,14 @@ def main():
25672563
plugins[tomography.contenttype] = tomography
25682564
tomography.init(abspath_and_dataprep, settings.urlbase)
25692565

2566+
# Mount media
2567+
media = settings.statedir / "media"
2568+
media.mkdir(exist_ok=True, parents=True)
2569+
app.mount("/media", StaticFiles(directory=media), name="media")
2570+
templates.env.globals["brand"] = {
2571+
"logo": brand_logo(),
2572+
}
2573+
25702574
# Run
25712575
root_path = str(furl.furl(settings.urlbase).path)
25722576
srv_utils.uvicorn_run(app, args, root_path=root_path)

caterva2/services/templates/base_anon.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
<body class="vh-100 d-flex align-items-center">
1212
<main class="card m-auto" style="width: 450px" id="page-login">
1313
<div class="card-body">
14-
<img src="{{ brand.logo }}" alt="Caterva2 logo" id="logo" class="mb-4">
14+
<img src="{{ brand.logo }}" alt="Logo" id="logo" class="mb-4">
1515
{% block main %}
1616
{% endblock %}
1717
</div>

caterva2/services/templates/logout.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@
33
{% block title %}User logout{% endblock %}
44

55
{% block main %}
6-
<p>Thanks for using Caterva2</p>
6+
<p>Have a good day!</p>
77
<a href="{{ url('login') }}">Return to sign in</a>
88
{% endblock %}

caterva2/services/templates/root_list.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<a href="{{ url('') }}" class="mx-2">
2-
<img src="{{ brand.logo }}" alt="Caterva2 logo" id="logo">
2+
<img src="{{ brand.logo }}" alt="Logo" id="logo">
33
</a>
44

55
<form hx-get="{{ url('htmx/path-list/') }}"

0 commit comments

Comments
 (0)