From b8e3a598e3a61c0aac0a8365feacf3c45243c136 Mon Sep 17 00:00:00 2001 From: Adrian Short Date: Tue, 29 Oct 2019 12:55:00 +0000 Subject: [PATCH] Add RSS media feeds for individual authorities --- lib/site.rb | 27 ++++++++++++++++++++++++++- views/authority.haml | 15 +++++++++++++-- 2 files changed, 39 insertions(+), 3 deletions(-) diff --git a/lib/site.rb b/lib/site.rb index 6dd6042..17c791b 100644 --- a/lib/site.rb +++ b/lib/site.rb @@ -102,7 +102,6 @@ class Site end end end - end Petrify.file('media', 'index.xml', feed) @@ -131,6 +130,32 @@ class Site Petrify.page(path, 'authority', \ { apps: apps, auth: auth, summary: summary, stories: this_stories, title: auth['authority_name'] }) Petrify.csv(path, slug(auth['authority_name']), apps) + + # RSS feed for this authority's media stories + feed = RSS::Maker.make("2.0") do |maker| + maker.channel.title = "#{auth['authority_name']} InLinkUK kiosks media coverage" + maker.channel.description = "News and views about Google's UK street kiosk network in #{auth['authority_name']}." + maker.channel.link = "#{SITEURL}#{authority_url(auth['authority_name'])}" + maker.channel.updated = Time.now.to_s + + this_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'] + + if story['authorities'] + links = [] + story['authorities'].split('|').each do |auth| + auth.strip! + links << "%s" % [ SITEURL + authority_url(auth), auth ] + end + item.description = links.join(', ') + end + end + end + end + Petrify.file(path, 'media.xml', feed) end end end diff --git a/views/authority.haml b/views/authority.haml index 4c5cf3e..92dd8d9 100644 --- a/views/authority.haml +++ b/views/authority.haml @@ -21,10 +21,19 @@ %td= cleanup(row['appeal_decision']) %td.right= row['qty'] -- if stories.size > 0 - %h2 Media +%h2 Media + +%p + %a{ :href => 'media.xml' } + RSS feed for InLinkUK media stories in + = auth['authority_name'] +%p + %a.button{ :href => 'https://github.com/adrianshort/kiosks-campaign/issues/1' } + Add more media here + +- if stories.size > 0 %table - stories.each do |item| %tr @@ -33,6 +42,8 @@ %td %a{ :href => item['url'] }< = item['title'] +- else + %p No media stories. %h2 Applications