minimum-omniauth-scaffold 0.1.10 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8e4c6257e1b1be005843a1c89e7cd072ccdacff2
4
- data.tar.gz: 8cef10adc8d4bce93c3259e76e7fa329dfa98273
3
+ metadata.gz: 95c5062c1e0686de1fd6c70f74cb5f7f64f940fe
4
+ data.tar.gz: c406d7a6cf6faf23f6365dd7cc4502f4158610d9
5
5
  SHA512:
6
- metadata.gz: 494e627c8181280efba5c85bfaea12c27fe91d7fb22cb7b2abe69c47b966964147f0107bbf5b7ae616c888efd3f4d22ce7c7cf0bc309077266ef39a6381076d5
7
- data.tar.gz: 1c6c705c9205b060ec892a80c1b1ba0b23ba3f17c5cb5c10835c2af48671e5a4ed31ef7d0da39e92e4de107369b304d4a6277796541b3c7a1ad111b6003d6725
6
+ metadata.gz: a4643d4474da688ac6fb31a83351763124e81a3fb51eb377d718a4d29c282c4280e5e16cb437dbe9ccfdbd7285b39acb8b1c9e1156198d068d3cc2cf5e464a53
7
+ data.tar.gz: 6ec0c22bb2837e778dd1ecb524b7c2007a4bb0e9f03426913241687986435c6a071b9436ee6432b90dc87332e8ecb0276d4d080ce4ae8fa3fa6fbbcf3bc864bb
data/README.md CHANGED
@@ -65,7 +65,7 @@ rails g minimum:omniauth:scaffold
65
65
  rake db:migrate
66
66
  ```
67
67
 
68
- ### キー作成
68
+ ### 開発用キー作成
69
69
 
70
70
  * Twitter
71
71
  * [Create an application | Twitter Developers](https://dev.twitter.com/apps/new)
@@ -97,6 +97,8 @@ github_secret: "Client Secret"
97
97
 
98
98
  ## Heroku環境変数設定
99
99
 
100
+ ※Production用キーを別途作成
101
+
100
102
  * Twitter
101
103
 
102
104
  ```
@@ -10,86 +10,84 @@ require 'awesome_print'
10
10
  module Minimum
11
11
  module Omniauth
12
12
  class ScaffoldGenerator < Rails::Generators::Base
13
- @@template_path = source_root File.expand_path( "../scaffold/templates", __FILE__ )
13
+ @@template_path = source_root File.expand_path("../scaffold/templates", __FILE__)
14
14
 
15
15
  def generate_scaffold
16
16
  app_name = Rails.application.class.name.split('::').first
17
17
 
18
- # ----- rails_config ----- #
19
- copy_file( "#{@@template_path}/rails_config/rails_config.rb", "config/initializers/rails_config.rb" )
20
- copy_file( "#{@@template_path}/rails_config/settings.yml", "config/settings.yml" )
21
- copy_file( "#{@@template_path}/rails_config/settings.local.yml", "config/settings.local.yml" )
22
- copy_file( "#{@@template_path}/rails_config/development.yml", "config/settings/development.yml" )
23
- copy_file( "#{@@template_path}/rails_config/production.yml", "config/settings/production.yml" )
24
- copy_file( "#{@@template_path}/rails_config/test.yml", "config/settings/test.yml" )
18
+ ## rails_config
19
+ copy_file "#{@@template_path}/rails_config/rails_config.rb", "config/initializers/rails_config.rb"
20
+ copy_file "#{@@template_path}/rails_config/settings.yml", "config/settings.yml"
21
+ copy_file "#{@@template_path}/rails_config/settings.local.yml", "config/settings.local.yml"
22
+ copy_file "#{@@template_path}/rails_config/development.yml", "config/settings/development.yml"
23
+ copy_file "#{@@template_path}/rails_config/production.yml", "config/settings/production.yml"
24
+ copy_file "#{@@template_path}/rails_config/test.yml", "config/settings/test.yml"
25
25
 
26
- # ----- omniauth ----- #
27
- copy_file( "#{@@template_path}/initializers/omniauth.rb", "config/initializers/omniauth.rb" )
26
+ ## omniauth
27
+ copy_file "#{@@template_path}/initializers/omniauth.rb", "config/initializers/omniauth.rb"
28
28
 
29
- # ----- routes.rb ----- #
29
+ ## routes.rb
30
30
  content = "\n # For OmniAuth\n"
31
31
  content += " get \"/auth/:provider/callback\" => \"sessions#callback\"\n"
32
32
  content += " get \"/auth/failure\" => \"sessions#failure\"\n"
33
33
  content += " get \"/logout\" => \"sessions#destroy\", as: :logout\n"
34
34
  content += "\n"
35
- insert_into_file( "config/routes.rb", content.force_encoding('ASCII-8BIT'), after: "Application.routes.draw do\n" )
36
- insert_into_file( "config/routes.rb", " root to: 'top#index'\n", after: "Application.routes.draw do\n" )
37
-
38
- # ----- application.rb ----- #
39
- content = " config.time_zone = 'Tokyo'\n"
40
- # content += " config.active_record.default_timezone = :local\n"
41
- insert_into_file( "config/application.rb", content.force_encoding('ASCII-8BIT'), after: "# config.time_zone = 'Central Time (US & Canada)'\n" )
42
- insert_into_file( "config/application.rb", " config.i18n.default_locale = :ja\nI18n.enforce_available_locales = true\n", after: "# config.i18n.default_locale = :de\n" )
43
- # content = " # For Heroku\n"
44
- # content += " config.assets.initialize_on_precompile = false\n"
45
- content = " # For Tapp\n"
46
- content += " Tapp.config.default_printer = :awesome_print\n"
47
- content += "\n"
48
- insert_into_file( "config/application.rb", content.force_encoding('ASCII-8BIT'), after: "class Application < Rails::Application\n" )
49
-
50
- # ----- production.rb ----- #
51
- insert_into_file( "config/environments/production.rb", " config.force_ssl = true\n", after: "# config.force_ssl = true\n" ) # 強制SSL設定
52
-
53
- # ----- development.rb ----- #
54
- # content = "\n # For LogRotate\n"
55
- # content += " config.logger = Logger.new( 'log/development.log', 3, 10*1024*1024 ) # 10MB * 3\n"
56
- # insert_into_file( "config/environments/development.rb", content.force_encoding('ASCII-8BIT'), after: "config.assets.debug = true\n" )
57
- gsub_file "config/environments/development.rb", /(config.assets.debug = true)+/, "# config.assets.debug = true" # コメントアウト追加
58
- insert_into_file( "config/environments/development.rb", " config.assets.debug = false\n", after: "config.assets.debug = true\n" ) # false設定追加
59
-
60
- # ----- ja.yml ----- #
61
- copy_file( "#{@@template_path}/locales/ja.yml", "config/locales/ja.yml" )
62
- copy_file( "#{@@template_path}/locales/translation_ja.yml", "config/locales/translation_ja.yml" )
63
-
64
- # ----- migration ----- #
65
- copy_file( "#{@@template_path}/migrate/create_users.rb", "db/migrate/20000101000000_create_users.rb" )
66
- copy_file( "#{@@template_path}/migrate/create_authentications.rb", "db/migrate/20000102000000_create_authentications.rb" )
67
-
68
- # ----- models ----- #
69
- copy_file( "#{@@template_path}/models/user.rb", "app/models/user.rb" )
70
- copy_file( "#{@@template_path}/models/authentication.rb", "app/models/authentication.rb" )
71
-
72
- # ----- controllers ----- #
73
- content = File.read( "#{@@template_path}/controllers/application_controller.rb", encoding: Encoding::UTF_8 )
74
- insert_into_file( "app/controllers/application_controller.rb", content.force_encoding('ASCII-8BIT'), after: "protect_from_forgery with: :exception\n" )
75
- copy_file( "#{@@template_path}/controllers/sessions_controller.rb", "app/controllers/sessions_controller.rb" )
76
- copy_file( "#{@@template_path}/controllers/top_controller.rb", "app/controllers/top_controller.rb" )
77
-
78
- # ----- views ----- #
79
- content = File.read( "#{@@template_path}/views/application.html.erb", encoding: Encoding::UTF_8 )
80
- gsub_file "app/views/layouts/application.html.erb", /(<%= yield %>)+/, content.force_encoding('ASCII-8BIT')
81
- gsub_file "app/views/layouts/application.html.erb", Regexp.new("<title>#{app_name}</title>"), "<title><%= Settings.app_name %></title>"
82
- copy_file( "#{@@template_path}/views/_user_icon.html.erb", "app/views/layouts/_user_icon.html.erb" )
83
- copy_file( "#{@@template_path}/views/index.html.erb", "app/views/top/index.html.erb" )
84
-
85
- # ----- assets ----- #
86
- copy_file( "#{@@template_path}/stylesheets/scaffolds.css.scss", "app/assets/stylesheets/scaffolds.css.scss" )
87
-
88
- # ----- README ----- #
89
- remove_file( 'README.rdoc' )
90
- copy_file( "#{@@template_path}/README.md", "README.md" )
91
-
92
- # ----- .gitignore ----- #
35
+ insert_into_file "config/routes.rb", content.force_encoding('ASCII-8BIT'), after: "Rails.application.routes.draw do\n"
36
+ insert_into_file "config/routes.rb", " root to: 'top#index'\n", after: "Rails.application.routes.draw do\n"
37
+
38
+ # ## application.rb
39
+ # content = " config.time_zone = 'Tokyo'\n"
40
+ # insert_into_file( "config/application.rb", content.force_encoding('ASCII-8BIT'), after: "# config.time_zone = 'Central Time (US & Canada)'\n" )
41
+ # insert_into_file( "config/application.rb", " config.i18n.default_locale = :ja\nI18n.enforce_available_locales = true\n", after: "# config.i18n.default_locale = :de\n" )
42
+ # content = " # For Tapp\n"
43
+ # content += " Tapp.config.default_printer = :awesome_print\n"
44
+ # content += "\n"
45
+ # insert_into_file( "config/application.rb", content.force_encoding('ASCII-8BIT'), after: "class Application < Rails::Application\n" )
46
+
47
+ # ## production.rb
48
+ # insert_into_file( "config/environments/production.rb", " config.force_ssl = true\n", after: "# config.force_ssl = true\n" ) # 強制SSL設定
49
+
50
+ # ## development.rb
51
+ # gsub_file "config/environments/development.rb", /(config.assets.debug = true)+/, "# config.assets.debug = true" # コメントアウト追加
52
+ # insert_into_file( "config/environments/development.rb", " config.assets.debug = false\n", after: "config.assets.debug = true\n" ) # false設定追加
53
+
54
+ ## ja.yml
55
+ copy_file "#{@@template_path}/locales/ja.yml", "config/locales/ja.yml"
56
+ copy_file "#{@@template_path}/locales/translation_ja.yml", "config/locales/translation_ja.yml"
57
+
58
+ ## migration
59
+ copy_file "#{@@template_path}/migrate/create_users.rb", "db/migrate/20000101000000_create_users.rb"
60
+ copy_file "#{@@template_path}/migrate/create_authentications.rb", "db/migrate/20000102000000_create_authentications.rb"
61
+
62
+ ## models
63
+ copy_file "#{@@template_path}/models/user.rb", "app/models/user.rb"
64
+ copy_file "#{@@template_path}/models/authentication.rb", "app/models/authentication.rb"
65
+
66
+ ## controllers
67
+ content = File.read("#{@@template_path}/controllers/application_controller.rb", encoding: Encoding::UTF_8)
68
+ insert_into_file "app/controllers/application_controller.rb", content.force_encoding('ASCII-8BIT'), after: "protect_from_forgery with: :exception\n"
69
+ copy_file "#{@@template_path}/controllers/sessions_controller.rb", "app/controllers/sessions_controller.rb"
70
+ copy_file "#{@@template_path}/controllers/top_controller.rb", "app/controllers/top_controller.rb"
71
+
72
+ ## views
73
+ # content = File.read( "#{@@template_path}/views/application.html.erb", encoding: Encoding::UTF_8 )
74
+ # gsub_file "app/views/layouts/application.html.erb", /(<%= yield %>)+/, content.force_encoding('ASCII-8BIT')
75
+ # gsub_file "app/views/layouts/application.html.erb", Regexp.new("<title>#{app_name}</title>"), "<title><%= Settings.app_name %></title>"
76
+
77
+ # copy_file 'app/views/layouts/application.html.erb', 'app/views/layouts/_____application.html.erb'
78
+ remove_file 'app/views/layouts/application.html.erb'
79
+ copy_file "#{@@template_path}/views/application.html.haml", 'app/views/layouts/application.html.haml'
80
+ copy_file "#{@@template_path}/views/_user_icon.html.haml", "app/views/layouts/_user_icon.html.haml"
81
+ copy_file "#{@@template_path}/views/index.html.haml", "app/views/top/index.html.haml"
82
+
83
+ ## assets
84
+ copy_file "#{@@template_path}/stylesheets/scaffolds.css.scss", "app/assets/stylesheets/scaffolds.css.scss"
85
+
86
+ ## README
87
+ remove_file 'README.rdoc'
88
+ copy_file "#{@@template_path}/README.md", "README.md"
89
+
90
+ ## .gitignore
93
91
  content = "\n# Add\n"
94
92
  content += ".DS_Store\n"
95
93
  content += "vendor/bundle\n"
@@ -98,7 +96,7 @@ module Minimum
98
96
  content += "config/settings.local.yml\n"
99
97
  content += "config/settings/*.local.yml\n"
100
98
  content += "config/environments/*.local.yml\n"
101
- append_file( ".gitignore", content.force_encoding('ASCII-8BIT') )
99
+ append_file ".gitignore", content.force_encoding('ASCII-8BIT')
102
100
  end
103
101
  end
104
102
  end
@@ -1,5 +1,5 @@
1
- before_filter :authenticate # ログイン認証
2
- before_filter :reset_session_expires # セッション有効期限延長
1
+ before_action :authenticate # ログイン認証
2
+ before_action :reset_session_expires # セッション有効期限延長
3
3
 
4
4
  private
5
5
 
@@ -1,5 +1,5 @@
1
1
  class SessionsController < ApplicationController
2
- skip_before_filter :authenticate
2
+ skip_before_action :authenticate
3
3
 
4
4
  # ログイン
5
5
  def callback
@@ -8,7 +8,7 @@ class SessionsController < ApplicationController
8
8
  authentication.auth_update(auth)
9
9
 
10
10
  # ユーザ取得or作成
11
- user = User.find_by(id: authentication.user_id) || User.create_with_auth(authentication)
11
+ user = User.find_by(id: authentication.user_id) || User.create_with_auth(authentication, request)
12
12
 
13
13
  session[:user_id] = user.id
14
14
  flash[:notice] = "ログインしました。"
@@ -1,5 +1,5 @@
1
1
  class TopController < ApplicationController
2
- skip_before_filter :authenticate
2
+ skip_before_action :authenticate
3
3
 
4
4
  # トップ
5
5
  def index
@@ -7,6 +7,7 @@ class CreateUsers < ActiveRecord::Migration
7
7
  t.boolean :admin_flag, default: false
8
8
  t.string :last_login_provider
9
9
  t.timestamp :last_login_at
10
+ t.text :user_agent
10
11
 
11
12
  t.timestamps
12
13
  end
@@ -4,7 +4,7 @@ class User < ActiveRecord::Base
4
4
  private
5
5
 
6
6
  # ユーザ作成
7
- def self.create_with_auth(authentication)
7
+ def self.create_with_auth(authentication, request)
8
8
  # ユーザ作成
9
9
  user = User.new
10
10
  user.name = (authentication.nickname.presence || authentication.name)
@@ -12,6 +12,7 @@ class User < ActiveRecord::Base
12
12
  user.email = authentication.email if authentication.email.present?
13
13
  user.last_login_provider = authentication.provider if authentication.provider.present?
14
14
  user.last_login_at = Time.now
15
+ user.user_agent = request.env['HTTP_USER_AGENT'] rescue 'error'
15
16
 
16
17
  # データ保存
17
18
  user.save!
@@ -0,0 +1,2 @@
1
+ - if user.present?
2
+ = link_to_unless(user.name.blank?, image_tag(user.image, size: size, class: klass), "#{Settings[user.last_login_provider + '_page']}#{user.name}", target: "_blank", title: user.name, rel: "tooltip", "data-original-title" => user.name)
@@ -0,0 +1,40 @@
1
+ !!!
2
+ %html
3
+ %head
4
+ %title= Settings.app_name
5
+ = stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track' => true
6
+ = javascript_include_tag 'application', 'data-turbolinks-track' => true
7
+ = csrf_meta_tags
8
+ %body{ 'data-no-turbolink' => true }
9
+ = link_to Settings.app_name, :root
10
+
11
+ - if signed_in?
12
+ = render partial: '/layouts/user_icon', locals: { user: current_user, size: "18x18", klass: "margin_minus2" }
13
+ = link_to "Top", root_path
14
+ = link_to "Logout", logout_path
15
+ - else
16
+ Login:
17
+ = link_to 'Twitter', '/auth/twitter'
18
+ = link_to 'Facebook', '/auth/facebook'
19
+ = link_to 'GitHub', '/auth/github'
20
+
21
+ = simple_format(flash[:notice], style: "color: green;") if flash[:notice].present?
22
+ = simple_format(flash[:alert], style: "color: red;") if flash[:alert].present?
23
+
24
+ = yield
25
+
26
+ %br/
27
+ %br/
28
+
29
+ %center
30
+ Developed by
31
+ = succeed "," do
32
+ %a{ href: "https://twitter.com/#{Settings.programmer_twitter_id}/", target: '_blank' }
33
+ = "@#{Settings.programmer_twitter_id}"
34
+ Designed by
35
+ = succeed "," do
36
+ %a{ href: "https://twitter.com/#{Settings.designer_twitter_id}/", target: '_blank' }
37
+ = "@#{Settings.designer_twitter_id}"
38
+ Licence by
39
+ %a{ href: 'https://creativecommons.org/licenses/by-nc-sa/2.1/jp/', target: '_blank' }
40
+ CC BY-NC-SA 2.1
@@ -0,0 +1 @@
1
+ %h1= "Welcome to #{Settings.app_name}"
@@ -1,7 +1,7 @@
1
1
  module Minimum
2
2
  module Omniauth
3
3
  module Scaffold
4
- VERSION = '0.1.10'
4
+ VERSION = '0.2.0'
5
5
  end
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: minimum-omniauth-scaffold
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.10
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - shu0115
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-03-20 00:00:00.000000000 Z
11
+ date: 2014-12-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -154,8 +154,11 @@ files:
154
154
  - lib/minimum/omniauth/scaffold/templates/rails_config/test.yml
155
155
  - lib/minimum/omniauth/scaffold/templates/stylesheets/scaffolds.css.scss
156
156
  - lib/minimum/omniauth/scaffold/templates/views/_user_icon.html.erb
157
+ - lib/minimum/omniauth/scaffold/templates/views/_user_icon.html.haml
157
158
  - lib/minimum/omniauth/scaffold/templates/views/application.html.erb
159
+ - lib/minimum/omniauth/scaffold/templates/views/application.html.haml
158
160
  - lib/minimum/omniauth/scaffold/templates/views/index.html.erb
161
+ - lib/minimum/omniauth/scaffold/templates/views/index.html.haml
159
162
  - lib/minimum/omniauth/scaffold/version.rb
160
163
  - minimum-omniauth-scaffold.gemspec
161
164
  homepage: https://github.com/shu0115/minimum-omniauth-scaffold