Private
Public Access
Rebuild the reader UI to match FreshRSS's two-column layout
The previous UI was plain unstyled lists. Rebuilt around what FreshRSS actually looks like (per reference screenshots): a persistent left sidebar (folders/feeds with unread counts, favourites, tags) and a single main column with a date-grouped article list, where clicking a title expands the full article inline in place rather than navigating to a separate page. - apps/core/context_processors.py: feeds the sidebar's folder/feed tree, tags, and starred count to every authenticated page in one shared query set, so base.html can render it without each view wiring it up. - apps/reader/views.py: date-grouped stream (itertools.groupby over the already-ordered queryset), ?feed=/?folder= scoping alongside the existing ?tag=, a bulk mark-all-read endpoint (bulk_create/update, not one UserArticleState per article), and article_inline — the htmx endpoint behind the inline expand, sharing its mark-read logic with the full article_detail view via _load_article_and_mark_read. - templates/reader/_article_inline.html returns the article content plus an out-of-band swap of _article_actions.html, so the row's read/star icons update immediately when an article is expanded and marked read. - static/js/stream.js: the accordion toggle (one article open at a time), calling htmx.ajax() directly rather than hx-* attributes so a second click on an already-open row can collapse it without re-fetching. - static/css/base.css: full FreshRSS-like dark theme (with a light variant under prefers-color-scheme) replacing the previous unstyled pass — sidebar, topbar search, row/icon states, inline-expand styling. Verified end to end against a running dev server: folder/feed/tag scoping, mark-all-read, the inline-expand mark-read side effect and its icon update, and — against config.settings.prod specifically — that no inline <script> crept back in anywhere (would silently break under the CSP added in the previous commit) and the CSP header is still present on every page. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
4c20558525
commit
cfa64b5485
18 files changed
+860
-159
No files matched your search
@@ -1,20 +1,26 @@
|
||||
<div id="article-actions-{{ article.pk }}" class="article-actions">
|
||||
<div id="article-actions-{{ article.pk }}" class="article-actions"{% if oob %} hx-swap-oob="true"{% endif %}>
|
||||
<button
|
||||
hx-post="{% url 'reader:toggle_read' article.pk %}"
|
||||
hx-target="#article-actions-{{ article.pk }}"
|
||||
hx-swap="outerHTML"
|
||||
class="icon-btn{% if article.is_read %} active{% endif %}"
|
||||
title="Toggle read">{% if article.is_read %}Read{% else %}Unread{% endif %}</button>
|
||||
class="icon-btn icon-btn-read{% if not article.is_read %} is-unread{% endif %}"
|
||||
title="{% if article.is_read %}Mark unread{% else %}Mark read{% endif %}">
|
||||
<svg viewBox="0 0 16 16" width="15" height="15" aria-hidden="true"><circle cx="8" cy="8" r="5"></circle></svg>
|
||||
</button>
|
||||
<button
|
||||
hx-post="{% url 'reader:toggle_star' article.pk %}"
|
||||
hx-target="#article-actions-{{ article.pk }}"
|
||||
hx-swap="outerHTML"
|
||||
class="icon-btn{% if article.is_starred %} active{% endif %}"
|
||||
title="Toggle star">★</button>
|
||||
class="icon-btn icon-btn-star{% if article.is_starred %} active{% endif %}"
|
||||
title="{% if article.is_starred %}Remove star{% else %}Star{% endif %}">
|
||||
<svg viewBox="0 0 16 16" width="15" height="15" aria-hidden="true"><path d="M8 1.3l2.1 4.3 4.7.7-3.4 3.3.8 4.7L8 12.1l-4.2 2.2.8-4.7-3.4-3.3 4.7-.7z"></path></svg>
|
||||
</button>
|
||||
<button
|
||||
hx-post="{% url 'reader:toggle_saved' article.pk %}"
|
||||
hx-target="#article-actions-{{ article.pk }}"
|
||||
hx-swap="outerHTML"
|
||||
class="icon-btn{% if article.is_saved_for_later %} active{% endif %}"
|
||||
title="Save for later">🔖</button>
|
||||
class="icon-btn icon-btn-saved{% if article.is_saved_for_later %} active{% endif %}"
|
||||
title="{% if article.is_saved_for_later %}Remove from saved{% else %}Save for later{% endif %}">
|
||||
<svg viewBox="0 0 16 16" width="15" height="15" aria-hidden="true"><path d="M3.5 1.5h9v13l-4.5-3-4.5 3z"></path></svg>
|
||||
</button>
|
||||
</div>
|
||||
@@ -0,0 +1,19 @@
|
||||
<div class="article-content-header">
|
||||
<h2 class="article-content-title">{{ article.title|default:"(untitled)" }}</h2>
|
||||
<p class="article-meta">
|
||||
{% if article.feed.favicon_url %}<img src="{{ article.feed.favicon_url }}" alt="" class="feed-favicon">{% endif %}
|
||||
{{ article.feed.title }} · {{ article.published_at|date:"M j, Y H:i" }}
|
||||
{% if article.author %} · {{ article.author }}{% endif %}
|
||||
{% if article.link %} · <a href="{{ article.link }}" target="_blank" rel="noopener noreferrer">Original ↗</a>{% endif %}
|
||||
</p>
|
||||
|
||||
<div
|
||||
id="article-tags-{{ article.pk }}"
|
||||
hx-get="{% url 'articles:article_tags_partial' article.pk %}"
|
||||
hx-trigger="load"
|
||||
hx-swap="outerHTML"></div>
|
||||
</div>
|
||||
|
||||
<div class="article-content">
|
||||
{{ article.content_html|safe }}
|
||||
</div>
|
||||
@@ -0,0 +1,2 @@
|
||||
{% include "reader/_article_content.html" %}
|
||||
{% include "reader/_article_actions.html" with oob=True %}
|
||||
@@ -1,6 +1,9 @@
|
||||
<ul class="article-list">
|
||||
{% for article in articles %}
|
||||
{% include "reader/_article_row.html" %}
|
||||
{% for group in date_groups %}
|
||||
<li class="date-header">{{ group.label }}</li>
|
||||
{% for article in group.articles %}
|
||||
{% include "reader/_article_row.html" %}
|
||||
{% endfor %}
|
||||
{% empty %}
|
||||
<li class="empty-state">Nothing here.</li>
|
||||
{% endfor %}
|
||||
|
||||
@@ -1,7 +1,14 @@
|
||||
<li id="article-{{ article.pk }}" class="article-row{% if article.is_read %} is-read{% endif %}">
|
||||
<div class="article-row-main">
|
||||
<a class="article-title" href="{% url 'reader:article_detail' article.pk %}">{{ article.title|default:"(untitled)" }}</a>
|
||||
<span class="article-meta">{{ article.feed.title }} · {{ article.published_at|date:"M j, Y" }}</span>
|
||||
{% include "reader/_article_actions.html" %}
|
||||
{% if article.feed.favicon_url %}
|
||||
<img src="{{ article.feed.favicon_url }}" alt="" class="feed-favicon">
|
||||
{% endif %}
|
||||
<span class="article-feed-name">{{ article.feed.title|default:article.feed.feed_url }}</span>
|
||||
<a href="{% url 'reader:article_detail' article.pk %}" class="article-title"
|
||||
data-inline-url="{% url 'reader:article_inline' article.pk %}"
|
||||
onclick="return toggleArticle(event, {{ article.pk }})">{{ article.title|default:"(untitled)" }}</a>
|
||||
<span class="article-time">{{ article.published_at|date:"g:i A" }}</span>
|
||||
</div>
|
||||
{% include "reader/_article_actions.html" %}
|
||||
<div id="article-body-{{ article.pk }}" class="article-inline-body" hidden></div>
|
||||
</li>
|
||||
@@ -2,25 +2,8 @@
|
||||
{% block title %}{{ article.title|default:"Article" }} — Evection{% endblock %}
|
||||
{% block content %}
|
||||
<p><a href="{% url 'reader:stream' %}">← Back to stream</a></p>
|
||||
|
||||
<article>
|
||||
<h1>{{ article.title|default:"(untitled)" }}</h1>
|
||||
<p class="article-meta">
|
||||
{{ article.feed.title }} · {{ article.published_at|date:"M j, Y H:i" }}
|
||||
{% if article.author %} · {{ article.author }}{% endif %}
|
||||
{% if article.link %} · <a href="{{ article.link }}" target="_blank" rel="noopener noreferrer">Original</a>{% endif %}
|
||||
</p>
|
||||
|
||||
{% 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>
|
||||
{% include "reader/_article_content.html" %}
|
||||
</article>
|
||||
{% endblock %}
|
||||
@@ -1,32 +1,28 @@
|
||||
{% extends "base.html" %}
|
||||
{% block title %}Stream — Evection{% endblock %}
|
||||
{% block content %}
|
||||
<header class="stream-header">
|
||||
<h1>Evection</h1>
|
||||
<nav class="top-nav">
|
||||
<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>
|
||||
{% if user.is_staff %}<a href="{% url 'core:dashboard' %}">Dashboard</a>{% endif %}
|
||||
<a href="{% url 'accounts:logout' %}">Log out</a>
|
||||
</nav>
|
||||
</header>
|
||||
<div class="stream-toolbar">
|
||||
<h1 class="stream-scope-title">
|
||||
{% if active_feed %}{{ active_feed.title|default:active_feed.feed_url }}
|
||||
{% elif active_folder %}{{ active_folder.name }}
|
||||
{% elif active_tag %}{{ active_tag.name }}
|
||||
{% else %}All articles{% endif %}
|
||||
</h1>
|
||||
|
||||
<nav class="filter-tabs">
|
||||
{% for key, label in filters %}
|
||||
<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>
|
||||
<nav class="filter-tabs">
|
||||
{% for key, label in filters %}
|
||||
<a href="?filter={{ key }}{% if active_tag %}&tag={{ active_tag.pk }}{% endif %}{% if active_feed %}&feed={{ active_feed.pk }}{% endif %}{% if active_folder %}&folder={{ active_folder.pk }}{% endif %}"
|
||||
class="{% if active_filter == key %}active{% endif %}">{{ label }}</a>
|
||||
{% endfor %}
|
||||
</nav>
|
||||
{% endif %}
|
||||
|
||||
<form method="post"
|
||||
action="{% url 'reader:mark_all_read' %}?filter={{ active_filter }}{% if active_tag %}&tag={{ active_tag.pk }}{% endif %}{% if active_feed %}&feed={{ active_feed.pk }}{% endif %}{% if active_folder %}&folder={{ active_folder.pk }}{% endif %}"
|
||||
class="inline-form">
|
||||
{% csrf_token %}
|
||||
<button type="submit">Mark all as read</button>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
{% include "reader/_article_list.html" %}
|
||||
{% endblock %}
|
||||
Reference in new issue
Block a user