Show if entry is whitelisted or blacklisted
This commit is contained in:
@ -49,9 +49,11 @@ from reader import (
|
|||||||
from starlette.responses import RedirectResponse
|
from starlette.responses import RedirectResponse
|
||||||
from starlette.templating import _TemplateResponse # noqa
|
from starlette.templating import _TemplateResponse # noqa
|
||||||
|
|
||||||
|
from discord_rss_bot.blacklist import has_black_tags, should_be_skipped
|
||||||
from discord_rss_bot.feeds import send_to_discord
|
from discord_rss_bot.feeds import send_to_discord
|
||||||
from discord_rss_bot.search import create_html_for_search_results
|
from discord_rss_bot.search import create_html_for_search_results
|
||||||
from discord_rss_bot.settings import get_reader, list_webhooks
|
from discord_rss_bot.settings import get_reader, list_webhooks
|
||||||
|
from discord_rss_bot.whitelist import has_white_tags, should_be_sent
|
||||||
|
|
||||||
app: FastAPI = FastAPI()
|
app: FastAPI = FastAPI()
|
||||||
app.mount("/static", StaticFiles(directory="discord_rss_bot/static"), name="static")
|
app.mount("/static", StaticFiles(directory="discord_rss_bot/static"), name="static")
|
||||||
@ -76,7 +78,41 @@ def encode_url(url_to_quote: str) -> str:
|
|||||||
print("url_to_quote is None") # TODO: Send error to Discord.
|
print("url_to_quote is None") # TODO: Send error to Discord.
|
||||||
|
|
||||||
|
|
||||||
|
def entry_is_whitelisted(entry_to_check: Entry) -> bool:
|
||||||
|
"""
|
||||||
|
Check if the entry is whitelisted.
|
||||||
|
|
||||||
|
Args:
|
||||||
|
entry_to_check: The feed to check.
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
bool: True if the feed is whitelisted, False otherwise.
|
||||||
|
|
||||||
|
"""
|
||||||
|
if has_white_tags(reader, entry_to_check.feed):
|
||||||
|
if should_be_sent(reader, entry_to_check):
|
||||||
|
return True
|
||||||
|
|
||||||
|
|
||||||
|
def entry_is_blacklisted(entry_to_check: Entry) -> bool:
|
||||||
|
"""
|
||||||
|
Check if the entry is blacklisted.
|
||||||
|
|
||||||
|
Args:
|
||||||
|
entry_to_check: The feed to check.
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
bool: True if the feed is blacklisted, False otherwise.
|
||||||
|
|
||||||
|
"""
|
||||||
|
if has_black_tags(reader, entry_to_check.feed):
|
||||||
|
if should_be_skipped(reader, entry_to_check):
|
||||||
|
return True
|
||||||
|
|
||||||
|
|
||||||
templates.env.filters["encode_url"] = encode_url
|
templates.env.filters["encode_url"] = encode_url
|
||||||
|
templates.env.filters["entry_is_whitelisted"] = entry_is_whitelisted
|
||||||
|
templates.env.filters["entry_is_blacklisted"] = entry_is_blacklisted
|
||||||
|
|
||||||
|
|
||||||
@app.post("/add_webhook")
|
@app.post("/add_webhook")
|
||||||
|
@ -30,6 +30,13 @@
|
|||||||
</div>
|
</div>
|
||||||
{% for entry in entries %}
|
{% for entry in entries %}
|
||||||
<div class="p-2 mb-2 border border-dark">
|
<div class="p-2 mb-2 border border-dark">
|
||||||
|
{% if entry|entry_is_blacklisted %}
|
||||||
|
<span class="text-danger">Blacklisted</span>
|
||||||
|
{% endif %}
|
||||||
|
{% if entry|entry_is_whitelisted %}
|
||||||
|
<span class="text-success">Whitelisted</span>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
<h2>
|
<h2>
|
||||||
<a class="text-muted text-decoration-none" href="{{ entry.link }}">
|
<a class="text-muted text-decoration-none" href="{{ entry.link }}">
|
||||||
{{ entry.title }}
|
{{ entry.title }}
|
||||||
|
Reference in New Issue
Block a user