diff options
| author | Ben Sima <ben@bsima.me> | 2025-11-16 09:07:37 -0500 |
|---|---|---|
| committer | Ben Sima <ben@bsima.me> | 2025-11-16 09:07:37 -0500 |
| commit | f3167698665482c8ee2ed9a02d84315f599031f0 (patch) | |
| tree | b85eb446e02451df8d59e815e809eb8dc43e0f46 /Biz/PodcastItLater/Web.py | |
| parent | 8235889345a37da308a19bed304cceb62d4dda53 (diff) | |
Fix public feed display and admin access issues
Issue #1: demo@example.com admin status - Confirmed demo@example.com
IS in ADMIN_EMAILS (working as intended) - Both Core.py and UI.py
have demo@example.com in whitelist
Issue #2: /public page auto-refresh causing disappearing articles -
Created PublicFeedPage component without auto-refresh - Separated
from HomePage which has dashboard auto-updates - /public route now
uses PublicFeedPage instead of HomePage
Issue #3: Homepage missing public feed for logged-out users - Updated
HomePage to show public feed when user is not logged in - Shows
login form with public episodes below - Includes marketing message:
'Sign up to create your own personal feed!' - Public episodes are
fetched and displayed prominently
Additional improvements: - Added 'Public Feed' link to navbar for
easy access - PublicFeedPage shows RSS feed link for public.rss -
Clear separation between user dashboard (auto-refresh) and public feed
(static)
All tests passing (48 tests)
Diffstat (limited to 'Biz/PodcastItLater/Web.py')
| -rw-r--r-- | Biz/PodcastItLater/Web.py | 63 |
1 files changed, 59 insertions, 4 deletions
diff --git a/Biz/PodcastItLater/Web.py b/Biz/PodcastItLater/Web.py index 60818e9..57d9b91 100644 --- a/Biz/PodcastItLater/Web.py +++ b/Biz/PodcastItLater/Web.py @@ -683,6 +683,45 @@ class HomePageAttrs(Attrs): error: str | None +class PublicFeedPageAttrs(Attrs): + """Attributes for PublicFeedPage component.""" + + episodes: list[dict[str, typing.Any]] + user: dict[str, typing.Any] | None + + +class PublicFeedPage(Component[AnyChildren, PublicFeedPageAttrs]): + """Public feed page without auto-refresh.""" + + @override + def render(self) -> UI.PageLayout: + episodes = self.attrs["episodes"] + user = self.attrs.get("user") + + return UI.PageLayout( + html.div( + html.h2( + html.i(classes=["bi", "bi-globe", "me-2"]), + "Public Feed", + classes=["mb-3"], + ), + html.p( + "Featured articles converted to audio by our community. " + "Subscribe to get new episodes in your podcast app!", + classes=["lead", "text-muted", "mb-4"], + ), + EpisodeList( + episodes=episodes, + rss_url=f"{BASE_URL}/public.rss", + user=user, + ), + ), + user=user, + current_page="public", + error=None, + ) + + class HomePage(Component[AnyChildren, HomePageAttrs]): """Main page combining all components.""" @@ -766,8 +805,26 @@ class HomePage(Component[AnyChildren, HomePageAttrs]): error = self.attrs.get("error") if not user: + # Show public feed with login form for logged-out users return UI.PageLayout( LoginForm(error=error), + html.div( + html.h4( + html.i(classes=["bi", "bi-broadcast", "me-2"]), + "Public Feed", + classes=["mb-3", "mt-4"], + ), + html.p( + "Featured articles converted to audio. " + "Sign up to create your own personal feed!", + classes=["text-muted", "mb-3"], + ), + EpisodeList( + episodes=episodes, + rss_url=None, + user=None, + ), + ), user=None, current_page="home", error=error, @@ -855,18 +912,16 @@ def index(request: Request) -> HomePage: @app.get("/public") -def public_feed(request: Request) -> HomePage: +def public_feed(request: Request) -> PublicFeedPage: """Display public feed page.""" # Always show public episodes, whether user is logged in or not episodes = Core.Database.get_public_episodes(50) user_id = request.session.get("user_id") user = Core.Database.get_user_by_id(user_id) if user_id else None - return HomePage( - queue_items=[], + return PublicFeedPage( episodes=episodes, user=user, - error=None, ) |
