Add tags and tag-based stream filtering

Implements tag management (create/delete) and per-article tagging with
a freeform "add tag" input that creates the tag on first use instead
of requiring a separate create-then-assign flow. Tags render as pills
in the stream header; clicking one filters the stream to articles
carrying that tag, combinable with the existing read/starred/saved
filters.

The "Saved" filter already added in the reading-UI milestone functions
as the reading list, so this closes out the reading-list/tags
milestone without a separate dedicated view.

Verified live in-browser: creating a tag from an article, the pill
appearing in the stream nav, filtering by it, and deleting it from the
tag-management page, all via htmx without full page reloads.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
ksmithandClaude Sonnet 5 committed 2026-10-30 16:26:30 -06:00
1 parent 69e3520e3b
commit 579696efc0
12 files changed
+386 -5

No files matched your search

+26
View File
@@ -0,0 +1,26 @@
<div id="article-tags-{{ article.pk }}" class="article-tags">
{% for tag in tags %}
<span class="tag-pill" {% if tag.color %}style="--tag-color: {{ tag.color }};"{% endif %}>
{{ tag.name }}
<button
hx-post="{% url 'articles:remove_tag_from_article' article.pk tag.pk %}"
hx-target="#article-tags-{{ article.pk }}"
hx-swap="outerHTML"
class="tag-remove" title="Remove tag">&times;</button>
</span>
{% endfor %}
<form
hx-post="{% url 'articles:add_tag_to_article' article.pk %}"
hx-target="#article-tags-{{ article.pk }}"
hx-swap="outerHTML"
class="add-tag-form">
<input type="text" name="tag_name" placeholder="Add tag" list="user-tags-{{ article.pk }}" maxlength="100">
<button type="submit" class="icon-btn">Add</button>
</form>
<datalist id="user-tags-{{ article.pk }}">
{% for tag in all_user_tags %}
<option value="{{ tag.name }}">
{% endfor %}
</datalist>
</div>
+28
View File
@@ -0,0 +1,28 @@
{% extends "base.html" %}
{% block title %}Tags — Evection{% endblock %}
{% block content %}
<p><a href="{% url 'reader:stream' %}">&larr; Back to stream</a></p>
<h1>Tags</h1>
<ul class="tag-manage-list">
{% for tag in tags %}
<li>
<a href="{% url 'reader:stream' %}?tag={{ tag.pk }}" class="tag-pill"
{% if tag.color %}style="--tag-color: {{ tag.color }};"{% endif %}>{{ tag.name }}</a>
<form method="post" action="{% url 'articles:delete_tag' tag.pk %}" class="inline-form">
{% csrf_token %}
<button type="submit" class="icon-btn">Delete</button>
</form>
</li>
{% empty %}
<li class="empty-state">No tags yet.</li>
{% endfor %}
</ul>
<h2>New tag</h2>
<form method="post">
{% csrf_token %}
{{ form.as_p }}
<button type="submit">Create</button>
</form>
{% endblock %}
+2 -2
View File
@@ -8,9 +8,9 @@
<nav class="pagination">
{% if has_previous_page %}
<a href="?filter={{ active_filter }}&page={{ page|add:"-1" }}">&larr; Newer</a>
<a href="?filter={{ active_filter }}{% if active_tag %}&tag={{ active_tag.pk }}{% endif %}&page={{ page|add:"-1" }}">&larr; Newer</a>
{% endif %}
{% if has_next_page %}
<a href="?filter={{ active_filter }}&page={{ page|add:"1" }}">Older &rarr;</a>
<a href="?filter={{ active_filter }}{% if active_tag %}&tag={{ active_tag.pk }}{% endif %}&page={{ page|add:"1" }}">Older &rarr;</a>
{% endif %}
</nav>
+6
View File
@@ -13,6 +13,12 @@
{% include "reader/_article_actions.html" %}
<div
id="article-tags-{{ article.pk }}"
hx-get="{% url 'articles:article_tags_partial' article.pk %}"
hx-trigger="load"
hx-swap="outerHTML"></div>
<div class="article-content">
{{ article.content_html|safe }}
</div>
+11 -1
View File
@@ -5,15 +5,25 @@
<h1>Evection</h1>
<nav class="top-nav">
<a href="{% url 'feeds:add_feed' %}">Add feed</a>
<a href="{% url 'articles:tag_list' %}">Tags</a>
<a href="{% url 'accounts:logout' %}">Log out</a>
</nav>
</header>
<nav class="filter-tabs">
{% for key, label in filters %}
<a href="?filter={{ key }}" class="{% if active_filter == key %}active{% endif %}">{{ label }}</a>
<a href="?filter={{ key }}" class="{% if active_filter == key and not active_tag %}active{% endif %}">{{ label }}</a>
{% endfor %}
</nav>
{% if user_tags %}
<nav class="tag-tabs">
{% for tag in user_tags %}
<a href="?filter={{ active_filter }}&tag={{ tag.pk }}" class="tag-pill{% if active_tag.pk == tag.pk %} active{% endif %}"
{% if tag.color %}style="--tag-color: {{ tag.color }};"{% endif %}>{{ tag.name }}</a>
{% endfor %}
</nav>
{% endif %}
{% include "reader/_article_list.html" %}
{% endblock %}