Improve feed page
This commit is contained in:
@ -451,20 +451,18 @@ def create_html_for_feed(entries: Iterable[Entry]) -> str:
|
||||
|
||||
entry_id: str = urllib.parse.quote(entry.id)
|
||||
to_disord_html: str = f"<a class='text-muted' href='/post_entry?entry_id={entry_id}'>Send to Discord</a>"
|
||||
image_html: str = f"<img src='{first_image}' class='img-fluid' alt='{first_image_text}'>" if first_image else ""
|
||||
|
||||
html += f"""
|
||||
<div class="p-2 mb-2 border border-dark">
|
||||
{blacklisted}
|
||||
{whitelisted}
|
||||
html += f"""<div class="p-2 mb-2 border border-dark">
|
||||
{blacklisted}{whitelisted}<a class="text-muted text-decoration-none" href="{entry.link}"><h2>{entry.title}</h2></a>
|
||||
{f"By { entry.author } @" if entry.author else ""}{published} - {to_disord_html}
|
||||
|
||||
<a class="text-muted text-decoration-none" href="{entry.link}"><h2>{entry.title}</h2></a>
|
||||
{text}
|
||||
{image_html}
|
||||
</div>
|
||||
"""
|
||||
|
||||
{f"By { entry.author } @" if entry.author else ""} {published} - {to_disord_html}
|
||||
{text}
|
||||
{f"<img src='{first_image}' class='img-fluid' alt='{first_image_text}'>" if first_image else ""}
|
||||
</div>
|
||||
"""
|
||||
return html
|
||||
return html.strip()
|
||||
|
||||
|
||||
@app.get("/webhooks", response_class=HTMLResponse)
|
||||
|
@ -52,9 +52,9 @@ def convert_html_to_md(html: str) -> str:
|
||||
for tag in soup.find_all(True):
|
||||
tag.replace_with(tag.text)
|
||||
|
||||
# If the text ends with a newline, remove it
|
||||
# return soup.text[:-1] if soup.text.endswith("\n") else soup.text
|
||||
return soup.text
|
||||
# Remove all leading and trailing whitespace
|
||||
soup_text = soup.text
|
||||
return soup_text.strip()
|
||||
|
||||
|
||||
# Test the function
|
||||
|
@ -38,5 +38,7 @@
|
||||
<a class="text-muted" href="/custom?feed_url={{ feed.url|encode_url }}">Custom message</a>
|
||||
</div>
|
||||
{# HTML is created in main.create_html_for_feed #}
|
||||
<pre>
|
||||
{{ html|safe }}
|
||||
</pre>
|
||||
{% endblock content %}
|
||||
|
Reference in New Issue
Block a user