-
Notifications
You must be signed in to change notification settings - Fork 2
/
main.rb
54 lines (41 loc) · 1.16 KB
/
main.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
# Third-Party
require 'rubygems'
require 'bundler'
Bundler.setup
# Sinatra
require 'sinatra'
require 'haml'
require 'redis'
require 'ohm'
require 'shield'
# Helpers
require_relative 'lib/helpers/init'
class Main < Sinatra::Base
helpers Sinatra::Partials, Sinatra::RedirectWithObjects, Sinatra::TwilioHelpers
helpers Shield::Helpers
configure :development, :test do
REDIS = Redis.new
end
configure :production do
# This needs to be changed if not using heroku
uri = URI.parse(ENV["REDISTOGO_URL"])
REDIS = Redis.new(:host => uri.host, :port => uri.port, :password => uri.password)
set :sass, { :style => :compressed }
end
configure do
# Configure public directory
set :public, File.join(File.dirname(__FILE__), 'public')
set :views, File.dirname(__FILE__)+'/lib/views'
# Configure HAML and SASS
set :haml, { :format => :html5 }
enable :sessions
REDIS.set("extention:key", 100) if REDIS.get("extention:key").nil?
end
end
# Models
require_relative 'lib/models/init'
# Routes
require_relative 'lib/routes/init'
if User.find(:username=>'admin').size == 0
User.create(:username=>'admin', :password=>'admin')
end