From 0e275f023095f58033fda045c22e695de16f3517 Mon Sep 17 00:00:00 2001 From: Steve Gattuso Date: Sun, 11 Jun 2023 16:40:15 +0200 Subject: [PATCH] better adhearance to spec --- feedon/blueprints/feeds.py | 6 ++- feedon/templates/feeds/atom.xml | 69 +++++++++++++-------------- feedon/templates/timelines/index.html | 2 +- 3 files changed, 38 insertions(+), 39 deletions(-) diff --git a/feedon/blueprints/feeds.py b/feedon/blueprints/feeds.py index 67627fe..d81bc1b 100644 --- a/feedon/blueprints/feeds.py +++ b/feedon/blueprints/feeds.py @@ -9,9 +9,11 @@ bp = Blueprint('feeds', __name__, url_prefix='/feeds') @bp.route('///atom.xml') def render_feed(user_id, password): - user = db.User.get(user_id) - timeline = user.timelines.where(db.Timeline.password == password).first() + user = db.User.get_or_none(user_id) + if user is None: + abort(404) + timeline = user.timelines.where(db.Timeline.password == password).first() if timeline is None: return abort(404) diff --git a/feedon/templates/feeds/atom.xml b/feedon/templates/feeds/atom.xml index 70d5cef..152499e 100644 --- a/feedon/templates/feeds/atom.xml +++ b/feedon/templates/feeds/atom.xml @@ -1,40 +1,33 @@ -{% macro render_toot_content(toot, parent=false) %} - {% if parent %} - RT: {{ toot.content | striptags }} - {% else %} - {{ toot.content | striptags }} - {% endif %} - - {% if parent %} -

Boosted by {{parent.account.display_name}} ({{parent.account.acct}}):

- {% endif %} +{%- macro render_toot_content(toot, parent=false) -%} + {%- if parent -%} +

Boosted by {{parent.account.display_name}} ({{parent.account.acct}}):

+ {%- endif -%} - {% if toot.content %} -
- {{toot.content | safe}} -
- {% endif %} -

- {{toot.account.display_name}} ({{toot.account.acct}})

+ {% if toot.content %} +
+ {{toot.content | safe}} +
+ {% endif %} +

- {{toot.account.display_name}} ({{toot.account.acct}})

- {% for attachment in toot.media_attachments %} - {% if attachment.type == "image" %} + {% for attachment in toot.media_attachments %} + {% if attachment.type == "image" %} +

+ + + +

+ {% if attachment.description %}

- - - + {{attachment.description}}

- {% if attachment.description %} -

- {{attachment.description}} -

- {% endif %} - {% else %} - Attachment {{attachment.type}} not supported. {% endif %} - {% endfor %} -
-{% endmacro %} + {% else %} + Attachment {{attachment.type}} not supported. + {% endif %} + {% endfor %} +{%- endmacro -%} {{timeline.title}} {{base_url}}/feeds @@ -63,11 +56,15 @@ {% endif %} {{toot.created_at}} {{toot.created_at}} - {% if toot.reblog %} - {{render_toot_content(toot.reblog, toot)}} - {% else %} - {{render_toot_content(toot)}} - {% endif %} + + {% filter forceescape %} + {% if toot.reblog %} + {{render_toot_content(toot.reblog, toot)}} + {% else %} + {{render_toot_content(toot)}} + {% endif %} + {% endfilter %} + {% endfor %} diff --git a/feedon/templates/timelines/index.html b/feedon/templates/timelines/index.html index 0215c4b..803d301 100644 --- a/feedon/templates/timelines/index.html +++ b/feedon/templates/timelines/index.html @@ -25,10 +25,10 @@
-
+
{% endfor %} -- 2.45.2