Browse Source

Add page titles

tags/v2.0.0
Adrian Short 6 years ago
parent
commit
ec0a4cb09d
11 changed files with 32 additions and 24 deletions
  1. +25
    -11
      bin/build
  2. +1
    -1
      views/body.haml
  3. +1
    -1
      views/candidate.haml
  4. +1
    -1
      views/candidates.haml
  5. +0
    -2
      views/district.haml
  6. +1
    -1
      views/election.haml
  7. +0
    -2
      views/electionsummary.haml
  8. +1
    -1
      views/guides.haml
  9. +1
    -1
      views/layout.haml
  10. +1
    -1
      views/parliament.haml
  11. +0
    -2
      views/resultsdistrict.haml

+ 25
- 11
bin/build View File

@@ -5,10 +5,16 @@ require_relative '../lib/helpers'
require 'pp' require 'pp'


def gen_info_pages def gen_info_pages
Petrify.page('about', 'about')
Petrify.page('guides', 'guides')
Petrify.page(%w(guides how-the-parliament-election-works), 'parliament')
Petrify.page(%w(guides how-the-council-election-works), 'election')
Petrify.page('about', 'about', { page_title: "About this website" })
Petrify.page('guides', 'guides', { page_title: "Guides"} )
Petrify.page(
%w(guides how-the-parliament-election-works),
'parliament',
{ page_title: "How parliamentary elections work"})
Petrify.page(
%w(guides how-the-council-election-works),
'election',
{ page_title: "How council elections work" })
end end


def gen_bodies_pages def gen_bodies_pages
@@ -16,7 +22,8 @@ def gen_bodies_pages
Body.each do |b| Body.each do |b|
locals = { locals = {
body: b, body: b,
districts: District.all(:body => b, :order => [:name])
districts: District.all(:body => b, :order => [:name]),
page_title: b.name
} }
locals['elections'] = repository(:default).adapter.select(" locals['elections'] = repository(:default).adapter.select("
@@ -43,7 +50,8 @@ def gen_bodies_pages
b.districts.each do |d| b.districts.each do |d|
locals = { locals = {
district: d, district: d,
body: b
body: b,
page_title: "#{d.name} #{d.body.district_name}, #{d.body.name}"
} }
Petrify.page(['bodies', b.slug, b.districts_name, d.slug], 'district', locals) Petrify.page(['bodies', b.slug, b.districts_name, d.slug], 'district', locals)
end end
@@ -52,14 +60,17 @@ end


def gen_candidates_pages def gen_candidates_pages
# Candidate index # Candidate index
locals = { candidates: Candidate.all(:order => [ :surname, :forenames ]) }
locals = {
candidates: Candidate.all(:order => [ :surname, :forenames ]),
page_title: "Candidates" }
Petrify.page('candidates', 'candidates', locals) Petrify.page('candidates', 'candidates', locals)


# Candidate pages # Candidate pages
# FIXME: What do we do about deleted candidates/redirects? # FIXME: What do we do about deleted candidates/redirects?
Candidate.each do |c| Candidate.each do |c|
locals = { locals = {
candidate: c
candidate: c,
page_title: c.name
} }


locals['candidacies'] = repository(:default).adapter.select(" locals['candidacies'] = repository(:default).adapter.select("
@@ -105,7 +116,8 @@ def gen_elections_pages
election: Election.first(:body => e.body, :d => e.d), election: Election.first(:body => e.body, :d => e.d),
elections_for_this_body: Election.all(:body => e.body, :order => [:d]), elections_for_this_body: Election.all(:body => e.body, :order => [:d]),
total_seats: Candidacy.sum(:seats, :election => e), total_seats: Candidacy.sum(:seats, :election => e),
total_votes: Candidacy.sum(:votes, :election => e)
total_votes: Candidacy.sum(:votes, :election => e),
page_title: "#{e.body.name} #{e.kind} #{long_date(e.d)}"
} }


# There's got to be a better way to do this, either with SQL or Datamapper # There's got to be a better way to do this, either with SQL or Datamapper
@@ -154,7 +166,8 @@ def gen_elections_pages
total_candidates: Candidacy.count(:district => d, :election => e), total_candidates: Candidacy.count(:district => d, :election => e),
total_seats: total_seats, total_seats: total_seats,
districts_in_this_election: e.candidacies.districts, districts_in_this_election: e.candidacies.districts,
poll: poll
poll: poll,
page_title: "#{d.name} #{d.body.district_name} results, #{d.body.name} election #{short_date(e.d)}"
} }


locals['share_message'] = nil locals['share_message'] = nil
@@ -197,7 +210,8 @@ end
def gen_homepage def gen_homepage
locals = { locals = {
future_elections: Election.future, future_elections: Election.future,
past_elections: Election.past
past_elections: Election.past,
page_title: ""
} }
Petrify.page('.', 'index', locals) Petrify.page('.', 'index', locals)
end end


+ 1
- 1
views/body.haml View File

@@ -1,4 +1,4 @@
%h1= page_title = body.name
%h1= body.name
%h2 Elections %h2 Elections




+ 1
- 1
views/candidate.haml View File

@@ -2,7 +2,7 @@
%a{ :href => "/candidates" } %a{ :href => "/candidates" }
« All candidates « All candidates


%h1= page_title = candidate.name
%h1= candidate.name


%h2 Elections contested %h2 Elections contested




+ 1
- 1
views/candidates.haml View File

@@ -1,4 +1,4 @@
%h1= page_title = "Candidates"
%h1= "Candidates"


%nav.letter_index %nav.letter_index
- ("A".."Z").each do |letter| - ("A".."Z").each do |letter|


+ 0
- 2
views/district.haml View File

@@ -1,5 +1,3 @@
- page_title = "#{district.name} #{district.body.district_name}, #{district.body.name}"

%nav %nav
%a{ :href => "/bodies/#{district.body.slug}" } %a{ :href => "/bodies/#{district.body.slug}" }
«  « 


+ 1
- 1
views/election.haml View File

@@ -1,7 +1,7 @@
%nav %nav
%a{ :href => '/guides'} « Guides %a{ :href => '/guides'} « Guides


%h1= @page_title = "How council elections work"
%h1 How council elections work


%p %p
Every four years you get to choose your local councillors and help to decide who runs Every four years you get to choose your local councillors and help to decide who runs


+ 0
- 2
views/electionsummary.haml View File

@@ -1,5 +1,3 @@
- page_title = "#{election.body.name} #{election.kind} #{long_date(election.d)}"

%nav %nav
%a{ :href => "/bodies/#{election.body.slug}" } %a{ :href => "/bodies/#{election.body.slug}" }
« «


+ 1
- 1
views/guides.haml View File

@@ -1,4 +1,4 @@
%h1= @page_title = "Guides"
%h1 Guides


%ul %ul
%li %li


+ 1
- 1
views/layout.haml View File

@@ -1,7 +1,7 @@
!!!5 !!!5
%html %html
%head %head
%title= @page_title ? @page_title + " - Sutton Elections" : "Sutton Elections - Your guide to voting and election results in the London Borough of Sutton"
%title= page_title ? page_title + " · Sutton Elections" : "Sutton Elections · Your guide to voting and election results in the London Borough of Sutton"
%link{ :rel => 'stylesheet', :type => 'text/css', :href => '/style.css' } %link{ :rel => 'stylesheet', :type => 'text/css', :href => '/style.css' }
%meta{ :name => 'referrer', :content => 'no-referrer' } %meta{ :name => 'referrer', :content => 'no-referrer' }
%meta{ :name => 'viewport', :content => 'width=device-width, initial-scale=1' } %meta{ :name => 'viewport', :content => 'width=device-width, initial-scale=1' }


+ 1
- 1
views/parliament.haml View File

@@ -1,7 +1,7 @@
%nav %nav
%a{ :href => '/guides'} « Guides %a{ :href => '/guides'} « Guides


%h1= @page_title = "How parliamentary elections work"
%h1 How parliamentary elections work


%p In parliament elections you can vote for your local member of parliament (MP) and help to decide who governs the UK. %p In parliament elections you can vote for your local member of parliament (MP) and help to decide who governs the UK.




+ 0
- 2
views/resultsdistrict.haml View File

@@ -1,5 +1,3 @@
- page_title = "#{district.name} #{district.body.district_name} results, #{body.name} election #{short_date(election.d)}"

%nav %nav
- if districts_in_this_election.size > 1 - if districts_in_this_election.size > 1
- district_index = districts_in_this_election.index(district) - district_index = districts_in_this_election.index(district)


Loading…
Cancel
Save