Skip to content

Commit

Permalink
Converted to haml. Can create provinces and incident types
Browse files Browse the repository at this point in the history
  • Loading branch information
peteygee123 committed Apr 3, 2012
1 parent 2a9cd32 commit 047fb62
Show file tree
Hide file tree
Showing 7 changed files with 91 additions and 98 deletions.
1 change: 1 addition & 0 deletions Gemfile
Expand Up @@ -8,3 +8,4 @@ gem 'datamapper'
gem 'dm-sqlite-adapter'
gem 'sqlite3'
gem 'json'
gem 'haml'
2 changes: 2 additions & 0 deletions Gemfile.lock
Expand Up @@ -54,6 +54,7 @@ GEM
data_objects (= 0.10.8)
eventmachine (0.12.10)
fastercsv (1.5.4)
haml (3.1.4)
json (1.6.6)
json_pure (1.6.6)
multi_json (1.0.4)
Expand Down Expand Up @@ -86,6 +87,7 @@ PLATFORMS
DEPENDENCIES
datamapper
dm-sqlite-adapter
haml
json
sinatra
sinatra-reloader
Expand Down
24 changes: 24 additions & 0 deletions app.rb
Expand Up @@ -22,12 +22,26 @@ def to_json(*)
end
end

get '/' do
haml :index
end

get '/provinces' do
provinces = Province.all
content_type :json
provinces.to_json
end

get '/provinces/new' do
haml :"provinces/new"
end

post 'province' do
province = Province.create(name: params[:name])
redirect '/'
end


class IncidentType
include DataMapper::Resource
property :id, Serial
Expand All @@ -50,4 +64,14 @@ def to_json(*)
incident_types.to_json
end

get '/incident_types/new' do
haml :"incident_types/new"
end

post 'incident_type' do
province = IncidentType.create(name: params[:name])
redirect '/'
end

DataMapper.finalize
DataMapper.auto_upgrade!
98 changes: 0 additions & 98 deletions public/index.html

This file was deleted.

3 changes: 3 additions & 0 deletions views/incident_types/new.haml
@@ -0,0 +1,3 @@
%form{action: '/incident_type', :method => "post"}
%input{:type=>'text', :size=>40, :name=>'name', :id=>'name'}
%input{:type=>'submit', :value=>'New Incident Type'}
58 changes: 58 additions & 0 deletions views/index.haml
@@ -0,0 +1,58 @@
!!!
/ paulirish.com/2008/conditional-stylesheets-vs-css-hacks-answer-neither/
/[if lt IE 7] <html class="no-js lt-ie9 lt-ie8 lt-ie7" lang="en">
/[if IE 7] <html class="no-js lt-ie9 lt-ie8" lang="en">
/[if IE 8] <html class="no-js lt-ie9" lang="en">
/ [if gt IE 8]><!
%html{:lang => "en"}
/ <![endif]
%head
%meta{:charset => "utf-8"}/
/ Set the viewport width to device width for mobile
%meta{:content => "width=device-width", :name => "viewport"}/
%title Eish - Incident Reporting for South Africa
/ Included CSS Files
%link{:href => "stylesheets/foundation.css", :rel => "stylesheet"}
%link{:href => "stylesheets/app.css", :rel => "stylesheet"}
/[if lt IE 9]
<link rel="stylesheet" href="stylesheets/ie.css">
/ IE Fix for HTML5 Tags
/[if lt IE 9]
<script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script>
%body
/ container
.container
.row
.twelve.columns
%h1 Eish - Incident Reports for South Africa
.row
%form.nice
.two.columns
%select#provinces
.seven.columns
%input#address.expand.input-text{:type => "text"}/
.three.columns
%a#find_address.green.button{:href => "#"} Find
.row
%form.nice
.two.columns
%select#incident_types
.seven.columns
%textarea.expand.text-area
.three.columns
%a#report_incident.green.button{:href => "#"} Report Incident
#map_container.row
.twelve.columns
#map_canvas
/ Included ZURB foundation JS Files
%script{:src => "javascripts/lib/jquery.min.js"}
%script{:src => "javascripts/lib/modernizr.foundation.js"}
%script{:src => "javascripts/lib/foundation.js"}
%script{:src => "javascripts/lib/app.js"}
/ Included backbone.js files
%script{:src => "javascripts/lib/underscore.js"}
%script{:src => "javascripts/lib/backbone.js"}
/ Google Maps
%script{:src => "http://maps.googleapis.com/maps/api/js?key=AIzaSyB_9LmLR7oC_Gsq1ireENLC6RDvDnYfNlw&sensor=true", :type => "text/javascript"}
/ JS Application entry point
%script{:src => "javascripts/app.js"}
3 changes: 3 additions & 0 deletions views/provinces/new.haml
@@ -0,0 +1,3 @@
%form{action: '/province', :method => "post"}
%input{:type=>'text', :size=>40, :name=>'name', :id=>'name'}
%input{:type=>'submit', :value=>'New Province'}

0 comments on commit 047fb62

Please sign in to comment.