diff --git a/app.rb b/app.rb index 9bc1724..f24c986 100644 --- a/app.rb +++ b/app.rb @@ -147,6 +147,30 @@ get '/about' do haml :about end +get '/scoreboard.csv' do + @councils = Council.all( :order => ['name'] ) + labels = %w[ + id + created_at + updated_at + name + slug + url + data_url + open_licence + machine_readable + start_d + end_d + ] + headers "Content-Disposition" => "attachment;filename=armchair-auditor-scoreboard.csv", + "Content-Type" => "text/csv" + output = "" + for council in @councils + output += council.to_csv + end + labels.join(',') + "\n" + output +end + get '/scoreboard' do @councils = Council.all( :order => ['name'] ) haml :scoreboard diff --git a/lib/models.rb b/lib/models.rb index 4c09d89..82cbdc6 100644 --- a/lib/models.rb +++ b/lib/models.rb @@ -100,7 +100,6 @@ class Council property :data_url, String, :length => 512 property :open_licence, Boolean, :default => false property :machine_readable, Boolean, :default => false - property :grade, String, :length => 1 property :start_d, Date property :end_d, Date diff --git a/public/style.css b/public/style.css index 809d334..e519931 100644 --- a/public/style.css +++ b/public/style.css @@ -104,6 +104,12 @@ strong color: #000; } +.strong +{ + color: #000; + font-weight: bold; +} + table { border-collapse: collapse; diff --git a/views/scoreboard.haml b/views/scoreboard.haml index 9bad92e..c639435 100644 --- a/views/scoreboard.haml +++ b/views/scoreboard.haml @@ -1,6 +1,10 @@ .grid_12 %h2= @page_title = "Council Spending Data Scoreboard" - + + %p.noprint.download + %a{ :href => "/scoreboard.csv" } + Download data as CSV + %table %tr %th Council @@ -24,7 +28,19 @@ %td= council.start_d.strftime("%b %Y") %td= council.end_d.strftime("%b %Y") %td= council.updated_at.strftime("%d %b %Y") - + + %p.highlight.noprint + This scoreboard data is free for you to use according to the + %a{ :href => "http://creativecommons.org/licenses/by/3.0/"}< + Creative Commons Attribution 3.0 Unported Licence. + Please credit to + %strong + Adrian Short/Armchair Auditor + and link back to + %a{ :href => "http://armchairauditor.co.uk/scoreboard" }< + http://armchairauditor.co.uk/scoreboard + where possible. + %h3 Notes %p