-
Notifications
You must be signed in to change notification settings - Fork 2
/
init.rb
34 lines (26 loc) · 945 Bytes
/
init.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
$:.unshift(*Dir["./vendor/*/lib"])
require "rubygems"
require "sinatra/base"
require "rtopia"
require "sinatra/content_for"
require "jsfiles"
require "user_agent"
class Main < Sinatra::Base
set :root, lambda { |*args| File.join(File.dirname(__FILE__), *args) }
set :views, root('app', 'views')
enable :raise_errors, :sessions, :logging,
:show_exceptions, :raise_errors
use Rack::Session::Cookie
helpers Rtopia
helpers Sinatra::ContentFor # sinatra-content_for
helpers Sinatra::UserAgentHelpers # agentsniff
# Load all, but load defaults first
Dir[root('config', '{*.defaults,*}.rb')].uniq.each { |f| load f }
configure :development do
require 'pistol'
use Pistol, Dir["./{lib,app}/**/*.rb"] { reset! and load(__FILE__) }
end
end
Dir["./{lib,app/**}/*.rb"].each { |rb| require rb }
Main.set :port, ENV['PORT'].to_i unless ENV['PORT'].nil?
Main.run! if __FILE__ == $0