@@ -8,7 +8,6 @@ require 'dm-timestamps' | |||||
require 'lib/models' | require 'lib/models' | ||||
get '/' do | get '/' do | ||||
# @wards = Ward.all( :order => ['name' ] ) | |||||
haml :home | haml :home | ||||
end | end | ||||
@@ -21,7 +20,13 @@ end | |||||
get '/wards' do | get '/wards' do | ||||
@postcode = params[:postcode].strip.upcase | @postcode = params[:postcode].strip.upcase | ||||
result = Pat.get(@postcode) | |||||
# Postcode not found/invalid | |||||
# Postcode valid but not in LB Sutton | |||||
unless result = Pat.get(@postcode) | |||||
redirect '/error' | |||||
end | |||||
@district_name = result['administrative']['district']['title'] | @district_name = result['administrative']['district']['title'] | ||||
@ward_name = result['administrative']['ward']['title'] | @ward_name = result['administrative']['ward']['title'] | ||||
@ward = Ward.first( { :name => @ward_name } ) | @ward = Ward.first( { :name => @ward_name } ) | ||||
@@ -38,6 +43,10 @@ end | |||||
# haml :voting | # haml :voting | ||||
# end | # end | ||||
get '/error' do | |||||
haml :error | |||||
end | |||||
get '/about' do | get '/about' do | ||||
@accounts = %w{ | @accounts = %w{ | ||||
adrianshort | adrianshort | ||||
@@ -1,9 +1,10 @@ | |||||
body | body | ||||
{ | { | ||||
background-color: #fffeda; | |||||
background-color: #fff; | |||||
color: #555; | |||||
font-family: Helvetica, Arial, sans-serif; | font-family: Helvetica, Arial, sans-serif; | ||||
width: 600px; | width: 600px; | ||||
margin: 60px auto; | |||||
margin: 70px auto; | |||||
line-height: 1.5em; | line-height: 1.5em; | ||||
} | } | ||||
@@ -31,32 +32,36 @@ input.postcode | |||||
#footer | #footer | ||||
{ | { | ||||
font-size: 90%; | |||||
font-size: 100%; | |||||
background-color: #fff; | |||||
} | } | ||||
.credit | .credit | ||||
{ | { | ||||
text-align: right; | text-align: right; | ||||
font-size: 80%; | |||||
} | } | ||||
a, a:visited | a, a:visited | ||||
{ | { | ||||
background-color: #e0ffd4; | |||||
padding: 2px 5px; | padding: 2px 5px; | ||||
background-color: #333; | |||||
color: #fff; | |||||
color: #111; | |||||
text-decoration: none; | text-decoration: none; | ||||
} | } | ||||
a:hover | a:hover | ||||
{ | { | ||||
background-color: #fff; | |||||
color: #333; | |||||
background-color: #4f4f4f; | |||||
color: #e0ffd4; | |||||
} | } | ||||
h2 | h2 | ||||
{ | { | ||||
margin-top: 50px; | margin-top: 50px; | ||||
line-height: 1.5em; | line-height: 1.5em; | ||||
font-weight: bold; | |||||
color: #000; | |||||
} | } | ||||
form | form | ||||
@@ -66,9 +71,16 @@ form | |||||
a.date | a.date | ||||
{ | { | ||||
font-size: 600%; | |||||
font-size: 610%; | |||||
font-weight: bold; | font-weight: bold; | ||||
padding: 30px 30px; | padding: 30px 30px; | ||||
background-color: red; | |||||
display: none; | |||||
position: absolute; | |||||
left: 0; | |||||
top: 1000; | |||||
-webkit-transform: rotate(-90deg); | |||||
-moz-transform: rotate(-90deg); | |||||
} | } | ||||
#header | #header | ||||
@@ -80,14 +92,28 @@ h1 | |||||
{ | { | ||||
margin-top: 50px; | margin-top: 50px; | ||||
line-height: 1.5em; | line-height: 1.5em; | ||||
font-weight: bold; | |||||
color: #000; | |||||
} | } | ||||
.candidate_name | .candidate_name | ||||
{ | { | ||||
font-size: 150%; | font-size: 150%; | ||||
font-weight: bold; | |||||
} | |||||
.candidate_party | |||||
{ | |||||
color: #999; | |||||
} | } | ||||
.highlight | .highlight | ||||
{ | { | ||||
background-color: yellow; | background-color: yellow; | ||||
padding: 5px; | |||||
} | |||||
strong | |||||
{ | |||||
color: #000; | |||||
} | } |
@@ -1,7 +1,7 @@ | |||||
%h1 About this website | %h1 About this website | ||||
%p | %p | ||||
This website was designed by | |||||
This website was designed and written by | |||||
%a{ :href => 'http://adrianshort.co.uk' }> Adrian Short | %a{ :href => 'http://adrianshort.co.uk' }> Adrian Short | ||||
\. | \. | ||||
You can contact me by email at | You can contact me by email at | ||||
@@ -23,9 +23,11 @@ | |||||
%p | %p | ||||
This site is written in Ruby using the Sinatra framework. The HTML templates use Haml. The database is sqlite for development and postgresql for production, abstracted through DataMapper. Source control and deployment is done with Git. | This site is written in Ruby using the Sinatra framework. The HTML templates use Haml. The database is sqlite for development and postgresql for production, abstracted through DataMapper. Source control and deployment is done with Git. | ||||
%h2 #followfooter | |||||
%ul | |||||
- for account in @accounts | |||||
%li | |||||
%a{ :href => "http://twitter.com/#{account}" }@#{account} | |||||
-# | |||||
%h2 #followfooter | |||||
%ul | |||||
- for account in @accounts | |||||
%li | |||||
%a{ :href => "http://twitter.com/#{account}" }@#{account} |
@@ -1,7 +1,7 @@ | |||||
%h1 | %h1 | ||||
Vote for your MP and councillors | Vote for your MP and councillors | ||||
%br | %br | ||||
in Sutton | |||||
in Sutton on 6 May | |||||
%p | %p | ||||
On 6 May you can vote to | On 6 May you can vote to | ||||
@@ -20,12 +20,4 @@ | |||||
%form{ :method => 'get', :action => '/wards' } | %form{ :method => 'get', :action => '/wards' } | ||||
%label{ :for => "postcode" } My postcode is | %label{ :for => "postcode" } My postcode is | ||||
%input{ :type => 'text', :name => 'postcode', :value => 'SM1 1EA', :size => 8, :maxlength => 8 } | %input{ :type => 'text', :name => 'postcode', :value => 'SM1 1EA', :size => 8, :maxlength => 8 } | ||||
%input{ :type => 'submit', :value => "Find it" } | |||||
-# | |||||
%h2 Council Wards | |||||
- for ward in @wards | |||||
%p | |||||
%a{ :href => "/wards/#{ward.id.to_s}" } | |||||
= ward.name | |||||
%input{ :type => 'submit', :value => "Find it" } |
@@ -4,12 +4,16 @@ | |||||
%head | %head | ||||
%title Sutton Elections 6 May 2010 | %title Sutton Elections 6 May 2010 | ||||
%link{ :rel => 'stylesheet', :type => 'text/css', :href => '/style.css' } | %link{ :rel => 'stylesheet', :type => 'text/css', :href => '/style.css' } | ||||
<script type="text/javascript" src="http://use.typekit.com/wfg6cvc.js"></script> | |||||
<script type="text/javascript">try{Typekit.load();}catch(e){}</script> | |||||
%body | %body | ||||
#header | #header | ||||
%a.date{ :href => '/' } 6 May 2010 | %a.date{ :href => '/' } 6 May 2010 | ||||
#main | #main | ||||
= yield | = yield | ||||
#footer | #footer | ||||
%p | |||||
%a{ :href => '/' } Home | |||||
%p | %p | ||||
%a{ :href => '/how-the-council-election-works' } How the council election works | %a{ :href => '/how-the-council-election-works' } How the council election works | ||||
-# | -# | ||||
@@ -1,3 +1,9 @@ | |||||
-# | |||||
- if @postcode | |||||
%h2 | |||||
If you live in | |||||
= @postcode | |||||
%h1 | %h1 | ||||
Candidates for | Candidates for | ||||
= @ward.constituency.name | = @ward.constituency.name | ||||
@@ -15,7 +21,8 @@ | |||||
= candidate.forenames | = candidate.forenames | ||||
= candidate.surname | = candidate.surname | ||||
%br | %br | ||||
= candidate.party.name | |||||
%span.candidate_party | |||||
= candidate.party.name | |||||
%p.highlight | %p.highlight | ||||
This list of candidates may be incomplete as people have until | This list of candidates may be incomplete as people have until | ||||
@@ -46,4 +53,5 @@ | |||||
= candidate.forenames | = candidate.forenames | ||||
= candidate.surname | = candidate.surname | ||||
%br | %br | ||||
= candidate.party.name | |||||
%span.candidate_party | |||||
= candidate.party.name |