-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.rb
executable file
·57 lines (47 loc) · 1.28 KB
/
app.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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#!/usr/bin/ruby2.0
require 'haml'
require 'sinatra/base'
require 'sinatra/config_file'
require_relative 'helpers'
require_relative 'routes/auth'
require_relative 'routes/waivers'
require_relative 'routes/members'
require_relative 'routes/images'
require_relative 'routes/log'
require_relative 'routes/password'
class MemberApp < Sinatra::Base
set :root, File.dirname(__FILE__)
set :sessions => true
register Sinatra::ConfigFile
config_file 'config.yaml'
configure do
mime_type :png, 'image/png'
end
set :db_handle => Sequel.connect(settings.db_url)
# home page
get '/' do
redirect "/login" unless is_user?
haml :index
end
# authentication system
register do
def auth(type)
condition do
redirect "/login" unless send("is_#{type}?")
end
end
end
before do
@db = settings.db_handle
@user = session[:username]
@member_id = session[:member_id]
@member_status = session[:member_status]
end
helpers Sinatra::MemberApp::Helpers
register Sinatra::MemberApp::Routing::Auth
register Sinatra::MemberApp::Routing::Waivers
register Sinatra::MemberApp::Routing::Members
register Sinatra::MemberApp::Routing::Images
register Sinatra::MemberApp::Routing::Log
register Sinatra::MemberApp::Routing::Password
end