From b72f3b3a9c0f32e48b32c2118ede3468e5d30e6a Mon Sep 17 00:00:00 2001 From: Adrian Short Date: Mon, 28 Oct 2019 20:44:01 +0000 Subject: [PATCH] Add media RSS feed --- lib/site.rb | 16 ++++++++++++++++ views/media.haml | 4 ++++ 2 files changed, 20 insertions(+) diff --git a/lib/site.rb b/lib/site.rb index 41e18d7..9b4a992 100644 --- a/lib/site.rb +++ b/lib/site.rb @@ -2,6 +2,7 @@ require 'scraperwiki' require 'petrify' require 'csv' require 'json' +require 'rss' class Site def self.generate @@ -70,6 +71,21 @@ class Site stories = CSV.read('media.csv', :headers => true ) Petrify.page('media', 'media', { stories: stories, title: "Media" }) + feed = RSS::Maker.make("2.0") do |maker| + maker.channel.title = "InLinkUK kiosks media coverage" + maker.channel.description = "News and views about Google's UK street kiosk network." + maker.channel.link = "https://kiosks.adrianshort.org/media/" + maker.channel.updated = Time.now.to_s + stories.each do |story| + maker.items.new_item do |item| + item.link = story['url'] + item.title = "%s: %s" % [ story['publication'], story['title'] ] + item.updated = story['publish_date'] + end + end + end + Petrify.file('media', 'index.xml', feed) + # Authority pages auths = ScraperWiki.select("distinct(authority_name) as authority_name from applications") diff --git a/views/media.haml b/views/media.haml index 80c4135..f014d90 100644 --- a/views/media.haml +++ b/views/media.haml @@ -1,5 +1,9 @@ %h1 Media +%p + %a{ :href => 'index.xml' } + RSS feed + %p %a.button{ :href => 'https://github.com/adrianshort/kiosks-campaign/issues/1' } Add more media here