minimum-omniauth-scaffold 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (29) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +17 -0
  3. data/Gemfile +4 -0
  4. data/LICENSE.txt +22 -0
  5. data/README.md +29 -0
  6. data/Rakefile +1 -0
  7. data/lib/minimum/omniauth/scaffold.rb +104 -0
  8. data/lib/minimum/omniauth/scaffold/templates/README.md +80 -0
  9. data/lib/minimum/omniauth/scaffold/templates/controllers/application_controller.rb +30 -0
  10. data/lib/minimum/omniauth/scaffold/templates/controllers/sessions_controller.rb +32 -0
  11. data/lib/minimum/omniauth/scaffold/templates/controllers/top_controller.rb +5 -0
  12. data/lib/minimum/omniauth/scaffold/templates/initializers/omniauth.rb +7 -0
  13. data/lib/minimum/omniauth/scaffold/templates/locales/ja.yml +209 -0
  14. data/lib/minimum/omniauth/scaffold/templates/locales/translation_ja.yml +5 -0
  15. data/lib/minimum/omniauth/scaffold/templates/migrate/create_users.rb +17 -0
  16. data/lib/minimum/omniauth/scaffold/templates/models/user.rb +47 -0
  17. data/lib/minimum/omniauth/scaffold/templates/rails_config/development.yml +0 -0
  18. data/lib/minimum/omniauth/scaffold/templates/rails_config/production.yml +14 -0
  19. data/lib/minimum/omniauth/scaffold/templates/rails_config/rails_config.rb +3 -0
  20. data/lib/minimum/omniauth/scaffold/templates/rails_config/settings.local.yml +11 -0
  21. data/lib/minimum/omniauth/scaffold/templates/rails_config/settings.yml +18 -0
  22. data/lib/minimum/omniauth/scaffold/templates/rails_config/test.yml +0 -0
  23. data/lib/minimum/omniauth/scaffold/templates/stylesheets/scaffolds.css.scss +129 -0
  24. data/lib/minimum/omniauth/scaffold/templates/views/_user_icon.html.erb +3 -0
  25. data/lib/minimum/omniauth/scaffold/templates/views/application.html.erb +28 -0
  26. data/lib/minimum/omniauth/scaffold/templates/views/index.html.erb +2 -0
  27. data/lib/minimum/omniauth/scaffold/version.rb +7 -0
  28. data/minimum-omniauth-scaffold.gemspec +31 -0
  29. metadata +183 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 00bd0317c6f0126cc22479c187ede3de49815319
4
+ data.tar.gz: 50ec3a28d07bf9a0a5f3524d726677eaccdb6de6
5
+ SHA512:
6
+ metadata.gz: ac71faf4bebeb71709f34c388c0e7b4d279bcbbe7c067b5b5abb8fb58736417f5c03782b094c2efb5b73d2df2d7263cadd086d81708f8eb6917f40fbffaf8e82
7
+ data.tar.gz: 6afbb762287da7f062a78c7453561545f5ca2f309c139d860235997e2e4eaeca092daf37048455882ab98abe1c86bd402266e29d15972f38d6dd3fe58664908d
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 minimum-omniauth-scaffold.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 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,29 @@
1
+ # Minimum::Omniauth::Scaffold
2
+
3
+ For Ruby2.0 and Rails4.0
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'minimum-omniauth-scaffold'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install minimum-omniauth-scaffold
18
+
19
+ ## Usage
20
+
21
+ TODO: Write usage instructions here
22
+
23
+ ## Contributing
24
+
25
+ 1. Fork it
26
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
27
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
28
+ 4. Push to the branch (`git push origin my-new-feature`)
29
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,104 @@
1
+ require "minimum/omniauth/scaffold/version"
2
+
3
+ require 'rails/generators'
4
+
5
+ require 'rails_config'
6
+ require 'omniauth-twitter'
7
+ require 'omniauth-facebook'
8
+ require 'omniauth-github'
9
+ require 'tapp'
10
+ require 'awesome_print'
11
+
12
+ module Minimum
13
+ module Omniauth
14
+ class ScaffoldGenerator < Rails::Generators::Base
15
+ @@template_path = source_root File.expand_path( "../scaffold/templates", __FILE__ )
16
+
17
+ def generate_scaffold
18
+ app_name = Rails.application.class.name.split('::').first
19
+
20
+ # ----- rails_config ----- #
21
+ copy_file( "#{@@template_path}/rails_config/rails_config.rb", "config/initializers/rails_config.rb" )
22
+ copy_file( "#{@@template_path}/rails_config/settings.yml", "config/settings.yml" )
23
+ copy_file( "#{@@template_path}/rails_config/settings.local.yml", "config/settings.local.yml" )
24
+ copy_file( "#{@@template_path}/rails_config/development.yml", "config/settings/development.yml" )
25
+ copy_file( "#{@@template_path}/rails_config/production.yml", "config/settings/production.yml" )
26
+ copy_file( "#{@@template_path}/rails_config/test.yml", "config/settings/test.yml" )
27
+
28
+ # ----- omniauth ----- #
29
+ copy_file( "#{@@template_path}/initializers/omniauth.rb", "config/initializers/omniauth.rb" )
30
+
31
+ # ----- routes.rb ----- #
32
+ content = "\n # For OmniAuth\n"
33
+ content += " get \"/auth/:provider/callback\" => \"sessions#callback\"\n"
34
+ content += " get \"/auth/failure\" => \"sessions#failure\"\n"
35
+ content += " get \"/logout\" => \"sessions#destroy\", as: :logout\n"
36
+ content += "\n"
37
+ insert_into_file( "config/routes.rb", content.force_encoding('ASCII-8BIT'), after: "Application.routes.draw do\n" )
38
+ insert_into_file( "config/routes.rb", " root to: 'top#index'\n", after: "Application.routes.draw do\n" )
39
+
40
+ # ----- application.rb ----- #
41
+ content = " config.time_zone = 'Tokyo'\n"
42
+ # content += " config.active_record.default_timezone = :local\n"
43
+ insert_into_file( "config/application.rb", content.force_encoding('ASCII-8BIT'), after: "# config.time_zone = 'Central Time (US & Canada)'\n" )
44
+ insert_into_file( "config/application.rb", " config.i18n.default_locale = :ja\n", after: "# config.i18n.default_locale = :de\n" )
45
+ content = "\n # For Heroku\n"
46
+ content += " config.assets.initialize_on_precompile = false\n"
47
+ content += "\n # For Tapp\n"
48
+ content += " Tapp.config.default_printer = :awesome_print\n"
49
+ insert_into_file( "config/application.rb", content.force_encoding('ASCII-8BIT'), after: "config.assets.version = '1.0'\n" )
50
+
51
+ # ----- production.rb ----- #
52
+ insert_into_file( "config/environments/production.rb", " config.force_ssl = true\n", after: "# config.force_ssl = true\n" ) # 強制SSL設定
53
+
54
+ # ----- development.rb ----- #
55
+ # content = "\n # For LogRotate\n"
56
+ # content += " config.logger = Logger.new( 'log/development.log', 3, 10*1024*1024 ) # 10MB * 3\n"
57
+ # insert_into_file( "config/environments/development.rb", content.force_encoding('ASCII-8BIT'), after: "config.assets.debug = true\n" )
58
+ gsub_file "config/environments/development.rb", /(config.assets.debug = true)+/, "# config.assets.debug = true" # コメントアウト追加
59
+ insert_into_file( "config/environments/development.rb", " config.assets.debug = false\n", after: "config.assets.debug = true\n" ) # false設定追加
60
+
61
+ # ----- ja.yml ----- #
62
+ copy_file( "#{@@template_path}/locales/ja.yml", "config/locales/ja.yml" )
63
+ copy_file( "#{@@template_path}/locales/translation_ja.yml", "config/locales/translation_ja.yml" )
64
+
65
+ # ----- create_users.rb ----- #
66
+ copy_file( "#{@@template_path}/migrate/create_users.rb", "db/migrate/20000101000000_create_users.rb" )
67
+
68
+ # ----- models ----- #
69
+ copy_file( "#{@@template_path}/models/user.rb", "app/models/user.rb" )
70
+
71
+ # ----- controllers ----- #
72
+ content = File.read( "#{@@template_path}/controllers/application_controller.rb", encoding: Encoding::UTF_8 )
73
+ insert_into_file( "app/controllers/application_controller.rb", content.force_encoding('ASCII-8BIT'), after: "protect_from_forgery with: :exception\n" )
74
+ copy_file( "#{@@template_path}/controllers/sessions_controller.rb", "app/controllers/sessions_controller.rb" )
75
+ copy_file( "#{@@template_path}/controllers/top_controller.rb", "app/controllers/top_controller.rb" )
76
+
77
+ # ----- views ----- #
78
+ content = File.read( "#{@@template_path}/views/application.html.erb", encoding: Encoding::UTF_8 )
79
+ gsub_file "app/views/layouts/application.html.erb", /(<%= yield %>)+/, content.force_encoding('ASCII-8BIT')
80
+ gsub_file "app/views/layouts/application.html.erb", Regexp.new("<title>#{app_name}</title>"), "<title><%= Settings.app_name %></title>"
81
+ copy_file( "#{@@template_path}/views/_user_icon.html.erb", "app/views/layouts/_user_icon.html.erb" )
82
+ copy_file( "#{@@template_path}/views/index.html.erb", "app/views/top/index.html.erb" )
83
+
84
+ # ----- assets ----- #
85
+ copy_file( "#{@@template_path}/stylesheets/scaffolds.css.scss", "app/assets/stylesheets/scaffolds.css.scss" )
86
+
87
+ # ----- README ----- #
88
+ remove_file( 'README.rdoc' )
89
+ copy_file( "#{@@template_path}/README.md", "README.md" )
90
+
91
+ # ----- .gitignore ----- #
92
+ content = "\n# Add\n"
93
+ content += ".DS_Store\n"
94
+ content += "vendor/bundle\n"
95
+ content += "/log/*.log.*\n"
96
+ content += "\n# rails_config\n"
97
+ content += "config/settings.local.yml\n"
98
+ content += "config/settings/*.local.yml\n"
99
+ content += "config/environments/*.local.yml\n"
100
+ append_file( ".gitignore", content.force_encoding('ASCII-8BIT') )
101
+ end
102
+ end
103
+ end
104
+ 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:setup
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,30 @@
1
+ before_filter :authorize # ログイン認証
2
+ before_filter :reset_session_expires # セッション有効期限延長
3
+
4
+ private
5
+
6
+ # ログイン認証
7
+ def authorize
8
+ # セッション/トップコントローラ以外で
9
+ if params[:controller] != "sessions" and params[:controller] != "top"
10
+ # 未ログインであれば
11
+ if current_user.blank?
12
+ # リクエストURL保管
13
+ session[:request_url] = request.url
14
+
15
+ # ルートヘリダイレクト
16
+ redirect_to :root and return
17
+ end
18
+ end
19
+ end
20
+
21
+ # セッション期限延長
22
+ def reset_session_expires
23
+ request.session_options[:expire_after] = 2.weeks
24
+ end
25
+
26
+ # ログインユーザ
27
+ def current_user
28
+ @current_user ||= User.where( id: session[:user_id] ).first
29
+ end
30
+ helper_method :current_user
@@ -0,0 +1,32 @@
1
+ class SessionsController < ApplicationController
2
+ # ログイン
3
+ def callback
4
+ auth = request.env["omniauth.auth"]
5
+
6
+ user = User.where( provider: auth["provider"], uid: auth["uid"] ).first || User.create_with_omniauth( auth )
7
+ user.auth_update( auth )
8
+
9
+ session[:user_id] = user.id
10
+
11
+ # 保管URLへリダイレクト
12
+ unless session[:request_url].blank?
13
+ redirect_to session[:request_url]
14
+ session[:request_url] = nil
15
+ return
16
+ end
17
+
18
+ redirect_to :root, notice: "ログインしました。"
19
+ end
20
+
21
+ # ログアウト
22
+ def destroy
23
+ session[:user_id] = nil
24
+
25
+ redirect_to :root, notice: "ログアウトしました。"
26
+ end
27
+
28
+ # ログインエラー
29
+ def failure
30
+ render text: "<span style='color: red;'>Auth Failure</span>"
31
+ end
32
+ end
@@ -0,0 +1,5 @@
1
+ class TopController < ApplicationController
2
+ # トップ
3
+ def index
4
+ end
5
+ end
@@ -0,0 +1,7 @@
1
+ Rails.application.config.middleware.use OmniAuth::Builder do
2
+ # Providers
3
+ # provider :developer unless Rails.env.production?
4
+ provider :twitter, Settings.twitter_key, Settings.twitter_secret
5
+ provider :facebook, Settings.facebook_app_id, Settings.facebook_app_secret
6
+ provider :github, Settings.github_client_id, Settings.github_secret
7
+ end
@@ -0,0 +1,209 @@
1
+ # From https://github.com/svenfuchs/rails-i18n/blob/master/rails/locale/ja.yml
2
+ ja:
3
+ # Add
4
+ menu:
5
+ new: "New"
6
+ show: "Show"
7
+ edit: "Edit"
8
+ destroy: "Delete"
9
+ top: "Top"
10
+ list: "List"
11
+ create: "Create"
12
+ update: "Update"
13
+
14
+ date:
15
+ abbr_day_names:
16
+ - 日
17
+ - 月
18
+ - 火
19
+ - 水
20
+ - 木
21
+ - 金
22
+ - 土
23
+ abbr_month_names:
24
+ -
25
+ - 1月
26
+ - 2月
27
+ - 3月
28
+ - 4月
29
+ - 5月
30
+ - 6月
31
+ - 7月
32
+ - 8月
33
+ - 9月
34
+ - 10月
35
+ - 11月
36
+ - 12月
37
+ day_names:
38
+ - 日曜日
39
+ - 月曜日
40
+ - 火曜日
41
+ - 水曜日
42
+ - 木曜日
43
+ - 金曜日
44
+ - 土曜日
45
+ formats:
46
+ default: ! '%Y/%m/%d'
47
+ long: ! '%Y年%m月%d日(%a)'
48
+ short: ! '%m/%d'
49
+ month_names:
50
+ -
51
+ - 1月
52
+ - 2月
53
+ - 3月
54
+ - 4月
55
+ - 5月
56
+ - 6月
57
+ - 7月
58
+ - 8月
59
+ - 9月
60
+ - 10月
61
+ - 11月
62
+ - 12月
63
+ order:
64
+ - :year
65
+ - :month
66
+ - :day
67
+ datetime:
68
+ distance_in_words:
69
+ about_x_hours:
70
+ one: 約1時間
71
+ other: 約%{count}時間
72
+ about_x_months:
73
+ one: 約1ヶ月
74
+ other: 約%{count}ヶ月
75
+ about_x_years:
76
+ one: 約1年
77
+ other: 約%{count}年
78
+ almost_x_years:
79
+ one: 1年弱
80
+ other: ! '%{count}年弱'
81
+ half_a_minute: 30秒前後
82
+ less_than_x_minutes:
83
+ one: 1分以内
84
+ other: ! '%{count}分以内'
85
+ less_than_x_seconds:
86
+ one: 1秒以内
87
+ other: ! '%{count}秒以内'
88
+ over_x_years:
89
+ one: 1年以上
90
+ other: ! '%{count}年以上'
91
+ x_days:
92
+ one: 1日
93
+ other: ! '%{count}日'
94
+ x_minutes:
95
+ one: 1分
96
+ other: ! '%{count}分'
97
+ x_months:
98
+ one: 1ヶ月
99
+ other: ! '%{count}ヶ月'
100
+ x_seconds:
101
+ one: 1秒
102
+ other: ! '%{count}秒'
103
+ prompts:
104
+ day: 日
105
+ hour: 時
106
+ minute: 分
107
+ month: 月
108
+ second: 秒
109
+ year: 年
110
+ errors: &errors
111
+ format: ! '%{attribute}%{message}'
112
+ messages:
113
+ accepted: を受諾してください。
114
+ blank: を入力してください。
115
+ confirmation: と確認の入力が一致しません。
116
+ empty: を入力してください。
117
+ equal_to: は%{count}にしてください。
118
+ even: は偶数にしてください。
119
+ exclusion: は予約されています。
120
+ greater_than: は%{count}より大きい値にしてください。
121
+ greater_than_or_equal_to: は%{count}以上の値にしてください。
122
+ inclusion: は一覧にありません。
123
+ invalid: は不正な値です。
124
+ less_than: は%{count}より小さい値にしてください。
125
+ less_than_or_equal_to: は%{count}以下の値にしてください。
126
+ not_a_number: は数値で入力してください。
127
+ not_an_integer: は整数で入力してください。
128
+ odd: は奇数にしてください。
129
+ record_invalid: バリデーションに失敗しました。 %{errors}
130
+ taken: はすでに存在します。
131
+ too_long: は%{count}文字以内で入力してください。
132
+ too_short: は%{count}文字以上で入力してください。
133
+ wrong_length: は%{count}文字で入力してください。
134
+ template:
135
+ body: 次の項目を確認してください。
136
+ header:
137
+ one: ! '%{model}にエラーが発生しました。'
138
+ other: ! '%{model}に%{count}つのエラーが発生しました。'
139
+ helpers:
140
+ select:
141
+ prompt: 選択してください。
142
+ submit:
143
+ create: 登録する
144
+ submit: 保存する
145
+ update: 更新する
146
+ number:
147
+ currency:
148
+ format:
149
+ delimiter: ! ','
150
+ format: ! '%n%u'
151
+ precision: 0
152
+ separator: .
153
+ significant: false
154
+ strip_insignificant_zeros: false
155
+ unit: 円
156
+ format:
157
+ delimiter: ! ','
158
+ precision: 3
159
+ separator: .
160
+ significant: false
161
+ strip_insignificant_zeros: false
162
+ human:
163
+ decimal_units:
164
+ format: ! '%n %u'
165
+ units:
166
+ billion: 十億
167
+ million: 百万
168
+ quadrillion: 千兆
169
+ thousand: 千
170
+ trillion: 兆
171
+ unit: ''
172
+ format:
173
+ delimiter: ''
174
+ precision: 3
175
+ significant: true
176
+ strip_insignificant_zeros: true
177
+ storage_units:
178
+ format: ! '%n%u'
179
+ units:
180
+ byte: バイト
181
+ gb: ギガバイト
182
+ kb: キロバイト
183
+ mb: メガバイト
184
+ tb: テラバイト
185
+ percentage:
186
+ format:
187
+ delimiter: ''
188
+ precision:
189
+ format:
190
+ delimiter: ''
191
+ support:
192
+ array:
193
+ last_word_connector: と
194
+ two_words_connector: と
195
+ words_connector: と
196
+ time:
197
+ am: 午前
198
+ formats:
199
+ default: ! '%Y/%m/%d %H:%M:%S'
200
+ long: ! '%Y年%m月%d日(%a) %H時%M分%S秒 %z'
201
+ short: ! '%y/%m/%d %H:%M'
202
+ pm: 午後
203
+ # remove these aliases after 'activemodel' and 'activerecord' namespaces are removed from Rails repository
204
+ activemodel:
205
+ errors:
206
+ <<: *errors
207
+ activerecord:
208
+ errors:
209
+ <<: *errors
@@ -0,0 +1,5 @@
1
+ # https://github.com/amatsuda/i18n_generators
2
+ ja:
3
+ activerecord:
4
+ models:
5
+ attributes:
@@ -0,0 +1,17 @@
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 :nickname
8
+ t.string :image
9
+ t.string :email
10
+ t.string :location
11
+ t.string :token
12
+ t.string :secret
13
+
14
+ t.timestamps
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,47 @@
1
+ class User < ActiveRecord::Base
2
+ # attr_accessible :provider, :uid, :name, :nickname, :image, :email, :location, :token, :secret
3
+
4
+ # auth情報更新
5
+ def auth_update( auth )
6
+ if auth["provider"] == "facebook"
7
+ image_path = "https://graph.facebook.com/#{auth['info']['nickname'].presence || auth["uid"]}/picture?width=200&height=200"
8
+ else
9
+ image_path = auth["info"]["image"]
10
+ end
11
+
12
+ if self.name != auth["info"]["name"] or self.nickname != auth["info"]["nickname"] or self.image != image_path or self.email != auth["info"]["email"] or self.location != auth["info"]["location"]
13
+ self.name = auth["info"]["name"]
14
+ self.nickname = auth["info"]["nickname"]
15
+ self.image = image_path
16
+ self.email = auth["info"]["email"]
17
+ self.location = auth["info"]["location"]
18
+ self.save!
19
+ end
20
+ end
21
+
22
+ private
23
+
24
+ # auth情報登録
25
+ def self.create_with_omniauth( auth )
26
+ user = User.new
27
+ user.provider = auth["provider"]
28
+ user.uid = auth["uid"]
29
+
30
+ if auth["info"].present?
31
+ user.name = auth["info"]["name"]
32
+ user.nickname = auth["info"]["nickname"]
33
+ user.image = auth["info"]["image"]
34
+ user.email = auth["info"]["email"]
35
+ user.location = auth["info"]["location"]
36
+ end
37
+
38
+ if auth["credentials"].present?
39
+ user.token = auth['credentials']['token']
40
+ user.secret = auth['credentials']['secret']
41
+ end
42
+
43
+ user.save!
44
+
45
+ return user
46
+ end
47
+ end
@@ -0,0 +1,14 @@
1
+ # Twitter OAuth Setting
2
+ twitter_key: <%= ENV['TWITTER_KEY'] %>
3
+ twitter_secret: <%= ENV['TWITTER_SECRET'] %>
4
+
5
+ # Facebook OAuth Setting
6
+ facebook_app_id: <%= ENV['FACEBOOK_APP_ID'] %>
7
+ facebook_app_secret: <%= ENV['FACEBOOK_APP_SECRET'] %>
8
+
9
+ # GitHub OAuth Setting
10
+ github_client_id: <%= ENV['GITHUB_CLIENT_ID'] %>
11
+ github_secret: <%= ENV['GITHUB_SECRET'] %>
12
+
13
+ # Mail Pass
14
+ mail_password: <%= ENV['MAIL_PASSWORD'] %>
@@ -0,0 +1,3 @@
1
+ RailsConfig.setup do |config|
2
+ config.const_name = "Settings"
3
+ end
@@ -0,0 +1,11 @@
1
+ # Twitter OAuth Local Setting
2
+ twitter_key: "TWITTER_KEY"
3
+ twitter_secret: "TWITTER_SECRET"
4
+
5
+ # Facebook OAuth Setting
6
+ facebook_app_id: "FACEBOOK_APP_ID"
7
+ facebook_app_secret: "FACEBOOK_APP_SECRET"
8
+
9
+ # GitHub OAuth Setting
10
+ github_client_id: "GITHUB_CLIENT_ID"
11
+ github_secret: "GITHUB_SECRET"
@@ -0,0 +1,18 @@
1
+ # # OmniAuth Provider
2
+ # provider: "twitter"
3
+ # #provider: "facebook"
4
+ # #provider: "github"
5
+
6
+ # Provider Page
7
+ twitter_page: "https://twitter.com/"
8
+ facebook_page: "https://www.facebook.com/"
9
+ github_page: "https://github.com/"
10
+
11
+ # アプリケーション名
12
+ app_name: "YOUR_APP_NAME"
13
+
14
+ # プログラマTwitterID
15
+ programmer_twitter_id: "PROGRAMMER_TWITTER_ID"
16
+
17
+ # デザイナーTwitterID
18
+ designer_twitter_id: "DESIGNER_TWITTER_ID"
@@ -0,0 +1,129 @@
1
+ body {
2
+ background-color: #fff;
3
+ color: #333;
4
+ font-family: verdana, arial, helvetica, sans-serif;
5
+ font-size: 13px;
6
+ line-height: 18px;
7
+ }
8
+
9
+ p, ol, ul, td {
10
+ font-family: verdana, arial, helvetica, sans-serif;
11
+ font-size: 13px;
12
+ line-height: 18px;
13
+ }
14
+
15
+ pre {
16
+ background-color: #eee;
17
+ padding: 10px;
18
+ font-size: 11px;
19
+ }
20
+
21
+ a {
22
+ color: #000;
23
+ &:visited {
24
+ color: #666;
25
+ }
26
+ &:hover {
27
+ color: #fff;
28
+ background-color: #000;
29
+ }
30
+ }
31
+
32
+ div {
33
+ &.field, &.actions {
34
+ margin-bottom: 10px;
35
+ }
36
+ }
37
+
38
+ #notice {
39
+ color: green;
40
+ }
41
+
42
+ .field_with_errors {
43
+ padding: 2px;
44
+ background-color: red;
45
+ display: table;
46
+ }
47
+
48
+ #error_explanation {
49
+ width: 450px;
50
+ border: 2px solid red;
51
+ padding: 7px;
52
+ padding-bottom: 0;
53
+ margin-bottom: 20px;
54
+ background-color: #f0f0f0;
55
+ h2 {
56
+ text-align: left;
57
+ font-weight: bold;
58
+ padding: 5px 5px 5px 15px;
59
+ font-size: 12px;
60
+ margin: -7px;
61
+ margin-bottom: 0px;
62
+ background-color: #c00;
63
+ color: #fff;
64
+ }
65
+ ul li {
66
+ font-size: 12px;
67
+ list-style: square;
68
+ }
69
+ }
70
+
71
+ /* Add minimum-omniauth-scaffold */
72
+ body {
73
+ font-family: Courier, monospace, verdana, arial, helvetica, sans-serif;
74
+ }
75
+
76
+ textarea {
77
+ font-family: Courier;
78
+ font-size: 12px;
79
+ }
80
+
81
+ pre {
82
+ font-family: Courier;
83
+ font-size: 12px;
84
+ background-color: #eee;
85
+ padding: 5px;
86
+ }
87
+
88
+ .navbar .brand {
89
+ display: block;
90
+ float: left;
91
+ padding: 8px 20px 6px 20px;
92
+ margin-left: -20px;
93
+ font-size: 20px;
94
+ font-weight: 200;
95
+ line-height: 1;
96
+ color: #999;
97
+ }
98
+
99
+ .backcolor_white {
100
+ background-color: #fff;
101
+ }
102
+
103
+ .padding_top10 {
104
+ padding: 10px 0px 0px 0px;
105
+ }
106
+
107
+ .margin_minus2 {
108
+ margin: -2px 0px -2px 0px;
109
+ }
110
+
111
+ .margin_top50 {
112
+ margin: 50px 0px 0px 0px;
113
+ }
114
+
115
+ table, tr, th, td {
116
+ border: 1px solid #aaa;
117
+ padding: 5px;
118
+ border-collapse: collapse;
119
+ border-spacing: 0px;
120
+ }
121
+
122
+ .search table, .search tr, .search td {
123
+ border: 0px solid #aaa;
124
+ padding: 0px;
125
+ }
126
+
127
+ th {
128
+ white-space: nowrap;
129
+ }
@@ -0,0 +1,3 @@
1
+ <% if user.present? %>
2
+ <%= link_to_unless( user.nickname.blank?, image_tag( user.image, size: size, class: klass ), "#{Settings[user.provider + '_page']}#{user.nickname}", target: "_blank", title: user.nickname, rel: "tooltip", "data-original-title" => user.nickname ) %>
3
+ <% end %>
@@ -0,0 +1,28 @@
1
+ <%= link_to Settings.app_name, :root %>
2
+
3
+ <% if current_user.present? %>
4
+ <%# ログイン済み %>
5
+ <%= render partial: '/layouts/user_icon', locals: { user: current_user, size: "18x18", klass: "margin_minus2" } %>
6
+ <%= link_to( "Top", root_path ) %>
7
+ <%= link_to( "Logout", logout_path ) %>
8
+ <% else %>
9
+ <%# 未ログイン %>
10
+ Login:
11
+ <%= link_to "Twitter", "/auth/twitter" %>
12
+ <%= link_to "Facebook", "/auth/facebook" %>
13
+ <%= link_to "GitHub", "/auth/gitHub" %>
14
+ <% end %>
15
+
16
+ <%# 通知/エラーメッセージ %>
17
+ <%= simple_format( flash[:notice], style: "color: green;" ) if flash[:notice].present? %>
18
+ <%= simple_format( flash[:alert], style: "color: red;" ) if flash[:alert].present? %>
19
+
20
+ <%= yield %>
21
+
22
+ <br /><br />
23
+
24
+ <center>
25
+ Developed by <a href="https://twitter.com/<%= Settings.programmer_twitter_id %>/" target="_blank">@<%= Settings.programmer_twitter_id %></a>,
26
+ Designed by <a href="https://twitter.com/<%= Settings.designer_twitter_id %>/" target="_blank">@<%= Settings.designer_twitter_id %></a>,
27
+ Licence by <a href="https://creativecommons.org/licenses/by-nc-sa/2.1/jp/" target="_blank">CC BY-NC-SA 2.1</a>
28
+ </center>
@@ -0,0 +1,2 @@
1
+
2
+ <h1>Welcome to <%= Settings.app_name %>.</h1>
@@ -0,0 +1,7 @@
1
+ module Minimum
2
+ module Omniauth
3
+ module Scaffold
4
+ VERSION = "0.0.1"
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,31 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'minimum/omniauth/scaffold/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "minimum-omniauth-scaffold"
8
+ spec.version = Minimum::Omniauth::Scaffold::VERSION
9
+ spec.authors = ["shu0115"]
10
+ spec.email = ["s.matsumoto0115@gmail.com"]
11
+ spec.description = %q{Scaffold for OmniAuth}
12
+ spec.summary = %q{Minimum OmniAuth Scaffold}
13
+ spec.homepage = "https://github.com/shu0115/minimum-omniauth-scaffold"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files`.split($/)
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_development_dependency "bundler", "~> 1.3"
22
+ spec.add_development_dependency "rake"
23
+
24
+ spec.add_dependency "rails_config"
25
+ spec.add_dependency "omniauth-twitter"
26
+ spec.add_dependency "omniauth-facebook"
27
+ spec.add_dependency "omniauth-github"
28
+ spec.add_dependency "tapp"
29
+ spec.add_dependency "awesome_print"
30
+ end
31
+
metadata ADDED
@@ -0,0 +1,183 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: minimum-omniauth-scaffold
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - shu0115
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2013-03-27 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ~>
18
+ - !ruby/object:Gem::Version
19
+ version: '1.3'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: '1.3'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rails_config
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - '>='
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: omniauth-twitter
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - '>='
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: omniauth-facebook
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - '>='
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - '>='
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: omniauth-github
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - '>='
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :runtime
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - '>='
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: tapp
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - '>='
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :runtime
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - '>='
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ - !ruby/object:Gem::Dependency
112
+ name: awesome_print
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - '>='
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :runtime
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - '>='
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
125
+ description: Scaffold for OmniAuth
126
+ email:
127
+ - s.matsumoto0115@gmail.com
128
+ executables: []
129
+ extensions: []
130
+ extra_rdoc_files: []
131
+ files:
132
+ - .gitignore
133
+ - Gemfile
134
+ - LICENSE.txt
135
+ - README.md
136
+ - Rakefile
137
+ - lib/minimum/omniauth/scaffold.rb
138
+ - lib/minimum/omniauth/scaffold/templates/README.md
139
+ - lib/minimum/omniauth/scaffold/templates/controllers/application_controller.rb
140
+ - lib/minimum/omniauth/scaffold/templates/controllers/sessions_controller.rb
141
+ - lib/minimum/omniauth/scaffold/templates/controllers/top_controller.rb
142
+ - lib/minimum/omniauth/scaffold/templates/initializers/omniauth.rb
143
+ - lib/minimum/omniauth/scaffold/templates/locales/ja.yml
144
+ - lib/minimum/omniauth/scaffold/templates/locales/translation_ja.yml
145
+ - lib/minimum/omniauth/scaffold/templates/migrate/create_users.rb
146
+ - lib/minimum/omniauth/scaffold/templates/models/user.rb
147
+ - lib/minimum/omniauth/scaffold/templates/rails_config/development.yml
148
+ - lib/minimum/omniauth/scaffold/templates/rails_config/production.yml
149
+ - lib/minimum/omniauth/scaffold/templates/rails_config/rails_config.rb
150
+ - lib/minimum/omniauth/scaffold/templates/rails_config/settings.local.yml
151
+ - lib/minimum/omniauth/scaffold/templates/rails_config/settings.yml
152
+ - lib/minimum/omniauth/scaffold/templates/rails_config/test.yml
153
+ - lib/minimum/omniauth/scaffold/templates/stylesheets/scaffolds.css.scss
154
+ - lib/minimum/omniauth/scaffold/templates/views/_user_icon.html.erb
155
+ - lib/minimum/omniauth/scaffold/templates/views/application.html.erb
156
+ - lib/minimum/omniauth/scaffold/templates/views/index.html.erb
157
+ - lib/minimum/omniauth/scaffold/version.rb
158
+ - minimum-omniauth-scaffold.gemspec
159
+ homepage: https://github.com/shu0115/minimum-omniauth-scaffold
160
+ licenses:
161
+ - MIT
162
+ metadata: {}
163
+ post_install_message:
164
+ rdoc_options: []
165
+ require_paths:
166
+ - lib
167
+ required_ruby_version: !ruby/object:Gem::Requirement
168
+ requirements:
169
+ - - '>='
170
+ - !ruby/object:Gem::Version
171
+ version: '0'
172
+ required_rubygems_version: !ruby/object:Gem::Requirement
173
+ requirements:
174
+ - - '>='
175
+ - !ruby/object:Gem::Version
176
+ version: '0'
177
+ requirements: []
178
+ rubyforge_project:
179
+ rubygems_version: 2.0.0
180
+ signing_key:
181
+ specification_version: 4
182
+ summary: Minimum OmniAuth Scaffold
183
+ test_files: []