Browse Source

Tidy media code

main
Adrian Short 5 years ago
parent
commit
f271213280
2 changed files with 12 additions and 10 deletions
  1. +6
    -4
      lib/site.rb
  2. +6
    -6
      views/media.haml

+ 6
- 4
lib/site.rb View File

@@ -53,8 +53,8 @@ class Site
Petrify.csv(path, 'inlink-appeals', apps) Petrify.csv(path, 'inlink-appeals', apps)


# Media page # 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 # Authority pages
auths = ScraperWiki.select("distinct(authority_name) as authority_name from applications") 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']) 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'])] 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) Petrify.csv(path, slug(auth['authority_name']), apps)
end end
end end


+ 6
- 6
views/media.haml View File

@@ -5,15 +5,15 @@
Add more media here Add more media here


%table %table
- media_items.each do |item|
- stories.each do |story|
%tr %tr
%td.nowrap= short_date(item['publish_date'])
%td.nowrap= item['publication']
%td.nowrap= short_date(story['publish_date'])
%td.nowrap= story['publication']
%td %td
%a{ :href => item['url'] }<
= item['title']
%a{ :href => story['url'] }<
= story['title']
-# -#
%div.tags %div.tags
- item['authorities'].split('|').each do |authority|
- story['authorities'].split('|').each do |authority|
%a{ :href => authority_url(authority) }< %a{ :href => authority_url(authority) }<
= authority = authority

Loading…
Cancel
Save