Browse Source

Add media to authority pages

main
Adrian Short 5 years ago
parent
commit
e9c4301325
2 changed files with 20 additions and 5 deletions
  1. +7
    -5
      lib/site.rb
  2. +13
    -0
      views/authority.haml

+ 7
- 5
lib/site.rb View File

@@ -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

+ 13
- 0
views/authority.haml View File

@@ -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')


Loading…
Cancel
Save