aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBradley Taunt <bt@btxx.org>2024-07-22 13:22:24 -0400
committerBradley Taunt <bt@btxx.org>2024-07-22 13:22:24 -0400
commit298a8d1bc1d1b58ee3e7beb2342866732e7f0331 (patch)
tree833375c3848d484b6d6baf9242740e5cd215a260
parentd90c77fe3b001ea9157fea3b866220dde313211d (diff)
Carry over changes from core wruby
-rw-r--r--footer.html2
-rw-r--r--wruby.rb23
2 files changed, 16 insertions, 9 deletions
diff --git a/footer.html b/footer.html
index 0700e8c..6d930c0 100644
--- a/footer.html
+++ b/footer.html
@@ -12,7 +12,7 @@
<li><a href="/now">Now</a></li>
<li><a href="/pizza">Pizza</a></li>
<li><a href="/recipes">Recipes</a></li>
- <li><a href="/index.atom">RSS</a></li>
+ <li><a href="/index.rss">RSS</a></li>
<li><a href="#top">&uarr; Top of the page</a></li>
</ul>
<small>
diff --git a/wruby.rb b/wruby.rb
index 42e891b..e47790b 100644
--- a/wruby.rb
+++ b/wruby.rb
@@ -1,6 +1,7 @@
require 'kramdown'
require 'fileutils'
require 'date'
+require 'time'
require 'rss'
require 'find'
@@ -20,7 +21,7 @@ pages_output_dir = "#{output_dir}/"
header_file = 'header.html'
footer_file = 'footer.html'
root_index_file = 'index.md'
-rss_file = "#{output_dir}/index.atom"
+rss_file = "#{output_dir}/index.rss"
# Make sure output directories exist
[posts_output_dir, pages_output_dir].each { |dir| FileUtils.mkdir_p(dir) }
@@ -84,19 +85,25 @@ end
# Generate the RSS feed
def generate_rss(posts, rss_file, author_name, site_name, site_url, posts_dir)
- rss = RSS::Maker.make("atom") do |maker|
+ rss = RSS::Maker.make("2.0") do |maker|
maker.channel.author = author_name
maker.channel.updated = Time.now.utc.to_s
- maker.channel.about = site_url
maker.channel.title = "#{site_name} RSS Feed"
+ maker.channel.description = "The official RSS Feed for #{site_url}"
+ maker.channel.link = site_url
posts.each do |post|
+ date = post[:date].utc
+ item_link = "#{site_url}/#{posts_dir}/#{post[:link]}"
+ item_title = post[:title]
+ item_content = post[:content]
+
maker.items.new_item do |item|
- item.link = "#{site_url}/#{posts_dir}/#{post[:link]}"
- item.title = post[:title]
- item.updated = post[:date].utc.to_s
- item.content.type = 'html'
- item.content.content = post[:content]
+ item.link = item_link
+ item.title = item_title
+ item.updated = date.to_s
+ item.pubDate = date.rfc822
+ item.description = item_content
end
end
end