home.wezm.net/infra/gen-items
Wesley Moore 9d34ed8ed6
Add RSS feed for news
Parse the RSS feed to generate the News section on the home page.
2025-05-31 12:29:13 +10:00

42 lines
1.5 KiB
Ruby

#!/usr/bin/env ruby
require 'shellwords'
# https://stackoverflow.com/a/1732454
def strip_tags(text)
text.gsub(/<\/?[^>]*>/, '').strip
end
ITEMS=<<~EOI
<li>22 May 2025 &middot; Answered the <a href="quiz.html">Rubenerd Blog Quiz 2025</a></li>
<li>25 Apr 2025 &middot; Renamed the site from Wes' Nonsense Website to Wes' Retro Site.</li>
<li>24 Apr 2025 &middot; Thanks to <a href="https://noelle.dev/">Noelle Leigh</a>
for contributing <a href="https://forge.wezm.net/wezm/home.wezm.net/pulls/1">a patch</a>
to reduce reflow by adding dimensions to all the images.</li>
<li>21 Apr 2025 &middot; Published <a href="https://www.wezm.net/v2/posts/2025/website-fit-for-1999/">a post about building this site</a>.</li>
<li>20 Apr 2025 &middot; Added Sunshine Coast page and site map.</li>
<li>19 Apr 2025 &middot; Added live energy stats.</li>
<li>16 Apr 2025 &middot; Added pineapple growing page.</li>
EOI
ITEMS.strip.split("</li>").each do |li|
li.sub!(/^<li>/, '')
date, description = li.split(' &middot; ')
date = "#{date.strip} 09:00:00"
description.strip!
uuid = `uuidgen --time`.strip
pub_date = `date -j -R -f "%d %b %Y %H:%M:%S" #{date.shellescape}`.strip
title = strip_tags(description).sub(/\.$/, '')
puts <<~ITEM
<item>
<guid isPermaLink="false">#{uuid}</guid>
<pubDate>#{pub_date}</pubDate>
<link>http://home.wezm.net/~wmoore/##{uuid}</link>
<title>#{title}</title>
<description><![CDATA[#{description}]]></description>
</item>
ITEM
end