Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Speaker list
  • Loading branch information
knowtheory committed Mar 7, 2011
1 parent 5d92da9 commit 5846da2
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 5 deletions.
13 changes: 8 additions & 5 deletions confoosed.rb
Expand Up @@ -11,22 +11,25 @@
get "/sessions/?" do
end

get "/sessions/:id", :provides => 'html' do
get "/sessions/:id(.html)?", :provides => 'html' do
@session = Confoosed::Session.first(:id => params[:id])
erb :session, :locals => { :session => @session }
end
get "/sessions/:id", :provides => 'json' do
get "/sessions/:id", :provides => 'json' do
JSON.dump(Confoosed::Session.first(:id => params[:id]).attributes)
end

get "/speakers/?" do
erb :speakers, :locals => { :speakers => Confoosed::Speaker.all }
end

get "/speakers/:id", :provides => 'html' do
get "/sessions/:id.json", :provides => 'json' do
JSON.dump(Confoosed::Speaker.first(:id=>params[:id]).attributes)
end
get "/speakers/:id" do # use %r{/speakers/(?<id>\d+)(.html)?} to match .html as well.
@speaker = Confoosed::Speaker.first(:id=>params[:id])
erb :speaker, :locals => { :speaker => @speaker }
end
get "/sessions/:id", :provides => 'json' do
end

not_found do
end
Expand Down
10 changes: 10 additions & 0 deletions views/speakers.erb
@@ -0,0 +1,10 @@
<html>
<body>
<h1>Speakers</h1>
<dl>
<% speakers.each do |speaker| %>
<dt><a href="<%= url("speakers/#{speaker.id}")%>"><%= speaker.name %></a></dt><dd><%= speaker.affiliation %></dd>
<% end %>
</dl>
</body>
</html>

0 comments on commit 5846da2

Please sign in to comment.