omniauth-scaffold 0.1.14 → 0.1.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.md +13 -3
- data/lib/omniauth-scaffold.rb +2 -0
- data/lib/omniauth-scaffold/templates/application.html.erb +36 -26
- data/lib/omniauth-scaffold/templates/application_controller.rb +4 -1
- data/lib/omniauth-scaffold/templates/ja.yml +7 -6
- data/lib/omniauth-scaffold/templates/omniauth.rb +5 -8
- data/lib/omniauth-scaffold/templates/rails_config/settings.local.yml +8 -0
- data/lib/omniauth-scaffold/templates/rails_config/settings.yml +7 -0
- data/lib/omniauth-scaffold/templates/sessions_controller.rb +7 -0
- data/lib/omniauth-scaffold/templates/z_style.css.scss +26 -0
- data/lib/omniauth-scaffold/version.rb +1 -1
- metadata +3 -2
data/README.md
CHANGED
@@ -15,8 +15,8 @@ vi Gemfile
|
|
15
15
|
gem 'rails_config'
|
16
16
|
gem 'omniauth-scaffold', :group => :development
|
17
17
|
gem 'omniauth-twitter'
|
18
|
-
|
19
|
-
|
18
|
+
gem 'omniauth-facebook'
|
19
|
+
gem 'omniauth-github'
|
20
20
|
```
|
21
21
|
|
22
22
|
And then execute:
|
@@ -31,6 +31,8 @@ Or install it yourself as:
|
|
31
31
|
gem install rails_config
|
32
32
|
gem install omniauth-scaffold
|
33
33
|
gem install omniauth-twitter
|
34
|
+
gem install omniauth-facebook
|
35
|
+
gem install omniauth-github
|
34
36
|
```
|
35
37
|
|
36
38
|
## Usage
|
@@ -83,8 +85,8 @@ app_name: "YOUR_APP_NAME"
|
|
83
85
|
### Keys
|
84
86
|
|
85
87
|
<a href="https://dev.twitter.com/apps" target="_blank">Twitter</a><br />
|
86
|
-
<a href="https://github.com/settings/applications" target="_blank">GitHub</a><br />
|
87
88
|
<a href="https://developers.facebook.com/apps" target="_blank">Facebook</a><br />
|
89
|
+
<a href="https://github.com/settings/applications" target="_blank">GitHub</a><br />
|
88
90
|
|
89
91
|
### Development Setting
|
90
92
|
|
@@ -94,6 +96,14 @@ Edit: config/settings.local.yml
|
|
94
96
|
# Twitter OAuth Local Setting
|
95
97
|
twitter_key: "TWITTER_KEY"
|
96
98
|
twitter_secret: "TWITTER_SECRET"
|
99
|
+
|
100
|
+
# Facebook OAuth Setting
|
101
|
+
facebook_app_id: "FACEBOOK_APP_ID"
|
102
|
+
facebook_app_secret: "FACEBOOK_APP_SECRET"
|
103
|
+
|
104
|
+
# GitHub OAuth Setting
|
105
|
+
github_client_id: "GITHUB_CLIENT_ID"
|
106
|
+
github_secret: "GITHUB_SECRET"
|
97
107
|
```
|
98
108
|
|
99
109
|
### Production Setting For Heroku
|
data/lib/omniauth-scaffold.rb
CHANGED
@@ -74,6 +74,7 @@ module Omniauth
|
|
74
74
|
# ----- assets ----- #
|
75
75
|
copy_file( "templates/base.css.scss", "app/assets/stylesheets/base.css.scss" )
|
76
76
|
copy_file( "templates/scaffolds.css.scss", "app/assets/stylesheets/scaffolds.css.scss" )
|
77
|
+
copy_file( "templates/z_style.css.scss", "app/assets/stylesheets/z_style.css.scss" )
|
77
78
|
|
78
79
|
# ----- public ----- #
|
79
80
|
remove_file( 'public/index.html' )
|
@@ -86,6 +87,7 @@ module Omniauth
|
|
86
87
|
content = "\n# Add\n"
|
87
88
|
content += ".DS_Store\n"
|
88
89
|
content += "vendor/bundle\n"
|
90
|
+
content += "/log/*.log.*\n"
|
89
91
|
content += "\n# rails_config\n"
|
90
92
|
content += "config/settings.local.yml\n"
|
91
93
|
content += "config/settings/*.local.yml\n"
|
@@ -1,26 +1,36 @@
|
|
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
|
-
<br />
|
1
|
+
<%# グローバルメニュー %>
|
2
|
+
<ul class="nav nav-tabs navbar-fixed-top backcolor_white padding_top10">
|
3
|
+
<li class="navbar offset2 <%= params[:controller] == 'top' ? 'active' : '' %>"><%= link_to Settings.app_name, :root, class: "brand" %></li>
|
4
|
+
<% unless session[:user_id].blank? %>
|
5
|
+
<%# ログイン済み %>
|
6
|
+
<li><%= link_to_unless( current_user.screen_name.blank?, image_tag( current_user.image, size: "18x18", class: "margin_minus2" ), "#{Settings.provider_page}#{current_user.screen_name}", target: "_blank" ) %></li>
|
7
|
+
<li class="<%= params[:controller] == 'controllers' ? 'active' : '' %>"><%= link_to( "controllers", { controller: "controllers" } ) %></li>
|
8
|
+
<li><%= link_to( "Logout", logout_path ) %></li>
|
9
|
+
<% else %>
|
10
|
+
<%# 未ログイン %>
|
11
|
+
<li><%= link_to "Login", "/auth/#{Settings.provider}" %></li>
|
12
|
+
<% end %>
|
13
|
+
</ul>
|
14
|
+
|
15
|
+
<div class="container">
|
16
|
+
|
17
|
+
<div class="margin_top50"><div>
|
18
|
+
|
19
|
+
<%# 通知/エラーメッセージ %>
|
20
|
+
<%= simple_format( flash[:notice], style: "color: green;" ) unless flash[:notice].blank? %>
|
21
|
+
<%= simple_format( flash[:alert], style: "color: red;" ) unless flash[:alert].blank? %>
|
22
|
+
|
23
|
+
<%= yield %>
|
24
|
+
|
25
|
+
<br />
|
26
|
+
<br />
|
27
|
+
|
28
|
+
<center>
|
29
|
+
Developed by <a href="https://twitter.com/#!/<%= Settings.programmer_twitter_id %>/" target="_blank">@<%= Settings.programmer_twitter_id %></a>,
|
30
|
+
Designed by <a href="https://twitter.com/#!/<%= Settings.designer_twitter_id %>/" target="_blank">@<%= Settings.designer_twitter_id %></a>,
|
31
|
+
Licence by <a href="https://creativecommons.org/licenses/by-nc-sa/2.1/jp/" target="_blank">CC BY-NC-SA 2.1</a>
|
32
|
+
</center>
|
33
|
+
|
34
|
+
<br />
|
35
|
+
|
36
|
+
</div>
|
@@ -6,7 +6,7 @@ class ApplicationController < ActionController::Base
|
|
6
6
|
# httpsリダイレクト
|
7
7
|
before_filter :ssl_redirect if Rails.env.production?
|
8
8
|
|
9
|
-
#
|
9
|
+
# ログイン認証
|
10
10
|
before_filter :authorize
|
11
11
|
|
12
12
|
# セッション有効期限延長
|
@@ -35,6 +35,9 @@ class ApplicationController < ActionController::Base
|
|
35
35
|
if params[:controller] != "sessions" and params[:controller] != "top"
|
36
36
|
# 未ログインであればルートヘリダイレクト
|
37
37
|
if session[:user_id].blank?
|
38
|
+
# リクエストURL保管
|
39
|
+
session[:request_url] = request.url
|
40
|
+
|
38
41
|
redirect_to :root and return
|
39
42
|
end
|
40
43
|
end
|
@@ -2,13 +2,14 @@
|
|
2
2
|
ja:
|
3
3
|
# Add
|
4
4
|
menu:
|
5
|
-
|
6
|
-
|
5
|
+
new: "New"
|
6
|
+
show: "Show"
|
7
|
+
edit: "Edit"
|
7
8
|
destroy: "Delete"
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
top: "Top"
|
10
|
+
list: "List"
|
11
|
+
create: "Create"
|
12
|
+
update: "Update"
|
12
13
|
|
13
14
|
date:
|
14
15
|
abbr_day_names:
|
@@ -1,10 +1,7 @@
|
|
1
1
|
Rails.application.config.middleware.use OmniAuth::Builder do
|
2
|
-
# ---
|
3
|
-
provider :
|
4
|
-
|
5
|
-
|
6
|
-
|
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
|
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
|
10
7
|
end
|
@@ -1,3 +1,11 @@
|
|
1
1
|
# Twitter OAuth Local Setting
|
2
2
|
twitter_key: "TWITTER_KEY"
|
3
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"
|
@@ -1,5 +1,12 @@
|
|
1
1
|
# OmniAuth Provider
|
2
2
|
provider: "twitter"
|
3
|
+
#provider: "facebook"
|
4
|
+
#provider: "github"
|
5
|
+
|
6
|
+
# Provider Page
|
7
|
+
provider_page: "https://twitter.com/"
|
8
|
+
#provider_page: "https://www.facebook.com/"
|
9
|
+
#provider_page: "https://github.com/"
|
3
10
|
|
4
11
|
# アプリケーション名
|
5
12
|
app_name: "YOUR_APP_NAME"
|
@@ -9,6 +9,13 @@ class SessionsController < ApplicationController
|
|
9
9
|
user = User.where( provider: auth["provider"], uid: auth["uid"] ).first || User.create_with_omniauth( auth )
|
10
10
|
session[:user_id] = user.id
|
11
11
|
|
12
|
+
# 保管URLへリダイレクト
|
13
|
+
unless session[:request_url].blank?
|
14
|
+
redirect_to session[:request_url]
|
15
|
+
session[:request_url] = nil
|
16
|
+
return
|
17
|
+
end
|
18
|
+
|
12
19
|
redirect_to :root, notice: "ログインしました。"
|
13
20
|
end
|
14
21
|
|
@@ -0,0 +1,26 @@
|
|
1
|
+
.navbar .brand {
|
2
|
+
display: block;
|
3
|
+
float: left;
|
4
|
+
padding: 8px 20px 6px 20px;
|
5
|
+
margin-left: -20px;
|
6
|
+
font-size: 20px;
|
7
|
+
font-weight: 200;
|
8
|
+
line-height: 1;
|
9
|
+
color: #999;
|
10
|
+
}
|
11
|
+
|
12
|
+
.backcolor_white {
|
13
|
+
background-color: #fff;
|
14
|
+
}
|
15
|
+
|
16
|
+
.padding_top10 {
|
17
|
+
padding: 10px 0px 0px 0px;
|
18
|
+
}
|
19
|
+
|
20
|
+
.margin_minus2 {
|
21
|
+
margin: -2px 0px -2px 0px;
|
22
|
+
}
|
23
|
+
|
24
|
+
.margin_top50 {
|
25
|
+
margin: 50px 0px 0px 0px;
|
26
|
+
}
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: omniauth-scaffold
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.15
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-07-
|
12
|
+
date: 2012-07-27 00:00:00.000000000 Z
|
13
13
|
dependencies: []
|
14
14
|
description: Scaffold for OmniAuth.
|
15
15
|
email:
|
@@ -42,6 +42,7 @@ files:
|
|
42
42
|
- lib/omniauth-scaffold/templates/sessions_controller.rb
|
43
43
|
- lib/omniauth-scaffold/templates/top_controller.rb
|
44
44
|
- lib/omniauth-scaffold/templates/user.rb
|
45
|
+
- lib/omniauth-scaffold/templates/z_style.css.scss
|
45
46
|
- lib/omniauth-scaffold/version.rb
|
46
47
|
- omniauth-scaffold.gemspec
|
47
48
|
homepage: https://github.com/shu0115/omniauth-scaffold
|