Skip to content
Browse files

Enhanced views and made search redirect to a pretty url

  • Loading branch information...
1 parent 42b4084 commit 75f46a843686d90c34f3df426f2ebfde1fac8663 @benschwarz committed Mar 17, 2009
Showing with 19 additions and 15 deletions.
  1. +1 −4 app.rb
  2. +4 −2 public/base.css
  3. +11 −6 views/index.erb
  4. +3 −3 views/layout.erb
View
5 app.rb
@@ -18,7 +18,6 @@ def get(ingredient = '')
end
get '/' do
- @recipes = Feed.get
erb :index
end
@@ -29,9 +28,7 @@ def get(ingredient = '')
end
post '/ingredient' do
- @ingredient = params[:ingredient]
- @recipes = Feed.get @ingredient
- erb :index
+ redirect "/ingredient/#{params[:ingredient]}"
end
get '/rss' do
View
6 public/base.css
@@ -5,10 +5,12 @@ h1 { font-size: 3em; text-transform: lowercase; margin: 1em 0; }
h1 a { color: black; text-decoration: none; }
h2 { font-size: 1.3em; text-transform: lowercase; margin: 0.5em 0; }
p { margin: 0.3em 0; color: #999; font-size: 0.8em; }
-li { margin: 0.3em 0; }
+li { margin: 0.5em 0; }
a { color: #00A0C6; }
form { margin: 2em 0; padding: 2em; background-color: #eee; }
form legend { color: #666; font-size: 0.9em; font-style:italic; }
form input { font-size: 3em; font-family: Helvetica; }
-form button { background-color: transparent; border: none; color: #999; font-size: 2em; }
+form button { background-color: transparent; border: none; color: #999; font-size: 2em; }
+
+ul#recipes li { margin-bottom: 1em; }
View
17 views/index.erb
@@ -22,9 +22,14 @@
<li><a href="/ingredient/tomato">Tomato</a></li>
</ul>
-<h2>All recipies <span>(<%= @recipes.size %>)</span></h2>
-<ul>
-<% for recipe in @recipes %>
- <li><a href="<%= recipe["link"] %>"><%= recipe["title"] %></a></li>
-<% end %>
-</ul>
+<% unless @ingredient.nil? %>
+ <h2>All recipies <span>(<%= @recipes.size %>)</span></h2>
+ <ul id="recipes">
+ <% for recipe in @recipes %>
+ <li>
+ <a href="<%= recipe["link"] %>"><%= recipe["title"] %></a>
+ <p class="source"><%= recipe["link"] %></p>
+ </li>
+ <% end %>
+ </ul>
+<% end %>
View
6 views/layout.erb
@@ -1,9 +1,9 @@
<!DOCTYPE html>
<head>
<title>Munch</title>
- <link href="/rss" rel="alternate" type="application/rss+xml" />
- <link rel="stylesheet" href="/reset.css" type="text/css" media="screen" charset="utf-8">
- <link rel="stylesheet" href="/base.css" type="text/css" media="screen" charset="utf-8">
+ <link href="/rss" rel="alternate" type="application/rss+xml">
+ <link rel="stylesheet" href="/reset.css" type="text/css" media="screen">
+ <link rel="stylesheet" href="/base.css" type="text/css" media="screen">
</head>
<body>
<div id="container">

0 comments on commit 75f46a8

Please sign in to comment.
Something went wrong with that request. Please try again.