- Add country name, city name, and state name to the RSS feed - Include weather description and AI-generated description - Add weather date to provide more context for each item These changes improve the RSS feed by providing more detailed information about the weather art, enhancing the user experience and making the feed more informative for subscribers.
30 lines
1.1 KiB
Ruby
30 lines
1.1 KiB
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.countryName art.city&.country&.name
|
|
xml.cityName art.city&.name
|
|
xml.stateName art.city&.state&.name
|
|
xml.weatherDescription art.description
|
|
xml.aiDescription art.prompt
|
|
xml.weatherData art.weather_date
|
|
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
|