Files
StarPunk/templates/admin/new.html
T
PhilandClaude Opus 5.5 978c13358b feat: article titles and summaries stored apart from the text (v2.16.0, ADR-076)
Articles as the IndieWeb defines them: a name separate from the content.

- Migration 023 adds notes.title and notes.summary. A one-time Python data
  step (migrations.DATA_MIGRATIONS) moves each note's '# Heading' first line
  into title, rewrites the file and hash, empties FTS for a rebuild, and puts
  files back if the migration fails. Trashed notes included.
- Micropub: name -> title, summary stored when sent with content, summary
  updatable, q=source returns both. MCP tools take a summary.
- Feeds: titles only for articles (RSS/JSON none, Atom empty); Atom and
  JSON Feed summaries; the title is no longer repeated in the content.
- Pages: p-name/p-summary on the article page. Homepage and tag pages show
  articles as title, summary and "Read more" without images (hidden u-photo
  keeps the post type for parsers).
- Crossposts: articles go out as title, summary, link and hashtags, no
  images; the Bluesky card is the article. Notes unchanged.
- Editor: Title and Summary fields; an article may have no body.
- Fix: a line starting with a hashtag ('#indieweb ...') was rendered as a
  heading and crossposted without its '#' (HashtagLineExtension).
- Fix: excerpts showed raw Markdown; they are plain text now.

Back up the database and the data folder before deploying: the migration
rewrites note files.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-11 17:05:38 -07:00

185 lines
5.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"><input type="hidden" name="csrf_token" value="{{ csrf_token() }}">
<div class="form-group">
<label for="title">Title (optional)</label>
<input type="text" id="title" name="title" value="" maxlength="200"
placeholder="Leave blank for a note; a title makes it an article">
</div>
<div class="form-group">
<label for="content">Content (Markdown)</label>
<textarea
id="content"
name="content"
rows="20"
placeholder="Write your note in markdown..."
autofocus
></textarea>
<small>Use Markdown syntax for formatting</small>
</div>
<div class="form-group">
<label for="summary">Summary (optional)</label>
<textarea id="summary" name="summary" rows="2"
placeholder="A sentence or two for the homepage, feeds and crossposts"></textarea>
<small>Articles only. Leave blank to use the start of the text.</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>
{% if syndication_targets %}
<input type="hidden" name="syndication_form" value="1">
<fieldset class="form-group">
<legend>Crosspost</legend>
{% for target in syndication_targets %}
<div class="form-checkbox">
<input type="checkbox" id="syndicate-{{ target.id }}" name="syndicate_to" value="{{ target.id }}" checked>
<label for="syndicate-{{ target.id }}">{{ target.name }}</label>
</div>
{% endfor %}
</fieldset>
{% endif %}
<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() }}
<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 %}