diff --git a/discord_rss_bot/main.py b/discord_rss_bot/main.py index 753b044..f0f9a29 100644 --- a/discord_rss_bot/main.py +++ b/discord_rss_bot/main.py @@ -763,11 +763,24 @@ def build_filter_preview_context( }, ) + preview_html = "" + if sent_count: + preview_html = create_html_for_feed( + reader=reader, + entries=[ + entry for entry in preview_entries if preview_decisions[get_entry_decision_key(entry)].should_send + ], + current_feed_url=feed.url, + entry_decisions=preview_decisions, + ) + return { "filter_name": filter_name, "filter_label": filter_name.title(), + "preview_entries": preview_entries, "preview_rendered_count": sent_count, "preview_rows": preview_rows, + "preview_html": preview_html, "preview_limit": FILTER_PREVIEW_LIMIT, "preview_summary": { "total": len(preview_entries), diff --git a/discord_rss_bot/static/styles.css b/discord_rss_bot/static/styles.css index 451cc9d..f6776b5 100644 --- a/discord_rss_bot/static/styles.css +++ b/discord_rss_bot/static/styles.css @@ -77,7 +77,7 @@ body { } .filter-preview__list { - max-height: 160vh; + max-height: 48vh; overflow-y: auto; padding-right: 0.25rem; } diff --git a/discord_rss_bot/templates/_filter_preview.html b/discord_rss_bot/templates/_filter_preview.html index 4b93b78..3deb6ff 100644 --- a/discord_rss_bot/templates/_filter_preview.html +++ b/discord_rss_bot/templates/_filter_preview.html @@ -70,4 +70,21 @@ {% endif %} +
+
+

Rendered entries

+ Uses the same entry rendering as the feed page. +
+ {% if preview_html %} +
{{ preview_html|safe }}
+ {% else %} +
+ {% if preview_entries %} +

No entries would be sent with the current rules.

+ {% else %} +

Rendered preview will appear here when entries are available.

+ {% endif %} +
+ {% endif %} +
diff --git a/discord_rss_bot/templates/add.html b/discord_rss_bot/templates/add.html index 760a228..5e5ba51 100644 --- a/discord_rss_bot/templates/add.html +++ b/discord_rss_bot/templates/add.html @@ -1,10 +1,7 @@ {% extends "base.html" %} {% block title %} - Add Feed | discord-rss-bot + | Add new feed {% endblock title %} -{% block description %} - Add a new RSS or Atom feed and attach it to a Discord webhook for delivery. -{% endblock description %} {% block content %}
diff --git a/discord_rss_bot/templates/add_webhook.html b/discord_rss_bot/templates/add_webhook.html index 72fa673..5948395 100644 --- a/discord_rss_bot/templates/add_webhook.html +++ b/discord_rss_bot/templates/add_webhook.html @@ -1,6 +1,7 @@ {% extends "base.html" %} -{% block title %}Add Webhook | discord-rss-bot{% endblock title %} -{% block description %}Register a Discord webhook so feeds can post updates into your server or thread.{% endblock description %} +{% block title %} +| Add new webhook +{% endblock title %} {% block content %}
diff --git a/discord_rss_bot/templates/base.html b/discord_rss_bot/templates/base.html index 1b51519..9146b35 100644 --- a/discord_rss_bot/templates/base.html +++ b/discord_rss_bot/templates/base.html @@ -3,38 +3,17 @@ - - {% block title %} - discord-rss-bot - {% endblock title %} - - {% set page_title = self.title() | striptags | trim %} - {% set page_description = self.description() | striptags | trim %} - {% set canonical_url = request.url %} - {% set social_image = request.base_url ~ "static/favicon.ico" %} + content="Stay updated with the latest news and events with our easy-to-use RSS bot. Never miss a message or announcement again with real-time notifications directly to your Discord server." /> - - - - - - - - - - - - - - - - + discord-rss-bot + {% block title %} + {% endblock title %} + {% block head %} {% endblock head %} diff --git a/discord_rss_bot/templates/blacklist.html b/discord_rss_bot/templates/blacklist.html index 8f296d2..54e1220 100644 --- a/discord_rss_bot/templates/blacklist.html +++ b/discord_rss_bot/templates/blacklist.html @@ -1,10 +1,7 @@ {% extends "base.html" %} {% block title %} - Blacklist: {{ feed.title if feed.title else feed.url }} | discord-rss-bot + | Blacklist {% endblock title %} -{% block description %} - Block matching entries from {{ feed.title if feed.title else feed.url }} before they are delivered to Discord. -{% endblock description %} {% block content %}
diff --git a/discord_rss_bot/templates/custom.html b/discord_rss_bot/templates/custom.html index 3146718..48cb3bc 100644 --- a/discord_rss_bot/templates/custom.html +++ b/discord_rss_bot/templates/custom.html @@ -1,6 +1,7 @@ {% extends "base.html" %} -{% block title %}Message Template: {{ feed.title if feed.title else feed.url }} | discord-rss-bot{% endblock title %} -{% block description %}Customize the plain text Discord message template for {{ feed.title if feed.title else feed.url }}.{% endblock description %} +{% block title %} +| Custom message +{% endblock title %} {% block content %}
diff --git a/discord_rss_bot/templates/embed.html b/discord_rss_bot/templates/embed.html index af800e3..ff42e16 100644 --- a/discord_rss_bot/templates/embed.html +++ b/discord_rss_bot/templates/embed.html @@ -1,6 +1,7 @@ {% extends "base.html" %} -{% block title %}Embed Template: {{ feed.title if feed.title else feed.url }} | discord-rss-bot{% endblock title %} -{% block description %}Customize the Discord embed layout, colors, and media for {{ feed.title if feed.title else feed.url }}.{% endblock description %} +{% block title %} +| Embed +{% endblock title %} {% block content %}
diff --git a/discord_rss_bot/templates/feed.html b/discord_rss_bot/templates/feed.html index d04a662..92e0e7b 100644 --- a/discord_rss_bot/templates/feed.html +++ b/discord_rss_bot/templates/feed.html @@ -1,10 +1,7 @@ {% extends "base.html" %} {% block title %} - {{ feed.title if feed.title else feed.url }} | discord-rss-bot + | {{ feed.title }} {% endblock title %} -{% block description %} - Review feed health, delivery settings, filters, webhook attachment, and update intervals for {{ feed.title if feed.title else feed.url }}. -{% endblock description %} {% block content %}
diff --git a/discord_rss_bot/templates/index.html b/discord_rss_bot/templates/index.html index 049d30d..6c12656 100644 --- a/discord_rss_bot/templates/index.html +++ b/discord_rss_bot/templates/index.html @@ -1,10 +1,4 @@ {% extends "base.html" %} -{% block title %} - Feeds Dashboard | discord-rss-bot -{% endblock title %} -{% block description %} - View configured feeds, broken sources, webhook groups, and delivery status across your Discord RSS bot dashboard. -{% endblock description %} {% block content %}
    diff --git a/discord_rss_bot/templates/search.html b/discord_rss_bot/templates/search.html index a83ef79..b37f988 100644 --- a/discord_rss_bot/templates/search.html +++ b/discord_rss_bot/templates/search.html @@ -1,12 +1,7 @@ {% extends "base.html" %} {% block title %} - Search - {% if query %}: {{ query }}{% endif %} - | discord-rss-bot + | Search {% endblock title %} -{% block description %} - Browse search results for {{ query if query else "your query" }} across tracked feed entries and feeds. -{% endblock description %} {% block content %}
    Your search for "{{ query }}" returned {{ search_amount.total }} results. diff --git a/discord_rss_bot/templates/settings.html b/discord_rss_bot/templates/settings.html index 1759738..40fd9d0 100644 --- a/discord_rss_bot/templates/settings.html +++ b/discord_rss_bot/templates/settings.html @@ -1,10 +1,7 @@ {% extends "base.html" %} {% block title %} - Settings | discord-rss-bot + | Settings {% endblock title %} -{% block description %} - Adjust default update intervals, delivery modes, and screenshot layout for feeds managed by your bot. -{% endblock description %} {% block content %}
    diff --git a/discord_rss_bot/templates/webhook_entries.html b/discord_rss_bot/templates/webhook_entries.html index b2bb0de..f808e77 100644 --- a/discord_rss_bot/templates/webhook_entries.html +++ b/discord_rss_bot/templates/webhook_entries.html @@ -1,10 +1,7 @@ {% extends "base.html" %} {% block title %} - {{ webhook_name }} | discord-rss-bot + | {{ webhook_name }} {% endblock title %} -{% block description %} - Review webhook settings, attached feeds, and latest entries delivered to {{ webhook_name }}. -{% endblock description %} {% block content %} {% if message %}{% endif %}
    diff --git a/discord_rss_bot/templates/webhooks.html b/discord_rss_bot/templates/webhooks.html index f1d95ca..d37e390 100644 --- a/discord_rss_bot/templates/webhooks.html +++ b/discord_rss_bot/templates/webhooks.html @@ -1,10 +1,7 @@ {% extends "base.html" %} {% block title %} - Webhooks | discord-rss-bot + | Webhooks {% endblock title %} -{% block description %} - Manage stored Discord webhooks and inspect the delivery endpoints connected to your feeds. -{% endblock description %} {% block content %}
    {% for hook in hooks_with_data %} diff --git a/discord_rss_bot/templates/whitelist.html b/discord_rss_bot/templates/whitelist.html index 4345f72..fd27eb6 100644 --- a/discord_rss_bot/templates/whitelist.html +++ b/discord_rss_bot/templates/whitelist.html @@ -1,10 +1,7 @@ {% extends "base.html" %} {% block title %} - Whitelist: {{ feed.title if feed.title else feed.url }} | discord-rss-bot + | Whitelist {% endblock title %} -{% block description %} - Allow only matching entries from {{ feed.title if feed.title else feed.url }} to reach Discord. -{% endblock description %} {% block content %}
    diff --git a/tests/test_main.py b/tests/test_main.py index b3b8ad3..1dc7db9 100644 --- a/tests/test_main.py +++ b/tests/test_main.py @@ -46,26 +46,6 @@ def ensure_preview_feed_exists() -> Reader: return reader -def assert_social_preview_metadata( - response: Response, - *, - title: str, - description: str, -) -> None: - assert response.status_code == 200, f"Expected page to render successfully: {response.text}" - assert f"{title}" in response.text - assert re.search( - rf'', - response.text, - ) - assert f'' in response.text - assert f'' in response.text - assert '' in response.text - assert '' in response.text - assert f'' in response.text - assert f'' in response.text - - def test_search() -> None: """Test the /search page.""" # Remove the feed if it already exists before we run the test. @@ -250,91 +230,6 @@ def test_get() -> None: assert response.status_code == 200, f"/whitelist failed: {response.text}" -def test_views_render_social_preview_metadata() -> None: - client.post(url="/delete_webhook", data={"webhook_url": webhook_url}) - response: Response = client.post( - url="/add_webhook", - data={"webhook_name": webhook_name, "webhook_url": webhook_url}, - ) - assert response.status_code == 200, f"Failed to add webhook: {response.text}" - - feeds: Response = client.get("/") - if feed_url in feeds.text: - client.post(url="/remove", data={"feed_url": feed_url}) - client.post(url="/remove", data={"feed_url": encoded_feed_url(feed_url)}) - - response = client.post(url="/add", data={"feed_url": feed_url, "webhook_dropdown": webhook_name}) - assert response.status_code == 200, f"Failed to add feed: {response.text}" - - assert_social_preview_metadata( - client.get(url="/"), - title="Feeds Dashboard | discord-rss-bot", - description="View configured feeds, broken sources, webhook groups, and delivery status across your Discord RSS bot dashboard.", # noqa: E501 - ) - assert_social_preview_metadata( - client.get(url="/add"), - title="Add Feed | discord-rss-bot", - description="Add a new RSS or Atom feed and attach it to a Discord webhook for delivery.", - ) - assert_social_preview_metadata( - client.get(url="/add_webhook"), - title="Add Webhook | discord-rss-bot", - description="Register a Discord webhook so feeds can post updates into your server or thread.", - ) - assert_social_preview_metadata( - client.get(url="/settings"), - title="Settings | discord-rss-bot", - description="Adjust default update intervals, delivery modes, and screenshot layout for feeds managed by your bot.", # noqa: E501 - ) - assert_social_preview_metadata( - client.get(url="/webhooks"), - title="Webhooks | discord-rss-bot", - description="Manage stored Discord webhooks and inspect the delivery endpoints connected to your feeds.", - ) - assert_social_preview_metadata( - client.get(url="/search", params={"query": "a"}), - title="Search: a | discord-rss-bot", - description="Browse search results for a across tracked feed entries and feeds.", - ) - - feed_response = client.get(url="/feed", params={"feed_url": encoded_feed_url(feed_url)}) - assert feed_response.status_code == 200, f"/feed failed: {feed_response.text}" - assert '' in webhook_entries_response.text - assert ( - f"Review webhook settings, attached feeds, and latest entries delivered to {webhook_name}." - in webhook_entries_response.text - ) - - def test_blacklist_page_uses_live_preview_layout() -> None: ensure_preview_feed_exists()