-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathmassr.rb
102 lines (82 loc) · 2.58 KB
/
massr.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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
# massr.rb : Massr - Mini Wassr
#
# Copyright (C) 2012 by The wasam@s production
# https://github.com/wasamas/massr
#
# Distributed under GPL
Bundler.require(:default, ENV['RACK_ENV'] || :development)
require 'json'
require_relative 'plugins/logging'
require_relative 'plugins/async_request'
module Massr
# definition of module of plugins
module Plugin
module Notify; end
module Media; end
module Cache; end
end
class App < Sinatra::Base
set :haml, {format: :html5}
set :assets_precompile, %w(application.js application.css *.png *.jpg *.svg)
set :assets_css_compressor, :yui
set :assets_js_compressor, :uglifier
set :assets_paths, %w(assets/js assets/css)
register Sinatra::AssetPipeline
RailsAssets.load_paths.each do |path|
settings.sprockets.append_path(path)
end
configure :production do
require 'newrelic_rpm' if ENV['NEW_RELIC_LICENSE_KEY']
Mail.defaults do # using sendgrid plugin
delivery_method :smtp, {
:address => 'smtp.sendgrid.net',
:port => ENV['SENDGRID_PORT'] || 587,
:domain => 'sendgrid.net',
:user_name => ENV['SENDGRID_USERNAME'],
:password => ENV['SENDGRID_PASSWORD'],
:authentication => :plain,
:enable_starttls_auto => true
}
end
enable :logging
Massr::Plugin::Logging.instance.level(Massr::Plugin::Logging::WARN)
end
configure :development, :test do
# loading TWITTER_CONSUMER_ID and TWITTER_CONSUMER_SECRET,
# GMAIL_USERNAME and GMAIL_PASSWORD
Dotenv.load
register Sinatra::Reloader
also_reload './*.rb'
also_reload './models/*.rb'
also_reload './helpers/*.rb'
disable :protection
Mail.defaults do # using sendgrid plugin
delivery_method :smtp, {
address: 'smtp.gmail.com',
port: '587',
user_name: ENV['GMAIL_USERNAME'],
password: ENV['GMAIL_PASSWORD'],
:authentication => :plain,
:enable_starttls_auto => true
}
end
enable :logging
Massr::Plugin::Logging.instance.level(Massr::Plugin::Logging::DEBUG)
end
Mongoid::load!('config/mongoid.yml')
Mongoid.raise_not_found_error = false
session_expire = 60 * 60 * 24 * 30 - 1
use Rack::Session::Dalli, cache: Dalli::Client.new, expire_after: session_expire
OmniAuth.config.full_host = ENV['FULL_HOST'] if ENV['FULL_HOST']
twitter_id = ENV['TWITTER_CONSUMER_ID']
twitter_secret = ENV['TWITTER_CONSUMER_SECRET']
use(OmniAuth::Strategies::Twitter, twitter_id, twitter_secret)
use Rack::Csrf
# max entries of 1st view
$limit = 20
end
end
require_relative 'models/init'
require_relative 'helpers/init'
require_relative 'routes/init'
Massr::App::run! if __FILE__ == $0