omniauth-scaffold 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in omniauth-scaffold.gemspec
4
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2012 shu0115
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,144 @@
1
+ # Omniauth::Scaffold
2
+
3
+ Scaffold for OmniAuth.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ vi Gemfile
11
+ ----------
12
+ # For OmniAuth
13
+ gem 'rails_config'
14
+ gem 'omniauth-scaffold', :group => :development
15
+ gem 'omniauth-twitter'
16
+ #gem 'omniauth-github'
17
+ #gem 'omniauth-facebook'
18
+ ----------
19
+ ```
20
+
21
+ And then execute:
22
+
23
+ ```
24
+ bundle install --without production
25
+ ```
26
+
27
+ Or install it yourself as:
28
+
29
+ ```
30
+ gem install rails_config
31
+ gem install omniauth-scaffold
32
+ gem install omniauth-twitter
33
+ ```
34
+
35
+ ## Usage
36
+
37
+ ### Generate omniauth scaffold
38
+
39
+ ```
40
+ rails g omniauth:scaffold
41
+ ----------
42
+ create config/initializers/rails_config.rb
43
+ create config/settings.yml
44
+ create config/settings.local.yml
45
+ create config/settings/development.yml
46
+ create config/settings/production.yml
47
+ create config/settings/test.yml
48
+ create config/initializers/omniauth.rb
49
+ insert config/routes.rb
50
+ insert config/routes.rb
51
+ insert config/routes.rb
52
+ insert config/application.rb
53
+ insert config/application.rb
54
+ insert config/application.rb
55
+ gsub config/environments/development.rb
56
+ insert config/environments/development.rb
57
+ create config/locales/ja.yml
58
+ create db/migrate/20000101000000_create_users.rb
59
+ create app/models/user.rb
60
+ create app/controllers/application_controller.rb
61
+ create app/controllers/sessions_controller.rb
62
+ create app/controllers/top_controller.rb
63
+ create app/views/layouts/application.html.erb
64
+ create app/views/top/index.html.erb
65
+ create app/assets/stylesheets/base.css.scss
66
+ create app/assets/stylesheets/scaffolds.css.scss
67
+ remove public/index.html
68
+ remove README.rdoc
69
+ create README.md
70
+ append .gitignore
71
+ ----------
72
+ ```
73
+
74
+ Edit: config/settings.yml
75
+
76
+ ```ruby
77
+ # アプリケーション名
78
+ app_name: "YOUR_APP_NAME"
79
+ ```
80
+
81
+ ### Keys
82
+
83
+ <a href="https://dev.twitter.com/apps/new" target="_blank">Twitter</a>
84
+ <a href="https://github.com/settings/applications/new" target="_blank">GitHub</a>
85
+ <a href="https://developers.facebook.com/apps" target="_blank">Facebook</a>
86
+
87
+ ### Development Setting
88
+
89
+ Edit: config/settings.local.yml
90
+
91
+ ```ruby
92
+ # Twitter OAuth Local Setting
93
+ twitter_key: "TWITTER_KEY"
94
+ twitter_secret: "TWITTER_SECRET"
95
+ ```
96
+
97
+ ### Production Setting For Heroku
98
+
99
+ Twitter
100
+
101
+ ```
102
+ heroku config:add TWITTER_KEY=YOUR_CONSUMER_KEY
103
+ heroku config:add TWITTER_SECRET=YOUR_CONSUMER_SECRET
104
+ ```
105
+
106
+ GitHub
107
+
108
+ ```
109
+ heroku config:add GITHUB_CLIENT_ID=YOUR_CLIENT_ID
110
+ heroku config:add GITHUB_SECRET=YOUR_SECRET
111
+ ```
112
+
113
+ Facebook
114
+
115
+ ```
116
+ heroku config:add FACEBOOK_APP_ID=YOUR_APP_ID
117
+ heroku config:add FACEBOOK_APP_SECRET=YOUR_APP_SECRET
118
+ ```
119
+
120
+ ### Heroku Timezone Setting
121
+
122
+ ```
123
+ heroku config:add TZ=Asia/Tokyo
124
+ ```
125
+
126
+ ### Migration
127
+
128
+ ```
129
+ rake db:migrate
130
+ ```
131
+
132
+ ### Start Server
133
+
134
+ ```
135
+ rails s
136
+ ```
137
+
138
+ ## Contributing
139
+
140
+ 1. Fork it
141
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
142
+ 3. Commit your changes (`git commit -am 'Added some feature'`)
143
+ 4. Push to the branch (`git push origin my-new-feature`)
144
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env rake
2
+ require "bundler/gem_tasks"
@@ -0,0 +1,92 @@
1
+ # coding: utf-8
2
+ require "omniauth-scaffold/version"
3
+ require 'rails/generators'
4
+
5
+ module Omniauth
6
+ module Generators
7
+ class ScaffoldGenerator < ::Rails::Generators::Base
8
+ source_root File.expand_path("../omniauth-scaffold", __FILE__)
9
+ desc "This generator scaffold for OmniAuth"
10
+
11
+ #-------------------#
12
+ # generate_scaffold #
13
+ #-------------------#
14
+ def generate_scaffold
15
+ # ----- rails_config ----- #
16
+ copy_file( "templates/rails_config/rails_config.rb", "config/initializers/rails_config.rb" )
17
+ copy_file( "templates/rails_config/settings.yml", "config/settings.yml" )
18
+ copy_file( "templates/rails_config/settings.local.yml", "config/settings.local.yml" )
19
+ copy_file( "templates/rails_config/development.yml", "config/settings/development.yml" )
20
+ copy_file( "templates/rails_config/production.yml", "config/settings/production.yml" )
21
+ copy_file( "templates/rails_config/test.yml", "config/settings/test.yml" )
22
+
23
+ # ----- omniauth ----- #
24
+ copy_file( "templates/omniauth.rb", "config/initializers/omniauth.rb" )
25
+
26
+ # ----- routes.rb ----- #
27
+ content = "\n # For OmniAuth\n"
28
+ content += " match \"/auth/:provider/callback\" => \"sessions#callback\"\n"
29
+ content += " match \"/auth/failure\" => \"sessions#failure\"\n"
30
+ content += " match \"/logout\" => \"sessions#destroy\", :as => :logout\n"
31
+ insert_into_file( "config/routes.rb", content.force_encoding('ASCII-8BIT'), after: "# first created -> highest priority.\n" )
32
+ insert_into_file( "config/routes.rb", " root to: 'top#index'\n", after: "# root :to => 'welcome#index'\n" )
33
+ insert_into_file( "config/routes.rb", " match ':controller(/:action(/:id))(.:format)'\n", after: "# match ':controller(/:action(/:id))(.:format)'\n" )
34
+
35
+ # ----- application.rb ----- #
36
+ content = " config.time_zone = 'Tokyo'\n"
37
+ content += " config.active_record.default_timezone = :local\n"
38
+ insert_into_file( "config/application.rb", content.force_encoding('ASCII-8BIT'), after: "# config.time_zone = 'Central Time (US & Canada)'\n" )
39
+ insert_into_file( "config/application.rb", " config.i18n.default_locale = :ja\n", after: "# config.i18n.default_locale = :de\n" )
40
+ content = "\n # For Heroku\n"
41
+ content += " config.assets.initialize_on_precompile = false\n"
42
+ insert_into_file( "config/application.rb", content.force_encoding('ASCII-8BIT'), after: "config.assets.version = '1.0'\n" )
43
+
44
+ # ----- development.rb ----- #
45
+ gsub_file "config/environments/development.rb", /(config.assets.debug = true)+/, "# config.assets.debug = true"
46
+ insert_into_file( "config/environments/development.rb", " config.assets.debug = false\n", after: "config.assets.debug = true\n" )
47
+
48
+ # ----- ja.yml ----- #
49
+ copy_file( "templates/ja.yml", "config/locales/ja.yml" )
50
+
51
+ # ----- create_users.rb ----- #
52
+ copy_file( "templates/create_users.rb", "db/migrate/20000101000000_create_users.rb" )
53
+
54
+ # ----- models ----- #
55
+ copy_file( "templates/user.rb", "app/models/user.rb" )
56
+
57
+ # ----- controllers ----- #
58
+ FileUtils.mv( "app/controllers/application_controller.rb", "app/controllers/application_controller_ORIGINAL.rb" )
59
+ copy_file( "templates/application_controller.rb", "app/controllers/application_controller.rb" )
60
+ copy_file( "templates/sessions_controller.rb", "app/controllers/sessions_controller.rb" )
61
+ copy_file( "templates/top_controller.rb", "app/controllers/top_controller.rb" )
62
+
63
+ # ----- views ----- #
64
+ FileUtils.mv( "app/views/layouts/application.html.erb", "app/views/layouts/application_ORIGINAL.html.erb" )
65
+ copy_file( "templates/application.html.erb", "app/views/layouts/application.html.erb" )
66
+ copy_file( "templates/index.html.erb", "app/views/top/index.html.erb" )
67
+
68
+ # ----- assets ----- #
69
+ copy_file( "templates/base.css.scss", "app/assets/stylesheets/base.css.scss" )
70
+ copy_file( "templates/scaffolds.css.scss", "app/assets/stylesheets/scaffolds.css.scss" )
71
+
72
+ # ----- public ----- #
73
+ remove_file( 'public/index.html' )
74
+
75
+ # ----- README ----- #
76
+ remove_file( 'README.rdoc' )
77
+ copy_file( "templates/README.md", "README.md" )
78
+
79
+ # ----- .gitignore ----- #
80
+ content = "\n# Add\n"
81
+ content += ".DS_Store\n"
82
+ content += "vendor/bundle\n"
83
+ content += "\n# rails_config\n"
84
+ content += "config/settings.local.yml\n"
85
+ content += "config/settings/*.local.yml\n"
86
+ content += "config/environments/*.local.yml\n"
87
+ append_file( ".gitignore", content.force_encoding('ASCII-8BIT') )
88
+ end
89
+ end
90
+
91
+ end
92
+ end
@@ -0,0 +1,80 @@
1
+ # APP_NAME
2
+
3
+ APP_DESCRIPTION.
4
+
5
+ ## Local Setting
6
+
7
+ ### GitHub上でFork
8
+
9
+ ```
10
+ https://github.com/USER_NAME/APP_NAME/
11
+ ```
12
+
13
+ ### リポジトリをローカルへ作成
14
+
15
+ ```
16
+ cd ~/WORK_DIRECTORY
17
+ git clone git@github.com:YOUR_USER_NAME/APP_NAME.git
18
+ cd APP_NAME
19
+ ```
20
+
21
+ ### ブランチ作成
22
+
23
+ ```
24
+ git checkout -b YOUR_NEW_BRANCH
25
+ ```
26
+
27
+ ### Twitterアプリ登録
28
+
29
+ <a href="https://dev.twitter.com/apps/new" target="_blank">Twitter Create an application</a>
30
+
31
+ ```
32
+ Name: [ (アプリケーションの名前) ]
33
+ Description: [ (アプリケーションの説明) ]
34
+ WebSite: [ http://0.0.0.0:3000/ ]
35
+ Callback URL: [ http://0.0.0.0:3000/ ] ※登録しないと動かない
36
+ □ Yes, I agree <= チェック
37
+ CAPTCHA入力後「Create your Twitter application」を押下
38
+ ```
39
+
40
+ ### ローカル用Twitterキー設定
41
+
42
+ Create: config/settings.local.yml
43
+
44
+ ```ruby
45
+ # Twitter OAuth Local Setting
46
+ twitter_key: "YOUR_CONSUMER_KEY"
47
+ twitter_secret: "YOUR_CONSUMER_SECRET"
48
+ ```
49
+
50
+ ※Twitterアプリ登録完了後に表示された「Consumer key」を「YOUR_CONSUMER_KEY」に、「Consumer secret」を「YOUR_CONSUMER_SECRET」にそれぞれ入力
51
+
52
+ ### Rails起動
53
+
54
+ Gemインストール
55
+
56
+ ```
57
+ bundle install --without production
58
+ ```
59
+
60
+ ローカルDB作成
61
+
62
+ ```
63
+ rake db:migrate
64
+ ```
65
+
66
+ ローカルサーバ起動
67
+
68
+ ```
69
+ bundle exec rails s
70
+ ```
71
+
72
+ ページアクセス
73
+
74
+ ```
75
+ http://0.0.0.0:3000/
76
+ ```
77
+
78
+ ## Copyright
79
+
80
+ Copyright (c) 2012 MY_NAME. <a href="http://creativecommons.org/licenses/by-nc-sa/2.1/jp/" target="_blank">CC BY-NC-SA 2.1</a>
@@ -0,0 +1,37 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title><%= Settings.app_name %></title>
5
+ <%= stylesheet_link_tag "application", :media => "all" %>
6
+ <%= javascript_include_tag "application" %>
7
+ <%= csrf_meta_tags %>
8
+ </head>
9
+ <body>
10
+
11
+ <% if current_user %>
12
+ <%# ログイン済み %>
13
+ <%= link_to_unless( current_user.screen_name.blank?, image_tag( current_user.image, size: "20x20" ), "https://twitter.com/#!/#{current_user.screen_name}", target: "_blank" ) %>
14
+ <%= current_user.screen_name %> :
15
+ || <%= link_to "Logout", logout_path %>
16
+ <% else %>
17
+ <%# 未ログイン %>
18
+ <%= link_to "Login", "/auth/#{Settings.provider}" %>
19
+ <% end %>
20
+
21
+ <%# 通知/エラーメッセージ %>
22
+ <%= simple_format( flash[:notice], style: "color: green;" ) unless flash[:notice].blank? %>
23
+ <%= simple_format( flash[:alert], style: "color: red;" ) unless flash[:alert].blank? %>
24
+
25
+ <%= yield %>
26
+
27
+ <br />
28
+ <br />
29
+
30
+ <center>
31
+ Developed by <a href="https://twitter.com/#!/<%= Settings.programmer_twitter_id %>/" target="_blank">@<%= Settings.programmer_twitter_id %></a>,
32
+ Designed by <a href="https://twitter.com/#!/<%= Settings.designer_twitter_id %>/" target="_blank">@<%= Settings.designer_twitter_id %></a>,
33
+ Licence by <a href="https://creativecommons.org/licenses/by-nc-sa/2.1/jp/" target="_blank">CC BY-NC-SA 2.1</a>
34
+ </center>
35
+
36
+ </body>
37
+ </html>
@@ -0,0 +1,60 @@
1
+ # coding: utf-8
2
+ class ApplicationController < ActionController::Base
3
+
4
+ protect_from_forgery
5
+
6
+ # httpsリダイレクト
7
+ before_filter :ssl_redirect if Rails.env.production?
8
+
9
+ # 未ログインリダイレクト
10
+ before_filter :authorize
11
+
12
+ # セッション有効期限延長
13
+ before_filter :reset_session_expires
14
+
15
+ private
16
+
17
+ #--------------#
18
+ # ssl_redirect #
19
+ #--------------#
20
+ # httpsへリダイレクト(Production環境のみ)
21
+ def ssl_redirect
22
+ unless request.env["HTTP_X_FORWARDED_PROTO"].to_s == "https"
23
+ request.env["HTTP_X_FORWARDED_PROTO"] = "https"
24
+
25
+ redirect_to request.url and return
26
+ end
27
+ end
28
+
29
+ #-----------#
30
+ # authorize #
31
+ #-----------#
32
+ # ログイン認証
33
+ def authorize
34
+ # セッション/トップコントローラ以外で
35
+ if params[:controller] != "sessions" and params[:controller] != "top"
36
+ # 未ログインであればルートヘリダイレクト
37
+ if session[:user_id].blank?
38
+ redirect_to :root and return
39
+ end
40
+ end
41
+ end
42
+
43
+ #-----------------------#
44
+ # reset_session_expires #
45
+ #-----------------------#
46
+ # セッション期限延長
47
+ def reset_session_expires
48
+ request.session_options[:expire_after] = 2.weeks
49
+ end
50
+
51
+ #--------------#
52
+ # current_user #
53
+ #--------------#
54
+ def current_user
55
+ @current_user ||= User.where( id: session[:user_id] ).first
56
+ end
57
+
58
+ helper_method :current_user
59
+
60
+ end
@@ -0,0 +1,16 @@
1
+ /* テーブル */
2
+ table, tr, th, td {
3
+ border: 1px solid #aaa;
4
+ padding: 5px;
5
+ border-collapse: collapse;
6
+ border-spacing: 0px;
7
+ }
8
+
9
+ .search table, .search tr, .search td {
10
+ border: 0px solid #aaa;
11
+ padding: 0px;
12
+ }
13
+
14
+ th {
15
+ white-space: nowrap;
16
+ }
@@ -0,0 +1,15 @@
1
+ class CreateUsers < ActiveRecord::Migration
2
+ def change
3
+ create_table :users do |t|
4
+ t.string :provider
5
+ t.string :uid
6
+ t.string :name
7
+ t.string :screen_name
8
+ t.string :image
9
+ t.string :token
10
+ t.string :secret
11
+
12
+ t.timestamps
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,2 @@
1
+
2
+ <h1>Welcome to <%= Settings.app_name %>.</h1>
@@ -0,0 +1,198 @@
1
+ # From https://github.com/svenfuchs/rails-i18n/blob/master/rails/locale/ja.yml
2
+ ja:
3
+ date:
4
+ abbr_day_names:
5
+ - 日
6
+ - 月
7
+ - 火
8
+ - 水
9
+ - 木
10
+ - 金
11
+ - 土
12
+ abbr_month_names:
13
+ -
14
+ - 1月
15
+ - 2月
16
+ - 3月
17
+ - 4月
18
+ - 5月
19
+ - 6月
20
+ - 7月
21
+ - 8月
22
+ - 9月
23
+ - 10月
24
+ - 11月
25
+ - 12月
26
+ day_names:
27
+ - 日曜日
28
+ - 月曜日
29
+ - 火曜日
30
+ - 水曜日
31
+ - 木曜日
32
+ - 金曜日
33
+ - 土曜日
34
+ formats:
35
+ default: ! '%Y/%m/%d'
36
+ long: ! '%Y年%m月%d日(%a)'
37
+ short: ! '%m/%d'
38
+ month_names:
39
+ -
40
+ - 1月
41
+ - 2月
42
+ - 3月
43
+ - 4月
44
+ - 5月
45
+ - 6月
46
+ - 7月
47
+ - 8月
48
+ - 9月
49
+ - 10月
50
+ - 11月
51
+ - 12月
52
+ order:
53
+ - :year
54
+ - :month
55
+ - :day
56
+ datetime:
57
+ distance_in_words:
58
+ about_x_hours:
59
+ one: 約1時間
60
+ other: 約%{count}時間
61
+ about_x_months:
62
+ one: 約1ヶ月
63
+ other: 約%{count}ヶ月
64
+ about_x_years:
65
+ one: 約1年
66
+ other: 約%{count}年
67
+ almost_x_years:
68
+ one: 1年弱
69
+ other: ! '%{count}年弱'
70
+ half_a_minute: 30秒前後
71
+ less_than_x_minutes:
72
+ one: 1分以内
73
+ other: ! '%{count}分以内'
74
+ less_than_x_seconds:
75
+ one: 1秒以内
76
+ other: ! '%{count}秒以内'
77
+ over_x_years:
78
+ one: 1年以上
79
+ other: ! '%{count}年以上'
80
+ x_days:
81
+ one: 1日
82
+ other: ! '%{count}日'
83
+ x_minutes:
84
+ one: 1分
85
+ other: ! '%{count}分'
86
+ x_months:
87
+ one: 1ヶ月
88
+ other: ! '%{count}ヶ月'
89
+ x_seconds:
90
+ one: 1秒
91
+ other: ! '%{count}秒'
92
+ prompts:
93
+ day: 日
94
+ hour: 時
95
+ minute: 分
96
+ month: 月
97
+ second: 秒
98
+ year: 年
99
+ errors: &errors
100
+ format: ! '%{attribute}%{message}'
101
+ messages:
102
+ accepted: を受諾してください。
103
+ blank: を入力してください。
104
+ confirmation: と確認の入力が一致しません。
105
+ empty: を入力してください。
106
+ equal_to: は%{count}にしてください。
107
+ even: は偶数にしてください。
108
+ exclusion: は予約されています。
109
+ greater_than: は%{count}より大きい値にしてください。
110
+ greater_than_or_equal_to: は%{count}以上の値にしてください。
111
+ inclusion: は一覧にありません。
112
+ invalid: は不正な値です。
113
+ less_than: は%{count}より小さい値にしてください。
114
+ less_than_or_equal_to: は%{count}以下の値にしてください。
115
+ not_a_number: は数値で入力してください。
116
+ not_an_integer: は整数で入力してください。
117
+ odd: は奇数にしてください。
118
+ record_invalid: バリデーションに失敗しました。 %{errors}
119
+ taken: はすでに存在します。
120
+ too_long: は%{count}文字以内で入力してください。
121
+ too_short: は%{count}文字以上で入力してください。
122
+ wrong_length: は%{count}文字で入力してください。
123
+ template:
124
+ body: 次の項目を確認してください。
125
+ header:
126
+ one: ! '%{model}にエラーが発生しました。'
127
+ other: ! '%{model}に%{count}つのエラーが発生しました。'
128
+ helpers:
129
+ select:
130
+ prompt: 選択してください。
131
+ submit:
132
+ create: 登録する
133
+ submit: 保存する
134
+ update: 更新する
135
+ number:
136
+ currency:
137
+ format:
138
+ delimiter: ! ','
139
+ format: ! '%n%u'
140
+ precision: 0
141
+ separator: .
142
+ significant: false
143
+ strip_insignificant_zeros: false
144
+ unit: 円
145
+ format:
146
+ delimiter: ! ','
147
+ precision: 3
148
+ separator: .
149
+ significant: false
150
+ strip_insignificant_zeros: false
151
+ human:
152
+ decimal_units:
153
+ format: ! '%n %u'
154
+ units:
155
+ billion: 十億
156
+ million: 百万
157
+ quadrillion: 千兆
158
+ thousand: 千
159
+ trillion: 兆
160
+ unit: ''
161
+ format:
162
+ delimiter: ''
163
+ precision: 3
164
+ significant: true
165
+ strip_insignificant_zeros: true
166
+ storage_units:
167
+ format: ! '%n%u'
168
+ units:
169
+ byte: バイト
170
+ gb: ギガバイト
171
+ kb: キロバイト
172
+ mb: メガバイト
173
+ tb: テラバイト
174
+ percentage:
175
+ format:
176
+ delimiter: ''
177
+ precision:
178
+ format:
179
+ delimiter: ''
180
+ support:
181
+ array:
182
+ last_word_connector: と
183
+ two_words_connector: と
184
+ words_connector: と
185
+ time:
186
+ am: 午前
187
+ formats:
188
+ default: ! '%Y/%m/%d %H:%M:%S'
189
+ long: ! '%Y年%m月%d日(%a) %H時%M分%S秒 %z'
190
+ short: ! '%y/%m/%d %H:%M'
191
+ pm: 午後
192
+ # remove these aliases after 'activemodel' and 'activerecord' namespaces are removed from Rails repository
193
+ activemodel:
194
+ errors:
195
+ <<: *errors
196
+ activerecord:
197
+ errors:
198
+ <<: *errors
@@ -0,0 +1,10 @@
1
+ Rails.application.config.middleware.use OmniAuth::Builder do
2
+ # --- Twitter - Default --- #
3
+ provider :twitter, Settings.twitter_key, Settings.twitter_secret
4
+
5
+ # --- Others --- #
6
+ # provider :developer unless Rails.env.production?
7
+ # provider :twitter, Settings.twitter_key, Settings.twitter_secret
8
+ # provider :github, Settings.github_client_id, Settings.github_secret
9
+ # provider :facebook, Settings.facebook_app_id, Settings.facebook_app_secret
10
+ end
@@ -0,0 +1,11 @@
1
+ # Twitter OAuth Setting
2
+ twitter_key: <%= ENV['TWITTER_KEY'] %>
3
+ twitter_secret: <%= ENV['TWITTER_SECRET'] %>
4
+
5
+ # GitHub OAuth Setting
6
+ github_client_id: <%= ENV['GITHUB_CLIENT_ID'] %>
7
+ github_secret: <%= ENV['GITHUB_SECRET'] %>
8
+
9
+ # Facebook OAuth Setting
10
+ facebook_app_id: <%= ENV['FACEBOOK_APP_ID'] %>
11
+ facebook_app_secret: <%= ENV['FACEBOOK_APP_SECRET'] %>
@@ -0,0 +1,3 @@
1
+ RailsConfig.setup do |config|
2
+ config.const_name = "Settings"
3
+ end
@@ -0,0 +1,3 @@
1
+ # Twitter OAuth Local Setting
2
+ twitter_key: "TWITTER_KEY"
3
+ twitter_secret: "TWITTER_SECRET"
@@ -0,0 +1,11 @@
1
+ # OmniAuth Provider
2
+ provider: "twitter"
3
+
4
+ # アプリケーション名
5
+ app_name: "YOUR_APP_NAME"
6
+
7
+ # プログラマTwitterID
8
+ programmer_twitter_id: "PROGRAMMER_TWITTER_ID"
9
+
10
+ # デザイナーTwitterID
11
+ designer_twitter_id: "DESIGNER_TWITTER_ID"
@@ -0,0 +1,70 @@
1
+ body {
2
+ background-color: #fff;
3
+ color: #333;
4
+ font-family: Courier, verdana, arial, helvetica, sans-serif;
5
+ font-size: 14px;
6
+ line-height: 18px;
7
+ }
8
+
9
+ p, ol, ul, td {
10
+ font-family: Courier, verdana, arial, helvetica, sans-serif;
11
+ font-size: 14px;
12
+ line-height: 18px;
13
+ }
14
+
15
+ textarea, pre {
16
+ font-family: Courier;
17
+ font-size: 14px;
18
+ }
19
+
20
+ pre {
21
+ background-color: #eee;
22
+ padding: 10px;
23
+ }
24
+
25
+ a {
26
+ color: #000;
27
+ &:visited {
28
+ color: #666; }
29
+ &:hover {
30
+ color: #fff;
31
+ background-color: #000; }
32
+ }
33
+
34
+ div {
35
+ &.field, &.actions {
36
+ margin-bottom: 10px; }
37
+ }
38
+
39
+ #notice {
40
+ color: green;
41
+ }
42
+
43
+ .field_with_errors {
44
+ padding: 2px;
45
+ background-color: red;
46
+ display: table;
47
+ }
48
+
49
+ #error_explanation {
50
+ width: 450px;
51
+ border: 2px solid red;
52
+ padding: 7px;
53
+ padding-bottom: 0;
54
+ margin-bottom: 20px;
55
+ background-color: #f0f0f0;
56
+ h2 {
57
+ text-align: left;
58
+ font-weight: bold;
59
+ padding: 5px 5px 5px 15px;
60
+ font-size: 12px;
61
+ margin: -7px;
62
+ margin-bottom: 0px;
63
+ background-color: #c00;
64
+ color: #fff;
65
+ }
66
+ ul li {
67
+ font-size: 12px;
68
+ list-style: square;
69
+ }
70
+ }
@@ -0,0 +1,31 @@
1
+ # coding: utf-8
2
+ class SessionsController < ApplicationController
3
+
4
+ #----------#
5
+ # callback #
6
+ #----------#
7
+ def callback
8
+ auth = request.env["omniauth.auth"]
9
+ user = User.where( provider: auth["provider"], uid: auth["uid"] ).first || User.create_with_omniauth( auth )
10
+ session[:user_id] = user.id
11
+
12
+ redirect_to :root, notice: "ログインしました。"
13
+ end
14
+
15
+ #---------#
16
+ # destroy #
17
+ #---------#
18
+ def destroy
19
+ session[:user_id] = nil
20
+
21
+ redirect_to :root, notice: "ログアウトしました。"
22
+ end
23
+
24
+ #---------#
25
+ # failure #
26
+ #---------#
27
+ def failure
28
+ render text: "<span style='color: red;'>Auth Failure</span>"
29
+ end
30
+
31
+ end
@@ -0,0 +1,10 @@
1
+ # coding: utf-8
2
+ class TopController < ApplicationController
3
+
4
+ #-------#
5
+ # index #
6
+ #-------#
7
+ def index
8
+ end
9
+
10
+ end
@@ -0,0 +1,31 @@
1
+ # coding: utf-8
2
+ class User < ActiveRecord::Base
3
+ attr_accessible :provider, :uid, :name, :screen_name, :image, :token, :secret
4
+
5
+ private
6
+
7
+ #---------------------------#
8
+ # self.create_with_omniauth #
9
+ #---------------------------#
10
+ def self.create_with_omniauth( auth )
11
+ user = User.new
12
+ user[:provider] = auth["provider"]
13
+ user[:uid] = auth["uid"]
14
+
15
+ unless auth["info"].blank?
16
+ user[:name] = auth["info"]["name"]
17
+ user[:screen_name] = auth["info"]["nickname"]
18
+ user[:image] = auth["info"]["image"]
19
+ end
20
+
21
+ unless auth["credentials"].blank?
22
+ user.token = auth['credentials']['token']
23
+ user.secret = auth['credentials']['secret']
24
+ end
25
+
26
+ user.save
27
+
28
+ return user
29
+ end
30
+
31
+ end
@@ -0,0 +1,5 @@
1
+ module Omniauth
2
+ module Scaffold
3
+ VERSION = "0.0.1"
4
+ end
5
+ end
@@ -0,0 +1,17 @@
1
+ # -*- encoding: utf-8 -*-
2
+ require File.expand_path('../lib/omniauth-scaffold/version', __FILE__)
3
+
4
+ Gem::Specification.new do |gem|
5
+ gem.authors = ["shu0115"]
6
+ gem.email = ["raisondetre0115@gmail.com"]
7
+ gem.description = %q{Scaffold for OmniAuth.}
8
+ gem.summary = %q{OmniAuth Scaffold}
9
+ gem.homepage = "https://github.com/shu0115/omniauth-scaffold"
10
+
11
+ gem.files = `git ls-files`.split($\)
12
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
13
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
14
+ gem.name = "omniauth-scaffold"
15
+ gem.require_paths = ["lib"]
16
+ gem.version = Omniauth::Scaffold::VERSION
17
+ end
metadata ADDED
@@ -0,0 +1,71 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: omniauth-scaffold
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - shu0115
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-07-04 00:00:00.000000000 Z
13
+ dependencies: []
14
+ description: Scaffold for OmniAuth.
15
+ email:
16
+ - raisondetre0115@gmail.com
17
+ executables: []
18
+ extensions: []
19
+ extra_rdoc_files: []
20
+ files:
21
+ - .gitignore
22
+ - Gemfile
23
+ - LICENSE
24
+ - README.md
25
+ - Rakefile
26
+ - lib/omniauth-scaffold.rb
27
+ - lib/omniauth-scaffold/templates/README.md
28
+ - lib/omniauth-scaffold/templates/application.html.erb
29
+ - lib/omniauth-scaffold/templates/application_controller.rb
30
+ - lib/omniauth-scaffold/templates/base.css.scss
31
+ - lib/omniauth-scaffold/templates/create_users.rb
32
+ - lib/omniauth-scaffold/templates/index.html.erb
33
+ - lib/omniauth-scaffold/templates/ja.yml
34
+ - lib/omniauth-scaffold/templates/omniauth.rb
35
+ - lib/omniauth-scaffold/templates/rails_config/development.yml
36
+ - lib/omniauth-scaffold/templates/rails_config/production.yml
37
+ - lib/omniauth-scaffold/templates/rails_config/rails_config.rb
38
+ - lib/omniauth-scaffold/templates/rails_config/settings.local.yml
39
+ - lib/omniauth-scaffold/templates/rails_config/settings.yml
40
+ - lib/omniauth-scaffold/templates/rails_config/test.yml
41
+ - lib/omniauth-scaffold/templates/scaffolds.css.scss
42
+ - lib/omniauth-scaffold/templates/sessions_controller.rb
43
+ - lib/omniauth-scaffold/templates/top_controller.rb
44
+ - lib/omniauth-scaffold/templates/user.rb
45
+ - lib/omniauth-scaffold/version.rb
46
+ - omniauth-scaffold.gemspec
47
+ homepage: https://github.com/shu0115/omniauth-scaffold
48
+ licenses: []
49
+ post_install_message:
50
+ rdoc_options: []
51
+ require_paths:
52
+ - lib
53
+ required_ruby_version: !ruby/object:Gem::Requirement
54
+ none: false
55
+ requirements:
56
+ - - ! '>='
57
+ - !ruby/object:Gem::Version
58
+ version: '0'
59
+ required_rubygems_version: !ruby/object:Gem::Requirement
60
+ none: false
61
+ requirements:
62
+ - - ! '>='
63
+ - !ruby/object:Gem::Version
64
+ version: '0'
65
+ requirements: []
66
+ rubyforge_project:
67
+ rubygems_version: 1.8.23
68
+ signing_key:
69
+ specification_version: 3
70
+ summary: OmniAuth Scaffold
71
+ test_files: []