diff --git a/discord_rss_bot/main.py b/discord_rss_bot/main.py index 6a90530..274b18d 100644 --- a/discord_rss_bot/main.py +++ b/discord_rss_bot/main.py @@ -93,8 +93,8 @@ async def create_feed(feed_url: str = Form(), webhook_dropdown: str = Form()) -> # Check if set_hook_by_name() was successful. if isinstance( - set_hook_by_name(name=webhook_dropdown, feed_url=feed_url), - ResourceNotFoundError, + set_hook_by_name(name=webhook_dropdown, feed_url=feed_url), + ResourceNotFoundError, ): return set_hook_by_name(name=webhook_dropdown, feed_url=feed_url) @@ -154,7 +154,14 @@ async def get_feed(feed_url: str, request: Request) -> _TemplateResponse: logger.info(f"Got feed: {feed_url}") feed: Feed = reader.get_feed(feed_url) - return templates.TemplateResponse("feed.html", {"request": request, "feed": feed}) + # Get entries from the feed. + entries: Iterable[EntryCounts] = reader.get_entries(feed=feed_url) + + # Get the entries in the feed. + feed_counts: FeedCounts = reader.get_feed_counts(feed=feed_url) + + return templates.TemplateResponse("feed.html", {"request": request, "feed": feed, "entries": entries, + "feed_counts": feed_counts}) @app.get("/", response_class=HTMLResponse) diff --git a/discord_rss_bot/templates/feed.html b/discord_rss_bot/templates/feed.html index 31db085..11f46ca 100644 --- a/discord_rss_bot/templates/feed.html +++ b/discord_rss_bot/templates/feed.html @@ -1,26 +1,41 @@ {% extends "base.html" %} {% block title %}Feed{% endblock %} {% block content %} - URL: {{ feed.url }}
- Title: {{ feed.title }}
- Updated: {{ feed.updated }}
- Link: {{ feed.link }}
- Author: {{ feed.author }}
- Subtitle: {{ feed.subtitle }}
- Version: {{ feed.version }}
- User title: {{ feed.user_title }}
- Added on: {{ feed.added }}
- Last update: {{ feed.last_update }}
- Last exception: {{ feed.last_exception }}
- Updates enabled: {{ feed.updates_enabled }}
+

{{ feed.title }}

+ {% if feed.url %} Subtitle: {{ feed.subtitle }}
{% endif %} + {% if feed.url %} {{ feed.url }}
{% endif %} + {% if feed.updated %} Updated: {{ feed.updated.strftime('%Y-%m-%d, %T') }}
{% endif %} + {% if feed.version %} Version: {{ feed.version }}
{% endif %} + {% if feed.user_title %} User title: {{ feed.user_title }}
{% endif %} + {% if feed.added %} Added on: {{ feed.added.strftime('%Y-%m-%d, %T') }}
{% endif %} + {% if feed.last_update %} Last update: {{ feed.last_update }}
{% endif %} + {% if feed.last_exception %} Last exception: {{ feed.last_exception }}
{% endif %} + {% if not feed.updates_enabled %} Updates disabled!
{% endif %} -
+ {% for entry in entries %} + {% if entry.read %} + + {% else %} + + {% endif %} +
+

{{ entry.title }}

+ By {{ entry.author }}
+
+ {% if entry.published %} Published: {{ entry.published.strftime('%Y-%m-%d, %T') }}
{% endif %} + {% if entry.updated %} Updated: {{ entry.updated.strftime('%Y-%m-%d, %T') }}
{% endif %} + Summary: {{ entry.summary }}
+ {% if entry.read_modified %} Read modified: {{ entry.read_modified.strftime('%Y-%m-%d, %T') }}
{% endif %} +
+ {% endfor %} + + -
+