refactor RSS from Atom to 2.0 and hopefully get it working without guids

This commit is contained in:
Kyle Drake 2024-01-07 13:35:36 -06:00
parent 2f6ba312dc
commit f261db16b0
2 changed files with 16 additions and 10 deletions

View file

@ -1488,6 +1488,10 @@ class Site < Sequel::Model
File.exist? File.join(base_screenshots_path, "#{path}.#{resolution}.webp") File.exist? File.join(base_screenshots_path, "#{path}.#{resolution}.webp")
end end
def sharing_screenshot_url
'https://neocities.org'+base_screenshots_url+'/index.html.jpg'
end
def screenshot_url(path, resolution) def screenshot_url(path, resolution)
path[0] = '' if path[0] == '/' path[0] = '' if path[0] == '/'
out = '' out = ''
@ -1518,18 +1522,20 @@ class Site < Sequel::Model
end end
def to_rss def to_rss
RSS::Maker.make("atom") do |maker| RSS::Maker.make("2.0") do |m|
maker.channel.title = title m.channel.title = title
maker.channel.updated = (updated_at ? updated_at : created_at) m.channel.link = uri
maker.channel.author = username m.channel.description = "Site feed for #{title}"
maker.channel.id = "#{username}.neocities.org" m.image.url = sharing_screenshot_url
m.image.title = title
latest_events.each do |event| latest_events.each do |event|
if event.site_change_id if event.site_change_id
maker.items.new_item do |item| m.items.new_item do |i|
item.link = "https://#{host}" i.title = "#{title} has been updated."
item.title = "#{title} has been updated" i.link = "https://neocities.org/site/#{username}?event_id=#{event.id.to_s}"
item.updated = event.site_change.created_at i.pubDate = event.created_at
end end
end end
end end

View file

@ -3,7 +3,7 @@
page_uri = site.uri page_uri = site.uri
end end
%> %>
<a href="/site/<%= site.username %>.rss" target="_blank"><span>RSS/Atom Feed</span></a> <a href="/site/<%= site.username %>.rss" target="_blank"><span>RSS Feed</span></a>
<br> <br>
<a href="https://facebook.com/sharer.php?<%= Rack::Utils.build_query(u: "#{page_uri}") %>" target="_blank">Facebook</a> <a href="https://facebook.com/sharer.php?<%= Rack::Utils.build_query(u: "#{page_uri}") %>" target="_blank">Facebook</a>
<br> <br>