Skip to content

Commit

Permalink
fix link on item in rss feed
Browse files Browse the repository at this point in the history
  • Loading branch information
alifeee committed Jan 17, 2025
1 parent d481759 commit 4b2b35f
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 4 deletions.
4 changes: 2 additions & 2 deletions feed.xml
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@

<entry>
<title>How to create a blog (gist)</title>
<link href='https://blog.alifeee.co.uk/https://gist.github.com/alifeee/c857bfb45bfd260a9b9dd9c45e4f7478' />
<id>https://blog.alifeee.co.uk//https://gist.github.com/alifeee/c857bfb45bfd260a9b9dd9c45e4f7478</id>
<link href='https://gist.github.com/alifeee/c857bfb45bfd260a9b9dd9c45e4f7478' />
<id>https://gist.github.com/alifeee/c857bfb45bfd260a9b9dd9c45e4f7478</id>
<updated>2024-01-17T00:00:00+00:00</updated>
<summary>How to create a blog (gist)</summary>
</entry>
Expand Down
33 changes: 31 additions & 2 deletions utilities.py/rss_feed.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,26 @@
# sort posts by date
posts.sort(key=lambda post: post.date, reverse=True)

# list of posts to jank ID for
jank_ids = [
"https://blog.alifeee.co.uk/2024/12/hitchhiking/",
"https://blog.alifeee.co.uk/2024/09/sellotape-dispenser/",
"https://blog.alifeee.co.uk/2024/09/fold-an-envelope/",
"https://blog.alifeee.co.uk/railcards",
"https://blog.alifeee.co.uk/gists",
"https://blog.alifeee.co.uk/font-workshop",
"https://blog.alifeee.co.uk/making-bogface",
"https://blog.alifeee.co.uk/what-is-a-third-space",
"https://blog.alifeee.co.uk/hackspace-adventures",
"https://blog.alifeee.co.uk/factorio-proximity-chat",
"https://blog.alifeee.co.uk/hull-bus-sign",
"https://blog.alifeee.co.uk/steam-collage-api",
"https://blog.alifeee.co.uk/snippets-of-a-degree",
"https://blog.alifeee.co.uk/sketch-your-society",
"https://blog.alifeee.co.uk/ring-populations",
"https://blog.alifeee.co.uk/bike-to-cambridge",
]

# generate feed
feed = ""
feed += "<?xml version='1.0' encoding='UTF-8'?>\n"
Expand All @@ -27,11 +47,20 @@
feed += f"<id>{SUMMARY_ID}</id>\n"
feed += f"<icon>{SUMMARY_ICON}</icon>\n\n"
for post in posts:
link = SUMMARY_LINK + "/" + post.relative_url.lstrip("./")
if post.relative_url.startswith("http"):
link = post.relative_url
else:
link = SUMMARY_LINK + "/" + post.relative_url.lstrip("./")

# fix old IDs having erroneous double slash
id_ = link
if link in jank_ids:
id_ = id_.replace(".uk/", ".uk//")

feed += "<entry>\n"
feed += f" <title>{post.title}</title>\n"
feed += f" <link href='{link}' />\n"
feed += f" <id>{SUMMARY_ID}/{post.relative_url.lstrip('./')}</id>\n"
feed += f" <id>{id_}</id>\n"
feed += f" <updated>{post.date.isoformat()}</updated>\n"
feed += f" <summary>{post.description}</summary>\n"
feed += "</entry>\n\n"
Expand Down

0 comments on commit 4b2b35f

Please sign in to comment.