From 5d6d4f9ca0766d4dc281f673d1a790b77d137f41 Mon Sep 17 00:00:00 2001 From: TLSM Date: Mon, 30 May 2022 04:30:57 -0400 Subject: [PATCH] Feeds: make RSS valid. Patch provided via c/o tejmar of WPD. Intended to fix the invalid RSS format which caused issues when using the feeds with Discord and Telegram. --- files/routes/feeds.py | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/files/routes/feeds.py b/files/routes/feeds.py index 2d97ef0d2..a64a2827f 100644 --- a/files/routes/feeds.py +++ b/files/routes/feeds.py @@ -33,8 +33,12 @@ def feeds_user(sort='hot', t='all'): with tag("title", type="text"): text(f"{sort} posts from {domain}") - doc.stag("link", href=SITE_FULL + request.full_path) - doc.stag("link", href=SITE_FULL) + with tag("id"): + text(SITE_FULL + request.full_path) + with tag("updated"): + text(datetime.now().isoformat()+"Z") + doc.stag("link", rel="self", type="application/atom+xml", href=SITE_FULL + request.full_path) + doc.stag("link", rel="alternate", type="text/html", href=SITE_FULL) for post in posts: with tag("entry", ("xml:base", SITE_FULL + request.full_path)): @@ -42,14 +46,14 @@ def feeds_user(sort='hot', t='all'): text(post.realtitle(None)) with tag("id"): - text(post.fullname) + text(post.permalink) if (post.edited_utc): with tag("updated"): - text(datetime.utcfromtimestamp(post.edited_utc).isoformat()) + text(datetime.utcfromtimestamp(post.edited_utc).isoformat()+"Z") with tag("published"): - text(datetime.utcfromtimestamp(post.created_utc).isoformat()) + text(datetime.utcfromtimestamp(post.created_utc).isoformat()+"Z") with tag("author"): with tag("name"): @@ -67,4 +71,4 @@ def feeds_user(sort='hot', t='all'): with tag("content", type="html"): doc.cdata(f'''{post.realtitle(None)}
{post.realbody(None)}''') - return Response( ""+ doc.getvalue(), mimetype="application/xml") \ No newline at end of file + return Response( ""+ doc.getvalue(), mimetype="application/xml")