Browse Source

Add media to authority pages

main
Adrian Short 6 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.page(path, 'appeals', { summary: summary, apps: apps })
Petrify.csv(path, 'inlink-appeals', 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 # Authority pages
auths = ScraperWiki.select("distinct(authority_name) as authority_name from applications") 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']) 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'])] 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) Petrify.csv(path, slug(auth['authority_name']), apps)
end end
end end
# Media page
media_items = CSV.read('media.csv', :headers => true )
Petrify.page('media', 'media', { media_items: media_items })
end end

+ 13
- 0
views/authority.haml View File

@@ -21,6 +21,19 @@
%td= cleanup(row['appeal_decision']) %td= cleanup(row['appeal_decision'])
%td.right= row['qty'] %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 %h2 Applications


%p= download_button(slug(auth['authority_name']) + '.csv') %p= download_button(slug(auth['authority_name']) + '.csv')


Loading…
Cancel
Save