forked from zapnap/sinatra-template
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Steve Flinter
authored and
Steve Flinter
committed
Jun 24, 2009
1 parent
89004bc
commit ead2a8b
Showing
2 changed files
with
36 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,43 @@ | ||
require 'rubygems' | ||
require 'sinatra' | ||
require 'environment' | ||
require 'sinatra' | ||
require 'builder' | ||
require 'haml' | ||
require 'twitter' | ||
|
||
BASE_URL = 'http://semantictweet.com' | ||
|
||
mime :rdf, 'application/rdf+xml' | ||
|
||
configure do | ||
set :views, "#{File.dirname(__FILE__)}/views" | ||
end | ||
|
||
error do | ||
e = request.env['sinatra.error'] | ||
Kernel.puts e.backtrace.join("\n") | ||
'Application error' | ||
get '/' do | ||
haml :index | ||
end | ||
|
||
helpers do | ||
# add your helpers here | ||
get '/screen_name' do | ||
redirect "/#{params[:screen_name]}" | ||
end | ||
|
||
# root page | ||
get '/' do | ||
haml :root | ||
get '/:screen_name' do | ||
@twitter = Twitter.new(params[:screen_name]) | ||
if @twitter.exists? | ||
content_type :rdf | ||
builder :foaf | ||
else | ||
raise not_found | ||
end | ||
end | ||
|
||
error do | ||
e = require.env['sinatra.error'] | ||
Kernel.puts e.backtrace.join("\n") | ||
'Appliation error' | ||
end | ||
|
||
not_found do | ||
@screen_name = params[:screen_name] | ||
haml :'404' | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters