Skip to content

Commit

Permalink
Updated application & environment
Browse files Browse the repository at this point in the history
  • Loading branch information
Steve Flinter authored and Steve Flinter committed Jun 24, 2009
1 parent 89004bc commit ead2a8b
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 19 deletions.
41 changes: 31 additions & 10 deletions application.rb
@@ -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
14 changes: 5 additions & 9 deletions environment.rb
@@ -1,22 +1,18 @@
ENV['GEM_PATH'] = '/home/flintero/gems:/usr/lib/ruby/gems/1.8'

require 'rubygems'
require 'dm-core'
require 'dm-timestamps'
require 'dm-validations'
require 'dm-aggregates'
require 'haml'
require 'ostruct'

require 'sinatra' unless defined?(Sinatra)

configure do
SiteConfig = OpenStruct.new(
:title => 'Your Application Name',
:author => 'Your Name',
:url_base => 'http://localhost:4567/'
:title => 'SemanticTweet',
:author => 'Steve Flinter',
:url_base => 'http://semantictweet.com/'
)

DataMapper.setup(:default, "sqlite3:///#{File.expand_path(File.dirname(__FILE__))}/#{Sinatra::Base.environment}.db")

# load models
$LOAD_PATH.unshift("#{File.dirname(__FILE__)}/lib")
Dir.glob("#{File.dirname(__FILE__)}/lib/*.rb") { |lib| require File.basename(lib, '.*') }
Expand Down

0 comments on commit ead2a8b

Please sign in to comment.