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>
162 lines
4.4 KiB
HTML
162 lines
4.4 KiB
HTML
{% extends "admin/base.html" %}
|
|
|
|
{% block title %}New Note - StarPunk Admin{% endblock %}
|
|
|
|
{% block admin_content %}
|
|
<div class="note-editor">
|
|
<h2>Create New Note</h2>
|
|
|
|
<form action="{{ url_for('admin.create_note_submit') }}" method="POST" enctype="multipart/form-data" class="note-form">
|
|
<div class="form-group">
|
|
<label for="content">Content (Markdown)</label>
|
|
<textarea
|
|
id="content"
|
|
name="content"
|
|
rows="20"
|
|
placeholder="Write your note in markdown..."
|
|
required
|
|
autofocus
|
|
></textarea>
|
|
<small>Use Markdown syntax for formatting</small>
|
|
</div>
|
|
|
|
<div class="form-group">
|
|
<label for="custom_slug">Custom Slug (optional)</label>
|
|
<input type="text"
|
|
id="custom_slug"
|
|
name="custom_slug"
|
|
pattern="[a-z0-9-]+"
|
|
placeholder="leave-blank-for-auto-generation"
|
|
class="form-control">
|
|
<small class="form-text text-muted">
|
|
Lowercase letters, numbers, and hyphens only.
|
|
Leave blank to auto-generate from content.
|
|
</small>
|
|
</div>
|
|
|
|
<div class="form-group">
|
|
<label for="media_files">Images (optional, max 4)</label>
|
|
<input type="file"
|
|
name="media_files"
|
|
id="media_files"
|
|
accept="image/jpeg,image/png,image/gif,image/webp"
|
|
multiple
|
|
class="form-control">
|
|
<small class="form-text text-muted">
|
|
JPEG, PNG, GIF, WebP only. Max 10MB per file, 4 images total.
|
|
Images will appear at the top of your note.
|
|
</small>
|
|
</div>
|
|
|
|
<!-- Preview area (filled via JavaScript after file selection) -->
|
|
<div id="media-preview" class="media-preview" style="display: none;"></div>
|
|
|
|
<div class="form-group">
|
|
<label for="tags">Tags</label>
|
|
<input type="text"
|
|
id="tags"
|
|
name="tags"
|
|
placeholder="Comma-separated tags (e.g., IndieWeb, Python, Thoughts)">
|
|
<small>Separate multiple tags with commas</small>
|
|
</div>
|
|
|
|
<div class="form-group form-checkbox">
|
|
<input type="checkbox" id="published" name="published" checked>
|
|
<label for="published">Publish immediately</label>
|
|
</div>
|
|
|
|
<div class="form-actions">
|
|
<button type="submit" class="button button-primary">Create Note</button>
|
|
<a href="{{ url_for('admin.dashboard') }}" class="button button-secondary">Cancel</a>
|
|
</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>
|
|
|
|
<style>
|
|
.media-preview {
|
|
display: grid;
|
|
grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
|
|
gap: 1rem;
|
|
margin: 1rem 0;
|
|
padding: 1rem;
|
|
background: #f5f5f5;
|
|
border-radius: 4px;
|
|
}
|
|
|
|
.media-preview-item {
|
|
border: 1px solid #ddd;
|
|
padding: 0.5rem;
|
|
border-radius: 4px;
|
|
background: white;
|
|
}
|
|
|
|
.media-preview-item img {
|
|
width: 100%;
|
|
height: auto;
|
|
display: block;
|
|
margin-bottom: 0.5rem;
|
|
border-radius: 2px;
|
|
}
|
|
|
|
.caption-input {
|
|
width: 100%;
|
|
padding: 0.5rem;
|
|
border: 1px solid #ddd;
|
|
border-radius: 4px;
|
|
font-size: 0.9rem;
|
|
}
|
|
</style>
|
|
|
|
<script>
|
|
// Media upload preview and caption handling
|
|
// Per Q3: Show preview after selection
|
|
// Per Q7: Allow caption input per image
|
|
document.addEventListener('DOMContentLoaded', function() {
|
|
const fileInput = document.getElementById('media_files');
|
|
const preview = document.getElementById('media-preview');
|
|
|
|
fileInput.addEventListener('change', function(e) {
|
|
const files = Array.from(e.target.files);
|
|
|
|
if (files.length === 0) {
|
|
preview.style.display = 'none';
|
|
preview.innerHTML = '';
|
|
return;
|
|
}
|
|
|
|
if (files.length > 4) {
|
|
alert('Maximum 4 images allowed');
|
|
e.target.value = '';
|
|
return;
|
|
}
|
|
|
|
preview.innerHTML = '';
|
|
preview.style.display = 'grid';
|
|
|
|
files.forEach((file, index) => {
|
|
const reader = new FileReader();
|
|
reader.onload = function(event) {
|
|
const div = document.createElement('div');
|
|
div.className = 'media-preview-item';
|
|
div.innerHTML = `
|
|
<img src="${event.target.result}" alt="Preview ${index + 1}">
|
|
<input type="text"
|
|
name="captions[]"
|
|
placeholder="Caption (optional)"
|
|
class="caption-input">
|
|
`;
|
|
preview.appendChild(div);
|
|
};
|
|
reader.readAsDataURL(file);
|
|
});
|
|
});
|
|
});
|
|
</script>
|
|
{% endblock %}
|