From 6a058023db7bd5362dad4860adc9160b06f3b5dd Mon Sep 17 00:00:00 2001 From: Adrian Short Date: Sat, 22 Sep 2018 14:09:58 +0100 Subject: [PATCH] Generate new applications page --- bin/build | 6 ++++++ lib/helpers.rb | 4 ++++ views/layout.haml | 4 ++-- views/new.haml | 20 ++++++++++++++++++++ 4 files changed, 32 insertions(+), 2 deletions(-) create mode 100644 views/new.haml diff --git a/bin/build b/bin/build index 45ea8fb..e519e00 100755 --- a/bin/build +++ b/bin/build @@ -51,6 +51,11 @@ end def gen_homepage decisions = ScraperWiki.select("* from `applications` order by date_decision desc limit 20") write_page('.', 'index', { decisions: decisions }) + +def gen_new + apps = ScraperWiki.select("* from `applications` order by date_received desc limit 30") + write_page('new', 'new', { apps: apps }) +end end def gen_authorities @@ -83,4 +88,5 @@ puts @working_dir @pages = 0 create_output_dir gen_homepage +gen_new gen_authorities diff --git a/lib/helpers.rb b/lib/helpers.rb index f3ee114..4ce171a 100644 --- a/lib/helpers.rb +++ b/lib/helpers.rb @@ -16,3 +16,7 @@ end def slug(s) s.downcase.gsub(' ', '-') end + +def authority_url(authority_name) + "/authorities/#{slug(authority_name)}/" +end diff --git a/views/layout.haml b/views/layout.haml index a679515..400ab36 100644 --- a/views/layout.haml +++ b/views/layout.haml @@ -13,8 +13,8 @@ %a{ :href => '/' } Home %li - %a{ :href => '/authorities' } - Authorities + %a{ :href => '/new/' } + New applications = yield #footer diff --git a/views/new.haml b/views/new.haml new file mode 100644 index 0000000..838caf3 --- /dev/null +++ b/views/new.haml @@ -0,0 +1,20 @@ +%h1 New applications +%table + %thead + %tr + %th Authority + %th Reference + %th Received + %th Address + %tbody + - apps.each do |app| + %tr + %td + %a{ href: authority_url(app['authority_name']) } + = app['authority_name'] + %td + %a{ href: app['info_url']} + = app['council_reference'] + %td= short_date(app['date_received']) + %td= app['address'] + \ No newline at end of file