Replace Pico CSS with a custom Solis-style design system — warm amber
on cream, Outfit font, 260px sidebar (logged in) or sticky public
header (logged out), soft amber-tinted shadows, cubic-bezier spring
animations on toasts and modals.
- Add static/css/style.css with the full design token system
- Add base.html + content-block pattern; each page defines its own
{{define "content"}} and base.html provides the chrome
- pageData gains ActiveNav; adminPage(w, r, nav) sets it; handlers
pass the right value for every admin route
- Standalone pages (login, 404, embed) render without base.html
- Templates use Solis-style data-table, card, stats-bar, tag-pill,
alert, btn components
- Remove vendored Pico CSS (83KB) and the old style.css (12KB)
- Update AGENTS.md and CLAUDE.md to reflect the new design system
Bug fixes during the redesign:
- Preview dialog now only shows when [open] (UA default was being
overridden by display:flex)
- Preview dialog centered via explicit top/left/transform — the
browser's default margin:auto centering fights with display:flex
on <dialog>
- Add ?embed=1 route that renders paste content without base.html
chrome, so the admin paste preview iframe shows only the body
Tested: go build ./... clean, go vet ./... clean, binary boots.
164 lines
7.2 KiB
HTML
164 lines
7.2 KiB
HTML
{{define "title"}}Pastes — Admin{{end}}
|
|
{{define "content"}}
|
|
|
|
<div class="page-header">
|
|
<div class="page-title">
|
|
<h1>Pastes</h1>
|
|
<p>{{len .Pastes}} paste{{if ne (len .Pastes) 1}}s{{end}} — Markdown & plain text, optionally token-protected.</p>
|
|
</div>
|
|
<div class="page-actions">
|
|
<a href="/admin/bin/new" class="btn btn-primary">
|
|
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" style="width:18px;height:18px"><path stroke-linecap="round" stroke-linejoin="round" d="M12 4.5v15m7.5-7.5h-15"/></svg>
|
|
New Paste
|
|
</a>
|
|
</div>
|
|
</div>
|
|
|
|
{{if .Error}}
|
|
<div class="alert alert-error">{{.Error}}</div>
|
|
{{end}}
|
|
|
|
{{if .Pastes}}
|
|
<div class="paste-grid">
|
|
{{range .Pastes}}
|
|
<article class="paste-card js-preview" data-name="{{.Name}}" data-token="{{.Token}}" data-title="{{if .Title}}{{.Title}}{{else}}{{.Name}}{{end}}">
|
|
{{if .ThumbURL}}
|
|
<div class="paste-card-thumb">
|
|
<img src="{{.ThumbURL}}" alt="" loading="lazy">
|
|
</div>
|
|
{{else}}
|
|
<div class="paste-card-thumb">
|
|
<span class="paste-card-thumb-empty">{{.Format}}</span>
|
|
</div>
|
|
{{end}}
|
|
<div class="paste-card-body">
|
|
<h3 class="paste-card-title">{{if .Title}}{{.Title}}{{else}}{{.Name}}{{end}}</h3>
|
|
{{if .Summary}}<p class="paste-card-summary">{{.Summary}}</p>{{end}}
|
|
<div class="paste-card-meta">
|
|
<span class="tag-pill badge-format">{{.Format}}</span>
|
|
{{if .Token}}
|
|
<span class="tag-pill badge-token">🔒</span>
|
|
{{else}}
|
|
<span class="tag-pill badge-public">public</span>
|
|
{{end}}
|
|
{{if .Hidden}}<span class="tag-pill badge-hidden">hidden</span>{{end}}
|
|
<span class="paste-card-date">{{.UpdatedAt.Format "01-02 15:04"}}</span>
|
|
</div>
|
|
</div>
|
|
<div class="paste-card-actions">
|
|
<button type="button" class="btn btn-secondary btn-sm" onclick="event.stopPropagation();copyPasteLink('{{.Name}}','{{.Token}}', this)">Copy link</button>
|
|
<a href="/admin/bin/edit/{{.ID}}" class="btn btn-secondary btn-sm" onclick="event.stopPropagation()">Edit</a>
|
|
<button type="button" class="btn btn-secondary btn-sm" onclick="event.stopPropagation();showBinQR('{{.Name}}', false)">QR</button>
|
|
<form method="post" action="/admin/bin/delete/{{.ID}}" style="display:inline" onsubmit="return confirm('Delete paste {{.Name}}?')">
|
|
<input type="hidden" name="csrf_token" value="{{$.CSRFToken}}">
|
|
<button type="submit" class="btn btn-danger btn-sm">Del</button>
|
|
</form>
|
|
</div>
|
|
</article>
|
|
{{end}}
|
|
</div>
|
|
{{else}}
|
|
<div class="card">
|
|
<div class="empty-state">
|
|
<span class="empty-state-icon">📄</span>
|
|
<p class="empty-state-text">No pastes yet.</p>
|
|
<a href="/admin/bin/new" class="btn btn-primary empty-state-action">Create your first paste</a>
|
|
</div>
|
|
</div>
|
|
{{end}}
|
|
|
|
<!-- Paste preview dialog -->
|
|
<dialog id="preview-dialog" class="preview-dialog">
|
|
<div class="preview-head">
|
|
<span class="preview-title" id="preview-title">Preview</span>
|
|
<div class="preview-actions">
|
|
<a id="preview-open" href="#" target="_blank" rel="noopener" class="btn btn-secondary btn-sm">Open ↗</a>
|
|
<button type="button" class="btn btn-secondary btn-sm" id="preview-expand" onclick="toggleExpand()" aria-label="Expand">⤢</button>
|
|
<button type="button" class="btn btn-secondary btn-sm" onclick="closePreview()" aria-label="Close">✕</button>
|
|
</div>
|
|
</div>
|
|
<iframe id="preview-frame" class="preview-frame" src="about:blank" title="Paste preview"></iframe>
|
|
</dialog>
|
|
|
|
<script>
|
|
function previewURL(name, token) {
|
|
var u = '/bin/' + encodeURIComponent(name);
|
|
if (token) u += '/' + encodeURIComponent(token);
|
|
return u;
|
|
}
|
|
|
|
function openPreview(name, token, title) {
|
|
var dlg = document.getElementById('preview-dialog');
|
|
var fullURL = previewURL(name, token);
|
|
// iframe uses the embed view so it strips the sidebar / header / toolbar —
|
|
// only the paste body is rendered inside the dialog.
|
|
var embedURL = fullURL + '?embed=1';
|
|
document.getElementById('preview-frame').src = embedURL;
|
|
// The "Open ↗" link goes to the full URL (with chrome) so a new tab shows the
|
|
// normal public page.
|
|
document.getElementById('preview-open').href = fullURL;
|
|
document.getElementById('preview-title').textContent = title || name;
|
|
dlg.classList.remove('expanded');
|
|
document.getElementById('preview-expand').innerHTML = '⤢';
|
|
document.getElementById('preview-expand').setAttribute('aria-label', 'Expand');
|
|
dlg.showModal();
|
|
}
|
|
|
|
function closePreview() {
|
|
document.getElementById('preview-dialog').close();
|
|
}
|
|
|
|
function toggleExpand() {
|
|
var dlg = document.getElementById('preview-dialog');
|
|
var expanded = dlg.classList.toggle('expanded');
|
|
var btn = document.getElementById('preview-expand');
|
|
btn.innerHTML = expanded ? '⤡' : '⤢';
|
|
btn.setAttribute('aria-label', expanded ? 'Shrink' : 'Expand');
|
|
}
|
|
|
|
function copyPasteLink(name, token, btn) {
|
|
var url = location.origin + previewURL(name, token);
|
|
var orig = btn.textContent;
|
|
navigator.clipboard.writeText(url).then(function() {
|
|
btn.textContent = 'Copied!';
|
|
setTimeout(function() { btn.textContent = orig; }, 1500);
|
|
});
|
|
}
|
|
|
|
function showBinQR(name, full) {
|
|
var url = location.origin + '/bin/' + encodeURIComponent(name);
|
|
var fetchUrl = '/admin/bin/qr/' + encodeURIComponent(name);
|
|
if (full) fetchUrl += '?full=1';
|
|
var overlay = document.getElementById('qr-modal-overlay');
|
|
document.getElementById('qr-modal-image').src = fetchUrl;
|
|
document.getElementById('qr-modal-link').textContent = url + (full ? ' (with token)' : '');
|
|
var dl = document.getElementById('qr-modal-download');
|
|
dl.href = fetchUrl;
|
|
dl.download = name + '_QR.svg';
|
|
overlay.classList.add('show');
|
|
}
|
|
|
|
// Click on paste card opens preview, except when clicking action buttons
|
|
document.querySelectorAll('.js-preview').forEach(function(el) {
|
|
el.addEventListener('click', function(e) {
|
|
if (e.target.closest('.paste-card-actions')) return;
|
|
if (e.target.closest('a, button, form, input')) return;
|
|
openPreview(el.dataset.name, el.dataset.token, el.dataset.title);
|
|
});
|
|
el.setAttribute('tabindex', '0');
|
|
el.setAttribute('role', 'button');
|
|
el.addEventListener('keydown', function(e) {
|
|
if ((e.key === 'Enter' || e.key === ' ') && !e.target.closest('.paste-card-actions')) {
|
|
e.preventDefault();
|
|
openPreview(el.dataset.name, el.dataset.token, el.dataset.title);
|
|
}
|
|
});
|
|
});
|
|
|
|
// Clear iframe when dialog closes
|
|
document.getElementById('preview-dialog').addEventListener('close', function() {
|
|
document.getElementById('preview-frame').src = 'about:blank';
|
|
});
|
|
</script>
|
|
{{end}}
|