Files

67 lines
4.7 KiB
HTML

{% extends 'admin/base_site.html' %}{% load slx_brand %}{% load static %}
{% block extrahead %}{{ block.super }}<script defer src="{% static 'studio-traffic.js' %}"></script>{% endblock %}
{% block content %}
<main class="traffic-desk">
<p>Readership across <span class="studio-wordmark">{{ "SLUMP X LAND"|slx_brand }}</span>. Counts reflect eligible page loads, including repeat visits.</p>
{% if not analytics_enabled %}<p class="messagelist">New collection is disabled. Historical totals remain available.</p>{% endif %}
<form method="get" class="traffic-filters">
<label>Range <select name="days"><option value="7" {% if days == 7 %}selected{% endif %}>7 days</option><option value="30" {% if days == 30 %}selected{% endif %}>30 days</option><option value="90" {% if days == 90 %}selected{% endif %}>90 days</option></select></label>
<label>Content <select name="kind"><option value="all">Entire site</option><option value="chapter" {% if kind == 'chapter' %}selected{% endif %}>Chapter reader</option><option value="blog" {% if kind == 'blog' %}selected{% endif %}>Blog posts</option></select></label>
<button class="studio-button" type="submit">Apply</button></form>
<div class="traffic-totals">
<div><span>Pageviews in selection</span><strong>{{ total }}</strong></div>
<div><span>Chapter reader views</span><strong>{{ chapters }}</strong></div>
<div><span>Blog post views</span><strong>{{ blogs }}</strong></div>
</div>
<section class="traffic-panel" aria-labelledby="traffic-map-heading">
<h2 id="traffic-map-heading">Where readers are</h2>
{% if not geo_configured %}<p>Connect a GeoLite2 City database to locate new visits by country. Earlier and unresolved visits appear as Unknown.</p>{% endif %}
<div data-world-map data-map-url="{% static 'world-countries.json' %}"></div>
<p data-map-status aria-live="polite">Select a highlighted country to see its pageviews.</p>
{{ countries|json_script:"country-traffic" }}
<table class="traffic-table"><thead><tr><th scope="col">Country or territory</th><th scope="col">Pageviews</th></tr></thead><tbody>
{% for row in countries %}<tr><td data-country-name="{{ row.country }}">{{ row.country|default:'Unknown' }}</td><td>{{ row.views }}</td></tr>{% empty %}<tr><td colspan="2">No visits in this range yet.</td></tr>{% endfor %}
</tbody></table><small>Map boundaries: Natural Earth. Location is approximate.</small>
</section>
<div class="traffic-grid">
<section class="traffic-panel">
<h2>Regions and states</h2>
<table class="traffic-table">
<thead><tr><th scope="col">Country</th><th scope="col">Region / State</th><th scope="col">Views</th></tr></thead>
<tbody>
{% for row in regions %}
<tr><td>{{ row.country|default:'Unknown' }}</td><td>{{ row.region|default:'Unknown' }}</td><td>{{ row.views }}</td></tr>
{% empty %}
<tr><td colspan="3">No region data available yet.</td></tr>
{% endfor %}
</tbody>
</table>
</section>
<section class="traffic-panel">
<h2>Cities</h2>
<table class="traffic-table">
<thead><tr><th scope="col">City</th><th scope="col">Region</th><th scope="col">Country</th><th scope="col">Views</th></tr></thead>
<tbody>
{% for row in cities %}
<tr><td>{{ row.city|default:'Unknown' }}</td><td>{{ row.region|default:'Unknown' }}</td><td>{{ row.country|default:'Unknown' }}</td><td>{{ row.views }}</td></tr>
{% empty %}
<tr><td colspan="4">No city data available yet.</td></tr>
{% endfor %}
</tbody>
</table>
</section>
</div>
<div class="traffic-grid">
<section class="traffic-panel"><h2>Traffic sources</h2><p>Referring origins only. Direct visits and missing referrers are grouped together.</p>
<table class="traffic-table"><thead><tr><th scope="col">Source</th><th scope="col">Views</th></tr></thead><tbody>
{% for row in sources %}<tr><td>{% if row.source == 'internal' %}SLX site{% elif row.source %}<a href="{{ row.source }}" rel="noreferrer noopener" target="_blank">{{ row.source }}</a>{% else %}Direct / unavailable{% endif %}</td><td>{{ row.views }}</td></tr>{% empty %}<tr><td colspan="2">No sources in this range yet.</td></tr>{% endfor %}
</tbody></table></section>
<section class="traffic-panel"><h2>Most viewed chapters and posts</h2>
<table class="traffic-table"><thead><tr><th scope="col">Title</th><th scope="col">Views</th></tr></thead><tbody>
{% for row in top %}<tr><td>{{ row.title }}</td><td>{{ row.views }}</td></tr>{% empty %}<tr><td colspan="2">No chapter or post views yet.</td></tr>{% endfor %}
</tbody></table></section>
</div>
<section class="traffic-panel"><details><summary>Pageviews by date</summary><table class="traffic-table"><thead><tr><th>Date</th><th>Views</th></tr></thead><tbody>{% for row in series %}<tr><td>{{ row.day|date:'M j, Y' }}</td><td>{{ row.views }}</td></tr>{% empty %}<tr><td colspan="2">No visits yet.</td></tr>{% endfor %}</tbody></table></details></section>
</main>
{% endblock %}