Initial commit: simpleblog

This commit is contained in:
2026-11-14 17:05:01 +00:00
commit 31c4580da4
91 changed files with 53494 additions and 0 deletions
+11
View File
@@ -0,0 +1,11 @@
{% if pagination and pagination.pages > 1 %}
<nav class="pagination" aria-label="Pagination">
{% if pagination.has_prev %}
<a class="btn" rel="prev" href="{{ pagination.prev_url }}">&larr; Newer posts</a>
{% endif %}
<span class="pagination-info">Page {{ pagination.page }} of {{ pagination.pages }}</span>
{% if pagination.has_next %}
<a class="btn" rel="next" href="{{ pagination.next_url }}">Older posts &rarr;</a>
{% endif %}
</nav>
{% endif %}
+141
View File
@@ -0,0 +1,141 @@
{% extends "admin/base.html" %}
{% block title %}Albums &middot; {{ site_title }}{% endblock %}
{% block admin_content %}
<h1>Albums</h1>
<div class="admin-panel">
<h2>Upload a photo to an album</h2>
<form id="album-upload-form" method="POST" action="{{ url_for('admin.upload') }}" enctype="multipart/form-data" class="stack">
<input type="hidden" name="csrf_token" value="{{ csrf_token }}">
<div class="form-group">
<label for="album-photo-file">Photo file</label>
<input type="file" id="album-photo-file" name="file" accept="image/*" multiple required>
<small>Choose one or more photos to add to this album.</small>
</div>
<div class="form-group">
<label for="album-photo-album">Album</label>
<select id="album-photo-album" name="album" required>
{% for a in albums %}
<option value="{{ a.slug }}">{{ a.name }}</option>
{% endfor %}
</select>
</div>
<button type="submit" class="btn btn-primary">Upload photo</button>
</form>
</div>
<div class="admin-panel">
<h2>New album</h2>
<form method="POST" action="{{ url_for('admin.album_new') }}" class="stack">
<input type="hidden" name="csrf_token" value="{{ csrf_token }}">
<div class="form-group">
<label for="name">Album name</label>
<input type="text" id="name" name="name" placeholder="e.g. Road trip 2026" required>
</div>
<div class="form-group">
<label for="description">Description</label>
<textarea id="description" name="description" rows="3"></textarea>
</div>
<button type="submit" class="btn btn-primary">Create album</button>
</form>
</div>
{% if editing %}
<div class="admin-panel">
<h2>Edit: {{ editing.name }}</h2>
<form method="POST" action="{{ url_for('admin.album_edit', slug=editing.slug) }}" class="stack">
<input type="hidden" name="csrf_token" value="{{ csrf_token }}">
<div class="form-group">
<label for="name">Album name</label>
<input type="text" id="name" name="name" value="{{ editing.name }}" required>
</div>
<div class="form-group">
<label for="description">Description</label>
<textarea id="description" name="description" rows="3">{{ editing.description or '' }}</textarea>
</div>
<button type="submit" class="btn btn-primary">Save changes</button>
</form>
</div>
{% endif %}
<div class="admin-panel">
<h2>All albums</h2>
{% if albums %}
<table class="admin-table">
<thead><tr><th>Name</th><th>Photos</th><th></th></tr></thead>
<tbody>
{% for a in albums %}
<tr>
<td><a href="{{ url_for('public.photos', slug=a.slug) }}">{{ a.name }}</a></td>
<td>{{ album_counts.get(a.id, 0) }}</td>
<td>
<a class="primary" href="{{ url_for('admin.album_edit', slug=a.slug) }}">Edit</a>
<span class="field-hint">·</span>
<form method="POST" action="{{ url_for('admin.album_delete', slug=a.slug) }}" style="display:inline;" onsubmit="return confirm('Delete this album? Its photos stay, but become ungrouped.');">
<input type="hidden" name="csrf_token" value="{{ csrf_token }}">
<button class="btn btn-danger" type="submit">Delete</button>
</form>
</td>
</tr>
{% endfor %}
</tbody>
</table>
{% else %}
<p class="empty-state">No albums yet.</p>
{% endif %}
</div>
{% if ungrouped_count %}
<p><a class="primary" href="{{ url_for('admin.media_list') }}">Manage photos ({{ ungrouped_count }} ungrouped)</a></p>
{% endif %}
<script>
// NOTE: one file per request, with FormData built from scratch. Cloning the
// form (new FormData(form)) also re-sends the <input type="file"> parts, so
// the server stored the selected photo twice.
// NOTE: every upload is awaited before location.reload(). The old version
// fired all the fetches and reloaded synchronously in the same tick, which
// aborted the in-flight requests — the album came back unchanged, so uploads
// looked broken even though /admin/upload was healthy.
(function () {
var form = document.getElementById("album-upload-form");
if (!form) return;
form.addEventListener("submit", async function (e) {
e.preventDefault();
var fileInput = form.elements["album-photo-file"];
var files = Array.prototype.slice.call(fileInput.files);
if (!files.length) { alert("Choose one or more photos."); return; }
var album = form.elements["album-photo-album"].value;
var albumName = album ? form.elements["album-photo-album"].options[form.elements["album-photo-album"].selectedIndex].text : "";
var csrf = form.elements["csrf_token"].value;
var btn = form.querySelector("button[type=submit]");
btn.disabled = true;
var ok = 0, failed = [];
for (var i = 0; i < files.length; i++) {
btn.textContent = "Uploading " + (i + 1) + "/" + files.length + "...";
var fd = new FormData();
fd.append("csrf_token", csrf);
if (album) fd.append("album", album);
fd.append("file", files[i], files[i].name);
try {
var r = await fetch(form.action, { method: "POST", credentials: "same-origin", body: fd });
if (!r.ok) throw new Error("HTTP " + r.status);
await r.json();
ok++;
} catch (err) {
failed.push(files[i].name + ": " + err.message);
}
}
btn.disabled = false;
btn.textContent = "Upload photo";
if (failed.length) {
alert(ok + " added to '" + albumName + "', " + failed.length + " failed:\n" + failed.join("\n"));
} else {
alert(ok + " photo" + (ok === 1 ? "" : "s") + " added to '" + albumName + "'.");
}
location.reload();
});
})();
</script>
{% endblock %}
+187
View File
@@ -0,0 +1,187 @@
{% extends "admin/base.html" %}
{% block head_extra %}
<link rel="stylesheet" href="{{ url_for('static', filename='vendor/leaflet/leaflet.css') }}">
{% endblock %}
{% block admin_content %}
<div class="admin-panel">
<h1>Analytics</h1>
<p class="muted">Anonymous visitor tracking. Only an opaque <code>visitor_id</code> cookie is stored; locations are approximate and derived from the visitor's IP — the address itself is never saved.</p>
<div class="admin-stat-grid">
<div class="admin-stat"><span class="num">{{ total_visitors }}</span><span class="label">Unique visitors</span></div>
<div class="admin-stat"><span class="num">{{ total_visits }}</span><span class="label">Total visits</span></div>
<div class="admin-stat"><span class="num">{{ unique_pages }}</span><span class="label">Pages viewed</span></div>
<div class="admin-stat"><span class="num">{{ 'n/a' if total_visitors == 0 else (total_visits | int / (total_visitors or 1) | round(2)) }}</span><span class="label">Avg. pages/visit</span></div>
<div class="admin-stat"><span class="num">{{ total_countries }}</span><span class="label">Countries</span></div>
<div class="admin-stat"><span class="num">{{ total_cities }}</span><span class="label">Cities</span></div>
</div>
</div>
<div class="admin-panel">
<h2>Visitor map</h2>
{% if map_points %}
<p class="muted">Each circle is a city. Larger circles mean more visits — click one for the city, region, country and counts.</p>
{% else %}
<p class="empty-state">No location data yet. The map fills in as visitors arrive; locations come from the visitor's IP (or, for local/LAN visitors, this server's own region).</p>
{% endif %}
<div id="visitor-map" class="visitor-map"></div>
</div>
<div class="admin-panel">
<h2>Location trends</h2>
{% if location_trend.series %}
<p class="muted">Visits per day over the last {{ location_trend.labels|length }} days, by location. Hover the chart for daily counts.</p>
<div class="chart-wrap"><canvas id="location-trend-chart" height="280"></canvas></div>
<div id="location-trend-legend" class="chart-legend"></div>
{% else %}
<p class="empty-state">No visits in the last 30 days.</p>
{% endif %}
</div>
<div class="admin-panel">
<div class="admin-split">
<div>
<h2>Top countries</h2>
<table class="admin-table">
<thead><tr><th>Country</th><th>Visitors</th><th>Visits</th></tr></thead>
<tbody>
{% for r in top_countries %}
<tr>
<td>{% if r.country_code %}<span class="location-flag">{{ r.country_code|country_flag }}</span> {% endif %}{{ r.country }}</td>
<td>{{ r.visitors }}</td>
<td>{{ r.visits }}</td>
</tr>
{% else %}
<tr><td colspan="3" class="empty-state">No location data yet.</td></tr>
{% endfor %}
</tbody>
</table>
</div>
<div>
<h2>Top cities</h2>
<table class="admin-table">
<thead><tr><th>City</th><th>Visitors</th><th>Visits</th></tr></thead>
<tbody>
{% for r in top_cities %}
<tr>
<td>
{% if r.country_code %}<span class="location-flag">{{ r.country_code|country_flag }}</span> {% endif %}{{ r.city }}
<span class="muted">{% if r.region %}{{ r.region }}, {% endif %}{{ r.country }}</span>
</td>
<td>{{ r.visitors }}</td>
<td>{{ r.visits }}</td>
</tr>
{% else %}
<tr><td colspan="3" class="empty-state">No city data yet.</td></tr>
{% endfor %}
</tbody>
</table>
</div>
</div>
</div>
<div class="admin-panel">
<h2>Where visitors to each page come from</h2>
{% if page_locations %}
<p class="muted">The busiest pages and the countries their readers came from. Counts are unique visitors per country.</p>
<table class="admin-table">
<thead><tr><th>Page</th><th>Top locations</th><th>Visits</th></tr></thead>
<tbody>
{% for page in page_locations %}
<tr>
<td>
<a href="{{ page.path }}"><code>{{ page.path }}</code></a>
{% if page.title %}<br><span class="muted">{{ page.title }}</span>{% endif %}
</td>
<td>
{% for c in page.countries %}
<span class="location-chip">{% if c.country_code %}{{ c.country_code|country_flag }} {% endif %}{{ c.country }} <strong>{{ c.visitors }}</strong></span>
{% endfor %}
{% if page.more_countries %}<span class="muted">+{{ page.more_countries }} more</span>{% endif %}
</td>
<td>{{ page.visits }}</td>
</tr>
{% endfor %}
</tbody>
</table>
{% else %}
<p class="empty-state">No page visits yet.</p>
{% endif %}
</div>
<div class="admin-panel">
<h2>Most viewed pages</h2>
<table class="admin-table">
<thead><tr><th>Page</th><th>Title</th><th>Visits</th></tr></thead>
<tbody>
{% for r in top_pages %}
<tr>
<td><code>{{ r.page_path }}</code></td>
<td>{{ r.title or "(untitled)" }}</td>
<td>{{ r.c }}</td>
</tr>
{% else %}
<tr><td colspan="3" class="empty-state">No visits yet.</td></tr>
{% endfor %}
</tbody>
</table>
</div>
<div class="admin-panel">
<h2>Devices</h2>
<table class="admin-table">
<thead><tr><th>Device</th><th>Visitors</th></tr></thead>
<tbody>
{% for r in top_devices %}
<tr><td>{{ r.device }}</td><td>{{ r.c }}</td></tr>
{% else %}
<tr><td colspan="2" class="empty-state">No data yet.</td></tr>
{% endfor %}
</tbody>
</table>
</div>
<div class="admin-panel">
<h2>Browsers</h2>
<table class="admin-table">
<thead><tr><th>Browser</th><th>Visitors</th></tr></thead>
<tbody>
{% for r in top_browsers %}
<tr><td>{{ r.browser or "(unknown)" }}</td><td>{{ r.c }}</td></tr>
{% else %}
<tr><td colspan="2" class="empty-state">No data yet.</td></tr>
{% endfor %}
</tbody>
</table>
</div>
<div class="admin-panel">
<h2>Where they came from</h2>
<table class="admin-table">
<thead><tr><th>Source</th><th>Visitors</th></tr></thead>
<tbody>
{% for r in top_sources %}
<tr><td>{{ r.source }}{% if loop.first %} <span class="term" style="font-size:.8em">(raw referrers below)</span>{% endif %}</td><td>{{ r.c }}</td></tr>
{% else %}
<tr><td colspan="2" class="empty-state">No data yet.</td></tr>
{% endfor %}
</tbody>
</table>
<table class="admin-table">
<thead><tr><th>Referrer domain</th><th>Visitors</th></tr></thead>
<tbody>
{% for r in top_domains %}
<tr><td>{{ r.referrer_domain or "&mdash;" }}</td><td>{{ r.c }}</td></tr>
{% else %}
<tr><td colspan="2" class="empty-state">No referrers yet.</td></tr>
{% endfor %}
</tbody>
</table>
</div>
<script type="application/json" id="visitor-map-data">{{ map_points | tojson }}</script>
{% if location_trend.series %}
<script type="application/json" id="location-trend-data">{{ location_trend | tojson }}</script>
{% endif %}
<script src="{{ url_for('static', filename='vendor/leaflet/leaflet.js') }}"></script>
<script src="{{ url_for('static', filename='js/admin_analytics.js') }}"></script>
{% endblock %}
+447
View File
@@ -0,0 +1,447 @@
{% extends "admin/base.html" %}
{% block admin_content %}
<div class="admin-panel">
<h1>Appearance</h1>
<!-- ==========================================================================
ONE FORM. Every control lives in a single <form>, so a single "Save all"
submits site_title / site_tagline / comments_enabled AND custom_css (the
merged theme + raw CSS) together. Because they are all submitted at once,
saving one section can no longer clobber another — the handler only writes
keys that are present in request.form, and here every key is always present.
Theme styling (accent / background / text / sidebar / font / columns /
header layout / radius / dark) is rendered into the raw-CSS textarea live
as you tweak the controls (see buildTheme() below), so that textarea is the
single source of truth for custom_css: it holds the generated :root block
plus any hand-written CSS you add. The "Reset theme to defaults" button
regenerates the :root block from the built-in defaults.
========================================================================== -->
<form id="appearance-form" method="post" action="{{ url_for('admin.appearance') }}" enctype="multipart/form-data">
<input type="hidden" name="csrf_token" value="{{ csrf_token }}">
<!-- --- Site identity ---------------------------------------------------- -->
<div class="admin-panel identity">
<h2>Site identity</h2>
<div class="form-row">
<div class="form-group">
<label for="site-title">Site title</label>
<input type="text" id="site-title" name="site_title" value="{{ site_title }}" autocomplete="off">
</div>
<div class="form-group">
<label for="site-tagline">Tagline / statement</label>
<input type="text" id="site-tagline" name="site_tagline" value="{{ site_tagline }}" autocomplete="off">
</div>
</div>
<div class="form-group">
<label for="meta-description">Default meta description</label>
<input type="text" id="meta-description" name="meta_description" value="{{ meta_description }}" autocomplete="off"
placeholder="Used by search engines and social previews when a page has no excerpt">
<span class="field-hint">Posts use their excerpt first; this is the fallback for home, archive, tag and other pages.</span>
</div>
<!-- Use radio buttons (not checkbox+hidden): a checkbox's unchecked state
omits the key, so the old hidden "0" trick relied on "0" being truthy,
which it isn't in Python — meaning admins could never switch comments
OFF via this page. Radios submit an explicit 1/0 that the route reads
verbatim. -->
<div class="form-group">
<label class="checkbox-label">
<input type="radio" name="comments_enabled" value="1" {% if comments_enabled %}checked{% endif %}>
Enable comments on posts and pages
</label>
<label class="checkbox-label">
<input type="radio" name="comments_enabled" value="0" {% if not comments_enabled %}checked{% endif %}>
Disable comments on posts and pages
</label>
</div>
</div>
<!-- --- Theme editor (GUI) ------------------------------------------------ -->
<div class="theme-editor">
<h2>Theme</h2>
<p class="field-hint">These controls render into the Custom CSS box below as you change them. Edit the box directly for anything more advanced.</p>
<!-- Colour controls -->
<div class="form-row">
<div class="form-group">
<label for="t-accent">Accent / link colour</label>
<div class="swatch-row">
<input type="color" id="t-accent" name="t-accent" value="{{ theme.accent }}">
<input type="text" id="t-accent-hex" class="hex-input" value="{{ theme.accent }}" spellcheck="false" autocomplete="off">
</div>
</div>
<div class="form-group">
<label for="t-bg">Page background</label>
<div class="swatch-row">
<input type="color" id="t-bg" name="t-bg" value="{{ theme.background }}">
<input type="text" id="t-bg-hex" class="hex-input" value="{{ theme.background }}" spellcheck="false" autocomplete="off">
</div>
</div>
</div>
<div class="form-row">
<div class="form-group">
<label for="t-text">Text colour</label>
<div class="swatch-row">
<input type="color" id="t-text" name="t-text" value="{{ theme.text }}">
<input type="text" id="t-text-hex" class="hex-input" value="{{ theme.text }}" spellcheck="false" autocomplete="off">
</div>
</div>
<div class="form-group">
<label for="t-sidebar">Sidebar / panel background</label>
<div class="swatch-row">
<input type="color" id="t-sidebar" name="t-sidebar" value="{{ theme.sidebar }}">
<input type="text" id="t-sidebar-hex" class="hex-input" value="{{ theme.sidebar }}" spellcheck="false" autocomplete="off">
</div>
</div>
<div class="form-group">
<label for="t-font">Font family</label>
<select id="t-font" name="t-font">
{% for opt in theme.fonts %}
<option value="{{ opt.value }}" {% if opt.value == theme.font %}selected{% endif %}>{{ opt.label }}</option>
{% endfor %}
</select>
</div>
</div>
<!-- Layout controls -->
<div class="form-row">
<div class="form-group">
<label for="t-posts">Post grid columns</label>
<select id="t-posts" name="t-posts">
{% for opt in theme.post_columns %}
<option value="{{ opt.value }}" {% if opt.value == theme.posts %}selected{% endif %}>{{ opt.label }}</option>
{% endfor %}
</select>
</div>
<div class="form-group">
<label for="t-header">Site header</label>
<select id="t-header" name="t-header">
{% for opt in theme.header_layouts %}
<option value="{{ opt.value }}" {% if opt.value == theme.header %}selected{% endif %}>{{ opt.label }}</option>
{% endfor %}
</select>
</div>
</div>
<div class="form-group">
<label for="t-radius">Corner radius: <span id="radius-val">{{ theme.radius }}px</span></label>
<input type="range" id="t-radius" name="t-radius" min="0" max="24" step="1" value="{{ theme.radius }}">
</div>
<label class="checkbox-label" for="t-dark">
<input type="checkbox" id="t-dark" name="t-dark" {% if theme.dark %}checked{% endif %}>
Enable dark mode
</label>
</div>
<!-- --- Raw custom CSS (single source of truth for custom_css) ------------- -->
<div class="admin-panel">
<h2>Custom CSS</h2>
<p class="field-hint">The theme variables above are rendered here live; add any extra rules below them.</p>
<div class="form-group">
<label for="custom-css-editor">Custom CSS</label>
<textarea id="custom-css-editor" rows="16" placeholder="body { background: #fff; }"></textarea>
<input type="hidden" id="custom-css-hidden" name="custom_css" value="{{ custom_css }}">
</div>
</div>
<!-- --- Header image ------------------------------------------------------ -->
<div class="admin-panel">
<h2>Header image</h2>
<p class="field-hint">Upload a banner/header image for the top of every public page. Leave blank to remove it.</p>
{% if header_image %}
<div class="form-group">
<label>Current header image</label>
<img src="{{ header_image }}" alt="{{ site_title }}" style="max-height:90px;width:auto;border:1px solid var(--color-border);border-radius:6px;">
<button type="submit" class="btn-danger" name="remove_header" value="1">Remove</button>
</div>
{% endif %}
<div class="form-group">
<label for="header-image">Header image</label>
<input type="file" id="header-image" name="header_image" accept="image/png,image/jpeg,image/gif,image/webp">
</div>
</div>
<!-- --- Actions ------------------------------------------------------------ -->
<div class="admin-panel">
<button type="submit" class="btn-primary">Save all</button>
<button type="button" id="reset-theme" class="btn-secondary">Reset theme to defaults</button>
</div>
</form>
<!-- Live preview of the themed site -->
<div class="theme-preview-wrap">
<h2>Live preview</h2>
<p class="field-hint">This mini-site uses the exact variables you just set. Changes update as you tweak them.</p>
<div id="theme-preview" class="theme-preview">
<style id="theme-vars"></style>
<header class="site-header" id="preview-header">
<div class="header-inner">
<div class="site-logo"><span id="preview-logo">{{ site_title }}</span></div>
<nav class="main-nav" aria-label="preview nav">
<button type="button" id="preview-menu">Menu</button>
<ul class="nav-menu" id="preview-nav">
<li><a href="#!">Dashboard</a></li>
<li><a href="#!">Posts</a></li>
<li><a href="#!">Categories</a></li>
</ul>
</nav>
</div>
</header>
<main class="site-main" id="preview-main">
<p class="page-heading"><a href="#!">{{ site_title }}</a></p>
<section class="posts-grid" id="preview-posts">
{% for _i in range(0, 6) %}
<article class="post-card">
<h2><a href="#!">I Spent weeks Fighting My Local AI Coding Agent — Here's Everything I Learned</a></h2>
<p class="post-meta"><span>October 27, 2026 by brian</span></p>
<div class="post-excerpt">
<p>How I built a coding agent that runs entirely on my own hardware — no API, no cloud, no monthly bill — and the build steps that actually work. A while back I decided I wanted a coding agent I could leave running without paying for it.</p>
<p>Something that …</p>
</div>
<div class="post-tags"><span class="tag-icon">📁</span><a class="tag" href="#!">ai</a><a class="tag" href="#!">emerging_technology</a><a class="tag" href="#!">thoughts</a></div>
<div class="post-footer"><a href="#!" class="read-more">Read more →</a><a href="#!" class="comment-link">💬 Leave a comment</a></div>
</article>
{% endfor %}
</section>
</main>
</div>
</div>
<style>
/* --- Theme editor controls ------------------------------------------------- */
.theme-editor { border: 1px solid var(--color-border); border-radius: 8px; padding: 20px 24px; }
.swatch-row { display: flex; align-items: center; gap: 12px; margin-top: 6px; }
.swatch-row input[type="color"] { width: 56px; height: 40px; padding: 3px; border: 1px solid var(--color-border); border-radius: 6px; background: #fff; cursor: pointer; }
.swatch-row .hex-input { flex: 1; padding: 11px 12px; border: 1px solid var(--color-border); border-radius: 5px; font-family: var(--font-stack); }
.checkbox-label { display: flex; align-items: center; gap: 8px; margin: 16px 0 14px; font-size: 0.95rem; color: var(--color-text); }
.checkbox-label input { width: auto; }
/* --- Live preview (mini site) ---------------------------------------------- */
.theme-preview-wrap > h2 { margin-top: 0; }
.theme-preview { border: 1px solid var(--color-border); border-radius: 8px; overflow: hidden; background: #fff; }
.theme-preview .site-header { border-bottom-width: 2px; }
@media (max-width: 620px) {
.theme-preview .nav-menu { display: none !important; }
}
/* --- Action buttons -------------------------------------------------------- */
.admin-panel > .form-group:not(:last-of-type) button[type="submit"],
.admin-panel > .form-group:not(:last-of-type) input[type="file"] { margin-bottom: 12px; }
</style>
<script>
(function () {
// Defaults match the built-in theme.css :root so a fresh site looks unchanged.
var DEFAULTS = {
accent: '#00a0d1', background: '#ffffff', text: '#1e1e1e',
font: '"-apple-system", BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, "Helvetica Neue", Arial, sans-serif',
posts: 1, header: 'side', radius: 6, dark: false
};
var state = {
accent: document.getElementById('t-accent').value,
background: document.getElementById('t-bg').value,
text: document.getElementById('t-text').value,
sidebar: document.getElementById('t-sidebar').value,
font: document.getElementById('t-font').value,
posts: document.getElementById('t-posts').value,
header: document.getElementById('t-header').value,
radius: document.getElementById('t-radius').value,
dark: document.getElementById('t-dark').checked
};
function toHex(col) {
try { return getComputedStyle(document.documentElement || { style: function () {} }).getPropertyValue('color').trim(); } catch (e) {}
var c = document.createElement('canvas').getContext('2d');
c.fillStyle = col; return '#' + c.fillStyle.toString().slice(4);
}
// Build the :root variable block + grid/header rules as a CSS string. This is
// exactly what gets spliced into the raw-CSS textarea on submit (and reset), so
// the textarea stays the single source of truth for custom_css.
function buildTheme() {
var light = [
['--color-accent', state.accent],
['--color-link', state.accent],
['--color-link-hover', shade(state.accent, -18)],
['--color-text', state.text],
['--color-muted', lerpAlpha(state.text, 0.55)],
['--color-border', lerpAlpha(state.text, 0.92)],
['--color-bg', state.background],
['--color-sidebar-bg', state.sidebar],
['--color-card-bg', '#f7f8fa'],
['--font-stack', state.font],
['--border-radius', Math.round(Number(state.radius)) + 'px']
];
var dark = [
['--color-accent', state.accent],
['--color-link', state.accent],
['--color-link-hover', shade(state.accent, -22)],
['--color-text', state.text],
['--color-muted', lerpAlpha(state.text, 0.55)],
['--color-border', lerpAlpha(state.text, 0.92)],
['--color-bg', state.background],
['--color-sidebar-bg', state.sidebar],
['--color-card-bg', 'rgba(255, 255, 255, 0.03)'],
['--font-stack', state.font],
['--border-radius', Math.round(Number(state.radius)) + 'px']
];
var vars = (state.dark ? dark : light).map(function (pair) { return pair.join(':') + ';'; }).join('\n ');
var rules = [];
var cols = Number(state.posts);
rules.push('.posts-grid { grid-template-columns: repeat(' + cols + ', 1fr); }');
rules.push('#preview-header { flex-direction: ' + (state.header === 'stacked' ? 'column' : 'row') + '; }');
var out = ':root {\n' + vars + '\n}\n';
if (rules.length) out += '\n' + rules.join('\n') + '\n';
// Emit an explicit marker when dark mode is on. The old detection looked for
// a literal #121212/#1c1c1c background, but buildTheme() writes --color-bg
// from the chosen colour — so a custom dark background would silently lose
// dark mode on reload. This marker is unambiguous and always present in dark.
if (state.dark) out += '/* theme-dark */\n';
return out;
}
function renderVars() { document.getElementById('theme-vars').textContent = buildTheme(); }
// The hidden field is the single source of truth for custom_css. It always holds
// the generated theme block (from buildTheme()) followed by whatever manual CSS the
// user has typed in the editor. This avoids parsing/stripping the textarea on every
// change — no risk of duplicating the grid rules, dark marker, or manual CSS.
function setHidden() {
var ta = document.getElementById('custom-css-editor');
var hidden = document.getElementById('custom-css-hidden');
hidden.value = buildTheme() + '\n\n' + (ta.value || '');
}
// On load: the hidden field already holds the stored custom_css (from {{ custom_css }}).
// Split it into the generated block + manual CSS and show only the manual CSS in the
// editor. Any later change to a control or a keystroke rebuilds the hidden field.
function loadEditor() {
var ta = document.getElementById('custom-css-editor');
var stored = document.getElementById('custom-css-hidden').value;
var gen = buildTheme();
var match = new RegExp('^' + gen.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')).exec(stored);
ta.value = match ? stored.slice(match[0].length) : stored;
}
document.getElementById('custom-css-editor').addEventListener('input', function () {
setHidden();
});
// Apply the current state to the live preview DOM.
function applyPreview() {
var root = document.documentElement;
root.style.setProperty('--color-accent', state.accent);
root.style.setProperty('--color-link', state.accent);
root.style.setProperty('--color-link-hover', shade(state.accent, -18));
root.style.setProperty('--color-text', state.text);
root.style.setProperty('--color-bg', state.background);
root.style.setProperty('--font-stack', state.font);
root.style.setProperty('--color-sidebar-bg', state.sidebar);
document.getElementById('preview-posts').style.gridTemplateColumns = 'repeat(' + state.posts + ', 1fr)';
document.getElementById('preview-header').style.flexDirection = state.header === 'stacked' ? 'column' : 'row';
document.getElementById('preview-header').style.alignItems = state.header === 'stacked' ? 'stretch' : 'center';
var r = Math.round(Number(state.radius));
['post-card', '.site-header', '#preview-logo'].forEach(function (sel) {
var el = document.querySelector(sel);
if (el) el.style.borderRadius = r + 'px';
});
document.getElementById('theme-preview').classList.toggle('dark', state.dark);
}
function shade(hex, pct) {
var m = hex.replace('#', '');
if (m.length === 3) m = m.split('').map(function (c) { return c + c; }).join('');
var num = parseInt(m, 16);
var r = Math.max(0, Math.min(255, ((num >> 16) & 255) + pct));
var g = Math.max(0, Math.min(255, ((num >> 8) & 255) + pct));
var b = Math.max(0, Math.min(255, (num & 255) + pct));
return '#' + ((1 << 24) + (r << 16) + (g << 8) + b).toString(16).slice(1);
}
function lerpAlpha(hex, alpha) {
var m = hex.replace('#', '');
if (m.length === 3) m = m.split('').map(function (c) { return c + c; }).join('');
var num = parseInt(m, 16);
var r = (num >> 16) & 255, g = (num >> 8) & 255, b = num & 255;
return 'rgba(' + r + ',' + g + ',' + b + ',' + alpha + ')';
}
function syncRadiusLabel() { document.getElementById('radius-val').textContent = state.radius + 'px'; }
function bindPair(pickerId, hexId) {
var picker = document.getElementById(pickerId), hex = document.getElementById(hexId);
picker.addEventListener('input', function () {
state[pickerId.slice(2)] = picker.value;
hex.value = picker.value;
setHidden(); renderVars(); applyPreview();
});
hex.addEventListener('input', function () {
var v = hex.value.trim().replace(/^#/, '');
if (/^[\da-fA-F]{6}$/.test(v)) {
state[pickerId.slice(2)] = '#' + v;
picker.value = '#' + v;
setHidden(); renderVars(); applyPreview();
}
});
}
function bind() {
bindPair('t-accent', 't-accent-hex');
bindPair('t-bg', 't-bg-hex');
bindPair('t-text', 't-text-hex');
bindPair('t-sidebar', 't-sidebar-hex');
['t-font', 't-posts', 't-header'].forEach(function (id) {
document.getElementById(id).addEventListener('change', function () {
state[id.slice(2)] = document.getElementById(id).value;
setHidden(); renderVars(); applyPreview(); syncRadiusLabel();
});
});
document.getElementById('t-radius').addEventListener('input', function () {
state.radius = this.value;
document.getElementById('radius-val').textContent = this.value + 'px';
setHidden(); renderVars(); applyPreview();
});
document.getElementById('t-dark').addEventListener('change', function () {
state.dark = this.checked;
setHidden(); renderVars(); applyPreview();
});
// Reset theme controls (and the raw-CSS textarea's generated block) to defaults.
document.getElementById('reset-theme').addEventListener('click', function () {
var form = document.getElementById('appearance-form');
var set = function (id, v) { var el = document.getElementById(id); if (el) el.value = v; };
set('site-title', 'My Blog');
set('site-tagline', 'Thoughts on tech, self-hosting and life.');
set('t-accent', DEFAULTS.accent);
set('t-bg', DEFAULTS.background);
set('t-text', DEFAULTS.text);
set('t-sidebar', DEFAULTS.sidebar);
set('t-font', DEFAULTS.font);
set('t-posts', DEFAULTS.posts);
set('t-header', DEFAULTS.header);
set('t-radius', DEFAULTS.radius);
var dark = document.getElementById('t-dark'); if (dark) dark.checked = DEFAULTS.dark;
// Clear any manual CSS the user typed, then rebuild the hidden field from defaults.
document.getElementById('custom-css-editor').value = '';
setHidden(); renderVars(); applyPreview();
});
}
bind();
renderVars();
loadEditor();
applyPreview();
})();
</script>
{% endblock %}
+103
View File
@@ -0,0 +1,103 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
{# Routes that don't pass active_page (posts, comments, …) get their label
from the endpoint, so every admin tab is named correctly. #}
{% set page_label = (active_page or (request.endpoint or 'dashboard').rsplit('.', 1)[-1])|replace('_', ' ')|replace('-', ' ')|title %}
<title>{{ page_label }} &middot; {{ site_title }}</title>
<link rel="stylesheet" href="{{ url_for('static', filename='css/style.css') }}">
<link rel="stylesheet" href="{{ url_for('static', filename='css/admin.css') }}">
<!-- TinyMCE oxide skin (UI + content styles), served locally. -->
<link rel="stylesheet" href="{{ url_for('static', filename='js/skins/ui/oxide/skin.min.css') }}">
<link rel="stylesheet" href="{{ url_for('static', filename='js/skins/ui/oxide/content.min.css') }}">
<!-- TinyMCE WYSIWYG editor (replaces the Quill/TipTap build). Loaded locally in <head>;
it only initializes on pages containing a #body-editor element. Community edition,
no license key → no tin.cloud validation; theme/skin assets are served from /static/js/. -->
<!-- Absolute base is REQUIRED: this app is a subpath (/admin/*) and TinyMCE resolves its
theme/skin assets against the document root, so a relative path would 404. An absolute
base_url makes every asset resolve correctly regardless of subpath. Update host/port
here if you ever redeploy elsewhere. -->
{# Relative asset base (NOT absolute). Resolves against the PAGE origin, so tinymce assets
follow whatever protocol/host loads the page — works behind reverse proxies (https://domain,
http://IP, LAN host) without needing X-Forwarded-Proto or per-host edits. An absolute base
would be forced to http(s) as Flask sees it internally and break Mixed Content on HTTPS. #}
{# js_base has NO trailing slash; callers add the needed '/' themselves so paths stay clean #}
{% set js_base = "/static/js" %}
<script>
window.tinyMCEPreInit = { base: '{{ js_base }}', suffix: '.min' };
</script>
<script src="{{ url_for('static', filename='js/tinymce.min.js') }}"></script>
{% block head_extra %}{% endblock %}
</head>
<body>
<header class="admin-header">
<div class="header-inner">
<div class="site-logo"><a href="{{ url_for('admin.dashboard') }}">{{ site_title }}</a></div>
<nav class="main-nav" aria-label="Admin navigation">
<button type="button" aria-expanded="false" id="menuButton">Menu</button>
<ul class="nav-menu" id="navMenu" role="menu">
<li role="none"><a href="{{ url_for('admin.dashboard') }}" role="menuitem">Dashboard</a></li>
<li role="none"><a href="{{ url_for('admin.posts') }}" role="menuitem">Posts</a></li>
<li role="none"><a href="{{ url_for('admin.categories') }}" role="menuitem">Categories</a></li>
<li role="none"><a href="{{ url_for('admin.albums') }}" role="menuitem">Albums</a></li>
<li role="none"><a href="{{ url_for('admin.media_list') }}" role="menuitem">Media</a></li>
<li role="none"><a href="{{ url_for('admin.comments') }}" role="menuitem">Comments{% if pending_comments %}<span class="nav-badge" title="{{ pending_comments }} awaiting moderation">{{ pending_comments }}</span>{% endif %}</a></li>
<li role="none"><a href="{{ url_for('admin.analytics') }}" role="menuitem">Analytics</a></li>
<li role="none"><a href="{{ url_for('admin.visitors') }}" role="menuitem">Visitors</a></li>
<li role="none"><a href="{{ url_for('admin.import_export') }}" role="menuitem">Import/Export</a></li>
<li role="none"><a href="{{ url_for('admin.admin_password') }}" role="menuitem">Password</a></li>
<li role="none"><a href="{{ url_for('public.index') }}" role="menuitem">View site</a></li>
<li role="none">
<form method="post" action="{{ url_for('admin.admin_logout') }}" class="logout-form">
<input type="hidden" name="csrf_token" value="{{ csrf_token }}">
<button type="submit" role="menuitem" class="link-button">Log out</button>
</form>
</li>
</ul>
</nav>
</div>
</header>
<div class="admin-subnav">
<a href="{{ url_for('admin.dashboard') }}" class="{% if active_page == 'dashboard' %}active{% endif %}">Dashboard</a>
<a href="{{ url_for('admin.posts') }}" class="{% if active_page == 'posts' %}active{% endif %}">Posts</a>
<a href="{{ url_for('admin.categories') }}" class="{% if active_page == 'categories' %}active{% endif %}">Categories</a>
<a href="{{ url_for('admin.albums') }}" class="{% if active_page == 'albums' %}active{% endif %}">Albums</a>
<a href="{{ url_for('admin.media_list') }}" class="{% if active_page == 'media' %}active{% endif %}">Media</a>
<a href="{{ url_for('admin.comments') }}" class="{% if active_page == 'comments' %}active{% endif %}">Comments{% if pending_comments %}<span class="nav-badge">{{ pending_comments }}</span>{% endif %}</a>
<a href="{{ url_for('admin.pages') }}" class="{% if active_page == 'pages' %}active{% endif %}">Pages</a>
<a href="{{ url_for('admin.links') }}" class="{% if active_page == 'links' %}active{% endif %}">Links</a>
<a href="{{ url_for('admin.appearance') }}" class="{% if active_page == 'appearance' %}active{% endif %}">Appearance</a>
<a href="{{ url_for('admin.analytics') }}" class="{% if active_page == 'analytics' %}active{% endif %}">Analytics</a>
<a href="{{ url_for('admin.visitors') }}" class="{% if active_page == 'visitors' %}active{% endif %}">Visitors</a>
<a href="{{ url_for('admin.import_export') }}" class="{% if active_page == 'import-export' %}active{% endif %}">Import/Export</a>
<a href="{{ url_for('admin.admin_password') }}" class="{% if active_page == 'password' %}active{% endif %}">Password</a>
</div>
<div class="admin-wrap">
{% with messages = get_flashed_messages(with_categories=true) %}
{% for category, message in messages %}
<div class="notice notice-{{ category }}">{{ message }}</div>
{% endfor %}
{% endwith %}
{% block admin_content %}{% endblock %}
</div>
<script>
(function () {
var btn = document.getElementById("menuButton");
var menu = document.getElementById("navMenu");
if (btn && menu) {
btn.addEventListener("click", function () {
var open = menu.classList.toggle("open");
btn.setAttribute("aria-expanded", String(open));
});
}
})();
</script>
<!-- (Quill + turndown removed; TinyMCE is loaded in <head> and initializes
only on pages containing a #body-editor element.) -->
</body>
</html>
+51
View File
@@ -0,0 +1,51 @@
{% extends "admin/base.html" %}
{% block admin_content %}
<div class="admin-panel">
<h1>Categories</h1>
<div class="admin-actions">
<a class="primary" href="{{ url_for('admin.category_new') }}">+ New category</a>
</div>
{% if categories is not none %}
<table class="admin-table">
<thead>
<tr><th>Name</th><th>Slug</th><th style="width:120px;">Actions</th></tr>
</thead>
<tbody>
{% for slug, name in categories %}
<tr class="category-row">
<td>{{ name }}</td>
<td><code>{{ slug }}</code></td>
<td>
{% if slug != 'general' %}
<form method="post" action="{{ url_for('admin.category_delete', slug=slug) }}" style="display:inline;" onsubmit="return confirm('Delete this category?');">
<input type="hidden" name="csrf_token" value="{{ csrf_token }}">
<button class="btn btn-danger" type="submit">Delete</button>
</form>
{% else %}
<span class="field-hint">Default — cannot be deleted</span>
{% endif %}
</td>
</tr>
{% endfor %}
</tbody>
</table>
{% else %}
<p class="empty-state">No categories yet.</p>
{% endif %}
</div>
{% if categories is none %}
<div class="admin-panel">
<h2>Add a category</h2>
<form method="post" action="{{ url_for('admin.category_new') }}">
<input type="hidden" name="csrf_token" value="{{ csrf_token }}">
<div class="form-group">
<label for="name">Category name</label>
<input type="text" id="name" name="name" placeholder="e.g. Technology" required>
</div>
<button type="submit" class="btn btn-primary">Create category</button>
</form>
</div>
{% endif %}
{% endblock %}
+99
View File
@@ -0,0 +1,99 @@
{% extends "admin/base.html" %}
{% block admin_content %}
<div class="admin-panel">
<h1>Comments</h1>
<div class="comment-stats">
<span class="term {% if counts.pending > 0 %}warn{% endif %}">{{ counts.pending }} pending</span>
<span>{{ counts.approved }} approved</span>
<span>{{ counts.rejected }} rejected</span>
<span>{{ counts.spam }} spam</span>
</div>
{% if comments or rejected or spam %}
{% if comments %}
<h2>Pending moderation</h2>
<div class="comment-mod-list">
{% for c in comments %}
<div class="comment-block comment-pending">
<div class="comment-meta">
<span class="comment-author">{{ c.author }}</span>
{% if c.email %}<span class="comment-email">{{ c.email }}</span>{% endif %}
<time datetime="{{ c.created_at }}">{{ parse_date(c.created_at) }}</time>
</div>
<div class="comment-body">{{ render_markdown(c.body) }}</div>
<div class="comment-actions">
<form method="post" action="{{ url_for('admin.comment_approve', cid=c.id) }}" style="display:inline;">
<input type="hidden" name="csrf_token" value="{{ csrf_token }}">
<button class="btn btn-sm btn-success" type="submit">Approve</button>
</form>
<form method="post" action="{{ url_for('admin.comment_reject', cid=c.id) }}" style="display:inline;">
<input type="hidden" name="csrf_token" value="{{ csrf_token }}">
<button class="btn btn-sm" type="submit">Reject</button>
</form>
<form method="post" action="{{ url_for('admin.comment_spam', cid=c.id) }}" style="display:inline;">
<input type="hidden" name="csrf_token" value="{{ csrf_token }}">
<button class="btn btn-sm btn-warning" type="submit">Spam</button>
</form>
<form method="post" action="{{ url_for('admin.comment_delete', cid=c.id) }}" style="display:inline;" onsubmit="return confirm('Delete this comment permanently?');">
<input type="hidden" name="csrf_token" value="{{ csrf_token }}">
<button class="btn btn-sm btn-danger" type="submit">Delete</button>
</form>
</div>
</div>
{% endfor %}
</div>
{% endif %}
{% if rejected %}
<h2>Rejected comments</h2>
<div class="comment-mod-list">
{% for c in rejected %}
<div class="comment-block comment-rejected">
<div class="comment-meta">
<span class="comment-author">{{ c.author }}</span>
{% if c.email %}<span class="comment-email">{{ c.email }}</span>{% endif %}
<time datetime="{{ c.created_at }}">{{ parse_date(c.created_at) }}</time>
</div>
<div class="comment-body">{{ render_markdown(c.body) }}</div>
<div class="comment-actions">
<form method="post" action="{{ url_for('admin.comment_unreject', cid=c.id) }}" style="display:inline;">
<input type="hidden" name="csrf_token" value="{{ csrf_token }}">
<button class="btn btn-sm btn-success" type="submit">Un-reject</button>
</form>
<form method="post" action="{{ url_for('admin.comment_delete', cid=c.id) }}" style="display:inline;" onsubmit="return confirm('Delete this comment permanently?');">
<input type="hidden" name="csrf_token" value="{{ csrf_token }}">
<button class="btn btn-sm btn-danger" type="submit">Delete</button>
</form>
</div>
</div>
{% endfor %}
</div>
{% endif %}
{% if spam %}
<h2>Spam comments</h2>
<div class="comment-mod-list">
{% for c in spam %}
<div class="comment-block comment-spam">
<div class="comment-meta">
<span class="comment-author">{{ c.author }}</span>
{% if c.email %}<span class="comment-email">{{ c.email }}</span>{% endif %}
<time datetime="{{ c.created_at }}">{{ parse_date(c.created_at) }}</time>
</div>
<div class="comment-body">{{ render_markdown(c.body) }}</div>
<div class="comment-actions">
<form method="post" action="{{ url_for('admin.comment_delete', cid=c.id) }}" style="display:inline;" onsubmit="return confirm('Delete this comment permanently?');">
<input type="hidden" name="csrf_token" value="{{ csrf_token }}">
<button class="btn btn-sm btn-danger" type="submit">Delete</button>
</form>
</div>
</div>
{% endfor %}
</div>
{% endif %}
{% else %}
<p class="empty-state">No comments awaiting moderation.</p>
{% endif %}
</div>
{% endblock %}
+61
View File
@@ -0,0 +1,61 @@
{% extends "admin/base.html" %}
{% block admin_content %}
<div class="admin-panel">
<h1>Dashboard</h1>
<div style="display:grid;grid-template-columns:repeat(auto-fit,minmax(160px,1fr));gap:20px;margin:24px 0;">
<div class="admin-stat"><span class="num">{{ count }}</span><span class="label">Total posts</span></div>
<div class="admin-stat"><span class="num">{{ published }}</span><span class="label">Published</span></div>
<div class="admin-stat"><span class="num">{{ drafts }}</span><span class="label">Drafts</span></div>
<a class="admin-stat" href="{{ url_for('admin.comments') }}" style="text-decoration:none;">
<span class="num">{{ pending_comments }}</span><span class="label">Awaiting moderation</span>
</a>
</div>
</div>
<div class="admin-panel">
<h2>Recent posts</h2>
<table class="admin-table">
<thead>
<tr>
<th>Title</th>
<th>Status</th>
<th>Date</th>
</tr>
</thead>
<tbody>
{% for p in posts[:5] %}
<tr>
<td><a href="{{ url_for('admin.post_edit', pid=p.id) }}">{{ p.title }}</a></td>
<td>{% if p.status == 'published' %}<span class="term">Published</span>{% else %}Draft{% endif %}</td>
<td>{{ parse_date(p.created_at) }}</td>
</tr>
{% else %}
<tr><td colspan="3" class="empty-state">No posts yet.</td></tr>
{% endfor %}
</tbody>
</table>
</div>
<div class="admin-panel">
<h2>Comments awaiting moderation</h2>
{% if pending %}
<table class="admin-table">
<thead>
<tr><th>Author</th><th>Comment</th><th>Received</th><th></th></tr>
</thead>
<tbody>
{% for c in pending %}
<tr>
<td>{{ c.author }}</td>
<td>{{ c.body[:120] }}{% if c.body|length > 120 %}…{% endif %}</td>
<td>{{ parse_date(c.created_at) }}</td>
<td><a class="btn" href="{{ url_for('admin.comments') }}">Review</a></td>
</tr>
{% endfor %}
</tbody>
</table>
{% else %}
<p class="empty-state">Nothing waiting for moderation.</p>
{% endif %}
</div>
{% endblock %}
+31
View File
@@ -0,0 +1,31 @@
{% extends "admin/base.html" %}
{% block admin_content %}
<div class="admin-panel">
<h1>Import / Export</h1>
<p class="muted">Move content to and from a WordPress site using the standard WXR (XML) format.</p>
</div>
<div class="admin-panel">
<h2>Export this blog</h2>
<p>Download everything as a <strong>.xml</strong> file that you can upload into a fresh WordPress site via its "Tools → Import → WordPress" screen. Posts, categories and comments are included; images are left as-is (see the note below).</p>
<form id="export-form" method="post" action="{{ url_for('admin.import_export') }}">
<input type="hidden" name="csrf_token" value="{{ csrf_token }}">
<input type="hidden" name="export" value="1">
<button type="submit" class="btn-primary">Download simple-blog-export.xml</button>
</form>
<p class="muted small">Note: images in the post HTML keep their original URLs, so re-upload them through WordPress's Media Library after importing, or pick the image-reupload option if you want this tool to pull them for you.</p>
</div>
<div class="admin-panel">
<h2>Import from WordPress</h2>
<p>Choose a WXR <strong>.xml</strong> file exported from a WordPress site. Published posts, their categories/tags, and comments are imported into Posts. Existing rows are never overwritten.</p>
<form id="import-form" method="post" action="{{ url_for('admin.import_wxr_route') }}" enctype="multipart/form-data">
<input type="hidden" name="csrf_token" value="{{ csrf_token }}">
<div class="form-group">
<label for="file">WXR file (.xml)</label>
<input type="file" id="file" name="file" accept=".xml,application/xml">
</div>
<button type="submit" class="btn-primary">Import</button>
</form>
</div>
{% endblock %}
+53
View File
@@ -0,0 +1,53 @@
{% extends "admin/base.html" %}
{% block admin_content %}
<div class="admin-panel">
<h1>Links</h1>
<p class="field-hint">
These appear in the &ldquo;Links&rdquo; panel in the site sidebar, in the order
listed below. The panel stays hidden until at least one link is added.
</p>
<form method="post" action="{{ url_for('admin.links') }}">
<input type="hidden" name="csrf_token" value="{{ csrf_token }}">
<div class="form-row">
<div class="form-group">
<label for="link-label">Label</label>
<input type="text" id="link-label" name="label" placeholder="GitHub" maxlength="80" required>
</div>
<div class="form-group">
<label for="link-url">URL</label>
<input type="text" id="link-url" name="url" placeholder="https://github.com/you" maxlength="500" required>
<span class="field-hint">A bare domain gets https:// added automatically.</span>
</div>
</div>
<button type="submit" class="btn btn-primary">Add link</button>
</form>
</div>
<div class="admin-panel">
<h2>Current links</h2>
{% if links %}
<table class="admin-table">
<thead>
<tr><th>Label</th><th>URL</th><th style="width:120px;">Actions</th></tr>
</thead>
<tbody>
{% for link in links %}
<tr>
<td>{{ link.label }}</td>
<td><a href="{{ link.url }}" target="_blank" rel="noopener noreferrer">{{ link.url }}</a></td>
<td>
<form method="post" action="{{ url_for('admin.link_delete', lid=link.id) }}" onsubmit="return confirm('Remove this link?');">
<input type="hidden" name="csrf_token" value="{{ csrf_token }}">
<button type="submit" class="btn btn-danger btn-small">Delete</button>
</form>
</td>
</tr>
{% endfor %}
</tbody>
</table>
{% else %}
<p class="empty-state">No links yet — so the sidebar panel is currently hidden.</p>
{% endif %}
</div>
{% endblock %}
+124
View File
@@ -0,0 +1,124 @@
{% extends "admin/base.html" %}
{% block title %}Media &middot; {{ site_title }}{% endblock %}
{% block admin_content %}
<h1>Media</h1>
<div class="admin-panel">
<h2>Upload a photo</h2>
<form id="media-upload-form" method="POST" action="{{ url_for('admin.upload') }}" enctype="multipart/form-data" class="stack">
<input type="hidden" name="csrf_token" value="{{ csrf_token }}">
<div class="form-group">
<label for="media-photo-file">Photo file</label>
<input type="file" id="media-photo-file" name="file" accept="image/*" multiple required>
</div>
<div class="form-group">
<label for="media-photo-album">Add to album (optional)</label>
<select id="media-photo-album" name="album">
<option value="">— Leave ungrouped —</option>
{% for a in albums %}
<option value="{{ a.slug }}">{{ a.name }}</option>
{% endfor %}
</select>
</div>
<button type="submit" class="btn btn-primary">Upload photo</button>
</form>
</div>
{% if ungrouped %}
<div class="admin-panel">
<h2>Ungrouped photos ({{ ungrouped|length }})</h2>
{% for m in ungrouped %}
{{ _media_row(m, albums) }}
{% else %}
<p class="empty-state">No ungrouped photos.</p>
{% endfor %}
</div>
{% endif %}
{% for aid, rows in grouped.items() %}
<div class="admin-panel">
<h2>{{ album_names.get(aid, 'Album') }} ({{ rows|length }})</h2>
{% for m in rows %}
{{ _media_row(m, albums) }}
{% else %}
<p class="empty-state">No photos.</p>
{% endfor %}
</div>
{% else %}
<p class="empty-state">No photos yet. Upload one from the Albums page or a post/page editor.</p>
{% endfor %}
<script>
// NOTE: one file per request, with FormData built from scratch. Cloning the
// form (new FormData(form)) also re-sends the <input type="file"> parts, so
// the server stored the selected photo twice.
// NOTE: every upload is awaited before location.reload(). The old version
// fired all the fetches and reloaded synchronously in the same tick, which
// aborted the in-flight requests — the page came back with no new photos,
// so uploads looked broken even though /admin/upload was healthy.
(function () {
var form = document.getElementById("media-upload-form");
if (!form) return;
form.addEventListener("submit", async function (e) {
e.preventDefault();
var fileInput = form.elements["media-photo-file"];
var files = Array.prototype.slice.call(fileInput.files);
if (!files.length) { alert("Choose one or more photos."); return; }
var album = form.elements["media-photo-album"].value;
var csrf = form.elements["csrf_token"].value;
var btn = form.querySelector("button[type=submit]");
btn.disabled = true;
var ok = 0, failed = [];
for (var i = 0; i < files.length; i++) {
btn.textContent = "Uploading " + (i + 1) + "/" + files.length + "...";
var fd = new FormData();
fd.append("csrf_token", csrf);
if (album) fd.append("album", album);
fd.append("file", files[i], files[i].name);
try {
var r = await fetch(form.action, { method: "POST", credentials: "same-origin", body: fd });
if (!r.ok) throw new Error("HTTP " + r.status);
await r.json();
ok++;
} catch (err) {
failed.push(files[i].name + ": " + err.message);
}
}
btn.disabled = false;
btn.textContent = "Upload photo";
if (failed.length) {
alert(ok + " uploaded, " + failed.length + " failed:\n" + failed.join("\n"));
} else {
alert(ok + " photo" + (ok === 1 ? "" : "s") + " uploaded.");
}
location.reload();
});
})();
</script>
{% endblock %}
{% macro _media_row(m, albums) %}
<div class="media-row">
<img class="media-thumb" src="{{ m.thumb_url or m.url }}" data-src="{{ m.url }}" alt="" style="width:60px;height:60px;object-fit:cover;">
<div class="media-info">
<a href="{{ m.url }}" target="_blank" rel="noreferrer">{{ m.url }}</a>
<small>{{ m.created_at or '' }}</small>
</div>
<div class="media-actions">
<form method="POST" action="{{ url_for('admin.media_assign', mid=m.id) }}" style="display:inline;">
<input type="hidden" name="csrf_token" value="{{ csrf_token }}">
<select name="album_id" onchange="this.form.submit()">
{% for a in albums %}
<option value="{{ a.id }}">{{ a.name }}</option>
{% endfor %}
</select>
</form>
<span class="field-hint">·</span>
<form method="POST" action="{{ url_for('admin.media_remove', mid=m.id) }}" style="display:inline;" onsubmit="return confirm('Remove this photo permanently? The file will be deleted.');">
<input type="hidden" name="csrf_token" value="{{ csrf_token }}">
<button class="btn btn-danger" type="submit">Remove</button>
</form>
</div>
</div>
{% endmacro %}
+84
View File
@@ -0,0 +1,84 @@
{% extends "admin/base.html" %}
{% block admin_content %}
<div class="admin-panel">
<h1>{% if page %}Edit page{% else %}New page{% endif %}</h1>
<form method="post" action="{% if page %}{{ url_for('admin.page_edit', pid=page.id) }}{% else %}{{ url_for('admin.page_new') }}{% endif %}">
<input type="hidden" name="csrf_token" value="{{ csrf_token }}">
<div class="form-row">
<div class="form-group">
<label for="title">Title *</label>
<input type="text" id="title" name="title" value="{{ (page or {}).get('title', '') if page else '' }}" required>
</div>
<div class="form-group">
<label for="slug">Slug</label>
<input type="text" id="slug" name="slug" value="{{ (page or {}).get('slug', '') if page else '' }}" placeholder="auto-generated-from-title">
<span class="field-hint">URL-friendly version of the title. Leave blank to auto-generate.</span>
</div>
</div>
<div class="form-group">
<label for="published">Published</label>
<input type="checkbox" id="published" name="published" {% if page %}checked{% endif %}>
<span class="field-hint">{% if page %}Uncheck to hide this page from the navigation.{% else %}Live pages appear in the top nav.{% endif %}</span>
</div>
<div class="form-group">
<label for="content">Content <span class="field-hint">(Rich text editor — Markdown, links, images)</span></label>
<!-- Hidden field holds the stored HTML. TinyMCE loads it into #page-editor
on init and writes it back here on submit; the public pipeline passes
stored HTML straight through (render_markdown/to_html detect it). -->
<input type="hidden" id="content" name="content" value="{{ body_html|forceescape }}">
<div id="page-editor" class="tinymce-editor"></div>
</div>
<p>
<button type="submit" class="btn btn-primary">Save</button>
<a class="btn" href="{{ url_for('admin.pages') }}">Cancel</a>
</p>
</form>
</div>
<script>
// TinyMCE: load stored HTML on init, write it back to #content on submit.
document.addEventListener('DOMContentLoaded', function () {
var contentField = document.getElementById("content");
try {
tinymce.init({
base_url: '{{ js_base }}',
theme_url: '{{ js_base }}/themes/silver/theme.min.js',
icons_url: '{{ js_base }}/icons/default/icons.min.js',
model_url: '{{ js_base }}/models/dom/model.min.js',
license_key: 'gpl',
skin: 'oxide',
content_css: '/static/js/skins/ui/oxide/content.min.css',
selector: '#page-editor',
init_instance_callback: function (editor) {
editor.setContent(contentField ? contentField.value : '');
},
convert_urls: false,
plugins: 'anchor autolink charmap codesample emoticons image link lists media searchreplace table visualblocks wordcount',
toolbar: 'undo redo | blocks fontfamily fontsize | bold italic underline strikethrough | link image media table | align lineheight | numlist bullist indent outdent | emoticons charmap | removeformat',
});
} catch (e) {
console.error('[debug] page editor init FAILED:', e);
}
// Write the WYSIWYG content back to the hidden #content field on submit.
// A div-based editor does NOT save into a separate hidden field via its
// default behaviour (TinyMCE would restore the div instead), so we must
// bridge it explicitly — same pattern as post_edit.html's #body editor.
// Same bug as post_edit.html: document.querySelector('form') returns the
// logout form in the admin header, so the editor content was never copied
// into #content and saved pages had an empty body.
var form = contentField ? contentField.form : null;
if (form) {
form.addEventListener('submit', function () {
var editor = tinymce.get('page-editor') || tinymce.activeEditor;
if (editor && contentField) contentField.value = editor.getContent();
});
}
});
</script>
{% endblock %}
+36
View File
@@ -0,0 +1,36 @@
{% extends "admin/base.html" %}
{% block admin_content %}
<div class="admin-panel">
<div class="page-head">
<h1>Pages</h1>
<a class="btn btn-primary" href="{{ url_for('admin.page_new') }}">New page</a>
</div>
{% if pages is none %}
<p class="empty-state">No pages yet. Create your first one.</p>
{% else %}
<table class="data-table">
<thead>
<tr><th>Title</th><th>Slug</th><th>Status</th><th>Order</th><th></th></tr>
</thead>
<tbody>
{% for p in pages %}
<tr>
<td><a href="{{ url_for('admin.page_edit', pid=p.id) }}">{{ p.title }}</a></td>
<td><code>/p/{{ p.slug }}</code></td>
<td>{% if p.published %}<span class="badge badge-live">Live</span>{% else %}<span class="badge badge-draft">Draft</span>{% endif %}</td>
<td>{{ p.position }}</td>
<td class="actions">
<a class="btn btn-small" href="{{ url_for('admin.page_edit', pid=p.id) }}">Edit</a>
<form method="post" action="{{ url_for('admin.page_delete', pid=p.id) }}" onsubmit="return confirm('Delete this page?');">
<input type="hidden" name="csrf_token" value="{{ csrf_token }}">
<button type="submit" class="btn btn-danger btn-small">Delete</button>
</form>
</td>
</tr>
{% endfor %}
</tbody>
</table>
{% endif %}
</div>
{% endblock %}
+36
View File
@@ -0,0 +1,36 @@
{% extends "admin/base.html" %}
{% block admin_content %}
<div class="admin-panel" style="max-width:520px;">
<h1>Change password</h1>
<p class="field-hint">
The current password is required. Changing it signs out every other
browser that is logged in; this session stays signed in.
</p>
<form method="post" action="{{ url_for('admin.admin_password') }}">
<input type="hidden" name="csrf_token" value="{{ csrf_token }}">
<div class="form-group">
<label for="current-password">Current password</label>
<input type="password" id="current-password" name="current_password"
autocomplete="current-password" maxlength="1024" required autofocus>
</div>
<div class="form-group">
<label for="new-password">New password</label>
<input type="password" id="new-password" name="new_password"
autocomplete="new-password" minlength="{{ min_length }}"
maxlength="1024" required>
<p class="field-hint">At least {{ min_length }} characters; well-known defaults are rejected.</p>
</div>
<div class="form-group">
<label for="confirm-password">Repeat new password</label>
<input type="password" id="confirm-password" name="confirm_password"
autocomplete="new-password" minlength="{{ min_length }}"
maxlength="1024" required>
</div>
<button type="submit" class="btn btn-primary">Update password</button>
</form>
</div>
{% endblock %}
+179
View File
@@ -0,0 +1,179 @@
{% extends "admin/base.html" %}
{% block admin_content %}
<div class="admin-panel">
<h1>{% if post %}Edit post{% else %}New post{% endif %}</h1>
<form method="post" action="{% if post %}{{ url_for('admin.post_edit', pid=post.id) }}{% else %}{{ url_for('admin.post_new') }}{% endif %}">
<input type="hidden" name="csrf_token" value="{{ csrf_token }}">
<div class="form-row">
<div class="form-group">
<label for="title">Title *</label>
<input type="text" id="title" name="title" value="{{ (post or {}).get('title', '') if post else '' }}" required>
</div>
<div class="form-group">
<label for="slug">Slug</label>
<input type="text" id="slug" name="slug" value="{{ (post or {}).get('slug', '') if post else '' }}" placeholder="auto-generated-from-title">
<span class="field-hint">URL-friendly version of the title. Leave blank to auto-generate.</span>
</div>
</div>
<div class="form-row">
<div class="form-group">
<label for="author">Author</label>
<input type="text" id="author" name="author" value="{{ (post or {}).get('author', 'editor') if post else '' }}">
</div>
<div class="form-group">
<label for="category">Category</label>
<input type="text" id="category" name="category" value="{{ (post or {}).get('category', 'General') if post else '' }}" list="category-options">
<datalist id="category-options">
{% for slug, name in categories %}
<option value="{{ name }}"></option>
{% endfor %}
</datalist>
</div>
</div>
<div class="form-row">
<div class="form-group">
<label for="excerpt">Excerpt</label>
<input type="text" id="excerpt" name="excerpt" value="{{ (post or {}).get('excerpt', '') if post else '' }}" placeholder="Short summary shown on the homepage">
</div>
<div class="form-group">
<label for="tags">Tags</label>
<input type="text" id="tags" name="tags" value="{{ (post or {}).get('tags', '') if post else '' }}" placeholder="ai, selfhost, tips">
<span class="field-hint">Comma separated.</span>
</div>
</div>
<div class="form-group">
<label for="body">Body <span class="field-hint">(Rich text editor)</span></label>
<!-- Hidden field holds the stored HTML. TinyMCE loads it into #body-editor
on init and writes it back here on submit; the public pipeline passes
stored HTML straight through (render_markdown/to_html detect it). -->
<!-- forceescape is REQUIRED: body_html is Markup, so Jinja would emit
quotes unescaped and the first src="/..." would terminate the value
attribute, truncating the stored body. -->
<input type="hidden" id="body" name="body" value="{{ body_html|forceescape }}">
<div id="body-editor" class="tinymce-editor"></div>
</div>
<div class="form-row">
<div class="form-group">
<label for="status">Status</label>
<select id="status" name="status">
<option value="published" {% if post and post.status == 'published' %}selected{% endif %}>Published</option>
<option value="draft" {% if post and post.status == 'draft' %}selected{% endif %}>Draft</option>
</select>
</div>
<div class="form-group">
<label for="post_date">Post date</label>
<input type="date" id="post_date" name="post_date"
value="{{ post.created_at[:10] if post and post.created_at else request.form.get('post_date', '') }}">
<span class="field-hint">Shown on the post and used for ordering and archive months. Pick an earlier date to backdate it; leave blank for today.</span>
</div>
</div>
<p>
<button type="submit" class="btn btn-primary">Save</button>
{% if post %}<a class="btn" href="{{ preview_url(post) }}" target="_blank" rel="noreferrer">Preview</a>{% endif %}
<a class="btn" href="{{ url_for('admin.posts') }}">Cancel</a>
</p>
</form>
</div>
<script>
// TinyMCE: load stored HTML on init, write it back to #body on submit,
// and upload images to /admin/upload (multipart csrf_token form field).
document.addEventListener('DOMContentLoaded', function () {
var bodyField = document.getElementById('body');
console.log('[debug] editor init started; tinymce global defined:', !!(window.tinymce));
try {
tinymce.init({
// Community edition — no license key → no tin.cloud validation, works on any domain.
// Asset resolution uses TWO TinyMCE mechanisms (see static/tinymce.min.js):
// * base_url → drives plugins/icons/skins/langs (built as baseURL + "/plugins/..." etc.)
// * theme_url / model_url / icons_url → each asset's own URL, with a RELATIVE fallback
// when unset. On this subpath app the fallback would resolve against /admin/ and 404,
// so every non-base_url asset is given an explicit ABSOLUTE url.
// js_base (defined in base.html from request.host) makes these match however the
// app is reached — no hardcoded localhost, so it works on your LAN host too.
base_url: '{{ js_base }}',
theme_url: '{{ js_base }}/themes/silver/theme.min.js',
icons_url: '{{ js_base }}/icons/default/icons.min.js',
model_url: '{{ js_base }}/models/dom/model.min.js',
// Community Edition — license_key: 'gpl' agrees to the open-source terms so the bundled
// LicenseKeyManager plugin takes the 'use_gpl' path and does NOT request its own plugin
// file (plugins/licensekeymanager/plugin.min.js), which we don't serve and which 404s.
// NOTE: the config option is 'license_key' (underscore). TinyMCE does NOT read
// camelCase 'licenseKey', so that value would be silently ignored and the editor would
// be disabled. Free, works on ANY domain (no tiny.cloud validation, no Setup Partner bot).
license_key: 'gpl',
skin: 'oxide', // oxide SKIN provides BOTH the toolbar chrome AND content.min.css.
// NOTE: do NOT pair silver theme here — the silver theme looks for its own
// skins/content/silver/content.css (absent) and falls back to skins/content/default/...
// which 404s. The oxide skin is self-contained, so no separate theme is needed.
content_css: '/static/js/skins/ui/oxide/content.min.css',
selector: '#body-editor',
// NOTE: there is NO `initialData` option in TinyMCE (that's TipTap/
// ProseMirror). It is silently ignored -> the editor always opened
// empty, so editing an existing post showed no body. Set it explicitly
// once the editor instance exists.
init_instance_callback: function (editor) {
editor.setContent(bodyField ? bodyField.value : '');
},
// Keep stored image URLs as written (/static/uploads/...). Without
// this TinyMCE rewrites them relative to the CURRENT page (/admin/...),
// so a body saved on the edit page stored '../../static/uploads/...'.
convert_urls: false,
plugins: 'anchor autolink charmap codesample emoticons image link lists media searchreplace table visualblocks wordcount',
toolbar: 'undo redo | blocks fontfamily fontsize | bold italic underline strikethrough | link image media table | align lineheight | numlist bullist indent outdent | emoticons charmap | removeformat',
// NOTE: TinyMCE 8 calls this as (blobInfo, progress) and awaits the
// RETURNED PROMISE, which must resolve to the final URL string (or an
// object with .url). The old v5 (blobInfo, success, failure) callback
// form is gone: calling success(url) here hits the progress callback,
// the promise resolves to undefined, and TinyMCE throws
// "Cannot read properties of undefined (reading 'url')".
images_upload_handler: function (blobInfo) {
var f = blobInfo.blob();
// NOTE: use the MIME SUBTYPE (index 1), not the category (index 0).
// 'image/jpeg'.split('/')[0] === 'image' (matches no map key -> falls back to 'png'),
// which labels a JPEG as .png and fails the server's PNG signature check (400).
var type = (f.type || '').split('/')[1];
var ext = { png: 'png', jpg: 'jpg', jpeg: 'jpg', gif: 'gif', webp: 'webp' }[type] || 'png';
var fd = new FormData();
fd.append('file', f, 'tiny-image.' + ext);
var csrf = document.querySelector('[name="csrf_token"]');
if (csrf) fd.append('csrf_token', csrf.value);
return fetch('/admin/upload', { method: 'POST', body: fd })
.then(function (r) {
if (!r.ok) throw new Error('Upload failed: HTTP ' + r.status);
return r.json();
})
.then(function (d) {
if (!d || !d.url) throw new Error('Upload response had no url');
return d.url;
});
},
images_restricted_types: 'image/png,image/jpeg,image/gif,image/webp',
});
console.log('[debug] init returned; editors created:', tinymce.get().length, '| body-editor exists:', tinymce.get('body-editor') !== null);
// NOTE: bind to the editor's OWN form. document.querySelector('form')
// returned the logout form in the admin header (first form in the DOM),
// so this listener never ran for the post form: the editor's content was
// never copied into #body and every NEW post saved an empty body.
var form = bodyField ? bodyField.form : null;
if (form) {
form.addEventListener('submit', function () {
// NOTE: tinymce.get() takes an ELEMENT ID, not a CSS selector.
// tinymce.get('#body-editor') returns null -> .getContent() throws ->
// the old silent catch left #body empty, so every save stored no body.
var editor = tinymce.get('body-editor') || tinymce.activeEditor;
if (editor && bodyField) bodyField.value = editor.getContent();
});
}
} catch (e) {
console.error('[debug] editor init FAILED:', e);
}
});
</script>
{% endblock %}
+42
View File
@@ -0,0 +1,42 @@
{% extends "admin/base.html" %}
{% block admin_content %}
<div class="admin-panel">
<h1>Posts</h1>
<div class="admin-actions">
<a class="primary" href="{{ url_for('admin.post_new') }}">+ New post</a>
<a href="{{ url_for('admin.dashboard') }}">Dashboard</a>
</div>
<table class="admin-table">
<thead>
<tr>
<th>Title</th>
<th>Author</th>
<th>Category</th>
<th>Status</th>
<th>Created</th>
<th style="width:130px;">Actions</th>
</tr>
</thead>
<tbody>
{% for p in posts %}
<tr>
<td><a href="{{ url_for('public.post', slug=p.slug) }}">{{ p.title }}</a></td>
<td>{{ p.author }}</td>
<td>{{ p.category }}</td>
<td>{% if p.status == 'published' %}<span class="term">Published</span>{% else %}Draft{% endif %}</td>
<td>{{ parse_date(p.created_at) }}</td>
<td class="table-actions">
<a class="btn" href="{{ url_for('admin.post_edit', pid=p.id) }}">Edit</a>
<form method="post" action="{{ url_for('admin.post_delete', pid=p.id) }}" style="display:inline;" onsubmit="return confirm('Delete this post?');">
<input type="hidden" name="csrf_token" value="{{ csrf_token }}">
<button class="btn btn-danger" type="submit">Delete</button>
</form>
</td>
</tr>
{% else %}
<tr><td colspan="6" class="empty-state">No posts. Create your first post to get started.</td></tr>
{% endfor %}
</tbody>
</table>
</div>
{% endblock %}
+38
View File
@@ -0,0 +1,38 @@
{% extends "admin/base.html" %}
{% block admin_content %}
<div class="admin-panel">
<h1>Visitor history</h1>
<table class="admin-table">
<tbody>
<tr><th>Visitor ID</th><td><code>{{ visitor.visitor_id }}</code></td></tr>
<tr><th>Browser</th><td>{{ visitor.browser or "&mdash;" }}</td></tr>
<tr><th>Operating system</th><td>{{ visitor.os or "&mdash;" }}</td></tr>
<tr><th>Device</th><td>{{ visitor.device }}</td></tr>
<tr><th>Location</th><td>{% if visitor.city or visitor.country %}{% if visitor.country_code %}<span class="location-flag">{{ visitor.country_code|country_flag }}</span> {% endif %}{{ visitor.city or "—" }}{% if visitor.region %}, {{ visitor.region }}{% endif %}{% if visitor.country %}, {{ visitor.country }}{% endif %}{% if visitor.latitude is not none %} <span class="muted">({{ "%.2f"|format(visitor.latitude) }}, {{ "%.2f"|format(visitor.longitude) }})</span>{% endif %}{% else %}&mdash;{% endif %}</td></tr>
<tr><th>Source</th><td><span class="term">{{ visitor.source }}</span></td></tr>
<tr><th>Referrer domain</th><td>{{ visitor.referrer_domain or "direct (no referrer)" }}</td></tr>
<tr><th>Raw referrer</th><td>{{ visitor.referrer or "&mdash;" }}</td></tr>
<tr><th>First seen</th><td>{{ parse_date(visitor.first_seen) }}</td></tr>
<tr><th>Last seen</th><td>{{ parse_date(visitor.last_seen) }}</td></tr>
</tbody>
</table>
</div>
<div class="admin-panel">
<h2>Pages visited ({{ visits|length }})</h2>
<table class="admin-table">
<thead><tr><th>Page</th><th>Title</th><th>When</th></tr></thead>
<tbody>
{% for v in visits %}
<tr>
<td><code>{{ v.page_path }}</code></td>
<td>{{ v.title or "(untitled)" }}</td>
<td>{{ parse_date(v.timestamp) }}</td>
</tr>
{% else %}
<tr><td colspan="3" class="empty-state">This visitor has not visited any page yet.</td></tr>
{% endfor %}
</tbody>
</table>
</div>
{% endblock %}
+86
View File
@@ -0,0 +1,86 @@
{% extends "admin/base.html" %}
{% block admin_content %}
<div class="admin-panel">
<h1>Visitors</h1>
<p class="muted">Every tracked visitor. Click a row to see the pages they visited.</p>
<form method="get" action="{{ url_for('admin.visitors') }}" class="filter-form">
<label>
<span>Country</span>
<select name="country" id="country-filter">
<option value="">All countries</option>
{% for c in countries %}
<option value="{{ c.country_code }}" {% if c.country_code == selected_country %}selected{% endif %}>
{{ c.country_code|country_flag }} {{ c.country }} ({{ c.c }})
</option>
{% endfor %}
</select>
</label>
<label>
<span>City</span>
<select name="city" id="city-filter">
<option value="">All cities</option>
{% for city in cities %}
<option value="{{ city }}" {% if city == selected_city %}selected{% endif %}>{{ city }}</option>
{% endfor %}
</select>
</label>
<noscript><button type="submit" class="btn">Filter</button></noscript>
{% if selected_country or selected_city %}
<a class="btn" href="{{ url_for('admin.visitors') }}">Clear filters</a>
{% endif %}
<span class="muted">{{ rows|length }} shown</span>
</form>
<table class="admin-table">
<thead>
<tr>
<th>Visitor ID</th>
<th>Browser</th>
<th>OS</th>
<th>Device</th>
<th>Location</th>
<th>Source</th>
<th>Referrer domain</th>
<th>First seen</th>
<th>Last seen</th>
<th>Visits</th>
</tr>
</thead>
<tbody>
{% for r in rows %}
<tr>
<td><a href="{{ url_for('admin.visit_history', vid=r.visitor_id) }}"><code>{{ r.visitor_id }}</code></a></td>
<td>{{ r.browser or "&mdash;" }}</td>
<td>{{ r.os or "&mdash;" }}</td>
<td>{{ r.device }}</td>
<td>{% if r.city or r.country %}{% if r.country_code %}<span class="location-flag">{{ r.country_code|country_flag }}</span> {% endif %}{{ r.city or "—" }}{% if r.country %}<span class="muted">, {{ r.country }}</span>{% endif %}{% else %}&mdash;{% endif %}</td>
<td><span class="term">{{ r.source }}</span></td>
<td>{{ r.referrer_domain or "&mdash;" }}</td>
<td>{{ parse_date(r.first_seen) }}</td>
<td>{{ parse_date(r.last_seen) }}</td>
<td>{{ r.visits }}</td>
</tr>
{% else %}
<tr><td colspan="10" class="empty-state">No visitors match these filters.</td></tr>
{% endfor %}
</tbody>
</table>
</div>
<script>
(function () {
var country = document.getElementById("country-filter");
var city = document.getElementById("city-filter");
if (!country || !city) return;
// Changing country resets the city, otherwise a city that no longer
// belongs to the selection would keep filtering the table to zero rows.
country.addEventListener("change", function () {
city.value = "";
country.form.submit();
});
city.addEventListener("change", function () {
city.form.submit();
});
})();
</script>
{% endblock %}
+76
View File
@@ -0,0 +1,76 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>{% block title %}{{ site_title }}{% endblock %}</title>
<meta name="description" content="{% block meta_description %}{{ meta_description or site_tagline }}{% endblock %}">
<meta name="robots" content="{% block robots %}index, follow{% endblock %}">
<!-- Canonical + social-preview tags (rendered on every page). Paginated
listings keep their ?page= so page 2 doesn't canonicalise to page 1. -->
{% set page_arg = request.args.get('page') %}
<link rel="canonical" href="{{ request.url.split('?')[0] }}{% if page_arg and page_arg != '1' %}?page={{ page_arg }}{% endif %}">
<link rel="alternate" type="application/atom+xml" title="{{ site_title }}"
href="{{ url_for('public.feed') }}">
<meta property="og:type" content="{% block og_type %}website{% endblock %}">
<meta property="og:site_name" content="{{ site_title }}">
<meta property="og:title" content="{% block og_title %}{{ site_title }}{% endblock %}">
<meta property="og:description" content="{% block og_description %}{{ meta_description or site_tagline }}{% endblock %}">
<meta property="og:url" content="{{ request.url.split('?')[0] }}">
{% set social_image = og_image if og_image else header_image %}
{% if social_image %}
<meta property="og:image" content="{{ social_image }}">
{% endif %}
<meta name="twitter:card" content="{{ 'summary_large_image' if social_image else 'summary' }}">
<meta name="twitter:title" content="{% block twitter_title %}{{ site_title }}{% endblock %}">
<meta name="twitter:description" content="{% block twitter_description %}{{ meta_description or site_tagline }}{% endblock %}">
{% if social_image %}
<meta name="twitter:image" content="{{ social_image }}">
{% endif %}
<link rel="stylesheet" href="{{ url_for('static', filename='css/style.css') }}">
<!-- Admin-custom CSS, written by /admin/appearance and served as a static asset. -->
<link rel="stylesheet" href="{{ url_for('static', filename='css/custom.css') }}">
{% block head %}{% endblock %}
</head>
<body>
<header class="site-header">
<div class="header-inner {% if header_image %}has-banner{% endif %}">
{% if header_image %}
<img src="{{ header_image }}" class="site-banner-img" alt="{{ site_title }}">
{% endif %}
<div class="site-logo">
<a href="{{ url_for('public.index') }}">{{ site_title }}</a>
{% if site_tagline %}<span class="hero-tagline">{{ site_tagline }}</span>{% endif %}
</div>
<nav class="main-nav" aria-label="Main navigation">
<ul class="nav-links">
<li class="nav-item"><a href="{{ url_for('public.index') }}">Home</a></li>
<li class="nav-item"><a href="{{ url_for('public.photos_index') }}">Photos</a></li>
{% for p in pages %}
<li class="nav-item"><a href="{{ url_for('public.page', slug=p.slug) }}">{{ p.title }}</a></li>
{% endfor %}
</ul>
</nav>
</div>
</header>
<main class="site-main">
{% block content %}{% endblock %}
</main>
<footer class="site-footer">
<div class="footer-inner">
<span>&copy; {{ current_year() }}</span>
<span>Built with a simple CMS</span>
</div>
</footer>
<!-- (The old dropdown menu button/JS was removed; navigation is now simple
inline links shown directly in the header.) -->
<!-- Click any page image (incl. uploaded TinyMCE images) to view it full-size. -->
<script src="{{ url_for('static', filename='js/lightbox.js') }}"></script>
<!-- Full-album gallery viewer for /photos/<slug>. -->
<script src="{{ url_for('static', filename='js/gallery_lightbox.js') }}"></script>
</body>
</html>
+59
View File
@@ -0,0 +1,59 @@
<section class="comments-section" aria-label="Comments">
<h2 class="page-heading">Comments</h2>
{% if not comments_enabled %}
<p class="empty-state">Comments are closed.</p>
{% else %}
{% if comment_count > 0 %}
<p class="field-hint">{{ comment_count }} comment{{ 's' if comment_count != 1 }} so far.</p>
{% endif %}
{% if comments %}
<div class="comment-list">
{% for c in comments %}
<article class="comment-block" data-comment-id="{{ c.id }}">
<div class="comment-meta">
<span class="comment-author">{{ c.author }}</span>
<time datetime="{{ c.created_at }}">{{ parse_date(c.created_at) }}</time>
</div>
<div class="comment-body">{{ render_markdown(c.body) }}</div>
{% if logged_in and c.author == session.get('username') %}
<form method="post" action="{{ url_for('public.public_comment_delete', cid=c.id) }}" style="display:inline;" onsubmit="return confirm('Delete this comment?');">
<input type="hidden" name="csrf_token" value="{{ csrf_token }}">
<button class="btn btn-sm btn-danger" type="submit">Delete my comment</button>
</form>
{% endif %}
</article>
{% endfor %}
</div>
{% else %}
<p class="empty-state">No comments yet — be the first!</p>
{% endif %}
<form method="post" action="{% if object_type == 'post' %}{{ url_for('public.post_comment', slug=slug) }}{% else %}{{ url_for('public.page_comment', slug=slug) }}{% endif %}" class="comment-form">
<input type="hidden" name="csrf_token" value="{{ csrf_token }}">
{# Bot traps (hidden, no visual change): a field humans never fill in and
the time this page was rendered. #}
<div hidden aria-hidden="true">
<label for="c-website">Website</label>
<input type="text" id="c-website" name="website" tabindex="-1" autocomplete="off">
</div>
<input type="hidden" name="ts" value="{{ now_ts }}">
<div class="form-row">
<div class="form-group">
<label for="c-author">Name</label>
<input type="text" id="c-author" name="author" required autocomplete="name" placeholder="Your name">
</div>
<div class="form-group">
<label for="c-email">Email <small>(optional, not published)</small></label>
<input type="email" id="c-email" name="email" autocomplete="email" placeholder="you@example.com">
</div>
</div>
<div class="form-group">
<label for="c-body">Comment</label>
<textarea id="c-body" name="body" rows="4" required placeholder="Share your thoughts…"></textarea>
</div>
<button type="submit" class="btn-primary">Post comment</button>
</form>
{% endif %}
</section>
+135
View File
@@ -0,0 +1,135 @@
{% extends "base.html" %}
{% block title %}{% if page == 'tag' %}Tag: {{ tag_name }} &middot; {{ site_title }}{% elif page == 'category' %}Category: {{ category_name }} &middot; {{ site_title }}{% elif page == 'archive' %}{{ parse_date(month ~ '-01') }} &middot; {{ site_title }}{% else %}{{ site_title }}{% endif %}{% endblock %}
{% block meta_description %}{% if page == 'tag' %}Posts tagged &ldquo;{{ tag_name }}&rdquo; on {{ site_title }}.{% elif page == 'category' %}Posts in {{ category_name }} on {{ site_title }}.{% else %}{{ meta_description or site_tagline }}{% endif %}{% endblock %}
{% block head %}
{% if pagination and pagination.has_prev %}<link rel="prev" href="{{ pagination.prev_url }}">{% endif %}
{% if pagination and pagination.has_next %}<link rel="next" href="{{ pagination.next_url }}">{% endif %}
{% if page == 'tag' %}
<link rel="alternate" type="application/atom+xml" title="Tag: {{ tag_name }}"
href="{{ url_for('public.tag_feed', slug=tag_slug) }}">
{% endif %}
{% endblock %}
{% block content %}
{% if page == "category" %}
<h1 class="page-heading">Category: {{ category_name }}</h1>
{% elif page == "tag" %}
<h1 class="page-heading">Tag: {{ tag_name }}</h1>
{% elif page == "archive" %}
<h1 class="page-heading">{{ parse_date(month ~ '-01') }}</h1>
{% else %}
<h1 class="page-heading">Latest Posts</h1>
{% endif %}
<div class="content-area">
<section class="posts">
{% if posts %}
<div class="posts-grid">
{% for p in posts %}
<article class="post-card">
<h2>
<a href="{{ url_for('public.post', slug=p.slug) }}">{{ p.title }}</a>
</h2>
<div class="post-meta">
<span><strong>{{ parse_date(p.created_at) }}</strong></span>
<span>by {{ p.author }}</span>
</div>
{% if p.excerpt %}
<div class="post-excerpt">
{{ p.excerpt|replace("\n", "\n\n")|safe }}
</div>
{% endif %}
<div class="post-footer">
<div class="post-tax">
{% if p.category %}<span class="term">{{ p.category }}</span> &middot; {% endif %}
{% for t in p.tags|tag_list %}
<a class="term" href="{{ url_for('public.tag', slug=t.slug) }}">{{ t.name }}</a>
{% endfor %}
</div>
<a class="read-more" href="{{ url_for('public.post', slug=p.slug) }}">Read more &rarr;</a>
</div>
</article>
{% endfor %}
</div>
{% include "_pagination.html" %}
{% else %}
<p class="empty-state">No posts yet. Sign in to the admin area to add one.</p>
{% endif %}
</section>
<aside class="sidebar">
{# Link tree managed from /admin/links. Rendered only once at least one
link exists, so the panel never appears empty. #}
{% if sidebar.links %}
<div class="widget">
<h2 class="widget-title">Links</h2>
<ul>
{% for link in sidebar.links %}
<li>
{% if link.url.startswith('http') %}
<a href="{{ link.url }}" target="_blank" rel="noopener noreferrer">{{ link.label }}</a>
{% else %}
<a href="{{ link.url }}">{{ link.label }}</a>
{% endif %}
</li>
{% endfor %}
</ul>
</div>
{% endif %}
<div class="widget">
<h2 class="widget-title">Search</h2>
<form class="search-form" method="get" action="{{ url_for('public.search') }}">
<input type="search" name="q" placeholder="Search posts…" value="{{ query if query else '' }}" aria-label="Search">
<button type="submit">Search</button>
</form>
</div>
<div class="widget">
<h2 class="widget-title">Recent Posts</h2>
<ul>
{% for p in sidebar.recent %}
<li><a href="{{ url_for('public.post', slug=p.slug) }}">{{ p.title }}</a></li>
{% else %}
<li><span>No recent posts.</span></li>
{% endfor %}
</ul>
</div>
<div class="widget">
<h2 class="widget-title">Archives</h2>
<ul>
{# One link per month from a GROUP BY query, so pagination can't hide
older months the way deriving this from the current page's posts did. #}
{% for row in sidebar.months %}
<li><a href="{{ url_for('public.archive', month=row.month) }}">{{ parse_date(row.month ~ '-01') }}</a></li>
{% else %}
<li><span>No archives yet.</span></li>
{% endfor %}
</ul>
</div>
<div class="widget">
<h2 class="widget-title">Categories</h2>
<ul>
{% for slug, name in category_map.items() %}
<li><a href="{{ url_for('public.category', slug=slug) }}">{{ name }}</a></li>
{% endfor %}
</ul>
</div>
<div class="widget">
<h2 class="widget-title">Tags</h2>
<div class="tag-cloud">
{% for t in sidebar.tags %}
<a class="term" href="{{ url_for('public.tag', slug=t.slug) }}">{{ t.name }} <small>{{ t.count }}</small></a>
{% else %}
<span class="field-hint">No tags yet.</span>
{% endfor %}
</div>
{% if sidebar.tags %}<p class="field-hint"><a href="{{ url_for('public.tags') }}">All tags &rarr;</a></p>{% endif %}
</div>
</aside>
</div>
{% endblock %}
+26
View File
@@ -0,0 +1,26 @@
{% extends "base.html" %}
{% block title %}Sign in &middot; {{ site_title }}{% endblock %}
{% block content %}
<div class="admin-wrap" style="max-width:420px;">
<div class="admin-panel">
<h1 class="page-heading" style="font-size:1.6rem;">Admin</h1>
{% with messages = get_flashed_messages(with_categories=true) %}
{% for category, message in messages %}
<div class="notice notice-{{ category }}">{{ message }}</div>
{% endfor %}
{% endwith %}
<form method="post" action="{{ url_for('admin.admin_login') }}">
<input type="hidden" name="csrf_token" value="{{ csrf_token }}">
<div class="form-group">
<label for="password">Password</label>
<input type="password" id="password" name="password" autocomplete="current-password" maxlength="1024" autofocus required>
</div>
<button type="submit" class="btn btn-primary" style="width:100%;">Sign in</button>
</form>
<p style="font-size:0.85rem;color:var(--color-muted);margin-top:18px;">
<a href="{{ url_for('public.index') }}" style="color:var(--color-link);">← Back to site</a>
</p>
</div>
</div>
{% endblock %}
+25
View File
@@ -0,0 +1,25 @@
{% extends "base.html" %}
{% block title %}{{ page.title }} &middot; {{ site_title }}{% endblock %}
{% block og_title %}{{ page.title }}{% endblock %}
{% block og_description %}{{ page.title }} &middot; {{ site_title }}{% endblock %}
{% block twitter_title %}{{ page.title }}{% endblock %}
{% block twitter_description %}{{ page.title }} &middot; {{ site_title }}{% endblock %}
{% block content %}
<nav class="breadcrumb">
<a href="{{ url_for('public.index') }}">Home</a>
<span>&rsaquo;</span>
<span>{{ page.title }}</span>
</nav>
<article class="single-post">
<h1 class="page-heading">{{ page.title }}</h1>
<div class="entry-content">
{{ render_markdown(page.content) }}
</div>
</article>
{# comments.html renders its own <section> + "Comments" heading; wrapping it
here duplicated both. #}
{% include "comments.html" %}
{% endblock %}
+44
View File
@@ -0,0 +1,44 @@
{% extends "base.html" %}
{% block title %}{{ album.name }} &middot; {{ site_title }}{% endblock %}
{% block content %}
<nav class="breadcrumb">
<a href="{{ url_for('public.index') }}">Home</a>
<span>&rsaquo;</span>
<span>{{ album.name }}</span>
</nav>
<article class="single-post">
<h1 class="page-heading">{{ album.name }}</h1>
{% if album.description %}
<p class="lead">{{ album.description }}</p>
{% endif %}
{% if media %}
<!-- Random featured image; click it (or any thumbnail) to open the gallery lightbox. -->
<figure class="gallery-hero" id="gallery-hero">
<img class="gallery-hero-img" data-no-lightbox src="{{ media[0].url }}" alt="{{ album.name }}">
<figcaption class="hero-caption">{{ album.name }}</figcaption>
</figure>
<div class="gallery" style="display:grid;grid-template-columns:repeat(auto-fill,minmax(200px,1fr));gap:12px;">
{% for m in media %}
<img class="gallery-img" data-no-lightbox src="{{ m.thumb_url or m.url }}" data-src="{{ m.url }}" alt="" loading="lazy">
{% endfor %}
</div>
<!-- Gallery lightbox (populated by gallery_lightbox.js). -->
<div class="gallery-lightbox" id="gallery-lightbox" hidden>
<button type="button" class="lightbox-close" aria-label="Close gallery">&times;</button>
<header class="lightbox-header">{{ album.name }}</header>
<div class="lightbox-body">
<button type="button" class="lightbox-prev" aria-label="Previous photo">&#8249;</button>
<img class="lightbox-img-main" src="" alt="">
<button type="button" class="lightbox-next" aria-label="Next photo">&#8250;</button>
</div>
</div>
{% else %}
<p class="empty-state">This album has no photos yet.</p>
{% endif %}
</article>
{% endblock %}
+79
View File
@@ -0,0 +1,79 @@
{% extends "base.html" %}
{% block title %}{{ post.title }} &middot; {{ site_title }}{% endblock %}
{% block meta_description %}{{ post.excerpt or post.body|striptags|truncate(160, True, '…') }}{% endblock %}
{% block robots %}{% if preview %}noindex, nofollow{% else %}index, follow{% endif %}{% endblock %}
{% block og_type %}article{% endblock %}
{% block og_title %}{{ post.title }}{% endblock %}
{% block og_description %}{{ post.excerpt or post.body|striptags|truncate(160, True, '…') }}{% endblock %}
{% block twitter_title %}{{ post.title }}{% endblock %}
{% block twitter_description %}{{ post.excerpt or post.body|striptags|truncate(160, True, '…') }}{% endblock %}
{% block head %}
{# Structured data for search engines (head only — no visual change). #}
<script type="application/ld+json">
{
"@context": "https://schema.org",
"@type": "BlogPosting",
"headline": {{ post.title|tojson }},
"datePublished": {{ post.created_at|replace(' ', 'T')|tojson }},
"dateModified": {{ post.updated_at|replace(' ', 'T')|tojson }},
"author": {"@type": "Person", "name": {{ post.author|tojson }}},
{% if og_image %}"image": {{ og_image|tojson }},
{% endif %}"url": {{ request.url.split('?')[0]|tojson }}
}
</script>
{% endblock %}
{% block content %}
<nav class="breadcrumb">
<a href="{{ url_for('public.index') }}">Home</a>
<span>&rsaquo;</span>
<a href="{{ url_for('public.category', slug=cat_slug) }}">{{ post.category }}</a>
<span>&rsaquo;</span>
<span>{{ post.title }}</span>
</nav>
{% if preview %}
<div class="preview-banner">
<strong>Draft preview.</strong> This post is not public yet.
<a href="{{ url_for('admin.post_edit', pid=post.id) }}">Back to the editor</a>
</div>
{% endif %}
<article class="single-post">
<h1 class="post-title">{{ post.title }}</h1>
<div class="post-meta">
<span><strong>{{ parse_date(post.created_at) }}</strong></span>
<span>by {{ post.author }}</span>
{% if post.category %}<span>{{ post.category }}</span>{% endif %}
{% if post.tags %}<span>Tags: {% for t in post.tags|tag_list %}<a href="{{ url_for('public.tag', slug=t.slug) }}">{{ t.name }}</a>{% if not loop.last %}, {% endif %}{% endfor %}</span>{% endif %}
</div>
<div class="entry-content">
{{ render_markdown(post.body) }}
</div>
<div class="post-share">
Published on {{ parse_date(post.created_at) }} in {{ post.category }}.
</div>
</article>
{# comments.html renders its own <section> + "Comments" heading; wrapping it
here duplicated both. #}
{% if related %}
<section class="related-posts" aria-label="Related posts">
<h2 class="page-heading">{% if related_fallback %}More from the blog{% else %}Related posts{% endif %}</h2>
<div class="related-grid">
{% for r in related %}
<article class="related-card">
<h3><a href="{{ url_for('public.post', slug=r.slug) }}">{{ r.title }}</a></h3>
<div class="post-meta">
<span>{{ parse_date(r.created_at) }}</span>
{% if r.category %}<span>{{ r.category }}</span>{% endif %}
</div>
</article>
{% endfor %}
</div>
</section>
{% endif %}
{% if not preview %}{% include "comments.html" %}{% endif %}
{% endblock %}
+36
View File
@@ -0,0 +1,36 @@
{% extends "base.html" %}
{% block title %}Photos &middot; {{ site_title }}{% endblock %}
{% block content %}
<nav class="breadcrumb">
<a href="{{ url_for('public.index') }}">Home</a>
<span>&rsaquo;</span>
<span>Photos</span>
</nav>
<article class="single-post">
<h1 class="page-heading">Photos</h1>
{% if albums %}
<div class="gallery" style="display:grid;grid-template-columns:repeat(auto-fill,minmax(220px,1fr));gap:16px;">
{% for a in albums %}
<a class="album-card" href="{{ url_for('public.photos', slug=a.slug) }}">
{% if album_thumbs.get(a.id) %}
{# The whole card opens the album. Without data-no-lightbox the
page-wide single-image viewer swallowed this click and showed
only the preview photo instead of navigating to the gallery. #}
<img class="album-thumb" src="{{ album_thumbs.get(a.id) }}" alt="{{ a.name }}" loading="lazy" data-no-lightbox>
{% endif %}
<h2>{{ a.name }}</h2>
{% if a.description %}
<p class="lead">{{ a.description }}</p>
{% endif %}
<span class="album-count">{{ album_counts.get(a.id, 0) }} photo{{ '' if album_counts.get(a.id, 0) == 1 else 's' }}</span>
</a>
{% endfor %}
</div>
{% else %}
<p class="empty-state">No albums yet. Create one from the admin panel.</p>
{% endif %}
</article>
{% endblock %}
+37
View File
@@ -0,0 +1,37 @@
{% extends "base.html" %}
{% block title %}Search &middot; {{ site_title }}{% endblock %}
{% block meta_description %}Search {{ site_title }}.{% endblock %}
{% block robots %}noindex, follow{% endblock %}
{% block content %}
<h1 class="page-heading">Search</h1>
<form class="search-form" method="get" action="{{ url_for('public.search') }}">
<input type="search" name="q" placeholder="Search posts…" value="{{ query }}" aria-label="Search">
<button type="submit">Search</button>
</form>
{% if query %}
<h2 class="page-heading" style="font-size:1.3rem;">Results for &ldquo;{{ query }}&rdquo;</h2>
<div class="posts-grid">
{% for p in posts %}
<article class="post-card">
<h2><a href="{{ url_for('public.post', slug=p.slug) }}">{{ p.title }}</a></h2>
<div class="post-meta"><span><strong>{{ parse_date(p.created_at) }}</strong></span><span>by {{ p.author }}</span></div>
{% if p.excerpt %}<div class="post-excerpt">{{ p.excerpt|replace("\n", "\n\n")|safe }}</div>{% endif %}
<div class="post-footer">
<div class="post-tax">
{% if p.category %}<span class="term">{{ p.category }}</span> &middot; {% endif %}
{% for t in p.tags|tag_list %}
<a class="term" href="{{ url_for('public.tag', slug=t.slug) }}">{{ t.name }}</a>
{% endfor %}
</div>
<a class="read-more" href="{{ url_for('public.post', slug=p.slug) }}">Read more &rarr;</a>
</div>
</article>
{% else %}
<p class="empty-state">No posts matched &ldquo;{{ query }}&rdquo;.</p>
{% endfor %}
</div>
{% include "_pagination.html" %}
{% endif %}
{% endblock %}
+23
View File
@@ -0,0 +1,23 @@
{% extends "base.html" %}
{% block title %}Tags &middot; {{ site_title }}{% endblock %}
{% block meta_description %}Browse every topic on {{ site_title }}.{% endblock %}
{% block content %}
<nav class="breadcrumb">
<a href="{{ url_for('public.index') }}">Home</a>
<span>&rsaquo;</span>
<span>Tags</span>
</nav>
<h1 class="page-heading">Tags</h1>
{% if tag_index %}
<div class="tag-cloud tag-cloud-page">
{% for t in tag_index %}
<a class="term" href="{{ url_for('public.tag', slug=t.slug) }}">{{ t.name }} <small>{{ t.count }}</small></a>
{% endfor %}
</div>
{% else %}
<p class="empty-state">No tags yet. Add tags to a post from the editor.</p>
{% endif %}
{% endblock %}