Skip to content

Commit ff61134

Browse files
committed
refactor: same base template for admin
1 parent 6acaaf6 commit ff61134

2 files changed

Lines changed: 35 additions & 24 deletions

File tree

templates/admin/base_site.html

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,12 @@
77
{% if subtitle %}{{ subtitle }} |{% endif %}
88
{{ title }} | {{ site_title|default:_("Django site admin") }}
99
{% endblock %}
10+
{# Unfold's base_site.html also defines this; our override drops it, so the
11+
captured `branding` var is empty and the sidebar header (logo/name/version)
12+
renders nothing on model pages. Restore it like Unfold does. #}
13+
{% block branding %}
14+
{% include "unfold/helpers/site_branding.html" %}
15+
{% endblock %}
1016
{% block extrastyle %}
1117
{{ block.super }}
1218
<link rel="stylesheet"

templates/admin/index.html

Lines changed: 29 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,51 @@
1-
{% extends 'admin/base.html' %}
2-
1+
{# title + branding blocks are inherited from admin/base_site.html. #}
2+
{% extends 'admin/base_site.html' %}
33
{% load i18n %}
4-
5-
{% block title %}{% if subtitle %}{{ subtitle }} | {% endif %}{{ title }} | {{ site_title|default:_('Django site admin') }}{% endblock %}
6-
7-
{% block branding %}
8-
{% include "unfold/helpers/site_branding.html" %}
9-
{% endblock %}
10-
114
{% block content %}
125
<div class="flex flex-col lg:flex-row lg:gap-8">
136
<div class="grow">
147
{% if metrics %}
158
<div class="mb-8 grid grid-cols-1 gap-4 sm:grid-cols-3">
169
<div class="rounded-default border border-base-200 bg-white p-4 dark:border-base-800 dark:bg-base-900">
17-
<div class="text-font-subtle-light text-xs uppercase tracking-wide dark:text-font-subtle-dark">{% trans "Views (7 days)" %}</div>
18-
<div class="mt-1 text-2xl font-semibold text-font-important-light dark:text-font-important-dark">{{ metrics.views_7d }}</div>
10+
<div class="text-font-subtle-light text-xs uppercase tracking-wide dark:text-font-subtle-dark">
11+
{% trans "Views (7 days)" %}
12+
</div>
13+
<div class="mt-1 text-2xl font-semibold text-font-important-light dark:text-font-important-dark">
14+
{{ metrics.views_7d }}
15+
</div>
1916
</div>
2017
<div class="rounded-default border border-base-200 bg-white p-4 dark:border-base-800 dark:bg-base-900">
21-
<div class="text-font-subtle-light text-xs uppercase tracking-wide dark:text-font-subtle-dark">{% trans "Unique visitors (7 days)" %}</div>
22-
<div class="mt-1 text-2xl font-semibold text-font-important-light dark:text-font-important-dark">{{ metrics.uniques_7d }}</div>
18+
<div class="text-font-subtle-light text-xs uppercase tracking-wide dark:text-font-subtle-dark">
19+
{% trans "Unique visitors (7 days)" %}
20+
</div>
21+
<div class="mt-1 text-2xl font-semibold text-font-important-light dark:text-font-important-dark">
22+
{{ metrics.uniques_7d }}
23+
</div>
2324
</div>
2425
<div class="rounded-default border border-base-200 bg-white p-4 dark:border-base-800 dark:bg-base-900">
25-
<div class="text-font-subtle-light text-xs uppercase tracking-wide dark:text-font-subtle-dark">{% trans "Views (30 days)" %}</div>
26-
<div class="mt-1 text-2xl font-semibold text-font-important-light dark:text-font-important-dark">{{ metrics.views_30d }}</div>
26+
<div class="text-font-subtle-light text-xs uppercase tracking-wide dark:text-font-subtle-dark">
27+
{% trans "Views (30 days)" %}
28+
</div>
29+
<div class="mt-1 text-2xl font-semibold text-font-important-light dark:text-font-important-dark">
30+
{{ metrics.views_30d }}
31+
</div>
2732
</div>
2833
</div>
2934
{% endif %}
30-
3135
{% if views_series %}
3236
<div class="mb-8 rounded-default border border-base-200 bg-white p-4 dark:border-base-800 dark:bg-base-900">
3337
<div class="mb-3 flex items-baseline justify-between">
34-
<h2 class="font-semibold text-font-important-light dark:text-font-important-dark">{% trans "Views per day (30 days)" %}</h2>
38+
<h2 class="font-semibold text-font-important-light dark:text-font-important-dark">
39+
{% trans "Views per day (30 days)" %}
40+
</h2>
3541
<span class="text-font-subtle-light text-xs dark:text-font-subtle-dark">{% trans "peak" %} {{ views_peak }}</span>
3642
</div>
3743
<div class="flex h-20 items-end gap-[2px]">
3844
{% for d in views_series %}
3945
<div class="group relative flex-1" title="{{ d.day }} — {{ d.count }}">
4046
<div class="w-full rounded-t bg-primary-600 transition-colors group-hover:bg-primary-500 dark:bg-primary-500 dark:group-hover:bg-primary-400"
41-
style="height: {{ d.pct }}%; min-height: {% if d.count %}3px{% else %}0{% endif %}"></div>
47+
style="height: {{ d.pct }}%;
48+
min-height: {% if d.count %}3px{% else %}0{% endif %}"></div>
4249
</div>
4350
{% endfor %}
4451
</div>
@@ -48,7 +55,6 @@ <h2 class="font-semibold text-font-important-light dark:text-font-important-dark
4855
</div>
4956
</div>
5057
{% endif %}
51-
5258
{% if top_pages %}
5359
<div class="mb-8 rounded-default border border-base-200 bg-white dark:border-base-800 dark:bg-base-900">
5460
<h2 class="border-b border-base-200 font-semibold px-4 py-3 text-font-important-light dark:border-base-800 dark:text-font-important-dark">
@@ -57,14 +63,14 @@ <h2 class="border-b border-base-200 font-semibold px-4 py-3 text-font-important-
5763
<ul class="divide-y divide-base-200 dark:divide-base-800">
5864
{% for page in top_pages %}
5965
<li class="flex items-center gap-3 px-4 py-2 text-sm">
60-
<a href="{{ page.path }}" class="grow truncate text-primary-600 hover:underline dark:text-primary-500">{{ page.path }}</a>
66+
<a href="{{ page.path }}"
67+
class="grow truncate text-primary-600 hover:underline dark:text-primary-500">{{ page.path }}</a>
6168
<span class="shrink-0 font-medium text-font-default-light dark:text-font-default-dark">{{ page.n }}</span>
6269
</li>
6370
{% endfor %}
6471
</ul>
6572
</div>
6673
{% endif %}
67-
6874
{% if recent_activity %}
6975
<div class="mb-8 rounded-default border border-base-200 bg-white dark:border-base-800 dark:bg-base-900">
7076
<h2 class="border-b border-base-200 font-semibold px-4 py-3 text-font-important-light dark:border-base-800 dark:text-font-important-dark">
@@ -76,7 +82,8 @@ <h2 class="border-b border-base-200 font-semibold px-4 py-3 text-font-important-
7682
<span class="status-badge status-badge--{{ item.action_css }}">{{ item.action }}</span>
7783
<span class="grow truncate text-font-default-light dark:text-font-default-dark">
7884
{% if item.url %}
79-
<a href="{{ item.url }}" class="font-medium text-primary-600 hover:underline dark:text-primary-500">{{ item.repr }}</a>
85+
<a href="{{ item.url }}"
86+
class="font-medium text-primary-600 hover:underline dark:text-primary-500">{{ item.repr }}</a>
8087
{% else %}
8188
<span class="font-medium">{{ item.repr }}</span>
8289
{% endif %}
@@ -90,10 +97,8 @@ <h2 class="border-b border-base-200 font-semibold px-4 py-3 text-font-important-
9097
</ul>
9198
</div>
9299
{% endif %}
93-
94100
{% include "unfold/helpers/app_list_default.html" %}
95101
</div>
96-
97102
{% include "unfold/helpers/history.html" %}
98103
</div>
99104
{% endblock %}

0 commit comments

Comments
 (0)