diff --git a/examples/week2/first_route/app.rb b/examples/week2/first_route/app.rb index 32bd99d..141626a 100644 --- a/examples/week2/first_route/app.rb +++ b/examples/week2/first_route/app.rb @@ -2,10 +2,7 @@ # Main route - this is the form where we take the input get '/' do - <<-HTML - This is an example of simple routes. - Check out this route - HTML + "This is an example of simple routes. Check out this route" end get '/same_route' do diff --git a/examples/week2/params/app.rb b/examples/week2/params/app.rb index 651111c..38f808a 100644 --- a/examples/week2/params/app.rb +++ b/examples/week2/params/app.rb @@ -2,12 +2,7 @@ # Main route - this is the form where we take the input get '/' do - <<-HTML - This is an example of simple routes. - Check out route 1 or - route 2 or - route 4032467! - HTML + "This is an example of simple routes. Check out route 1 or route 2 or route 4032467!" end get '/route/:id' do diff --git a/examples/week2/returning_something/app.rb b/examples/week2/returning_something/app.rb index c88854f..85d253d 100644 --- a/examples/week2/returning_something/app.rb +++ b/examples/week2/returning_something/app.rb @@ -2,11 +2,7 @@ # Main route - this is the form where we take the input get '/' do - <<-HTML - This is an example of simple routes. - Check out the first route or - the second route - HTML + "This is an example of simple routes. Check out the first route or the second route" end # You can see this at http://itp.nyu.edu/~irs221/sinatra/returns_last_line/first_route diff --git a/examples/week2/route_conditionals/app.rb b/examples/week2/route_conditionals/app.rb index 1c00481..214d7e5 100644 --- a/examples/week2/route_conditionals/app.rb +++ b/examples/week2/route_conditionals/app.rb @@ -1,30 +1,23 @@ require 'sinatra' get '/' do - <<-HTML -
-

-

-
- HTML + erb :form end get '/conditional_greeting' do - image_url = "" + + @image_url = "" if (params[:yourname] == "World") - image_url = "http://www.buddhanet.info/wbd/images/maps/WBD_world-map.jpg" + @image_url = "http://www.buddhanet.info/wbd/images/maps/WBD_world-map.jpg" elsif (params[:yourname] == "Flower") - image_url = "http://upload.wikimedia.org/wikipedia/commons/thumb/0/0c/White_and_yellow_flower.JPG/250px-White_and_yellow_flower.JPG" + @image_url = "http://upload.wikimedia.org/wikipedia/commons/thumb/0/0c/White_and_yellow_flower.JPG/250px-White_and_yellow_flower.JPG" elsif (params[:yourname] == "Ruxy" || params[:yourname] == "Cat") - image_url = "http://www.vectorsigma.co.uk/blog/wp-content/uploads/2011/07/cute_cat1.jpg" + @image_url = "http://www.vectorsigma.co.uk/blog/wp-content/uploads/2011/07/cute_cat1.jpg" else - image_url = "http://tectabs.com/wp-content/uploads/2011/07/hello-1769.jpg" + @image_url = "http://tectabs.com/wp-content/uploads/2011/07/hello-1769.jpg" end - - <<-HTML -

Hi, #{params[:yourname]}!

- - HTML - + + erb :result + end \ No newline at end of file diff --git a/examples/week2/route_conditionals/views/form.erb b/examples/week2/route_conditionals/views/form.erb new file mode 100644 index 0000000..923340e --- /dev/null +++ b/examples/week2/route_conditionals/views/form.erb @@ -0,0 +1,4 @@ +
+

+

+
\ No newline at end of file diff --git a/examples/week2/route_conditionals/views/result.erb b/examples/week2/route_conditionals/views/result.erb new file mode 100644 index 0000000..83ff44a --- /dev/null +++ b/examples/week2/route_conditionals/views/result.erb @@ -0,0 +1,2 @@ +

Hi, #{params[:yourname]}!

+ \ No newline at end of file diff --git a/examples/week2/routes/app.rb b/examples/week2/routes/app.rb index 9bb3a65..5d58bc1 100644 --- a/examples/week2/routes/app.rb +++ b/examples/week2/routes/app.rb @@ -2,11 +2,7 @@ # Main route - this is the form where we take the input get '/' do - <<-HTML - This is an example of simple routes. - Check out the first route or - the second route - HTML + "This is an example of simple routes. Check out the first route or the second route" end # You can see this at http://itp.nyu.edu/~irs221/sinatra/simple_routes/first_route