From 37e7aa9a6a034269c1cfc1036d056aebe5ae9140 Mon Sep 17 00:00:00 2001 From: Adrian Short Date: Tue, 29 Oct 2019 11:36:32 +0000 Subject: [PATCH] Improve media RSS feed Move SITEURL config to env var Add authority links to item descriptions --- lib/site.rb | 22 +++++++++++++++++++++- views/layout.haml | 4 ++-- 2 files changed, 23 insertions(+), 3 deletions(-) diff --git a/lib/site.rb b/lib/site.rb index 9b4a992..6dd6042 100644 --- a/lib/site.rb +++ b/lib/site.rb @@ -4,6 +4,15 @@ require 'csv' require 'json' require 'rss' + +if ENV['KIOSKS_SITEURL'] + SITEURL = ENV['KIOSKS_SITEURL'] +else + puts "KIOSKS_SITEURL environment variable must be set to the base URL of the site without a trailing slash" + puts "eg https://kiosks.adrianshort.org" + exit 1 +end + class Site def self.generate # Home page @@ -74,15 +83,26 @@ class Site 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.link = "#{SITEURL}/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'] + + 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('media', 'index.xml', feed) diff --git a/views/layout.haml b/views/layout.haml index 164c854..5fe8bd6 100644 --- a/views/layout.haml +++ b/views/layout.haml @@ -2,7 +2,7 @@ %html %head %title - - subtitle = "InLink kiosks planning applications" + - subtitle = "InLinkUK from BT kiosks planning applications" - if defined? title = "#{title} · #{subtitle}" - else @@ -11,7 +11,7 @@ %body #main %header - %h1 InLink kiosks planning applications + %h1 InLinkUK from BT kiosks planning applications %nav %ul.menu %li