diff --git a/apps/articles/queries.py b/apps/articles/queries.py index eb54edc..c4657ff 100644 --- a/apps/articles/queries.py +++ b/apps/articles/queries.py @@ -1,4 +1,6 @@ -from .models import UserArticleState +from django.db.models import Count + +from .models import Article, UserArticleState def with_user_state(articles, user): @@ -26,3 +28,17 @@ def with_user_state(articles, user): 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 unread_counts_by_feed(user): + """{feed_id: unread_count} for every feed the user subscribes to, in one + query — used by the sidebar, so it must stay cheap regardless of how + many feeds/articles exist.""" + rows = ( + Article.objects.filter(feed__subscriptions__user=user) + .exclude(user_states__user=user, user_states__is_read=True) + .exclude(user_states__user=user, user_states__is_hidden=True) + .values("feed_id") + .annotate(unread=Count("id")) + ) + return {row["feed_id"]: row["unread"] for row in rows} diff --git a/apps/core/context_processors.py b/apps/core/context_processors.py new file mode 100644 index 0000000..8864a87 --- /dev/null +++ b/apps/core/context_processors.py @@ -0,0 +1,41 @@ +from apps.articles.models import Tag, UserArticleState +from apps.articles.queries import unread_counts_by_feed +from apps.feeds.models import Folder, Subscription + + +def sidebar(request): + """Folder/feed tree, tags, and starred count for the persistent sidebar + rendered by base.html on every authenticated page. Kept out of + individual views so every page gets the same sidebar for free. + """ + user = getattr(request, "user", None) + if user is None or not user.is_authenticated: + return {} + + unread_counts = unread_counts_by_feed(user) + subscriptions = ( + Subscription.objects.filter(user=user) + .select_related("feed", "folder") + .order_by("order", "id") + ) + + folders = list(Folder.objects.filter(user=user).order_by("order", "name")) + by_folder = {folder.pk: [] for folder in folders} + unfoldered = [] + for subscription in subscriptions: + subscription.unread_count = unread_counts.get(subscription.feed_id, 0) + if subscription.folder_id and subscription.folder_id in by_folder: + by_folder[subscription.folder_id].append(subscription) + else: + unfoldered.append(subscription) + + return { + "sidebar_folders": [ + {"folder": folder, "subscriptions": by_folder[folder.pk]} for folder in folders + ], + "sidebar_unfoldered": unfoldered, + "sidebar_tags": Tag.objects.filter(user=user), + "sidebar_starred_count": UserArticleState.objects.filter( + user=user, is_starred=True + ).count(), + } diff --git a/apps/core/tests.py b/apps/core/tests.py index d9feede..e570127 100644 --- a/apps/core/tests.py +++ b/apps/core/tests.py @@ -35,7 +35,10 @@ def test_dashboard_lists_erroring_feeds(client, django_user_model): assert response.status_code == 200 assert b"Broken Feed" in response.content assert b"Connection timed out" in response.content - assert b"OK Feed" not in response.content + # "OK Feed" legitimately appears elsewhere on the page (the sidebar + # lists every subscription), so check the dashboard's own error table + # scope via context rather than raw page content. + assert list(response.context["erroring_feeds"]) == [broken_feed] @pytest.mark.django_db diff --git a/apps/reader/urls.py b/apps/reader/urls.py index 1a081ea..cf683ab 100644 --- a/apps/reader/urls.py +++ b/apps/reader/urls.py @@ -6,7 +6,13 @@ app_name = "reader" urlpatterns = [ path("", views.stream, name="stream"), + path("mark-all-read/", views.mark_all_read, name="mark_all_read"), path("articles//", views.article_detail, name="article_detail"), + path( + "articles//inline/", + views.article_inline, + name="article_inline", + ), path("articles//toggle-read/", views.toggle_read, name="toggle_read"), path("articles//toggle-star/", views.toggle_star, name="toggle_star"), path("articles//toggle-saved/", views.toggle_saved, name="toggle_saved"), diff --git a/apps/reader/views.py b/apps/reader/views.py index 9e1b958..e050185 100644 --- a/apps/reader/views.py +++ b/apps/reader/views.py @@ -1,11 +1,15 @@ +from itertools import groupby + from django.contrib.auth.decorators import login_required from django.http import Http404 -from django.shortcuts import get_object_or_404, render +from django.shortcuts import get_object_or_404, redirect, render +from django.urls import reverse from django.utils import timezone from django.views.decorators.http import require_POST from apps.articles.models import Article, Tag, UserArticleState from apps.articles.queries import with_user_state +from apps.feeds.models import Feed, Folder FILTER_CHOICES = [ ("unread", "Unread"), @@ -32,6 +36,69 @@ def _get_or_create_state(user, article): return state +def _apply_scope(request, queryset): + """Narrows an already-base-scoped Article queryset by the optional + ?tag=/?feed=/?folder= params the sidebar links use. feed_id alone is + enough to scope by feed (the base queryset already restricts to the + user's own subscriptions); folder_id must be combined with user in the + same .filter() call — Feed is shared across users, so a separate call + would match any user's subscription with that folder_id, not just this + user's, leaking other users' folder contents in. + """ + active_tag = None + tag_id = request.GET.get("tag") + if tag_id: + active_tag = Tag.objects.filter(user=request.user, pk=tag_id).first() + if active_tag: + queryset = queryset.filter( + article_tags__user=request.user, article_tags__tag=active_tag + ) + + active_feed = None + feed_id = request.GET.get("feed") + if feed_id: + active_feed = Feed.objects.filter(pk=feed_id, subscriptions__user=request.user).first() + if active_feed: + queryset = queryset.filter(feed_id=active_feed.pk) + + active_folder = None + folder_id = request.GET.get("folder") + if folder_id: + active_folder = Folder.objects.filter(user=request.user, pk=folder_id).first() + if active_folder: + queryset = queryset.filter( + feed__subscriptions__user=request.user, + feed__subscriptions__folder_id=active_folder.pk, + ) + + return queryset, active_tag, active_feed, active_folder + + +def _date_label(day, today): + if day is None: + return "Undated" + diff = (today - day).days + if diff == 0: + return f"Received today — {day.strftime('%-d %B %Y')}" + if diff == 1: + return f"Received yesterday — {day.strftime('%-d %B %Y')}" + return f"Received {day.strftime('%-d %B %Y')}" + + +def _group_by_date(articles): + """Articles are already ordered newest-first (Article.Meta.ordering), + so same-day articles are contiguous and groupby doesn't need a sort.""" + today = timezone.localdate() + + def day_of(article): + return timezone.localtime(article.published_at).date() if article.published_at else None + + return [ + {"label": _date_label(day, today), "articles": list(items)} + for day, items in groupby(articles, key=day_of) + ] + + @login_required def stream(request): active_filter = request.GET.get("filter", "unread") @@ -48,14 +115,7 @@ def stream(request): user_states__user=request.user, user_states__is_saved_for_later=True ) - active_tag = None - tag_id = request.GET.get("tag") - if tag_id: - active_tag = Tag.objects.filter(user=request.user, pk=tag_id).first() - if active_tag: - queryset = queryset.filter( - article_tags__user=request.user, article_tags__tag=active_tag - ) + queryset, active_tag, active_feed, active_folder = _apply_scope(request, queryset) try: page = max(int(request.GET.get("page", 1)), 1) @@ -67,10 +127,12 @@ def stream(request): articles = with_user_state(queryset[start:end], request.user) context = { - "articles": articles, + "date_groups": _group_by_date(articles), "active_filter": active_filter, "filters": FILTER_CHOICES, "active_tag": active_tag, + "active_feed": active_feed, + "active_folder": active_folder, "user_tags": Tag.objects.filter(user=request.user), "page": page, "has_next_page": end < total_count, @@ -80,10 +142,45 @@ def stream(request): @login_required -def article_detail(request, article_id): - article = get_object_or_404(_base_queryset(request.user), pk=article_id) +@require_POST +def mark_all_read(request): + """Marks every unread article currently matching the stream's filter + scope (tag included, "unread"/"all" filter excluded since it's a no-op + choice here) as read — bulk, not one UserArticleState per article.""" + queryset = _base_queryset(request.user) + queryset, _active_tag, _active_feed, _active_folder = _apply_scope(request, queryset) - state = _get_or_create_state(request.user, article) + unread_articles = queryset.exclude(user_states__user=request.user, user_states__is_read=True) + unread_ids = list(unread_articles.values_list("id", flat=True)) + + if unread_ids: + now = timezone.now() + existing_state_article_ids = set( + UserArticleState.objects.filter( + user=request.user, article_id__in=unread_ids + ).values_list("article_id", flat=True) + ) + UserArticleState.objects.filter( + user=request.user, article_id__in=existing_state_article_ids + ).update(is_read=True, read_at=now) + + new_article_ids = [aid for aid in unread_ids if aid not in existing_state_article_ids] + UserArticleState.objects.bulk_create( + [ + UserArticleState(user=request.user, article_id=aid, is_read=True, read_at=now) + for aid in new_article_ids + ] + ) + + stream_url = reverse("reader:stream") + query = request.GET.urlencode() + return redirect(f"{stream_url}?{query}" if query else stream_url) + + +def _load_article_and_mark_read(user, article_id): + article = get_object_or_404(_base_queryset(user), pk=article_id) + + state = _get_or_create_state(user, article) if not state.is_read: state.is_read = True state.read_at = timezone.now() @@ -92,10 +189,25 @@ def article_detail(request, article_id): article.is_read = state.is_read article.is_starred = state.is_starred article.is_saved_for_later = state.is_saved_for_later + return article + +@login_required +def article_detail(request, article_id): + article = _load_article_and_mark_read(request.user, article_id) return render(request, "reader/article_detail.html", {"article": article}) +@login_required +def article_inline(request, article_id): + """Fetched via htmx when a row in the stream is expanded in place — + mirrors article_detail's mark-read side effect, but renders just the + content fragment plus an out-of-band update of the row's own read/star + icons (see templates/reader/_article_inline.html).""" + article = _load_article_and_mark_read(request.user, article_id) + return render(request, "reader/_article_inline.html", {"article": article}) + + @login_required @require_POST def toggle_read(request, article_id): diff --git a/apps/search/test_views.py b/apps/search/test_views.py index c450f79..1c5d363 100644 --- a/apps/search/test_views.py +++ b/apps/search/test_views.py @@ -54,4 +54,4 @@ def test_search_results_carry_user_state(client, alice, feed): response = client.get(reverse("search:search"), {"q": "Django"}) content = response.content.decode() - assert 'class="icon-btn active"' in content + assert 'class="icon-btn icon-btn-star active"' in content diff --git a/config/settings/base.py b/config/settings/base.py index 2ea64ec..017d430 100644 --- a/config/settings/base.py +++ b/config/settings/base.py @@ -63,6 +63,7 @@ TEMPLATES = [ "django.template.context_processors.request", "django.contrib.auth.context_processors.auth", "django.contrib.messages.context_processors.messages", + "apps.core.context_processors.sidebar", ], }, }, diff --git a/static/css/base.css b/static/css/base.css index 9896db3..0a58ed5 100644 --- a/static/css/base.css +++ b/static/css/base.css @@ -1,18 +1,74 @@ :root { - color-scheme: light dark; + color-scheme: dark; font-family: system-ui, -apple-system, Segoe UI, Roboto, sans-serif; + + --bg: #17181c; + --bg-sidebar: #1b1c21; + --bg-row-hover: #24262c; + --bg-row-selected: #1d3252; + --accent: #3b82f6; + --accent-dark: #1d4ed8; + --star: #f5b400; + --text: #e8e8ea; + --text-muted: #a3a3a8; + --text-dim: #74747a; + --border: #2a2b31; +} + +@media (prefers-color-scheme: light) { + :root { + color-scheme: light; + --bg: #ffffff; + --bg-sidebar: #f4f5f7; + --bg-row-hover: #eef0f3; + --bg-row-selected: #e4edfd; + --accent: #1a56db; + --accent-dark: #163f99; + --star: #b7790f; + --text: #1a1b1e; + --text-muted: #5b5c63; + --text-dim: #85868c; + --border: #e2e3e7; + } +} + +* { + box-sizing: border-box; } body { margin: 0; - padding: 1rem; - max-width: 48rem; - margin-inline: auto; + background: var(--bg); + color: var(--text); +} + +a { + color: var(--accent); +} + +h1, h2, h3 { + color: var(--text); + margin: 0 0 0.5rem; +} + +input, textarea, select, button { + background: var(--bg); + color: var(--text); + border: 1px solid var(--border); + border-radius: 0.375rem; + font-size: 1rem; + padding: 0.5rem; + font-family: inherit; +} + +button { + cursor: pointer; } .messages { list-style: none; - padding: 0; + padding: 1rem 1.25rem 0; + margin: 0; } .message { @@ -32,99 +88,413 @@ form p { gap: 0.25rem; } -input, button { - font-size: 1rem; - padding: 0.5rem; +.inline-form { + display: inline; } -.stream-header { +.empty-state { + opacity: 0.6; + padding: 2rem 0; + text-align: center; +} + +.feed-favicon { + width: 14px; + height: 14px; + border-radius: 2px; + flex: 0 0 auto; +} + +/* App shell: sidebar + main content, used on every authenticated page */ + +.app-shell { display: flex; - justify-content: space-between; - align-items: center; - flex-wrap: wrap; - gap: 0.5rem; + min-height: 100vh; + align-items: stretch; } -.top-nav a { - margin-left: 1rem; +.sidebar { + width: 230px; + flex: 0 0 230px; + background: var(--bg-sidebar); + border-right: 1px solid var(--border); + display: flex; + flex-direction: column; + overflow-y: auto; +} + +.sidebar-brand { + padding: 0.9rem 1rem; + font-weight: 600; + font-size: 1.1rem; + border-bottom: 1px solid var(--border); +} + +.sidebar-brand a { + color: var(--text); + text-decoration: none; +} + +.sidebar-manage-btn { + display: block; + margin: 0.75rem 1rem; + padding: 0.5rem 0.75rem; + background: var(--accent); + color: #fff; + text-align: center; + border-radius: 0.375rem; + text-decoration: none; + font-size: 0.85rem; +} + +.sidebar-manage-btn:hover { + background: var(--accent-dark); +} + +.sidebar-top-nav { + list-style: none; + margin: 0; + padding: 0 0.5rem; +} + +.sidebar-top-nav li a { + display: block; + padding: 0.4rem 0.75rem; + color: var(--text-muted); + text-decoration: none; + border-radius: 0.375rem; + font-size: 0.9rem; +} + +.sidebar-top-nav li a:hover { + background: var(--bg-row-hover); + color: var(--text); +} + +.sidebar-top-nav li a.active { + background: var(--bg-row-selected); + color: var(--text); + font-weight: 600; +} + +.sidebar-footer-nav { + margin-top: auto; + border-top: 1px solid var(--border); + padding-top: 0.5rem; + padding-bottom: 0.5rem; +} + +.sidebar-section { + padding: 0 0.5rem; +} + +.sidebar-section summary { + padding: 0.4rem 0.75rem; + cursor: pointer; + color: var(--text-dim); + font-size: 0.75rem; + text-transform: uppercase; + letter-spacing: 0.04em; +} + +.sidebar-folder-link { + color: inherit; + text-decoration: none; +} + +.sidebar-folder-link.active { + color: var(--accent); +} + +.sidebar-item-list { + list-style: none; + margin: 0; + padding: 0 0.5rem 0.5rem; +} + +.sidebar-item-list li { + display: flex; + align-items: center; + justify-content: space-between; + gap: 0.4rem; +} + +.sidebar-feed-link { + flex: 1; + display: flex; + align-items: center; + gap: 0.4rem; + padding: 0.3rem 0.5rem; + color: var(--text-muted); + text-decoration: none; + border-radius: 0.375rem; + font-size: 0.85rem; + min-width: 0; +} + +.sidebar-feed-link span { + overflow: hidden; + text-overflow: ellipsis; + white-space: nowrap; +} + +.sidebar-feed-link:hover { + background: var(--bg-row-hover); + color: var(--text); +} + +.sidebar-feed-link.active { + background: var(--bg-row-selected); + color: var(--text); + font-weight: 600; +} + +.unread-count { + font-size: 0.75rem; + color: var(--text-dim); + padding-right: 0.5rem; + flex: 0 0 auto; +} + +.app-main { + flex: 1; + min-width: 0; + display: flex; + flex-direction: column; +} + +.app-topbar { + padding: 0.6rem 1rem; + border-bottom: 1px solid var(--border); +} + +.topbar-search input[type="search"] { + width: 100%; + max-width: 420px; + border-radius: 999px; + padding: 0.45rem 0.9rem; +} + +.app-content { + padding: 1rem 1.25rem 2rem; + flex: 1; + min-width: 0; +} + +.auth-content { + max-width: 28rem; + margin: 3rem auto; + padding: 0 1rem; +} + +/* Stream toolbar and article list */ + +.stream-toolbar { + display: flex; + align-items: center; + gap: 1rem; + flex-wrap: wrap; + margin-bottom: 0.75rem; +} + +.stream-scope-title { + font-size: 1.15rem; + flex: 0 0 auto; + margin: 0; } .filter-tabs { display: flex; - gap: 0.5rem; - margin: 1rem 0; - border-bottom: 1px solid #ddd; + gap: 0.25rem; + margin: 0; } .filter-tabs a { - padding: 0.5rem 0.75rem; + padding: 0.3rem 0.65rem; + border-radius: 999px; text-decoration: none; - color: inherit; - border-bottom: 2px solid transparent; + font-size: 0.85rem; + color: var(--text-muted); +} + +.filter-tabs a:hover { + background: var(--bg-row-hover); } .filter-tabs a.active { - border-bottom-color: currentColor; + background: var(--bg-row-selected); + color: var(--text); font-weight: 600; } +.stream-toolbar .inline-form { + margin-left: auto; +} + +.stream-toolbar button[type="submit"] { + background: none; + font-size: 0.85rem; + padding: 0.4rem 0.75rem; +} + .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; +.date-header { + padding: 0.5rem 0.25rem; + margin-top: 0.75rem; + font-size: 0.78rem; + text-transform: uppercase; + letter-spacing: 0.04em; + color: var(--text-dim); + border-bottom: 1px solid var(--border); } -.article-row.is-read .article-title { - opacity: 0.55; +.article-row { + border-bottom: 1px solid var(--border); } .article-row-main { display: flex; - flex-direction: column; - gap: 0.15rem; - min-width: 0; - flex: 1; + align-items: center; + gap: 0.6rem; + padding: 0.4rem 0.25rem; +} + +.article-row-main:hover { + background: var(--bg-row-hover); +} + +.article-row.is-expanded .article-row-main { + background: var(--bg-row-selected); + box-shadow: inset 3px 0 0 var(--accent); +} + +.article-feed-name { + font-size: 0.8rem; + color: var(--text-dim); + flex: 0 0 auto; + max-width: 140px; + overflow: hidden; + text-overflow: ellipsis; + white-space: nowrap; } .article-title { + flex: 1; + min-width: 0; + overflow: hidden; + text-overflow: ellipsis; + white-space: nowrap; font-weight: 600; + color: var(--text); text-decoration: none; - color: inherit; } -.article-meta { - font-size: 0.85rem; - opacity: 0.65; +.article-row.is-read .article-title { + font-weight: 400; + color: var(--text-muted); +} + +.article-time { + font-size: 0.8rem; + color: var(--text-dim); + flex: 0 0 auto; } .article-actions { display: flex; - gap: 0.35rem; - flex-wrap: nowrap; + gap: 0.15rem; + flex: 0 0 auto; } .icon-btn { background: none; - border: 1px solid #ccc; - border-radius: 0.375rem; - cursor: pointer; - padding: 0.35rem 0.6rem; - font-size: 0.9rem; + border: none; + padding: 0.25rem; + color: var(--text-dim); + display: inline-flex; + align-items: center; + justify-content: center; + border-radius: 0.25rem; } -.icon-btn.active { - background: #fde68a; - border-color: #f59e0b; +.icon-btn:hover { + background: var(--bg-row-hover); + color: var(--text); +} + +.icon-btn svg { + fill: none; + stroke: currentColor; + stroke-width: 1.6; +} + +.icon-btn-read.is-unread { + color: var(--accent); +} + +.icon-btn-read.is-unread svg { + fill: var(--accent); +} + +.icon-btn-star.active { + color: var(--star); +} + +.icon-btn-star.active svg { + fill: var(--star); +} + +.icon-btn-saved.active { + color: var(--accent); +} + +.icon-btn-saved.active svg { + fill: var(--accent); +} + +.article-inline-body { + padding: 0.75rem 1rem 1.5rem 2.1rem; + border-bottom: 1px solid var(--border); +} + +.article-content-header { + margin-bottom: 0.75rem; +} + +.article-content-title { + font-size: 1.3rem; + margin: 0 0 0.3rem; + font-weight: 600; +} + +.article-meta { + font-size: 0.85rem; + color: var(--text-muted); +} + +.article-meta .feed-favicon { + vertical-align: -2px; + margin-right: 0.3rem; +} + +.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%; } .pagination { @@ -133,11 +503,7 @@ input, button { margin: 1rem 0; } -.empty-state { - opacity: 0.6; - padding: 2rem 0; - text-align: center; -} +/* Tags */ .tag-tabs { display: flex; @@ -147,7 +513,7 @@ input, button { } .tag-pill { - --tag-color: #6b7280; + --tag-color: var(--accent); display: inline-flex; align-items: center; gap: 0.3rem; @@ -161,7 +527,7 @@ input, button { .tag-pill.active { background: var(--tag-color); - color: #111; + color: var(--bg); } .tag-remove { @@ -203,12 +569,10 @@ input, button { align-items: center; gap: 0.75rem; padding: 0.5rem 0; - border-bottom: 1px solid #eee; + border-bottom: 1px solid var(--border); } -.inline-form { - display: inline; -} +/* Rules */ .rule-list { list-style: none; @@ -221,7 +585,7 @@ input, button { align-items: center; gap: 1rem; padding: 0.75rem 0; - border-bottom: 1px solid #eee; + border-bottom: 1px solid var(--border); flex-wrap: wrap; } @@ -239,12 +603,20 @@ input, button { gap: 0.35rem; } +/* Search */ + .search-form { display: flex; gap: 0.5rem; margin: 1rem 0; } +.search-form input { + flex: 1; +} + +/* Subscriptions */ + .subscription-list { list-style: none; padding: 0; @@ -256,34 +628,10 @@ input, button { align-items: center; gap: 1rem; padding: 0.5rem 0; - border-bottom: 1px solid #eee; + border-bottom: 1px solid var(--border); } -.search-form input { - flex: 1; -} - -.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; - } -} +/* Dashboard */ .dashboard-stats { list-style: none; @@ -304,6 +652,28 @@ input, button { .feed-error-table td { text-align: left; padding: 0.5rem; - border-bottom: 1px solid currentColor; + border-bottom: 1px solid var(--border); font-size: 0.9rem; } + +@media (max-width: 760px) { + .app-shell { + flex-direction: column; + } + + .sidebar { + width: 100%; + flex: 0 0 auto; + max-height: 40vh; + border-right: none; + border-bottom: 1px solid var(--border); + } + + .article-feed-name { + display: none; + } + + .stream-toolbar .inline-form { + margin-left: 0; + } +} diff --git a/static/js/stream.js b/static/js/stream.js new file mode 100644 index 0000000..4c4ff68 --- /dev/null +++ b/static/js/stream.js @@ -0,0 +1,29 @@ +function toggleArticle(event, id) { + event.preventDefault(); + var link = event.currentTarget; + var row = link.closest("li.article-row"); + var body = document.getElementById("article-body-" + id); + var wasOpen = row.classList.contains("is-expanded"); + + document.querySelectorAll("li.article-row.is-expanded").forEach(function (openRow) { + openRow.classList.remove("is-expanded"); + var openBody = openRow.querySelector(".article-inline-body"); + if (openBody) { + openBody.hidden = true; + } + }); + + if (!wasOpen) { + row.classList.add("is-expanded"); + body.hidden = false; + if (!body.dataset.loaded) { + body.dataset.loaded = "1"; + htmx.ajax("GET", link.dataset.inlineUrl, { target: body, swap: "innerHTML" }).then( + function () { + row.classList.add("is-read"); + } + ); + } + } + return false; +} diff --git a/templates/base.html b/templates/base.html index 6b8802d..88e2b34 100644 --- a/templates/base.html +++ b/templates/base.html @@ -17,6 +17,17 @@ + {% if user.is_authenticated %} +
+ {% include "core/_sidebar.html" %} +
+
+ +
+ {% endif %} + {% if messages %}
    {% for message in messages %} @@ -24,9 +35,17 @@ {% endfor %}
{% endif %} -
+ +
{% block content %}{% endblock %}
+ + {% if user.is_authenticated %} +
+
+ {% endif %} + + diff --git a/templates/core/_sidebar.html b/templates/core/_sidebar.html new file mode 100644 index 0000000..c7d932e --- /dev/null +++ b/templates/core/_sidebar.html @@ -0,0 +1,88 @@ + diff --git a/templates/reader/_article_actions.html b/templates/reader/_article_actions.html index 644d894..a969158 100644 --- a/templates/reader/_article_actions.html +++ b/templates/reader/_article_actions.html @@ -1,20 +1,26 @@ -
+
+ 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 %}"> + + + class="icon-btn icon-btn-star{% if article.is_starred %} active{% endif %}" + title="{% if article.is_starred %}Remove star{% else %}Star{% endif %}"> + + + 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 %}"> + +
diff --git a/templates/reader/_article_content.html b/templates/reader/_article_content.html new file mode 100644 index 0000000..62f55fa --- /dev/null +++ b/templates/reader/_article_content.html @@ -0,0 +1,19 @@ +
+

{{ article.title|default:"(untitled)" }}

+ + +
+
+ +
+ {{ article.content_html|safe }} +
diff --git a/templates/reader/_article_inline.html b/templates/reader/_article_inline.html new file mode 100644 index 0000000..8fac175 --- /dev/null +++ b/templates/reader/_article_inline.html @@ -0,0 +1,2 @@ +{% include "reader/_article_content.html" %} +{% include "reader/_article_actions.html" with oob=True %} diff --git a/templates/reader/_article_list.html b/templates/reader/_article_list.html index 954055c..be9f896 100644 --- a/templates/reader/_article_list.html +++ b/templates/reader/_article_list.html @@ -1,6 +1,9 @@
    - {% for article in articles %} - {% include "reader/_article_row.html" %} + {% for group in date_groups %} +
  • {{ group.label }}
  • + {% for article in group.articles %} + {% include "reader/_article_row.html" %} + {% endfor %} {% empty %}
  • Nothing here.
  • {% endfor %} diff --git a/templates/reader/_article_row.html b/templates/reader/_article_row.html index 95f4a46..35cc7d9 100644 --- a/templates/reader/_article_row.html +++ b/templates/reader/_article_row.html @@ -1,7 +1,14 @@
  • - {{ article.title|default:"(untitled)" }} - + {% include "reader/_article_actions.html" %} + {% if article.feed.favicon_url %} + + {% endif %} + {{ article.feed.title|default:article.feed.feed_url }} + {{ article.title|default:"(untitled)" }} + {{ article.published_at|date:"g:i A" }}
    - {% include "reader/_article_actions.html" %} +
  • diff --git a/templates/reader/article_detail.html b/templates/reader/article_detail.html index 9402668..3562083 100644 --- a/templates/reader/article_detail.html +++ b/templates/reader/article_detail.html @@ -2,25 +2,8 @@ {% block title %}{{ article.title|default:"Article" }} — Evection{% endblock %} {% block content %}

    ← Back to stream

    -
    -

    {{ article.title|default:"(untitled)" }}

    - - {% include "reader/_article_actions.html" %} - -
    - -
    - {{ article.content_html|safe }} -
    + {% include "reader/_article_content.html" %}
    {% endblock %} diff --git a/templates/reader/stream.html b/templates/reader/stream.html index e40cdc8..4e399a0 100644 --- a/templates/reader/stream.html +++ b/templates/reader/stream.html @@ -1,32 +1,28 @@ {% extends "base.html" %} {% block title %}Stream — Evection{% endblock %} {% block content %} -
    -

    Evection

    - -
    +
    +

    + {% 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 %} +

    - - - {% if user_tags %} -
    {% include "reader/_article_list.html" %} {% endblock %}