122 lines
4.0 KiB
HTML
122 lines
4.0 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="en" data-theme="dark">
|
|
<head>
|
|
<link rel="icon" type="image/x-icon" href="/static/favicon.ico">
|
|
<meta charset="utf-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
<title>Pastes — Admin</title>
|
|
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@picocss/pico@2/css/pico.min.css">
|
|
<link rel="stylesheet" href="/static/style.css">
|
|
</head>
|
|
<body>
|
|
<nav>
|
|
<ul><li><strong><a href="/">Glimmer</a></strong></li></ul>
|
|
<ul>
|
|
<li><a href="/">Home</a></li>
|
|
<li>
|
|
<form method="post" action="/admin/logout" style="margin:0">
|
|
<input type="hidden" name="csrf_token" value="{{$.CSRFToken}}">
|
|
<button type="submit" class="outline secondary btn-sm">Logout</button>
|
|
</form>
|
|
</li>
|
|
</ul>
|
|
</nav>
|
|
<div class="admin-tabs">
|
|
<a href="/admin" class="tab-link">Links</a>
|
|
<a href="/admin/bin" class="tab-link active">Pastes</a>
|
|
</div>
|
|
<main class="container" style="max-width:960px">
|
|
{{if .Error}}
|
|
<article aria-label="error" class="alert-error">{{.Error}}</article>
|
|
{{end}}
|
|
|
|
<article class="card-table">
|
|
<div class="section-header">
|
|
<hgroup>
|
|
<h2>Pastes</h2>
|
|
<p>{{len .Pastes}} pastes</p>
|
|
</hgroup>
|
|
<a href="/admin/bin/new" role="button" class="btn-sm">+ New Paste</a>
|
|
</div>
|
|
<figure>
|
|
<table role="grid">
|
|
<thead>
|
|
<tr>
|
|
<th>Name</th>
|
|
<th>Title</th>
|
|
<th>Format</th>
|
|
<th>Token</th>
|
|
<th>Updated</th>
|
|
<th>Actions</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
{{range .Pastes}}
|
|
<tr>
|
|
<td><a href="/bin/{{.Name}}{{if .Token}}/{{.Token}}{{end}}" target="_blank">{{.Name}}</a></td>
|
|
<td>{{.Title}}</td>
|
|
<td><mark class="badge-format">{{.Format}}</mark></td>
|
|
<td>{{if .Token}}<mark class="badge-token">🔒 token</mark>{{else}}<mark class="badge-public">public</mark>{{end}}{{if .Hidden}} <mark class="badge-hidden">hidden</mark>{{end}}</td>
|
|
<td>{{.UpdatedAt.Format "2006-01-02 15:04"}}</td>
|
|
<td>
|
|
<div role="group">
|
|
<a href="/admin/bin/edit/{{.ID}}" role="button" class="outline">Edit</a>
|
|
<button type="button" class="outline" onclick="showBinQR('{{.Name}}', false)">QR</button>
|
|
{{if .Token}}<button type="button" class="outline" onclick="showBinQR('{{.Name}}', true)">Full QR</button>{{end}}
|
|
<form method="post" action="/admin/bin/delete/{{.ID}}" onsubmit="return confirm('Delete paste {{.Name}}?')">
|
|
<input type="hidden" name="csrf_token" value="{{$.CSRFToken}}">
|
|
<button type="submit" class="outline secondary">Del</button>
|
|
</form>
|
|
</div>
|
|
</td>
|
|
</tr>
|
|
{{else}}
|
|
<tr>
|
|
<td colspan="6">
|
|
<div class="empty-state">
|
|
<span class="empty-icon">📄</span>
|
|
<p>No pastes yet.</p>
|
|
<a href="/admin/bin/new">Create your first paste</a>
|
|
</div>
|
|
</td>
|
|
</tr>
|
|
{{end}}
|
|
</tbody>
|
|
</table>
|
|
</figure>
|
|
</article>
|
|
</main>
|
|
<dialog id="qr-dialog">
|
|
<article>
|
|
<header>
|
|
<button aria-label="Close" rel="prev" onclick="document.getElementById('qr-dialog').close()"></button>
|
|
<h3 id="qr-title">QR Code</h3>
|
|
</header>
|
|
<div id="qr-container" style="text-align:center"></div>
|
|
</article>
|
|
</dialog>
|
|
<script>
|
|
function showBinQR(name, full) {
|
|
var container = document.getElementById('qr-container');
|
|
var title = document.getElementById('qr-title');
|
|
container.innerHTML = '<p>Loading...</p>';
|
|
title.textContent = full ? 'Full QR Code (with token)' : 'QR Code';
|
|
document.getElementById('qr-dialog').showModal();
|
|
var url = '/admin/bin/qr/' + encodeURIComponent(name);
|
|
if (full) url += '?full=1';
|
|
fetch(url)
|
|
.then(function(r) { return r.text(); })
|
|
.then(function(svg) {
|
|
var fullLink = location.origin + '/bin/' + name;
|
|
var note = '';
|
|
if (full) {
|
|
note = '<small style="color:var(--pico-muted-color)">(includes access token)</small>';
|
|
}
|
|
container.innerHTML = svg +
|
|
'<p style="margin-top:0.5rem;word-break:break-all">' + fullLink + '</p>' + note;
|
|
});
|
|
}
|
|
</script>
|
|
</body>
|
|
</html>
|