diff --git a/lib/site.rb b/lib/site.rb index 9fe7909..0f1785b 100644 --- a/lib/site.rb +++ b/lib/site.rb @@ -52,6 +52,10 @@ class Site Petrify.page(path, 'appeals', { summary: summary, apps: apps }) Petrify.csv(path, 'inlink-appeals', apps) + # Media page + media_items = CSV.read('media.csv', :headers => true ) + Petrify.page('media', 'media', { media_items: media_items }) + # Authority pages auths = ScraperWiki.select("distinct(authority_name) as authority_name from applications") @@ -65,13 +69,11 @@ 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'])} + path = ['authorities', slug(auth['authority_name'])] - Petrify.page(path, 'authority', { apps: apps, auth: auth, summary: summary }) + Petrify.page(path, 'authority', { apps: apps, auth: auth, summary: summary, stories: stories }) Petrify.csv(path, slug(auth['authority_name']), apps) end end - - # Media page - media_items = CSV.read('media.csv', :headers => true ) - Petrify.page('media', 'media', { media_items: media_items }) end diff --git a/views/authority.haml b/views/authority.haml index 6c08791..4c5cf3e 100644 --- a/views/authority.haml +++ b/views/authority.haml @@ -21,6 +21,19 @@ %td= cleanup(row['appeal_decision']) %td.right= row['qty'] +- if stories.size > 0 + + %h2 Media + + %table + - stories.each do |item| + %tr + %td.nowrap= short_date(item['publish_date']) + %td.nowrap= item['publication'] + %td + %a{ :href => item['url'] }< + = item['title'] + %h2 Applications %p= download_button(slug(auth['authority_name']) + '.csv')