diff --git a/app.rb b/app.rb
index ddc00d1..297b50f 100644
--- a/app.rb
+++ b/app.rb
@@ -8,7 +8,6 @@ require 'dm-timestamps'
require 'lib/models'
get '/' do
-# @wards = Ward.all( :order => ['name' ] )
haml :home
end
@@ -21,7 +20,13 @@ end
get '/wards' do
@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']
@ward_name = result['administrative']['ward']['title']
@ward = Ward.first( { :name => @ward_name } )
@@ -38,6 +43,10 @@ end
# haml :voting
# end
+get '/error' do
+ haml :error
+end
+
get '/about' do
@accounts = %w{
adrianshort
diff --git a/public/style.css b/public/style.css
index 22a3e87..55a24f6 100644
--- a/public/style.css
+++ b/public/style.css
@@ -1,9 +1,10 @@
body
{
- background-color: #fffeda;
+ background-color: #fff;
+ color: #555;
font-family: Helvetica, Arial, sans-serif;
width: 600px;
- margin: 60px auto;
+ margin: 70px auto;
line-height: 1.5em;
}
@@ -31,32 +32,36 @@ input.postcode
#footer
{
- font-size: 90%;
+ font-size: 100%;
+ background-color: #fff;
}
.credit
{
text-align: right;
+ font-size: 80%;
}
a, a:visited
{
+ background-color: #e0ffd4;
padding: 2px 5px;
- background-color: #333;
- color: #fff;
+ color: #111;
text-decoration: none;
}
a:hover
{
- background-color: #fff;
- color: #333;
+ background-color: #4f4f4f;
+ color: #e0ffd4;
}
h2
{
margin-top: 50px;
line-height: 1.5em;
+ font-weight: bold;
+ color: #000;
}
form
@@ -66,9 +71,16 @@ form
a.date
{
- font-size: 600%;
+ font-size: 610%;
font-weight: bold;
padding: 30px 30px;
+ background-color: red;
+ display: none;
+ position: absolute;
+ left: 0;
+ top: 1000;
+ -webkit-transform: rotate(-90deg);
+ -moz-transform: rotate(-90deg);
}
#header
@@ -80,14 +92,28 @@ h1
{
margin-top: 50px;
line-height: 1.5em;
+ font-weight: bold;
+ color: #000;
}
.candidate_name
{
font-size: 150%;
+ font-weight: bold;
+}
+
+.candidate_party
+{
+ color: #999;
}
.highlight
{
background-color: yellow;
+ padding: 5px;
+}
+
+strong
+{
+ color: #000;
}
\ No newline at end of file
diff --git a/views/about.haml b/views/about.haml
index 856a268..a9ed40a 100644
--- a/views/about.haml
+++ b/views/about.haml
@@ -1,7 +1,7 @@
%h1 About this website
%p
- This website was designed by
+ This website was designed and written by
%a{ :href => 'http://adrianshort.co.uk' }> Adrian Short
\.
You can contact me by email at
@@ -23,9 +23,11 @@
%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.
-%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}
diff --git a/views/home.haml b/views/home.haml
index febf305..414fd49 100644
--- a/views/home.haml
+++ b/views/home.haml
@@ -1,7 +1,7 @@
%h1
Vote for your MP and councillors
%br
- in Sutton
+ in Sutton on 6 May
%p
On 6 May you can vote to
@@ -20,12 +20,4 @@
%form{ :method => 'get', :action => '/wards' }
%label{ :for => "postcode" } My postcode is
%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
\ No newline at end of file
+ %input{ :type => 'submit', :value => "Find it" }
\ No newline at end of file
diff --git a/views/layout.haml b/views/layout.haml
index 7a28c96..eb2fb22 100644
--- a/views/layout.haml
+++ b/views/layout.haml
@@ -4,12 +4,16 @@
%head
%title Sutton Elections 6 May 2010
%link{ :rel => 'stylesheet', :type => 'text/css', :href => '/style.css' }
+
+
%body
#header
%a.date{ :href => '/' } 6 May 2010
#main
= yield
#footer
+ %p
+ %a{ :href => '/' } Home
%p
%a{ :href => '/how-the-council-election-works' } How the council election works
-#
diff --git a/views/wards.haml b/views/wards.haml
index 192ada7..9c9006c 100644
--- a/views/wards.haml
+++ b/views/wards.haml
@@ -1,3 +1,9 @@
+-#
+ - if @postcode
+ %h2
+ If you live in
+ = @postcode
+
%h1
Candidates for
= @ward.constituency.name
@@ -15,7 +21,8 @@
= candidate.forenames
= candidate.surname
%br
- = candidate.party.name
+ %span.candidate_party
+ = candidate.party.name
%p.highlight
This list of candidates may be incomplete as people have until
@@ -46,4 +53,5 @@
= candidate.forenames
= candidate.surname
%br
- = candidate.party.name
\ No newline at end of file
+ %span.candidate_party
+ = candidate.party.name
\ No newline at end of file