Illustrations/web/templates/stats.html

129 lines
4.2 KiB
HTML

{% extends "base.html" %}
{% block body_class %}themed-bg{% endblock %}
{% block content %}
<div class="container">
<h1 class="page-title">Statistics</h1>
<div class="card" style="padding:16px; margin-bottom:16px;">
<div class="meta-grid">
<div>
<div class="meta-label">Total Illustrations</div>
<div class="subject-title" style="margin:0">{{ total }}</div>
</div>
<div>
<div class="meta-label">Added in last 30 days</div>
<div class="subject-title" style="margin:0">{{ last30 }}</div>
</div>
<div>
<div class="meta-label">Added in last 365 days</div>
<div class="subject-title" style="margin:0">{{ last365 }}</div>
</div>
</div>
</div>
<!-- Sparkline (simple bars) -->
<div class="card" style="padding:16px; margin-bottom:16px;">
<div class="meta-label">Adds by Month (last 12)</div>
<div style="display:flex; align-items:flex-end; gap:6px; height:140px; margin-top:8px;">
{% for label, value, height in heights %}
<div title="{{ label }} = {{ value }}"
style="width:22px; height:{{ height }}px; background:#cfe3f6; border:1px solid #bcd4ee; border-radius:6px;"></div>
{% endfor %}
</div>
<div class="small muted" style="margin-top:6px;">
{% for label, value in series %}{% if not forloop.last %}{{ label }} · {% else %}{{ label }}{% endif %}{% endfor %}
</div>
</div>
<!-- Tag Cloud (replaces Top Subjects) -->
<div class="card" style="padding:16px; margin-bottom:16px;">
<div class="meta-label">Subject Cloud</div>
{% if top_subjects %}
{# max count is the first item because list is sorted desc in the view #}
{% with maxc=top_subjects.0.count|default:1 %}
<div class="tag-cloud" aria-label="Subject Tag Cloud">
{% for s in top_subjects %}
{# font-size from 14px up to 32px based on weight #}
<a
class="tag"
href="{% url 'search' %}?q={{ s.name|urlencode }}&subject=on"
title="{{ s.name }} ({{ s.count }})"
style="font-size: calc(14px + ({{ s.count }} / {{ maxc }}) * 18px);
opacity: calc(.6 + ({{ s.count }} / {{ maxc }}) * .4);"
>
{{ s.name }}
</a>
{% endfor %}
</div>
{% endwith %}
{% else %}
<span class="muted">No subjects.</span>
{% endif %}
</div>
<!-- Scripture usage -->
<div class="card" style="padding:16px; margin-bottom:16px;">
<h3 style="margin:0 0 10px;">Scripture Usage</h3>
<div class="chip" style="margin-bottom:10px;"><strong>Avg. refs per scripture-bearing entry:</strong>&nbsp;{{ avg_refs_per_entry }}</div>
<div style="display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:16px;">
<div>
<h4 style="margin:0 0 6px;">Top 10 Books</h4>
<ol class="small" style="margin:0; padding-left:18px;">
{% for book, cnt in top_books %}
<li><strong>{{ book }}</strong> — {{ cnt }}</li>
{% empty %}
<li class="muted">No data yet.</li>
{% endfor %}
</ol>
</div>
<div>
<h4 style="margin:0 0 6px;">Top 10 Scriptures</h4>
<ol class="small" style="margin:0; padding-left:18px;">
{% for ref, cnt in top_refs %}
<li>
<a
class="chip chip-link"
href="{% url 'search' %}?q={{ ref|urlencode }}&scripture_raw=on"
title="Search in Scripture field: {{ ref }}"
>
{{ ref }}
</a> — {{ cnt }}
</li>
{% empty %}
<li class="muted">No data yet.</li>
{% endfor %}
</ol>
</div>
</div>
</div>
</div>
<style>
.tag-cloud{
display:flex;
flex-wrap:wrap;
gap:10px 14px;
margin-top:10px;
align-items:flex-end;
}
.tag{
line-height:1.1;
padding:6px 10px;
border-radius:12px;
text-decoration:none;
color:#0f172a;
background:#eef5fc;
border:1px solid #d7e6f7;
transition: transform .1s ease, background .12s ease, border-color .12s ease;
white-space:nowrap;
}
.tag:hover{
transform: translateY(-1px);
background:#e2effc;
border-color:#c9def5;
}
</style>
{% endblock %}