Some checks failed
Docker / docker (push) Has been cancelled
- Introduce RssController to handle RSS feed requests - Add a new route for the RSS feed - Implement RSS feed view to display weather art - Update application layout to include RSS feed link - Set content type for RSS responses This commit adds an RSS feed feature that allows users to subscribe to updates on daily AI-generated weather art. The feed includes the latest weather art and relevant metadata, enhancing user engagement and accessibility.
25 lines
897 B
Ruby
25 lines
897 B
Ruby
# app/views/rss/feed.rss.builder
|
|
xml.instruct! :xml, version: "1.0"
|
|
xml.rss version: "2.0",
|
|
"xmlns:atom" => "http://www.w3.org/2005/Atom" do
|
|
xml.channel do
|
|
xml.title "Today AI Weather Art"
|
|
xml.description "Daily AI-generated weather art and forecasts"
|
|
xml.link root_url
|
|
xml.language "en"
|
|
xml.atom :link, href: rss_feed_url(format: :rss), rel: "self", type: "application/rss+xml"
|
|
|
|
@weather_arts.each do |art|
|
|
xml.item do
|
|
xml.title "#{art.city.full_name} Weather Art"
|
|
xml.description art.description
|
|
xml.pubDate art.created_at.to_fs(:rfc822)
|
|
xml.link city_weather_art_url(art.city, art)
|
|
xml.guid city_weather_art_url(art.city, art)
|
|
# 如果有图片,添加图片链接
|
|
xml.enclosure url: rails_blob_url(art.webp_image.processed), type: "image/jpeg" if art.image.attached?
|
|
end
|
|
end
|
|
end
|
|
end
|