Add OPML import/export and a subscriptions management page

Implements OPML parsing with defusedxml (untrusted upload, XXE risk)
and export with the stdlib's plain ElementTree (trusted, app-generated
output). Nesting deeper than one level flattens into its nearest
enclosing folder, matching the app's flat-folder model. Import reuses
existing Feed/Subscription rows via get_or_create, so re-importing the
same file is idempotent and cross-user Feed dedup is preserved.

Large imports (>50 entries) dispatch to a Celery task instead of
blocking the request; newly imported feeds aren't fetched immediately
since they have no last_fetched_at, so the next poll_due_feeds beat
cycle picks them up naturally.

Adds a Subscriptions page (replacing the standalone "Add feed" link in
nav) listing current subscriptions with unsubscribe, plus Import/
Export OPML actions.

Verified live: imported a 2-feed/1-folder OPML file against the
running dev server (via an authenticated session, since this browser
tool has no file-picker automation), confirmed the resulting
subscriptions and folder in the UI, exported and inspected the
resulting OPML structure, and unsubscribed from one feed.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
ksmithandClaude Sonnet 5 committed 2026-10-30 16:41:18 -06:00
1 parent 8653dbeaf9
commit ea214dd9ce
11 files changed
+533 -3

No files matched your search

+12
View File
@@ -0,0 +1,12 @@
{% extends "base.html" %}
{% block title %}Import OPML — Evection{% endblock %}
{% block content %}
<p><a href="{% url 'feeds:subscription_list' %}">&larr; Back to subscriptions</a></p>
<h1>Import OPML</h1>
<p>Upload an OPML file exported from FreshRSS or another feed reader.</p>
<form method="post" enctype="multipart/form-data">
{% csrf_token %}
{{ form.as_p }}
<button type="submit">Import</button>
</form>
{% endblock %}
+29
View File
@@ -0,0 +1,29 @@
{% extends "base.html" %}
{% block title %}Subscriptions — Evection{% endblock %}
{% block content %}
<p><a href="{% url 'reader:stream' %}">&larr; Back to stream</a></p>
<h1>Subscriptions</h1>
<p>
<a href="{% url 'feeds:add_feed' %}">Add feed</a>
&middot; <a href="{% url 'feeds:import_opml' %}">Import OPML</a>
&middot; <a href="{% url 'feeds:export_opml' %}">Export OPML</a>
</p>
<ul class="subscription-list">
{% for subscription in subscriptions %}
<li class="subscription-row">
<div>
<strong>{{ subscription.display_title }}</strong>
{% if subscription.folder %}<span class="rule-summary">{{ subscription.folder.name }}</span>{% endif %}
</div>
<form method="post" action="{% url 'feeds:unsubscribe' subscription.pk %}" class="inline-form">
{% csrf_token %}
<button type="submit" class="icon-btn">Unsubscribe</button>
</form>
</li>
{% empty %}
<li class="empty-state">No subscriptions yet.</li>
{% endfor %}
</ul>
{% endblock %}
+1 -1
View File
@@ -4,7 +4,7 @@
<header class="stream-header">
<h1>Evection</h1>
<nav class="top-nav">
<a href="{% url 'feeds:add_feed' %}">Add feed</a>
<a href="{% url 'feeds:subscription_list' %}">Subscriptions</a>
<a href="{% url 'articles:tag_list' %}">Tags</a>
<a href="{% url 'rules:rule_list' %}">Rules</a>
<a href="{% url 'search:search' %}">Search</a>