-
Notifications
You must be signed in to change notification settings - Fork 0
/
config.ru
64 lines (50 loc) · 1.42 KB
/
config.ru
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
Encoding.default_internal = Encoding.default_external = 'UTF-8' if RUBY_VERSION >= '1.9'
require 'sinatra/base'
require 'sinatra/cookies'
require 'dm-core'
require 'dm-migrations'
require 'dm-types'
require 'bcrypt'
module Alexandra
module Structure
MODELS = 'lib/models'
VIEWS = 'sinatra/views'
CONTROLLERS = 'sinatra/controllers'
HELPERS = 'sinatra/helpers'
PUBLIC = 'sinatra/public'
DATABASE_PATH = "sqlite3://#{File.join File.dirname(__FILE__), 'db/development.db'}"
end
end
DataMapper::Logger.new(STDOUT, :debug)
DataMapper.setup(:default, Alexandra::Structure::DATABASE_PATH)
Dir[File.join Alexandra::Structure::MODELS, '*.rb'].each do |file|
require "./#{file}"
end
DataMapper.auto_upgrade!
DataMapper.finalize
Dir[File.join 'lib/core', '*.rb'].each do |file|
require "./#{file}"
end
require "./lib/mapper"
class AlexandraMain < Sinatra::Base
disable :run
set :public_folder, Alexandra::Structure::PUBLIC
set :views, File.join(File.dirname(__FILE__), Alexandra::Structure::VIEWS)
set :session_secret, 'too secret'
use Rack::Session::Cookie
get '/' do
redirect '/login'
end
end
Dir[File.join Alexandra::Structure::HELPERS, '*.rb'].each do |file|
require "./#{file}"
end
Dir[File.join Alexandra::Structure::CONTROLLERS, '*.rb'].each do |file|
require "./#{file}"
end
AlexandraApp = Rack::Builder.app do
map "/" do
run AlexandraMain
end
end
run AlexandraApp