- Add Jinja2 templates with data-testid attributes for testing - Create light/dark themes based on Gitea color scheme - Add theme switching with localStorage persistence - Create base CSS, components, and layout styles - Add mock web routes for UI demonstration - Register web router and static files in main.py - Add data-testid requirements to AGENTS.md - Install jinja2 dependency
100 lines
3.8 KiB
HTML
100 lines
3.8 KiB
HTML
{% extends "base.html" %}
|
|
|
|
{% block title %}{% if is_edit %}Edit Post{% else %}New Post{% endif %} - Blog{% endblock %}
|
|
|
|
{% block content %}
|
|
<section class="page-header" data-testid="page-header-form">
|
|
<h1 class="page-title" data-testid="page-title-form">
|
|
{% if is_edit %}Edit Post{% else %}Create New Post{% endif %}
|
|
</h1>
|
|
</section>
|
|
|
|
<form
|
|
method="POST"
|
|
action="{% if is_edit %}/posts/{{ post.id }}/edit{% else %}/posts/new{% endif %}"
|
|
class="card"
|
|
data-testid="form-post"
|
|
>
|
|
<div class="card-body" data-testid="form-post-body">
|
|
<div class="form-group" data-testid="form-group-title">
|
|
<label for="title" class="form-label form-label-required" data-testid="label-title">
|
|
Title
|
|
</label>
|
|
<input
|
|
type="text"
|
|
id="title"
|
|
name="title"
|
|
class="input input-lg"
|
|
value="{% if post %}{{ post.title.value }}{% endif %}"
|
|
placeholder="Enter post title"
|
|
required
|
|
data-testid="input-title"
|
|
>
|
|
<span class="form-hint" data-testid="hint-title">A catchy title for your post</span>
|
|
</div>
|
|
|
|
<div class="form-group" data-testid="form-group-content">
|
|
<label for="content" class="form-label form-label-required" data-testid="label-content">
|
|
Content
|
|
</label>
|
|
<textarea
|
|
id="content"
|
|
name="content"
|
|
class="textarea"
|
|
rows="12"
|
|
placeholder="Write your post content here..."
|
|
required
|
|
data-testid="textarea-content"
|
|
>{% if post %}{{ post.content.value }}{% endif %}</textarea>
|
|
<span class="form-hint" data-testid="hint-content">The main content of your post. Markdown is supported.</span>
|
|
</div>
|
|
|
|
<div class="form-group" data-testid="form-group-tags">
|
|
<label for="tags" class="form-label" data-testid="label-tags">
|
|
Tags
|
|
</label>
|
|
<input
|
|
type="text"
|
|
id="tags"
|
|
name="tags"
|
|
class="input"
|
|
value="{% if post %}{{ post.tags|join(', ') }}{% endif %}"
|
|
placeholder="python, fastapi, tutorial"
|
|
data-testid="input-tags"
|
|
>
|
|
<span class="form-hint" data-testid="hint-tags">Comma-separated list of tags</span>
|
|
</div>
|
|
|
|
<div class="form-group" data-testid="form-group-published">
|
|
<label class="form-label" data-testid="label-published">
|
|
<input
|
|
type="checkbox"
|
|
name="published"
|
|
value="true"
|
|
{% if post and post.published %}checked{% endif %}
|
|
data-testid="checkbox-published"
|
|
>
|
|
Publish immediately
|
|
</label>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="card-footer" data-testid="form-post-footer">
|
|
<div class="flex justify-between items-center" data-testid="form-actions">
|
|
<a href="{% if is_edit %}/posts/{{ post.id }}{% else %}/{% endif %}" class="btn" data-testid="btn-cancel">
|
|
Cancel
|
|
</a>
|
|
|
|
<div class="flex gap-2" data-testid="form-submit-actions">
|
|
<button type="submit" name="action" value="draft" class="btn" data-testid="btn-save-draft">
|
|
Save as Draft
|
|
</button>
|
|
<button type="submit" name="action" value="publish" class="btn btn-primary" data-testid="btn-publish-post">
|
|
{% if is_edit %}Update Post{% else %}Publish Post{% endif %}
|
|
</button>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</form>
|
|
{% endblock %}
|