Move every inline <script> block and on*= attribute out of the templates into per-page files under static/js/, then tighten the CSP to script-src 'self' so injected inline scripts are actually blocked. - static/js/base.js: QR modal, form[data-confirm] submit confirmation, and a shared glimmerCopy clipboard helper (loaded by base.html) - One script per template: index, bin_view, bin_token, admin, admin_edit, admin_bin, admin_bin_edit, admin_uploads - Template data now flows through data-* attributes (data-slug, data-filename, data-max-mb, ...) instead of being interpolated into JS; confirm() prompts use data-confirm - style-src keeps unsafe-inline for the style="" attributes - Update CLAUDE.md / AGENTS.md with the no-inline-JS rule Verified in a live browser session: shorten flow, login, QR modal, paste editor (token radios, name preview), paste cards (preview dialog, expand/close), public paste view, token prompt redirect, and uploads page - no console errors or CSP violations. Co-Authored-By: Claude Fable 5 <[email protected]>
48 lines
1.5 KiB
HTML
48 lines
1.5 KiB
HTML
{{define "title"}}Edit Link — Glimmer{{end}}
|
|
{{define "content"}}
|
|
|
|
<div class="page-header">
|
|
<div class="page-title">
|
|
<h1>Edit Link</h1>
|
|
<p>Update the slug or destination URL.</p>
|
|
</div>
|
|
<div class="page-actions">
|
|
<a href="/admin" class="btn btn-secondary">Back to list</a>
|
|
</div>
|
|
</div>
|
|
|
|
{{if .Error}}
|
|
<div class="alert alert-error">{{.Error}}</div>
|
|
{{end}}
|
|
|
|
{{with .Link}}
|
|
<div class="card" style="max-width: 640px;">
|
|
<form method="post" action="/admin/edit/{{.ID}}">
|
|
<input type="hidden" name="csrf_token" value="{{$.CSRFToken}}">
|
|
|
|
<div class="form-group">
|
|
<label for="slug" class="form-label">Slug</label>
|
|
<input type="text" id="slug" name="slug" value="{{.Slug}}" required pattern="[a-zA-Z0-9_-]+" title="Letters, numbers, hyphens, underscores only">
|
|
<small class="form-help">The short path users will visit: <code>/<span id="slug-preview">{{.Slug}}</span></code></small>
|
|
</div>
|
|
|
|
<div class="form-group">
|
|
<label for="url" class="form-label">Destination URL</label>
|
|
<input type="url" id="url" name="url" value="{{.URL}}" required>
|
|
</div>
|
|
|
|
<hr class="divider">
|
|
|
|
<div class="flex gap-1">
|
|
<button type="submit" class="btn btn-primary">Save changes</button>
|
|
<a href="/admin" class="btn btn-secondary">Cancel</a>
|
|
</div>
|
|
</form>
|
|
</div>
|
|
|
|
<script src="/static/js/admin_edit.js"></script>
|
|
{{else}}
|
|
<div class="alert alert-error">Link not found.</div>
|
|
{{end}}
|
|
{{end}}
|