Compare commits
2 Commits
901d6cb1a6
...
2a6dbd33dd
Author | SHA1 | Date | |
---|---|---|---|
2a6dbd33dd
|
|||
96bcd81191
|
@ -68,8 +68,18 @@ def replace_tags_in_text_message(entry: Entry) -> str:
|
|||||||
|
|
||||||
first_image: str = get_first_image(summary, content)
|
first_image: str = get_first_image(summary, content)
|
||||||
|
|
||||||
summary = markdownify(html=summary, strip=["img", "table", "td", "tr", "tbody", "thead"], escape_misc=False)
|
summary = markdownify(
|
||||||
content = markdownify(html=content, strip=["img", "table", "td", "tr", "tbody", "thead"], escape_misc=False)
|
html=summary,
|
||||||
|
strip=["img", "table", "td", "tr", "tbody", "thead"],
|
||||||
|
escape_misc=False,
|
||||||
|
heading_style="ATX",
|
||||||
|
)
|
||||||
|
content = markdownify(
|
||||||
|
html=content,
|
||||||
|
strip=["img", "table", "td", "tr", "tbody", "thead"],
|
||||||
|
escape_misc=False,
|
||||||
|
heading_style="ATX",
|
||||||
|
)
|
||||||
|
|
||||||
if "[https://" in content or "[https://www." in content:
|
if "[https://" in content or "[https://www." in content:
|
||||||
content = content.replace("[https://", "[")
|
content = content.replace("[https://", "[")
|
||||||
@ -189,8 +199,18 @@ def replace_tags_in_embed(feed: Feed, entry: Entry) -> CustomEmbed:
|
|||||||
|
|
||||||
first_image: str = get_first_image(summary, content)
|
first_image: str = get_first_image(summary, content)
|
||||||
|
|
||||||
summary = markdownify(html=summary, strip=["img", "table", "td", "tr", "tbody", "thead"], escape_misc=False)
|
summary = markdownify(
|
||||||
content = markdownify(html=content, strip=["img", "table", "td", "tr", "tbody", "thead"], escape_misc=False)
|
html=summary,
|
||||||
|
strip=["img", "table", "td", "tr", "tbody", "thead"],
|
||||||
|
escape_misc=False,
|
||||||
|
heading_style="ATX",
|
||||||
|
)
|
||||||
|
content = markdownify(
|
||||||
|
html=content,
|
||||||
|
strip=["img", "table", "td", "tr", "tbody", "thead"],
|
||||||
|
escape_misc=False,
|
||||||
|
heading_style="ATX",
|
||||||
|
)
|
||||||
|
|
||||||
if "[https://" in content or "[https://www." in content:
|
if "[https://" in content or "[https://www." in content:
|
||||||
content = content.replace("[https://", "[")
|
content = content.replace("[https://", "[")
|
||||||
|
@ -921,6 +921,29 @@ async def remove_feed(feed_url: Annotated[str, Form()]):
|
|||||||
return RedirectResponse(url="/", status_code=303)
|
return RedirectResponse(url="/", status_code=303)
|
||||||
|
|
||||||
|
|
||||||
|
@app.get("/update", response_class=HTMLResponse)
|
||||||
|
async def update_feed(request: Request, feed_url: str):
|
||||||
|
"""Update a feed.
|
||||||
|
|
||||||
|
Args:
|
||||||
|
request: The request object.
|
||||||
|
feed_url: The feed URL to update.
|
||||||
|
|
||||||
|
Raises:
|
||||||
|
HTTPException: If the feed is not found.
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
RedirectResponse: Redirect to the feed page.
|
||||||
|
"""
|
||||||
|
try:
|
||||||
|
reader.update_feed(urllib.parse.unquote(feed_url))
|
||||||
|
except FeedNotFoundError as e:
|
||||||
|
raise HTTPException(status_code=404, detail="Feed not found") from e
|
||||||
|
|
||||||
|
logger.info("Manually updated feed: %s", feed_url)
|
||||||
|
return RedirectResponse(url="/feed?feed_url=" + urllib.parse.quote(feed_url), status_code=303)
|
||||||
|
|
||||||
|
|
||||||
@app.get("/search", response_class=HTMLResponse)
|
@app.get("/search", response_class=HTMLResponse)
|
||||||
async def search(request: Request, query: str):
|
async def search(request: Request, query: str):
|
||||||
"""Get entries matching a full-text search query.
|
"""Get entries matching a full-text search query.
|
||||||
|
@ -28,6 +28,8 @@
|
|||||||
|
|
||||||
<!-- Feed Actions -->
|
<!-- Feed Actions -->
|
||||||
<div class="mt-3 d-flex flex-wrap gap-2">
|
<div class="mt-3 d-flex flex-wrap gap-2">
|
||||||
|
<a href="/update?feed_url={{ feed.url|encode_url }}" class="btn btn-primary btn-sm">Update</a>
|
||||||
|
|
||||||
<form action="/remove" method="post" class="d-inline">
|
<form action="/remove" method="post" class="d-inline">
|
||||||
<button class="btn btn-danger btn-sm" name="feed_url" value="{{ feed.url }}"
|
<button class="btn btn-danger btn-sm" name="feed_url" value="{{ feed.url }}"
|
||||||
onclick="return confirm('Are you sure you want to delete this feed?')">Remove</button>
|
onclick="return confirm('Are you sure you want to delete this feed?')">Remove</button>
|
||||||
|
@ -229,3 +229,41 @@ def test_delete_webhook() -> None:
|
|||||||
response = client.get(url="/webhooks")
|
response = client.get(url="/webhooks")
|
||||||
assert response.status_code == 200, f"Failed to get /webhooks: {response.text}"
|
assert response.status_code == 200, f"Failed to get /webhooks: {response.text}"
|
||||||
assert webhook_name not in response.text, f"Webhook found in /webhooks: {response.text}"
|
assert webhook_name not in response.text, f"Webhook found in /webhooks: {response.text}"
|
||||||
|
|
||||||
|
|
||||||
|
def test_update_feed_success() -> None:
|
||||||
|
"""Test updating an existing feed."""
|
||||||
|
# Remove the feed if it already exists before we run the test
|
||||||
|
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)})
|
||||||
|
|
||||||
|
# Add the webhook
|
||||||
|
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}"
|
||||||
|
assert webhook_name in response.text, f"Webhook not found in /webhooks: {response.text}"
|
||||||
|
|
||||||
|
# Add the feed
|
||||||
|
response: 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}"
|
||||||
|
|
||||||
|
# Update the feed
|
||||||
|
response: Response = client.get(url="/update", params={"feed_url": encoded_feed_url(feed_url)})
|
||||||
|
assert response.status_code == 200, f"Failed to update feed: {response.status_code}, {response.text}"
|
||||||
|
|
||||||
|
|
||||||
|
def test_update_feed_not_found() -> None:
|
||||||
|
"""Test updating a non-existent feed."""
|
||||||
|
# Generate a feed URL that does not exist
|
||||||
|
nonexistent_feed_url = "https://nonexistent-feed.example.com/rss.xml"
|
||||||
|
|
||||||
|
# Try to update the non-existent feed
|
||||||
|
response: Response = client.get(url="/update", params={"feed_url": urllib.parse.quote(nonexistent_feed_url)})
|
||||||
|
|
||||||
|
# Check that it returns a 404 status code
|
||||||
|
assert response.status_code == 404, f"Expected 404 for non-existent feed, got: {response.status_code}"
|
||||||
|
assert "Feed not found" in response.text
|
||||||
|
Reference in New Issue
Block a user