Update web/templates/stats.html

This commit is contained in:
Joshua Laymon 2025-08-14 22:10:07 +00:00
parent 36b2c9ebbe
commit fa3e9fef92

View File

@ -5,7 +5,6 @@
<div class="container"> <div class="container">
<h1 class="page-title">Statistics</h1> <h1 class="page-title">Statistics</h1>
<!-- Top counters -->
<div class="card" style="padding:16px; margin-bottom:16px;"> <div class="card" style="padding:16px; margin-bottom:16px;">
<div class="meta-grid"> <div class="meta-grid">
<div> <div>
@ -37,6 +36,24 @@
</div> </div>
</div> </div>
<!-- Top subjects -->
<div class="card" style="padding:16px; margin-bottom:16px;">
<div class="meta-label">Top Subjects</div>
<div style="display:flex; flex-wrap:wrap; gap:8px; margin-top:8px;">
{% for s in top_subjects %}
<a
class="chip chip-link"
href="{% url 'search' %}?q={{ s.name|urlencode }}&subject=on"
title="Search subject: {{ s.name }}"
>
{{ s.name }} ({{ s.count }})
</a>
{% empty %}
<span class="muted">No subjects.</span>
{% endfor %}
</div>
</div>
<!-- Scripture usage --> <!-- Scripture usage -->
<div class="card" style="padding:16px; margin-bottom:16px;"> <div class="card" style="padding:16px; margin-bottom:16px;">
<h3 style="margin:0 0 10px;">Scripture Usage</h3> <h3 style="margin:0 0 10px;">Scripture Usage</h3>
@ -47,119 +64,156 @@
<h4 style="margin:0 0 6px;">Top 10 Books</h4> <h4 style="margin:0 0 6px;">Top 10 Books</h4>
<ol class="small" style="margin:0; padding-left:18px;"> <ol class="small" style="margin:0; padding-left:18px;">
{% for book, cnt in top_books %} {% for book, cnt in top_books %}
<li> <li><strong>{{ book }}</strong> — {{ cnt }}</li>
<a
class="chip chip-link"
href="{% url 'search' %}?q={{ book|urlencode }}&scripture_raw=on"
title="Search Scripture field for book: {{ book }}"
>
{{ book }}
</a> — {{ cnt }}
</li>
{% empty %} {% empty %}
<li class="muted">No data yet.</li> <li class="muted">No data yet.</li>
{% endfor %} {% endfor %}
</ol> </ol>
</div> </div>
<div> <div>
<h4 style="margin:0 0 6px;">Top 10 Scriptures</h4> <h4 style="margin:0 0 6px;">Top 10 Scriptures</h4>
<ol class="small" style="margin:0; padding-left:18px;"> <ol class="small" style="margin:0; padding-left:18px;">
{% for ref, cnt in top_refs %} {% for ref, cnt in top_refs %}
<li> <li>
<a
class="chip chip-link"
href="{% url 'search' %}?q={{ ref|urlencode }}&scripture_raw=on"
title="Search Scripture field for {{ ref }}"
>
{{ ref }}
</a> — {{ cnt }}
</li>
{% empty %}
<li class="muted">No data yet.</li>
{% endfor %}
</ol>
</div>
</div>
</div>
<!-- Top subjects -->
<div class="card" style="padding:16px; margin-bottom:16px;">
<div class="meta-label">Top Subjects</div>
<div style="display:flex; flex-wrap:wrap; gap:8px; margin-top:8px;">
{% for s in top_subjects %}
<a <a
class="chip chip-muted" class="chip chip-link"
href="{% url 'search' %}?q={{ s.name|urlencode }}&subject=on" href="{% url 'search' %}?q={{ ref|urlencode }}&scripture_raw=on"
title="Search Subject field for {{ s.name }}" title="Search in Scripture field: {{ ref }}"
> >
{{ s.name }} ({{ s.count }}) {{ ref }}
</a> </a> — {{ cnt }}
{% empty %} </li>
<span class="muted">No subjects.</span> {% empty %}
{% endfor %} <li class="muted">No data yet.</li>
{% endfor %}
</ol>
</div>
</div> </div>
</div> </div>
<!-- Tools (collapsed like Search Help) --> <!-- Tools: collapsible panel -->
<div class="card" style="padding:16px; margin-bottom:24px;"> <div class="card" style="padding:16px; margin-bottom:24px;">
<button id="tools-toggle" class="btn" type="button">⚙️ Tools</button> <div style="display:flex; align-items:center; justify-content:space-between; gap:10px;">
<div id="tools-panel" style="display:none; margin-top:12px;"> <div class="meta-label">Maintenance Tools</div>
<div class="small muted" style="margin:0 0 8px;"> <button
Batch maintenance utilities. Preview first; then apply changes sitewide. class="btn btn-secondary"
type="button"
id="tools-toggle"
aria-expanded="false"
aria-controls="tools-panel"
>
▾ Show tools
</button>
</div>
<div id="tools-panel" class="tools-panel" hidden>
<!-- Scripture Normalizer -->
<div class="tool-block">
<h4>Scripture Normalizer</h4>
<p class="small muted">
Standardizes Bible references (book abbreviations, separators, and repeats book names as needed).
Use preview first; Apply will modify all <code>scripture_raw</code> fields.
</p>
<div class="tool-actions">
<form method="get" action="{% url 'normalize_scripture' %}" class="inline">
<input type="number" min="0" name="limit" placeholder="Preview limit (optional)"
class="tool-input">
<button class="btn btn-secondary">Preview (dryrun)</button>
</form>
{% if user.is_authenticated and user.is_staff %}
<form method="post" action="{% url 'normalize_scripture' %}" class="inline">
{% csrf_token %}
<button class="btn btn-danger"
onclick="return confirm('Apply Scripture Normalizer to ALL entries? This will modify scripture_raw fields.');">
Apply to all
</button>
</form>
{% endif %}
</div>
</div> </div>
<!-- Scripture normalizer --> <hr class="tool-sep">
<div class="chip" style="margin:8px 0;">
<strong>Scripture Normalizer</strong> — Standardizes Bible references (book abbreviations, separators, repeats book name for multiple sets).
</div>
<div style="display:flex; gap:10px; flex-wrap:wrap; margin-bottom:10px;">
<form method="get" action="{% url 'normalize_scripture' %}">
<input type="hidden" name="limit" value="">
<button class="btn btn-secondary">Preview (dryrun)</button>
</form>
{% if user.is_authenticated and user.is_staff %} <!-- Source Normalizer -->
<form method="post" action="{% url 'normalize_scripture' %}"> <div class="tool-block">
{% csrf_token %} <h4>Source Normalizer</h4>
<button class="btn btn-danger" onclick="return confirm('Apply normalization to ALL entries? This will modify scripture_raw fields.');"> <p class="small muted">
Apply to all Converts Watchtower/Awake!/Yearbook/KM references (e.g., “March 15, 2013 WT page 14”) into WOL shortcodes
</button> like <code>w13 3/15 p.14</code>. NonJW sources are left unchanged. Use preview first; Apply will modify all
</form> <code>source</code> fields.
{% endif %} </p>
</div> <div class="tool-actions">
<form method="get" action="{% url 'normalize_source' %}" class="inline">
<input type="number" min="0" name="limit" placeholder="Preview limit (optional)"
class="tool-input">
<button class="btn btn-secondary">Preview (dryrun)</button>
</form>
<!-- Source normalizer --> {% if user.is_authenticated and user.is_staff %}
<div class="chip" style="margin:8px 0;"> <form method="post" action="{% url 'normalize_source' %}" class="inline">
<strong>Source Normalizer</strong> — Converts Watchtower/Awake!/Yearbook/KM references into WOL short-codes (e.g., <code>w13 3/15 p.14</code>). NonJW sources are left unchanged. {% csrf_token %}
</div> <button class="btn btn-danger"
<div style="display:flex; gap:10px; flex-wrap:wrap;"> onclick="return confirm('Apply Source Normalizer to ALL entries? This cannot be undone. Make a backup first.');">
<form method="get" action="{% url 'normalize_source' %}"> Apply to all
<input type="number" min="0" name="limit" placeholder="Preview limit (optional)" </button>
style="border:1px solid var(--border); border-radius:8px; padding:6px 8px;"> </form>
<button class="btn btn-secondary">Preview (dryrun)</button> {% endif %}
</form> </div>
{% if user.is_authenticated and user.is_staff %}
<form method="post" action="{% url 'normalize_source' %}">
{% csrf_token %}
<button class="btn btn-danger" onclick="return confirm('Apply normalization to ALL entries? This will modify source fields. Make a backup first.');">
Apply to all
</button>
</form>
{% endif %}
</div> </div>
</div> </div>
</div> </div>
</div> </div>
<!-- Tiny inline JS to toggle the Tools panel --> <!-- Tiny, scoped styles + JS for the collapsible panel -->
<style>
.tools-panel{
margin-top:12px;
border:1px solid var(--border);
border-radius:12px;
background:#fff;
padding:14px;
}
.tool-block h4{
margin:0 0 6px;
font-size:16px;
color:#0f172a;
}
.tool-actions{
display:flex;
flex-wrap:wrap;
gap:10px;
margin-top:8px;
}
.tool-input{
border:1px solid var(--border);
border-radius:8px;
padding:6px 8px;
font-size:14px;
margin-right:6px;
}
.tool-sep{
border:none;
border-top:1px solid var(--border);
margin:14px 0;
}
</style>
<script> <script>
(function () { (function(){
const btn = document.getElementById('tools-toggle'); var btn = document.getElementById('tools-toggle');
const panel = document.getElementById('tools-panel'); var panel = document.getElementById('tools-panel');
if (!btn || !panel) return; if(!btn || !panel) return;
btn.addEventListener('click', function () { btn.addEventListener('click', function(){
panel.style.display = (panel.style.display === 'none' || panel.style.display === '') ? 'block' : 'none'; var open = panel.hasAttribute('hidden') ? false : true;
if(open){
panel.setAttribute('hidden', '');
btn.textContent = '▾ Show tools';
btn.setAttribute('aria-expanded', 'false');
}else{
panel.removeAttribute('hidden');
btn.textContent = '▴ Hide tools';
btn.setAttribute('aria-expanded', 'true');
}
}); });
})(); })();
</script> </script>