Private
Public Access
Add the reading UI: stream, article detail, htmx actions
Implements the main reader surface: a filterable stream (Unread/All/ Starred/Saved) built on the lazy UserArticleState query pattern, an article detail view that marks articles read on open, and htmx-backed read/star/save-for-later toggles that update in place without a full page reload. Rule-hidden articles are excluded from every filter. Vendors htmx locally rather than loading it from a CDN, and adds mobile-first responsive CSS (verified at 375px width in-browser, plus dark mode via prefers-color-scheme). Verified live against the real Hacker News feed subscribed in the previous milestone: ingestion, filter switching, read/star/save toggles, and article detail all confirmed working in the browser, with two UI bugs fixed along the way (low-contrast message banners in dark mode, horizontal overflow from long URLs in article content). Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
d200ab80f7
commit
69e3520e3b
11 files changed
+478
-9
No files matched your search
+128
-1
@@ -1 +1,128 @@
|
||||
# Create your tests here.
|
||||
import pytest
|
||||
from django.contrib.auth import get_user_model
|
||||
from django.urls import reverse
|
||||
|
||||
from apps.articles.models import Article, UserArticleState
|
||||
from apps.feeds.models import Feed, Subscription
|
||||
|
||||
User = get_user_model()
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def alice(db):
|
||||
return User.objects.create_user("alice", password="pw-alice-123")
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def bob(db):
|
||||
return User.objects.create_user("bob", password="pw-bob-123")
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def alices_article(alice):
|
||||
feed = Feed.objects.create(feed_url="https://example.com/feed.xml", title="Example")
|
||||
Subscription.objects.create(user=alice, feed=feed)
|
||||
return Article.objects.create(feed=feed, guid="guid-1", title="Hello world")
|
||||
|
||||
|
||||
@pytest.mark.django_db
|
||||
def test_stream_requires_login(client):
|
||||
response = client.get(reverse("reader:stream"))
|
||||
assert response.status_code == 302
|
||||
|
||||
|
||||
@pytest.mark.django_db
|
||||
def test_stream_shows_only_own_subscriptions(client, alice, bob, alices_article):
|
||||
client.login(username="bob", password="pw-bob-123")
|
||||
response = client.get(reverse("reader:stream"))
|
||||
assert alices_article.title not in response.content.decode()
|
||||
|
||||
client.login(username="alice", password="pw-alice-123")
|
||||
response = client.get(reverse("reader:stream"))
|
||||
assert alices_article.title in response.content.decode()
|
||||
|
||||
|
||||
@pytest.mark.django_db
|
||||
def test_unread_filter_excludes_read_articles(client, alice, alices_article):
|
||||
UserArticleState.objects.create(user=alice, article=alices_article, is_read=True)
|
||||
client.login(username="alice", password="pw-alice-123")
|
||||
|
||||
response = client.get(reverse("reader:stream"), {"filter": "unread"})
|
||||
assert alices_article.title not in response.content.decode()
|
||||
|
||||
response = client.get(reverse("reader:stream"), {"filter": "all"})
|
||||
assert alices_article.title in response.content.decode()
|
||||
|
||||
|
||||
@pytest.mark.django_db
|
||||
def test_hidden_articles_are_excluded_from_every_filter(client, alice, alices_article):
|
||||
UserArticleState.objects.create(user=alice, article=alices_article, is_hidden=True)
|
||||
client.login(username="alice", password="pw-alice-123")
|
||||
|
||||
for active_filter in ["unread", "all"]:
|
||||
response = client.get(reverse("reader:stream"), {"filter": active_filter})
|
||||
assert alices_article.title not in response.content.decode()
|
||||
|
||||
|
||||
@pytest.mark.django_db
|
||||
def test_viewing_article_detail_marks_it_read(client, alice, alices_article):
|
||||
client.login(username="alice", password="pw-alice-123")
|
||||
assert not UserArticleState.objects.filter(user=alice, article=alices_article).exists()
|
||||
|
||||
response = client.get(reverse("reader:article_detail", args=[alices_article.pk]))
|
||||
assert response.status_code == 200
|
||||
|
||||
state = UserArticleState.objects.get(user=alice, article=alices_article)
|
||||
assert state.is_read is True
|
||||
assert state.read_at is not None
|
||||
|
||||
|
||||
@pytest.mark.django_db
|
||||
def test_user_cannot_view_another_users_article(client, alice, bob, alices_article):
|
||||
client.login(username="bob", password="pw-bob-123")
|
||||
response = client.get(reverse("reader:article_detail", args=[alices_article.pk]))
|
||||
assert response.status_code == 404
|
||||
|
||||
|
||||
@pytest.mark.django_db
|
||||
def test_toggle_star_flips_state_and_persists(client, alice, alices_article):
|
||||
client.login(username="alice", password="pw-alice-123")
|
||||
url = reverse("reader:toggle_star", args=[alices_article.pk])
|
||||
|
||||
response = client.post(url)
|
||||
assert response.status_code == 200
|
||||
state = UserArticleState.objects.get(user=alice, article=alices_article)
|
||||
assert state.is_starred is True
|
||||
assert state.starred_at is not None
|
||||
|
||||
client.post(url)
|
||||
state.refresh_from_db()
|
||||
assert state.is_starred is False
|
||||
assert state.starred_at is None
|
||||
|
||||
|
||||
@pytest.mark.django_db
|
||||
def test_toggle_read_requires_post(client, alice, alices_article):
|
||||
client.login(username="alice", password="pw-alice-123")
|
||||
response = client.get(reverse("reader:toggle_read", args=[alices_article.pk]))
|
||||
assert response.status_code == 405
|
||||
|
||||
|
||||
@pytest.mark.django_db
|
||||
def test_user_cannot_toggle_state_on_another_users_article(client, alice, bob, alices_article):
|
||||
client.login(username="bob", password="pw-bob-123")
|
||||
response = client.post(reverse("reader:toggle_star", args=[alices_article.pk]))
|
||||
assert response.status_code == 404
|
||||
assert not UserArticleState.objects.filter(article=alices_article).exists()
|
||||
|
||||
|
||||
@pytest.mark.django_db
|
||||
def test_saved_filter_only_shows_saved_articles(client, alice, alices_article):
|
||||
client.login(username="alice", password="pw-alice-123")
|
||||
client.post(reverse("reader:toggle_saved", args=[alices_article.pk]))
|
||||
|
||||
response = client.get(reverse("reader:stream"), {"filter": "saved"})
|
||||
assert alices_article.title in response.content.decode()
|
||||
|
||||
response = client.get(reverse("reader:stream"), {"filter": "starred"})
|
||||
assert alices_article.title not in response.content.decode()
|
||||
@@ -6,4 +6,8 @@ app_name = "reader"
|
||||
|
||||
urlpatterns = [
|
||||
path("", views.stream, name="stream"),
|
||||
path("articles/<int:article_id>/", views.article_detail, name="article_detail"),
|
||||
path("articles/<int:article_id>/toggle-read/", views.toggle_read, name="toggle_read"),
|
||||
path("articles/<int:article_id>/toggle-star/", views.toggle_star, name="toggle_star"),
|
||||
path("articles/<int:article_id>/toggle-saved/", views.toggle_saved, name="toggle_saved"),
|
||||
]
|
||||
+137
-2
@@ -1,7 +1,142 @@
|
||||
from django.contrib.auth.decorators import login_required
|
||||
from django.shortcuts import render
|
||||
from django.db.models import Prefetch
|
||||
from django.http import Http404
|
||||
from django.shortcuts import get_object_or_404, render
|
||||
from django.utils import timezone
|
||||
from django.views.decorators.http import require_POST
|
||||
|
||||
from apps.articles.models import Article, UserArticleState
|
||||
|
||||
FILTER_CHOICES = [
|
||||
("unread", "Unread"),
|
||||
("all", "All"),
|
||||
("starred", "Starred"),
|
||||
("saved", "Saved"),
|
||||
]
|
||||
VALID_FILTERS = {key for key, _ in FILTER_CHOICES}
|
||||
PAGE_SIZE = 30
|
||||
|
||||
|
||||
def _base_queryset(user):
|
||||
"""Articles from the user's subscriptions, with rule-hidden articles
|
||||
excluded regardless of which filter tab is active."""
|
||||
return (
|
||||
Article.objects.filter(feed__subscriptions__user=user)
|
||||
.exclude(user_states__user=user, user_states__is_hidden=True)
|
||||
.select_related("feed")
|
||||
)
|
||||
|
||||
|
||||
def _with_user_state_annotations(queryset, user):
|
||||
queryset = queryset.prefetch_related(
|
||||
Prefetch(
|
||||
"user_states",
|
||||
queryset=UserArticleState.objects.filter(user=user),
|
||||
to_attr="my_states",
|
||||
)
|
||||
)
|
||||
articles = list(queryset)
|
||||
for article in articles:
|
||||
state = article.my_states[0] if article.my_states else None
|
||||
article.is_read = state.is_read if state else False
|
||||
article.is_starred = state.is_starred if state else False
|
||||
article.is_saved_for_later = state.is_saved_for_later if state else False
|
||||
return articles
|
||||
|
||||
|
||||
def _get_or_create_state(user, article):
|
||||
state, _ = UserArticleState.objects.get_or_create(user=user, article=article)
|
||||
return state
|
||||
|
||||
|
||||
@login_required
|
||||
def stream(request):
|
||||
return render(request, "reader/stream.html")
|
||||
active_filter = request.GET.get("filter", "unread")
|
||||
if active_filter not in VALID_FILTERS:
|
||||
active_filter = "unread"
|
||||
|
||||
queryset = _base_queryset(request.user)
|
||||
if active_filter == "unread":
|
||||
queryset = queryset.exclude(user_states__user=request.user, user_states__is_read=True)
|
||||
elif active_filter == "starred":
|
||||
queryset = queryset.filter(user_states__user=request.user, user_states__is_starred=True)
|
||||
elif active_filter == "saved":
|
||||
queryset = queryset.filter(
|
||||
user_states__user=request.user, user_states__is_saved_for_later=True
|
||||
)
|
||||
|
||||
try:
|
||||
page = max(int(request.GET.get("page", 1)), 1)
|
||||
except ValueError:
|
||||
page = 1
|
||||
start, end = (page - 1) * PAGE_SIZE, page * PAGE_SIZE
|
||||
|
||||
total_count = queryset.count()
|
||||
articles = _with_user_state_annotations(queryset[start:end], request.user)
|
||||
|
||||
context = {
|
||||
"articles": articles,
|
||||
"active_filter": active_filter,
|
||||
"filters": FILTER_CHOICES,
|
||||
"page": page,
|
||||
"has_next_page": end < total_count,
|
||||
"has_previous_page": page > 1,
|
||||
}
|
||||
return render(request, "reader/stream.html", context)
|
||||
|
||||
|
||||
@login_required
|
||||
def article_detail(request, article_id):
|
||||
article = get_object_or_404(_base_queryset(request.user), pk=article_id)
|
||||
|
||||
state = _get_or_create_state(request.user, article)
|
||||
if not state.is_read:
|
||||
state.is_read = True
|
||||
state.read_at = timezone.now()
|
||||
state.save(update_fields=["is_read", "read_at"])
|
||||
|
||||
article.is_read = state.is_read
|
||||
article.is_starred = state.is_starred
|
||||
article.is_saved_for_later = state.is_saved_for_later
|
||||
|
||||
return render(request, "reader/article_detail.html", {"article": article})
|
||||
|
||||
|
||||
@login_required
|
||||
@require_POST
|
||||
def toggle_read(request, article_id):
|
||||
return _toggle(request, article_id, "is_read", "read_at")
|
||||
|
||||
|
||||
@login_required
|
||||
@require_POST
|
||||
def toggle_star(request, article_id):
|
||||
return _toggle(request, article_id, "is_starred", "starred_at")
|
||||
|
||||
|
||||
@login_required
|
||||
@require_POST
|
||||
def toggle_saved(request, article_id):
|
||||
return _toggle(request, article_id, "is_saved_for_later", None)
|
||||
|
||||
|
||||
def _toggle(request, article_id, flag_field, timestamp_field):
|
||||
try:
|
||||
article = _base_queryset(request.user).get(pk=article_id)
|
||||
except Article.DoesNotExist:
|
||||
raise Http404
|
||||
|
||||
state = _get_or_create_state(request.user, article)
|
||||
new_value = not getattr(state, flag_field)
|
||||
setattr(state, flag_field, new_value)
|
||||
update_fields = [flag_field]
|
||||
if timestamp_field:
|
||||
setattr(state, timestamp_field, timezone.now() if new_value else None)
|
||||
update_fields.append(timestamp_field)
|
||||
state.save(update_fields=update_fields)
|
||||
|
||||
article.is_read = state.is_read
|
||||
article.is_starred = state.is_starred
|
||||
article.is_saved_for_later = state.is_saved_for_later
|
||||
|
||||
return render(request, "reader/_article_actions.html", {"article": article})
|
||||
+128
-2
@@ -21,8 +21,10 @@ body {
|
||||
margin-bottom: 0.5rem;
|
||||
}
|
||||
|
||||
.message-success { background: #d1fae5; }
|
||||
.message-error { background: #fee2e2; }
|
||||
.message-success { background: #d1fae5; color: #065f46; }
|
||||
.message-error { background: #fee2e2; color: #991b1b; }
|
||||
.message-warning { background: #fef3c7; color: #92400e; }
|
||||
.message-info { background: #dbeafe; color: #1e40af; }
|
||||
|
||||
form p {
|
||||
display: flex;
|
||||
@@ -34,3 +36,127 @@ input, button {
|
||||
font-size: 1rem;
|
||||
padding: 0.5rem;
|
||||
}
|
||||
|
||||
.stream-header {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
flex-wrap: wrap;
|
||||
gap: 0.5rem;
|
||||
}
|
||||
|
||||
.top-nav a {
|
||||
margin-left: 1rem;
|
||||
}
|
||||
|
||||
.filter-tabs {
|
||||
display: flex;
|
||||
gap: 0.5rem;
|
||||
margin: 1rem 0;
|
||||
border-bottom: 1px solid #ddd;
|
||||
}
|
||||
|
||||
.filter-tabs a {
|
||||
padding: 0.5rem 0.75rem;
|
||||
text-decoration: none;
|
||||
color: inherit;
|
||||
border-bottom: 2px solid transparent;
|
||||
}
|
||||
|
||||
.filter-tabs a.active {
|
||||
border-bottom-color: currentColor;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.article-list {
|
||||
list-style: none;
|
||||
padding: 0;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.article-row {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
gap: 0.75rem;
|
||||
padding: 0.75rem 0;
|
||||
border-bottom: 1px solid #eee;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
|
||||
.article-row.is-read .article-title {
|
||||
opacity: 0.55;
|
||||
}
|
||||
|
||||
.article-row-main {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 0.15rem;
|
||||
min-width: 0;
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
.article-title {
|
||||
font-weight: 600;
|
||||
text-decoration: none;
|
||||
color: inherit;
|
||||
}
|
||||
|
||||
.article-meta {
|
||||
font-size: 0.85rem;
|
||||
opacity: 0.65;
|
||||
}
|
||||
|
||||
.article-actions {
|
||||
display: flex;
|
||||
gap: 0.35rem;
|
||||
flex-wrap: nowrap;
|
||||
}
|
||||
|
||||
.icon-btn {
|
||||
background: none;
|
||||
border: 1px solid #ccc;
|
||||
border-radius: 0.375rem;
|
||||
cursor: pointer;
|
||||
padding: 0.35rem 0.6rem;
|
||||
font-size: 0.9rem;
|
||||
}
|
||||
|
||||
.icon-btn.active {
|
||||
background: #fde68a;
|
||||
border-color: #f59e0b;
|
||||
}
|
||||
|
||||
.pagination {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
margin: 1rem 0;
|
||||
}
|
||||
|
||||
.empty-state {
|
||||
opacity: 0.6;
|
||||
padding: 2rem 0;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.article-content {
|
||||
line-height: 1.6;
|
||||
margin-top: 1rem;
|
||||
overflow-wrap: break-word;
|
||||
word-break: break-word;
|
||||
}
|
||||
|
||||
.article-content a {
|
||||
overflow-wrap: anywhere;
|
||||
}
|
||||
|
||||
.article-content img {
|
||||
max-width: 100%;
|
||||
}
|
||||
|
||||
@media (max-width: 480px) {
|
||||
.article-row {
|
||||
flex-direction: column;
|
||||
align-items: flex-start;
|
||||
}
|
||||
}
|
||||
Vendored
+1
@@ -0,0 +1 @@
|
||||
var htmx=function(){"use strict";const Q={onLoad:null,process:null,on:null,off:null,trigger:null,ajax:null,find:null,findAll:null,closest:null,values:function(e,t){const n=cn(e,t||"post");return n.values},remove:null,addClass:null,removeClass:null,toggleClass:null,takeClass:null,swap:null,defineExtension:null,removeExtension:null,logAll:null,logNone:null,logger:null,config:{historyEnabled:true,historyCacheSize:10,refreshOnHistoryMiss:false,defaultSwapStyle:"innerHTML",defaultSwapDelay:0,defaultSettleDelay:20,includeIndicatorStyles:true,indicatorClass:"htmx-indicator",requestClass:"htmx-request",addedClass:"htmx-added",settlingClass:"htmx-settling",swappingClass:"htmx-swapping",allowEval:true,allowScriptTags:true,inlineScriptNonce:"",inlineStyleNonce:"",attributesToSettle:["class","style","width","height"],withCredentials:false,timeout:0,wsReconnectDelay:"full-jitter",wsBinaryType:"blob",disableSelector:"[hx-disable], [data-hx-disable]",scrollBehavior:"instant",defaultFocusScroll:false,getCacheBusterParam:false,globalViewTransitions:false,methodsThatUseUrlParams:["get","delete"],selfRequestsOnly:true,ignoreTitle:false,scrollIntoViewOnBoost:true,triggerSpecsCache:null,disableInheritance:false,responseHandling:[{code:"204",swap:false},{code:"[23]..",swap:true},{code:"[45]..",swap:false,error:true}],allowNestedOobSwaps:true},parseInterval:null,_:null,version:"2.0.3"};Q.onLoad=j;Q.process=kt;Q.on=ye;Q.off=be;Q.trigger=de;Q.ajax=Rn;Q.find=r;Q.findAll=x;Q.closest=g;Q.remove=z;Q.addClass=K;Q.removeClass=G;Q.toggleClass=W;Q.takeClass=Z;Q.swap=$e;Q.defineExtension=Fn;Q.removeExtension=Bn;Q.logAll=V;Q.logNone=_;Q.parseInterval=h;Q._=e;const n={addTriggerHandler:St,bodyContains:le,canAccessLocalStorage:B,findThisElement:Se,filterValues:dn,swap:$e,hasAttribute:s,getAttributeValue:te,getClosestAttributeValue:re,getClosestMatch:i,getExpressionVars:En,getHeaders:fn,getInputValues:cn,getInternalData:ie,getSwapSpecification:gn,getTriggerSpecs:st,getTarget:Ee,makeFragment:P,mergeObjects:ce,makeSettleInfo:xn,oobSwap:He,querySelectorExt:ae,settleImmediately:Kt,shouldCancel:dt,triggerEvent:de,triggerErrorEvent:fe,withExtensions:Ft};const o=["get","post","put","delete","patch"];const R=o.map(function(e){return"[hx-"+e+"], [data-hx-"+e+"]"}).join(", ");function h(e){if(e==undefined){return undefined}let t=NaN;if(e.slice(-2)=="ms"){t=parseFloat(e.slice(0,-2))}else if(e.slice(-1)=="s"){t=parseFloat(e.slice(0,-1))*1e3}else if(e.slice(-1)=="m"){t=parseFloat(e.slice(0,-1))*1e3*60}else{t=parseFloat(e)}return isNaN(t)?undefined:t}function ee(e,t){return e instanceof Element&&e.getAttribute(t)}function s(e,t){return!!e.hasAttribute&&(e.hasAttribute(t)||e.hasAttribute("data-"+t))}function te(e,t){return ee(e,t)||ee(e,"data-"+t)}function c(e){const t=e.parentElement;if(!t&&e.parentNode instanceof ShadowRoot)return e.parentNode;return t}function ne(){return document}function m(e,t){return e.getRootNode?e.getRootNode({composed:t}):ne()}function i(e,t){while(e&&!t(e)){e=c(e)}return e||null}function H(e,t,n){const r=te(t,n);const o=te(t,"hx-disinherit");var i=te(t,"hx-inherit");if(e!==t){if(Q.config.disableInheritance){if(i&&(i==="*"||i.split(" ").indexOf(n)>=0)){return r}else{return null}}if(o&&(o==="*"||o.split(" ").indexOf(n)>=0)){return"unset"}}return r}function re(t,n){let r=null;i(t,function(e){return!!(r=H(t,ue(e),n))});if(r!=="unset"){return r}}function d(e,t){const n=e instanceof Element&&(e.matches||e.matchesSelector||e.msMatchesSelector||e.mozMatchesSelector||e.webkitMatchesSelector||e.oMatchesSelector);return!!n&&n.call(e,t)}function T(e){const t=/<([a-z][^\/\0>\x20\t\r\n\f]*)/i;const n=t.exec(e);if(n){return n[1].toLowerCase()}else{return""}}function q(e){const t=new DOMParser;return t.parseFromString(e,"text/html")}function L(e,t){while(t.childNodes.length>0){e.append(t.childNodes[0])}}function N(e){const t=ne().createElement("script");se(e.attributes,function(e){t.setAttribute(e.name,e.value)});t.textContent=e.textContent;t.async=false;if(Q.config.inlineScriptNonce){t.nonce=Q.config.inlineScriptNonce}return t}function A(e){return e.matches("script")&&(e.type==="text/javascript"||e.type==="module"||e.type==="")}function I(e){Array.from(e.querySelectorAll("script")).forEach(e=>{if(A(e)){const t=N(e);const n=e.parentNode;try{n.insertBefore(t,e)}catch(e){C(e)}finally{e.remove()}}})}function P(e){const t=e.replace(/<head(\s[^>]*)?>[\s\S]*?<\/head>/i,"");const n=T(t);let r;if(n==="html"){r=new DocumentFragment;const i=q(e);L(r,i.body);r.title=i.title}else if(n==="body"){r=new DocumentFragment;const i=q(t);L(r,i.body);r.title=i.title}else{const i=q('<body><template class="internal-htmx-wrapper">'+t+"</template></body>");r=i.querySelector("template").content;r.title=i.title;var o=r.querySelector("title");if(o&&o.parentNode===r){o.remove();r.title=o.innerText}}if(r){if(Q.config.allowScriptTags){I(r)}else{r.querySelectorAll("script").forEach(e=>e.remove())}}return r}function oe(e){if(e){e()}}function t(e,t){return Object.prototype.toStrinLine truncated
|
||||
+2
-1
@@ -6,8 +6,9 @@
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title>{% block title %}Evection{% endblock %}</title>
|
||||
<link rel="stylesheet" href="{% static 'css/base.css' %}">
|
||||
<script src="{% static 'js/htmx.min.js' %}" defer></script>
|
||||
</head>
|
||||
<body>
|
||||
<body hx-headers='{"X-CSRFToken": "{{ csrf_token }}"}'>
|
||||
{% if messages %}
|
||||
<ul class="messages">
|
||||
{% for message in messages %}
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
<div id="article-actions-{{ article.pk }}" class="article-actions">
|
||||
<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>
|
||||
<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>
|
||||
<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>
|
||||
</div>
|
||||
@@ -0,0 +1,16 @@
|
||||
<ul class="article-list">
|
||||
{% for article in articles %}
|
||||
{% include "reader/_article_row.html" %}
|
||||
{% empty %}
|
||||
<li class="empty-state">Nothing here.</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
|
||||
<nav class="pagination">
|
||||
{% if has_previous_page %}
|
||||
<a href="?filter={{ active_filter }}&page={{ page|add:"-1" }}">← Newer</a>
|
||||
{% endif %}
|
||||
{% if has_next_page %}
|
||||
<a href="?filter={{ active_filter }}&page={{ page|add:"1" }}">Older →</a>
|
||||
{% endif %}
|
||||
</nav>
|
||||
@@ -0,0 +1,7 @@
|
||||
<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>
|
||||
</div>
|
||||
{% include "reader/_article_actions.html" %}
|
||||
</li>
|
||||
@@ -0,0 +1,20 @@
|
||||
{% extends "base.html" %}
|
||||
{% 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 class="article-content">
|
||||
{{ article.content_html|safe }}
|
||||
</div>
|
||||
</article>
|
||||
{% endblock %}
|
||||
@@ -1,7 +1,19 @@
|
||||
{% extends "base.html" %}
|
||||
{% block title %}Stream — Evection{% endblock %}
|
||||
{% block content %}
|
||||
<h1>Your stream</h1>
|
||||
<p>No feeds yet. The reading UI lands in a later milestone.</p>
|
||||
<p><a href="{% url 'feeds:add_feed' %}">Add a feed</a> · <a href="{% url 'accounts:logout' %}">Log out</a></p>
|
||||
<header class="stream-header">
|
||||
<h1>Evection</h1>
|
||||
<nav class="top-nav">
|
||||
<a href="{% url 'feeds:add_feed' %}">Add feed</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>
|
||||
{% endfor %}
|
||||
</nav>
|
||||
|
||||
{% include "reader/_article_list.html" %}
|
||||
{% endblock %}
|
||||
Reference in new issue
Block a user