Update web/templates/stats.html
This commit is contained in:
parent
bb7e80462c
commit
9375355343
@ -5,7 +5,6 @@
|
|||||||
<div class="container">
|
<div class="container">
|
||||||
<h1 class="page-title">Statistics</h1>
|
<h1 class="page-title">Statistics</h1>
|
||||||
|
|
||||||
<!-- Totals -->
|
|
||||||
<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,23 +36,23 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Top subjects (clickable) -->
|
<!-- Top subjects -->
|
||||||
<div class="card" style="padding:16px; margin-bottom:16px;">
|
<div class="card" style="padding:16px; margin-bottom:16px;">
|
||||||
<div class="meta-label">Top Subjects</div>
|
<div class="meta-label">Top Subjects</div>
|
||||||
<div style="display:flex; flex-wrap:wrap; gap:8px; margin-top:8px;">
|
<div style="display:flex; flex-wrap:wrap; gap:8px; margin-top:8px;">
|
||||||
{% for s in top_subjects %}
|
{% 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={{ s.name|urlencode }}&subject=on"
|
||||||
title="Search by subject: {{ s.name }}"
|
title="Search subject: {{ s.name }}"
|
||||||
>
|
>
|
||||||
{{ s.name }} ({{ s.count }})
|
{{ s.name }} ({{ s.count }})
|
||||||
</a>
|
</a>
|
||||||
{% empty %}
|
{% empty %}
|
||||||
<span class="muted">No subjects.</span>
|
<span class="muted">No subjects.</span>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<!-- Scripture usage -->
|
<!-- Scripture usage -->
|
||||||
<div class="card" style="padding:16px; margin-bottom:16px;">
|
<div class="card" style="padding:16px; margin-bottom:16px;">
|
||||||
@ -65,157 +64,157 @@
|
|||||||
<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
|
|
||||||
href="{% url 'search' %}?q={{ book|urlencode }}&scripture_raw=on"
|
|
||||||
title="Search scripture field for book: {{ book }}"
|
|
||||||
>
|
|
||||||
<strong>{{ book }}</strong>
|
|
||||||
</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
|
<a
|
||||||
href="{% url 'search' %}?q={{ ref|urlencode }}&scripture_raw=on"
|
class="chip chip-link"
|
||||||
title="Search scripture field for: {{ ref }}"
|
href="{% url 'search' %}?q={{ ref|urlencode }}&scripture_raw=on"
|
||||||
>
|
title="Search in Scripture field: {{ ref }}"
|
||||||
<strong>{{ ref }}</strong>
|
>
|
||||||
</a>
|
{{ ref }}
|
||||||
— {{ cnt }}
|
</a> — {{ cnt }}
|
||||||
</li>
|
</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>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Maintenance tools (collapsible like the search help) -->
|
<!-- Tools: collapsible panel -->
|
||||||
<div class="card" style="padding:16px; margin-bottom:24px;">
|
<div class="card" style="padding:16px; margin-bottom:24px;">
|
||||||
<details class="tools-details">
|
<div style="display:flex; align-items:center; justify-content:space-between; gap:10px;">
|
||||||
<summary class="tools-summary">
|
<div class="meta-label">Maintenance Tools</div>
|
||||||
🛠️ Maintenance Tools
|
<button
|
||||||
</summary>
|
class="btn btn-secondary"
|
||||||
|
type="button"
|
||||||
|
id="tools-toggle"
|
||||||
|
aria-expanded="false"
|
||||||
|
aria-controls="tools-panel"
|
||||||
|
>
|
||||||
|
▾ Show tools
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div class="tools-grid">
|
<div id="tools-panel" class="tools-panel" hidden>
|
||||||
<!-- Scripture Normalizer -->
|
<!-- Scripture Normalizer -->
|
||||||
<div class="tool">
|
<div class="tool-block">
|
||||||
<h4>Scripture Normalizer</h4>
|
<h4>Scripture Normalizer</h4>
|
||||||
<p class="small muted">
|
<p class="small muted">
|
||||||
Normalize scripture references (abbreviations, separators, and repeat book names where needed).
|
Standardizes Bible references (book abbreviations, separators, and repeats book names as needed).
|
||||||
</p>
|
Use preview first; Apply will modify all <code>scripture_raw</code> fields.
|
||||||
<div class="tool-actions">
|
</p>
|
||||||
<form method="get" action="{% url 'normalize_scripture' %}">
|
<div class="tool-actions">
|
||||||
<input type="number" min="0" name="limit" placeholder="Preview limit (optional)"
|
<form method="get" action="{% url 'normalize_scripture' %}" class="inline">
|
||||||
class="tool-input">
|
<input type="number" min="0" name="limit" placeholder="Preview limit (optional)"
|
||||||
<button class="btn btn-secondary">Preview (dry-run)</button>
|
class="tool-input">
|
||||||
</form>
|
<button class="btn btn-secondary">Preview (dry‑run)</button>
|
||||||
|
</form>
|
||||||
|
|
||||||
{% if user.is_authenticated and user.is_staff %}
|
{% if user.is_authenticated and user.is_staff %}
|
||||||
<form method="post" action="{% url 'normalize_scripture' %}">
|
<form method="post" action="{% url 'normalize_scripture' %}" class="inline">
|
||||||
{% csrf_token %}
|
{% csrf_token %}
|
||||||
<button class="btn btn-danger"
|
<button class="btn btn-danger"
|
||||||
onclick="return confirm('Apply normalization to ALL entries? This will modify scripture_raw fields.');">
|
onclick="return confirm('Apply Scripture Normalizer to ALL entries? This will modify scripture_raw fields.');">
|
||||||
Apply to all
|
Apply to all
|
||||||
</button>
|
</button>
|
||||||
</form>
|
</form>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<!-- Source Normalizer -->
|
|
||||||
<div class="tool">
|
|
||||||
<h4>Source Normalizer</h4>
|
|
||||||
<p class="small muted">
|
|
||||||
Convert Watchtower/Awake!/Yearbook/KM references into WOL short-codes (e.g., <code>w13 3/15 p.14</code>).
|
|
||||||
Non-JW sources are left unchanged.
|
|
||||||
</p>
|
|
||||||
<div class="tool-actions">
|
|
||||||
<form method="get" action="{% url 'normalize_source' %}">
|
|
||||||
<input type="number" min="0" name="limit" placeholder="Preview limit (optional)"
|
|
||||||
class="tool-input">
|
|
||||||
<button class="btn btn-secondary">Preview (dry-run)</button>
|
|
||||||
</form>
|
|
||||||
|
|
||||||
{% 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 cannot be undone. Make a backup first.')">
|
|
||||||
Apply to all
|
|
||||||
</button>
|
|
||||||
</form>
|
|
||||||
{% endif %}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<!-- Subject Normalizer (NEW) -->
|
|
||||||
<div class="tool">
|
|
||||||
<h4>Subject Normalizer</h4>
|
|
||||||
<p class="small muted">
|
|
||||||
Unify delimiters (semicolons, dashes, slashes, etc.) into commas and trim spacing.
|
|
||||||
Preserves multi-word subjects. Most entries are already correct—this avoids over-splitting.
|
|
||||||
</p>
|
|
||||||
<div class="tool-actions">
|
|
||||||
<form method="get" action="{% url 'normalize_subjects' %}">
|
|
||||||
<input type="number" min="0" name="limit" placeholder="Preview limit (optional)"
|
|
||||||
class="tool-input">
|
|
||||||
<button class="btn btn-secondary">Preview (dry-run)</button>
|
|
||||||
</form>
|
|
||||||
|
|
||||||
{% if user.is_authenticated and user.is_staff %}
|
|
||||||
<form method="post" action="{% url 'normalize_subjects' %}">
|
|
||||||
{% csrf_token %}
|
|
||||||
<button class="btn btn-danger"
|
|
||||||
onclick="return confirm('Apply subject normalization to all entries? This will modify subject fields. Make a backup first.')">
|
|
||||||
Apply to all
|
|
||||||
</button>
|
|
||||||
</form>
|
|
||||||
{% endif %}
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="small muted" style="margin-top:10px;">
|
<hr class="tool-sep">
|
||||||
Tip: add <code>?limit=1000</code> on the preview to test against a subset before applying globally.
|
|
||||||
|
<!-- Source Normalizer -->
|
||||||
|
<div class="tool-block">
|
||||||
|
<h4>Source Normalizer</h4>
|
||||||
|
<p class="small muted">
|
||||||
|
Converts Watchtower/Awake!/Yearbook/KM references (e.g., “March 15, 2013 WT page 14”) into WOL short‑codes
|
||||||
|
like <code>w13 3/15 p.14</code>. Non‑JW sources are left unchanged. Use preview first; Apply will modify all
|
||||||
|
<code>source</code> fields.
|
||||||
|
</p>
|
||||||
|
<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 (dry‑run)</button>
|
||||||
|
</form>
|
||||||
|
|
||||||
|
{% if user.is_authenticated and user.is_staff %}
|
||||||
|
<form method="post" action="{% url 'normalize_source' %}" class="inline">
|
||||||
|
{% csrf_token %}
|
||||||
|
<button class="btn btn-danger"
|
||||||
|
onclick="return confirm('Apply Source Normalizer to ALL entries? This cannot be undone. Make a backup first.');">
|
||||||
|
Apply to all
|
||||||
|
</button>
|
||||||
|
</form>
|
||||||
|
{% endif %}
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</details>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Minimal styles for the collapsible tools, matching your existing look -->
|
<!-- Tiny, scoped styles + JS for the collapsible panel -->
|
||||||
<style>
|
<style>
|
||||||
.tools-details { margin-top: 4px; }
|
.tools-panel{
|
||||||
.tools-summary {
|
|
||||||
display:inline-flex; align-items:center; gap:8px;
|
|
||||||
padding:8px 12px; border-radius:10px;
|
|
||||||
background: var(--btn-bg); border:1px solid var(--btn-border);
|
|
||||||
color: var(--nav-ink); cursor:pointer; user-select:none;
|
|
||||||
}
|
|
||||||
.tools-summary:hover { background: var(--btn-hover); }
|
|
||||||
.tools-details[open] .tools-summary { background:#fff; }
|
|
||||||
|
|
||||||
.tools-grid {
|
|
||||||
margin-top:12px;
|
margin-top:12px;
|
||||||
display:grid; gap:16px;
|
border:1px solid var(--border);
|
||||||
grid-template-columns: repeat( auto-fit, minmax(260px, 1fr) );
|
border-radius:12px;
|
||||||
|
background:#fff;
|
||||||
|
padding:14px;
|
||||||
}
|
}
|
||||||
.tool { border:1px solid var(--nav-border); border-radius:12px; padding:12px; background:#fff; }
|
.tool-block h4{
|
||||||
.tool h4 { margin:0 0 6px; }
|
margin:0 0 6px;
|
||||||
.tool-actions { display:flex; flex-wrap:wrap; gap:8px; margin-top:8px; }
|
font-size:16px;
|
||||||
.tool-input {
|
color:#0f172a;
|
||||||
border:1px solid var(--nav-border);
|
}
|
||||||
border-radius:8px; padding:6px 8px; min-width: 190px;
|
.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>
|
</style>
|
||||||
|
<script>
|
||||||
|
(function(){
|
||||||
|
var btn = document.getElementById('tools-toggle');
|
||||||
|
var panel = document.getElementById('tools-panel');
|
||||||
|
if(!btn || !panel) return;
|
||||||
|
btn.addEventListener('click', function(){
|
||||||
|
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>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
Loading…
Reference in New Issue
Block a user