-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathapp.rb
86 lines (65 loc) · 2.15 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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
require 'cuba'
require 'cuba/render'
require 'tilt/erb'
require 'sequel'
require "rack/protection"
require 'omniauth-twitter'
require 'omniauth-facebook'
require 'hatch'
require 'i18n'
require 'sass/plugin/rack'
require_relative 'helpers/environment'
ENV['RACK_ENV'] ||= "development"
I18n.load_path += Dir['./locale/**/*.yml']
Encoding.default_internal, Encoding.default_external = ['utf-8'] * 2
FunkyWorldCup::Helpers.init_environment(ENV['RACK_ENV'])
Cuba.use Rack::Static,
root: File.expand_path(File.dirname(__FILE__)) + "/public",
urls: %w[/img /css /js /fonts]
Cuba.use Rack::Session::Cookie, :secret => ENV["SESSION_SECRET"]
Cuba.use Rack::Protection::AuthenticityToken, authenticity_param: "token"
Cuba.use Rack::MethodOverride
Cuba.use OmniAuth::Builder do
provider :twitter, ENV['TWITTER_KEY'], ENV['TWITTER_SECRET'], {
secure_image_url: true,
callback_url: File.join(ENV["FWC_URL"], "auth", "twitter", "callback")
}
provider :facebook, ENV['FACEBOOK_APP_ID'], ENV['FACEBOOK_SECRET'], {
callback_url: File.join(ENV["FWC_URL"], "auth", "facebook", "callback")
}
end
Dir["./helpers/**/*.rb"].each { |file| require file }
Dir["./models/**/*.rb"].each { |file| require file }
Dir["./contexts/**/*.rb"].each { |file| require file }
Dir["./validators/**/*.rb"].each { |file| require file }
Dir["./lib/**/*.rb"].each { |file| require file }
Cuba.plugin Cuba::Render
Cuba.plugin FunkyWorldCup::Helpers
Cuba.plugin FunkyWorldCup::Helpers::ContentFor
Cuba.plugin FunkyWorldCup::Validators
Cuba.use Sass::Plugin::Rack
Sass::Plugin.options[:style] = :compressed
Sass::Plugin.options[:template_location] = { "./assets/sass" => "public/css" }
include Cuba::Render::Helper
# Load all plugins before requiring routes
Dir["./routes/**/*.rb"].each { |file| require file }
Cuba.define do
init_locale(req.env)
@@champion ||= FunkyWorldCup.champion
on "groups" do
run FunkyWorldCup::Groups
end
on "cup-groups" do
run FunkyWorldCup::CupGroups
end
on "users" do
run FunkyWorldCup::Users
end
on "admin" do
run FunkyWorldCup::Admin
end
on "teams" do
run FunkyWorldCup::Teams
end
run FunkyWorldCup::Main
end