diff --git a/Gemfile b/Gemfile index f851a81..06d1e0b 100644 --- a/Gemfile +++ b/Gemfile @@ -8,3 +8,4 @@ gem 'datamapper' gem 'dm-sqlite-adapter' gem 'sqlite3' gem 'json' +gem 'haml' diff --git a/Gemfile.lock b/Gemfile.lock index 1c61488..8377f93 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -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) @@ -86,6 +87,7 @@ PLATFORMS DEPENDENCIES datamapper dm-sqlite-adapter + haml json sinatra sinatra-reloader diff --git a/app.rb b/app.rb index e284d5d..a62317e 100644 --- a/app.rb +++ b/app.rb @@ -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 @@ -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! diff --git a/public/index.html b/public/index.html deleted file mode 100644 index bbb4132..0000000 --- a/public/index.html +++ /dev/null @@ -1,98 +0,0 @@ - - - - - - - - - - - - - - Eish - Incident Reporting for South Africa - - - - - - - - - - - - - - - -
- -
-
-

Eish - Incident Reports for South Africa

-
- - -
-
-
-
- -
-
- -
-
- Find -
-
-
-
-
-
- -
-
- -
- -
-
- -
-
-
-
-
-
- - - - - - - - - - - - - - - - - - - - - diff --git a/views/incident_types/new.haml b/views/incident_types/new.haml new file mode 100644 index 0000000..9658d62 --- /dev/null +++ b/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'} diff --git a/views/index.haml b/views/index.haml new file mode 100644 index 0000000..5639cde --- /dev/null +++ b/views/index.haml @@ -0,0 +1,58 @@ +!!! +/ paulirish.com/2008/conditional-stylesheets-vs-css-hacks-answer-neither/ +/[if lt IE 7] +/[if IE 7] +/[if IE 8] +/ [if gt IE 8]> "en"} + / "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] + + / IE Fix for HTML5 Tags + /[if lt IE 9] + + %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"} diff --git a/views/provinces/new.haml b/views/provinces/new.haml new file mode 100644 index 0000000..b9b98ab --- /dev/null +++ b/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'}