From f271213280acc66a8d751940416d0837e84fbb5d Mon Sep 17 00:00:00 2001 From: Adrian Short Date: Sun, 14 Oct 2018 16:52:54 +0100 Subject: [PATCH] Tidy media code --- lib/site.rb | 10 ++++++---- views/media.haml | 12 ++++++------ 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/lib/site.rb b/lib/site.rb index 0f1785b..9a2cb16 100644 --- a/lib/site.rb +++ b/lib/site.rb @@ -53,8 +53,8 @@ class Site Petrify.csv(path, 'inlink-appeals', apps) # Media page - media_items = CSV.read('media.csv', :headers => true ) - Petrify.page('media', 'media', { media_items: media_items }) + stories = CSV.read('media.csv', :headers => true ) + Petrify.page('media', 'media', { stories: stories }) # Authority pages auths = ScraperWiki.select("distinct(authority_name) as authority_name from applications") @@ -69,10 +69,12 @@ class Site apps = ScraperWiki.select("* from applications where authority_name = ? order by date_received desc", auth['authority_name']) - stories = media_items.select { |s| s[4].match(auth['authority_name'])} + this_stories = stories.select \ + { |story| story['authorities'].match(auth['authority_name']) } path = ['authorities', slug(auth['authority_name'])] - Petrify.page(path, 'authority', { apps: apps, auth: auth, summary: summary, stories: stories }) + Petrify.page(path, 'authority', \ + { apps: apps, auth: auth, summary: summary, stories: this_stories }) Petrify.csv(path, slug(auth['authority_name']), apps) end end diff --git a/views/media.haml b/views/media.haml index 8cda20d..0baa8f7 100644 --- a/views/media.haml +++ b/views/media.haml @@ -5,15 +5,15 @@ Add more media here %table - - media_items.each do |item| + - stories.each do |story| %tr - %td.nowrap= short_date(item['publish_date']) - %td.nowrap= item['publication'] + %td.nowrap= short_date(story['publish_date']) + %td.nowrap= story['publication'] %td - %a{ :href => item['url'] }< - = item['title'] + %a{ :href => story['url'] }< + = story['title'] -# %div.tags - - item['authorities'].split('|').each do |authority| + - story['authorities'].split('|').each do |authority| %a{ :href => authority_url(authority) }< = authority