Files
StarPunk/templates/admin/edit.html
Phil Skentelbery 372064b116 feat(tags): Add tag archive route and admin interface integration
Implement Phase 3 of v1.3.0 tags feature per microformats-tags-design.md:

Routes (starpunk/routes/public.py):
- Add /tag/<tag> archive route with normalization and 404 handling
- Pre-load tags in index route for all notes
- Pre-load tags in note route for individual notes

Admin (starpunk/routes/admin.py):
- Parse comma-separated tag input in create route
- Parse tag input in update route
- Pre-load tags when displaying edit form
- Empty tag field removes all tags

Templates:
- Add tag input field to templates/admin/edit.html
- Add tag input field to templates/admin/new.html
- Use Jinja2 map filter to display existing tags

Implementation details:
- Tag URL parameter normalized to lowercase before lookup
- Tags pre-loaded using object.__setattr__ pattern (like media)
- parse_tag_input() handles trim, dedupe, normalization
- All existing tests pass (micropub categories, admin routes)

Per architect design:
- No pagination on tag archives (acceptable for v1.3.0)
- No autocomplete in admin (out of scope)
- Follows existing media loading patterns

Generated with Claude Code

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-10 11:42:16 -07:00

72 lines
2.5 KiB
HTML

{% extends "admin/base.html" %}
{% block title %}Edit Note - StarPunk Admin{% endblock %}
{% block admin_content %}
<div class="note-editor">
<h2>Edit Note</h2>
<p class="note-meta">
Slug: <code>{{ note.slug }}</code> |
Created: {{ note.created_at.strftime('%B %d, %Y at %I:%M %p') }}
</p>
<form action="{{ url_for('admin.update_note_submit', note_id=note.id) }}" method="POST" class="note-form">
<div class="form-group">
<label for="content">Content (Markdown)</label>
<textarea
id="content"
name="content"
rows="20"
required
autofocus
>{{ note.content }}</textarea>
<small>Use Markdown syntax for formatting</small>
</div>
<div class="form-group">
<label for="slug">Slug (permanent)</label>
<input type="text"
id="slug"
name="slug"
value="{{ note.slug }}"
readonly
class="form-control"
disabled>
<small class="form-text text-muted">
Slugs cannot be changed after creation to preserve permalinks.
</small>
</div>
<div class="form-group">
<label for="tags">Tags</label>
<input type="text"
id="tags"
name="tags"
value="{{ note.tags|map(attribute='display_name')|join(', ') if note.tags else '' }}"
placeholder="Comma-separated tags (e.g., IndieWeb, Python, Thoughts)">
<small>Separate multiple tags with commas. Leave blank to remove all tags.</small>
</div>
<div class="form-group form-checkbox">
<input type="checkbox" id="published" name="published" {% if note.published %}checked{% endif %}>
<label for="published">Published</label>
</div>
<div class="form-actions">
<button type="submit" class="button button-primary">Update Note</button>
<a href="{{ url_for('admin.dashboard') }}" class="button button-secondary">Cancel</a>
<form action="{{ url_for('admin.delete_note_submit', note_id=note.id) }}" method="POST" class="delete-form" style="display: inline;" onsubmit="return confirm('Are you sure you want to delete this note? This cannot be undone.');">
<input type="hidden" name="confirm" value="yes">
<button type="submit" class="button button-danger">Delete Note</button>
</form>
</div>
</form>
</div>
{% endblock %}
{% block head %}
{{ super() }}
<script src="https://cdn.jsdelivr.net/npm/marked/marked.min.js"></script>
<script src="{{ url_for('static', filename='js/preview.js') }}"></script>
{% endblock %}