forked from wasamas/massr
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmassr.rb
71 lines (57 loc) · 1.52 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
# -*- coding: utf-8; -*-
#
# massr.rb : Massr - Mini Wassr
#
# Copyright (C) 2012 by The wasam@s production
# https://github.com/tdtds/massr
#
# Distributed under GPL
#
require 'sinatra/base'
require 'haml'
require 'json'
require 'omniauth'
require 'omniauth-twitter'
require 'rack/csrf'
require 'mongo_mapper'
module Massr
class App < Sinatra::Base
enable :sessions
set :haml, { format: :html5, escape_html: true }
configure :production do
@auth_twitter = {
:id => ENV['TWITTER_CONSUMER_ID'],
:secret => ENV['TWITTER_CONSUMER_SECRET']
}
uri = URI.parse(ENV['MONGOHQ_URL'])
MongoMapper.connection = Mongo::Connection.from_uri(ENV['MONGOHQ_URL'])
MongoMapper.database = uri.path.gsub(/^\//, '')
end
configure :development, :test do
Bundler.require :development
register Sinatra::Reloader
disable :protection
@auth_twitter = Pit::get( 'auth_twitter', :require => {
:id => 'your CONSUMER KEY of Twitter APP.',
:secret => 'your CONSUMER SECRET of Twitter APP.',
} )
MongoMapper.connection = Mongo::Connection.new('localhost', 27017)
MongoMapper.database = 'massr'
end
use(
OmniAuth::Strategies::Twitter,
@auth_twitter[:id],
@auth_twitter[:secret])
use(
Rack::Session::Cookie,
:expire_after => 6 * 30 * 24 * 60 * 60,
:secret => ENV['SESSION_SECRET'])
use Rack::Csrf
#表示エントリ数
$limit = 20
end
end
require_relative 'models/init'
require_relative 'helpers/init'
require_relative 'routes/init'
Massr::App::run! if __FILE__ == $0