wired 0.1.2 → 0.2.0
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.
- checksums.yaml +6 -6
- data/lib/wired/builders/app_builder.rb +32 -2
- data/lib/wired/builders/facebook_builder.rb +37 -14
- data/lib/wired/generators/app_generator.rb +22 -3
- data/lib/wired/generators/facebook_generator.rb +6 -0
- data/lib/wired/version.rb +1 -1
- data/templates/Gemfile_clean +16 -2
- data/templates/README.md.erb +1 -1
- data/templates/_analytics.html.erb +13 -0
- data/templates/_flashes.html.erb +1 -1
- data/templates/database.rake +24 -0
- data/templates/facebook/env +2 -1
- data/templates/facebook/facebook.js.coffee +34 -17
- data/templates/facebook/facebook_controller.rb +21 -0
- data/templates/facebook/users_controller.rb +2 -4
- data/templates/layout.html.erb.erb +15 -0
- data/templates/spec/rspec +1 -0
- data/templates/spec/simplecov +10 -0
- data/templates/spec/spec_helper.rb +18 -0
- data/templates/spec/travis.yml +19 -0
- data/templates/wired_gitignore +2 -1
- metadata +14 -8
- data/templates/facebook/tab_controller.rb +0 -48
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
5
|
-
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
2
|
+
!binary "U0hBMQ==":
|
3
|
+
metadata.gz: 03d889e4572b34da064a5cee14db568b83772ae3
|
4
|
+
data.tar.gz: 7eb03fa3dad7a831f32f0a38629717bf98ba2155
|
5
|
+
!binary "U0hBNTEy":
|
6
|
+
metadata.gz: 48e8e754cbc8d9e196ad633fbd6ca70f0242afd06b2bdf2af01c15439e2669343d6de5a9258462682aaa91b07d576999f3ffaf2752cbcf7a65532bb2e45f49f8
|
7
|
+
data.tar.gz: 29d62ce0b4e61535b6ddfc93fb8c018c68b7b02f219f112d74a86c44ffba6dd9d36b3061cc16a932ab5c2f92490f2f9a16e073cc745c4c1851617edd95a573f9
|
@@ -40,6 +40,10 @@ module Wired
|
|
40
40
|
bundle_command 'exec rake db:create'
|
41
41
|
end
|
42
42
|
|
43
|
+
def add_postgres_drop_override
|
44
|
+
copy_file 'database.rake', 'lib/tasks/database.rake'
|
45
|
+
end
|
46
|
+
|
43
47
|
def create_partials_directory
|
44
48
|
empty_directory 'app/views/application'
|
45
49
|
end
|
@@ -49,6 +53,11 @@ module Wired
|
|
49
53
|
'app/views/application/_flashes.html.erb'
|
50
54
|
end
|
51
55
|
|
56
|
+
def create_shared_analytics
|
57
|
+
copy_file '_analytics.html.erb',
|
58
|
+
'app/views/application/_analytics.html.erb'
|
59
|
+
end
|
60
|
+
|
52
61
|
def create_application_layout
|
53
62
|
template 'layout.html.erb.erb',
|
54
63
|
'app/views/layouts/application.html.erb',
|
@@ -63,14 +72,28 @@ module Wired
|
|
63
72
|
inject_into_class 'config/application.rb', 'Application', config
|
64
73
|
end
|
65
74
|
|
66
|
-
def
|
75
|
+
def set_asset_host
|
67
76
|
config = <<-RUBY
|
68
77
|
config.action_controller.asset_host = ENV["ASSET_HOST"]
|
69
78
|
RUBY
|
70
|
-
inject_into_class 'config/application.rb', 'Application', config
|
71
79
|
inject_into_file 'config/environments/production.rb', config, :after => "config.action_controller.asset_host = \"http://assets.example.com\"\n"
|
72
80
|
end
|
73
81
|
|
82
|
+
def set_action_mailer_config
|
83
|
+
config = <<-RUBY
|
84
|
+
config.action_mailer.delivery_method = :letter_opener
|
85
|
+
config.action_mailer.default_url_options = { host: '#{app_powder_name}.dev' }
|
86
|
+
config.action_mailer.asset_host = 'http://#{app_powder_name}.dev'
|
87
|
+
RUBY
|
88
|
+
inject_into_file 'config/environments/development.rb', config, before: "end\n"
|
89
|
+
|
90
|
+
config = <<-RUBY
|
91
|
+
config.action_mailer.default_url_options = { host: ENV["MAILER_HOST"] }
|
92
|
+
config.action_mailer.asset_host = ENV["ASSET_HOST"]
|
93
|
+
RUBY
|
94
|
+
inject_into_file 'config/environments/production.rb', config, before: "end\n"
|
95
|
+
end
|
96
|
+
|
74
97
|
def customize_error_pages
|
75
98
|
meta_tags =<<-EOS
|
76
99
|
<meta charset='utf-8' />
|
@@ -110,6 +133,13 @@ module Wired
|
|
110
133
|
end
|
111
134
|
end
|
112
135
|
|
136
|
+
def test_configuration_files
|
137
|
+
copy_file 'spec/spec_helper.rb', 'spec/spec_helper.rb'
|
138
|
+
copy_file 'spec/simplecov', '.simplecov'
|
139
|
+
copy_file 'spec/travis.yml', 'travis.yml'
|
140
|
+
copy_file 'spec/rspec', '.rspec'
|
141
|
+
end
|
142
|
+
|
113
143
|
def setup_git
|
114
144
|
run 'git init'
|
115
145
|
run "git add ."
|
@@ -17,16 +17,17 @@ module Wired
|
|
17
17
|
|
18
18
|
def add_routes
|
19
19
|
facebook_routes =<<-ROUTES
|
20
|
-
root :to => 'tab
|
21
|
-
post '/' => 'tab
|
20
|
+
root :to => 'facebook#tab'
|
21
|
+
post '/' => 'facebook#tab'
|
22
22
|
|
23
23
|
get 'cookie' => 'sessions#cookie', as: 'cookie'
|
24
|
+
post 'user' => 'users#create', as: 'user'
|
24
25
|
ROUTES
|
25
26
|
inject_into_file "config/routes.rb", facebook_routes, :before => "end"
|
26
27
|
end
|
27
28
|
|
28
29
|
def add_controllers
|
29
|
-
copy_file 'facebook/
|
30
|
+
copy_file 'facebook/facebook_controller.rb', 'app/controllers/facebook_controller.rb'
|
30
31
|
end
|
31
32
|
|
32
33
|
def add_stylesheets
|
@@ -40,26 +41,28 @@ module Wired
|
|
40
41
|
end
|
41
42
|
|
42
43
|
def create_views
|
43
|
-
empty_directory 'app/views/
|
44
|
+
empty_directory 'app/views/facebook'
|
44
45
|
home_page =<<-HOME
|
45
|
-
Home pagina, show fangate: <%= @show_fangate
|
46
|
+
Home pagina, show fangate: <%= @show_fangate %>, <a href="javascript: " data-fb-login rel="no-follow">Login</a>
|
46
47
|
HOME
|
47
|
-
File.open("app/views/tab
|
48
|
+
File.open("app/views/facebook/tab.html.erb", 'w') { |file| file.write(home_page) }
|
48
49
|
end
|
49
50
|
|
50
51
|
def add_cookie_fix
|
51
52
|
copy_file 'facebook/sessions_controller.rb', 'app/controllers/sessions_controller.rb'
|
52
53
|
copy_file 'facebook/cookie.html.erb', 'app/views/sessions/cookie.html.erb'
|
53
54
|
facebook_cookie_fix =<<-COOKIE_FIX
|
54
|
-
|
55
|
+
include Mobylette::RespondToMobileRequests
|
56
|
+
|
57
|
+
before_action :allow_iframe_requests
|
55
58
|
helper_method :current_user
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
59
|
+
before_action :cookie_fix
|
60
|
+
before_action :add_global_javascript_variables
|
61
|
+
before_action :set_origin
|
62
|
+
before_action :set_p3p
|
60
63
|
|
61
|
-
|
62
|
-
|
64
|
+
mobylette_config do |config|
|
65
|
+
config[:skip_user_agents] = [:ipad]
|
63
66
|
end
|
64
67
|
|
65
68
|
private
|
@@ -72,7 +75,7 @@ Home pagina, show fangate: <%= @show_fangate %>
|
|
72
75
|
end
|
73
76
|
|
74
77
|
def current_user
|
75
|
-
@current_user ||= User.
|
78
|
+
@current_user ||= User.find_by fbid: session[:fbid]
|
76
79
|
end
|
77
80
|
|
78
81
|
def cookie_fix
|
@@ -87,6 +90,11 @@ Home pagina, show fangate: <%= @show_fangate %>
|
|
87
90
|
Gon.global.facebook = { 'app_id' => ENV["FB_APP_ID"] }
|
88
91
|
Gon.global.current_user = current_user.fbid if current_user.present?
|
89
92
|
end
|
93
|
+
|
94
|
+
def iframe_redirect_to(path)
|
95
|
+
render layout: false, inline: "<html><head>\\n<script type=\\"text/javascript\\">\\nwindow.top.location.href = '\#{path}';\\n</script>\\n<noscript>\\n<meta http-equiv=\\"refresh\\" content=\\"0;url=\#{path}\\" />\\n<meta http-equiv=\\"window-target\\" content=\\"_top\\" />\\n</noscript>\\n</head></html>\\n"
|
96
|
+
end
|
97
|
+
|
90
98
|
COOKIE_FIX
|
91
99
|
inject_into_file "app/controllers/application_controller.rb", facebook_cookie_fix, :before => "end"
|
92
100
|
copy_file 'facebook/cookie_fix.js.coffee', 'app/assets/javascripts/cookie_fix.js.coffee'
|
@@ -117,6 +125,7 @@ Home pagina, show fangate: <%= @show_fangate %>
|
|
117
125
|
|
118
126
|
def run_migrations
|
119
127
|
bundle_command 'exec rake db:migrate'
|
128
|
+
bundle_command 'exec rake db:test:prepare'
|
120
129
|
end
|
121
130
|
|
122
131
|
def powder_setup
|
@@ -127,5 +136,19 @@ Home pagina, show fangate: <%= @show_fangate %>
|
|
127
136
|
def create_initializers
|
128
137
|
#do nothing
|
129
138
|
end
|
139
|
+
|
140
|
+
def add_gems
|
141
|
+
gems =<<-GEMS
|
142
|
+
gem 'facebook-signed-request'
|
143
|
+
GEMS
|
144
|
+
inject_into_file "Gemfile", gems, :before => "group :development, :test do"
|
145
|
+
|
146
|
+
config = <<-RUBY
|
147
|
+
Facebook::SignedRequest.secret = ENV['FB_APP_SECRET']
|
148
|
+
RUBY
|
149
|
+
inject_into_class 'config/application.rb', 'Application', config
|
150
|
+
|
151
|
+
|
152
|
+
end
|
130
153
|
end
|
131
154
|
end
|
@@ -17,20 +17,28 @@ module Wired
|
|
17
17
|
def app_name_clean
|
18
18
|
clean = app_name.parameterize
|
19
19
|
clean = clean.gsub '_', '-'
|
20
|
-
clean = "
|
20
|
+
clean = "wl-#{clean}" if clean.length < 3
|
21
21
|
clean = clean[0..19] if clean.length > 20
|
22
22
|
clean
|
23
23
|
end
|
24
24
|
|
25
|
+
def app_powder_name
|
26
|
+
clean = app_name.parameterize
|
27
|
+
clean = clean.gsub '_', '-'
|
28
|
+
clean
|
29
|
+
end
|
30
|
+
|
25
31
|
def wired_customization
|
26
32
|
invoke :remove_files_we_dont_need
|
27
33
|
invoke :customize_gemfile
|
28
34
|
invoke :create_wired_views
|
35
|
+
invoke :setup_test
|
29
36
|
invoke :setup_database
|
30
37
|
invoke :configure_app
|
31
38
|
invoke :customize_error_pages
|
32
39
|
invoke :remove_routes_comment_lines
|
33
40
|
invoke :application_setup
|
41
|
+
invoke :bundle_gems
|
34
42
|
invoke :setup_git
|
35
43
|
invoke :create_heroku_apps
|
36
44
|
invoke :outro
|
@@ -51,13 +59,17 @@ module Wired
|
|
51
59
|
def customize_gemfile
|
52
60
|
build :replace_gemfile
|
53
61
|
build :set_ruby_to_version_being_used
|
54
|
-
|
62
|
+
end
|
63
|
+
|
64
|
+
def bundle_gems
|
65
|
+
bundle_command 'install'
|
55
66
|
end
|
56
67
|
|
57
68
|
def create_wired_views
|
58
69
|
say 'Creating views'
|
59
70
|
build :create_partials_directory
|
60
71
|
build :create_shared_flashes
|
72
|
+
build :create_shared_analytics
|
61
73
|
build :create_application_layout
|
62
74
|
end
|
63
75
|
|
@@ -65,12 +77,14 @@ module Wired
|
|
65
77
|
say 'Setting up database'
|
66
78
|
build :setup_database_config
|
67
79
|
build :create_database
|
80
|
+
build :add_postgres_drop_override
|
68
81
|
end
|
69
82
|
|
70
83
|
def configure_app
|
71
84
|
say 'Configuring app'
|
72
85
|
build :configure_time_zone
|
73
|
-
build :
|
86
|
+
build :set_asset_host
|
87
|
+
build :set_action_mailer_config
|
74
88
|
build :add_email_validator
|
75
89
|
end
|
76
90
|
|
@@ -87,6 +101,11 @@ module Wired
|
|
87
101
|
build :remove_routes_comment_lines
|
88
102
|
end
|
89
103
|
|
104
|
+
def setup_test
|
105
|
+
say 'Setting up test environment'
|
106
|
+
build :test_configuration_files
|
107
|
+
end
|
108
|
+
|
90
109
|
def setup_git
|
91
110
|
say 'Setting up git'
|
92
111
|
build :gitignore_files
|
@@ -19,6 +19,12 @@ module Wired
|
|
19
19
|
super
|
20
20
|
say "* Create Facebook apps on https://developers.facebook.com"
|
21
21
|
say "* Update FB_APP_ID env variables locally, on Heroku and in the readme"
|
22
|
+
say "* Add app to wiredev (http://www.facebook.com/dialog/pagetab?app_id=FB_APP_ID&next=http%3A%2F%2Ffacebook.com)"
|
23
|
+
end
|
24
|
+
|
25
|
+
def customize_gemfile
|
26
|
+
super
|
27
|
+
build :add_gems
|
22
28
|
end
|
23
29
|
|
24
30
|
protected
|
data/lib/wired/version.rb
CHANGED
data/templates/Gemfile_clean
CHANGED
@@ -30,5 +30,19 @@ gem 'simple_form'
|
|
30
30
|
gem 'flutie'
|
31
31
|
gem 'gon'
|
32
32
|
|
33
|
-
|
34
|
-
gem '
|
33
|
+
group :development, :test do
|
34
|
+
gem 'rspec-rails'
|
35
|
+
gem 'factory_girl_rails'
|
36
|
+
gem 'dotenv-rails'
|
37
|
+
end
|
38
|
+
|
39
|
+
group :test do
|
40
|
+
gem 'simplecov', require: false
|
41
|
+
gem 'database_cleaner'
|
42
|
+
gem 'shoulda-matchers'
|
43
|
+
gem 'timecop'
|
44
|
+
gem 'selenium-webdriver'
|
45
|
+
gem 'capybara'
|
46
|
+
end
|
47
|
+
|
48
|
+
gem 'unf'
|
data/templates/README.md.erb
CHANGED
@@ -0,0 +1,13 @@
|
|
1
|
+
<script type="text/javascript">
|
2
|
+
var _gaq = _gaq || [];
|
3
|
+
_gaq.push(['_setAccount', '<%%= ENV["GA_CODE"] %>']);
|
4
|
+
_gaq.push(['_addIgnoredRef', 'static.ak.facebook.com']);
|
5
|
+
_gaq.push(['_addIgnoredRef', 's-static.ak.facebook.com']);
|
6
|
+
_gaq.push(['_trackPageview']);
|
7
|
+
|
8
|
+
(function() {
|
9
|
+
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
|
10
|
+
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
|
11
|
+
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
|
12
|
+
})();
|
13
|
+
</script>
|
data/templates/_flashes.html.erb
CHANGED
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'active_record/connection_adapters/postgresql_adapter'
|
2
|
+
module ActiveRecord
|
3
|
+
module ConnectionAdapters
|
4
|
+
class PostgreSQLAdapter < AbstractAdapter
|
5
|
+
def drop_database(name)
|
6
|
+
if Rails.env.development?
|
7
|
+
execute <<-SQL
|
8
|
+
UPDATE pg_catalog.pg_database
|
9
|
+
SET datallowconn=false WHERE datname='#{name}'
|
10
|
+
SQL
|
11
|
+
|
12
|
+
execute <<-SQL
|
13
|
+
SELECT pg_terminate_backend(pg_stat_activity.pid)
|
14
|
+
FROM pg_stat_activity
|
15
|
+
WHERE pg_stat_activity.datname = '#{name}';
|
16
|
+
SQL
|
17
|
+
execute "DROP DATABASE IF EXISTS #{quote_table_name(name)}"
|
18
|
+
else
|
19
|
+
execute "DROP DATABASE IF EXISTS #{quote_table_name(name)}"
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
data/templates/facebook/env
CHANGED
@@ -1,15 +1,3 @@
|
|
1
|
-
((d) ->
|
2
|
-
js = undefined
|
3
|
-
id = "facebook-jssdk"
|
4
|
-
ref = d.getElementsByTagName("script")[0]
|
5
|
-
return if d.getElementById(id)
|
6
|
-
js = d.createElement("script")
|
7
|
-
js.id = id
|
8
|
-
js.async = true
|
9
|
-
js.src = "//connect.facebook.net/en_US/all.js"
|
10
|
-
ref.parentNode.insertBefore js, ref
|
11
|
-
) document
|
12
|
-
|
13
1
|
window.fbAsyncInit = ->
|
14
2
|
FB.init
|
15
3
|
appId : window.gon.global.facebook.app_id
|
@@ -18,11 +6,40 @@ window.fbAsyncInit = ->
|
|
18
6
|
xfbml : true
|
19
7
|
cookie: true
|
20
8
|
|
9
|
+
# track facebook events with analytics
|
10
|
+
FB.Event.subscribe "message.send", (href) ->
|
11
|
+
_gaq.push(['_trackEvent', 'facebook', 'send', href]) if _gaq?
|
12
|
+
_gaq.push(['_trackSocial', 'facebook', 'send', href]) if _gaq?
|
13
|
+
|
14
|
+
FB.Event.subscribe "edge.create", (href, widget) ->
|
15
|
+
_gaq.push(['_trackEvent', 'facebook', 'like', href]) if _gaq?
|
16
|
+
_gaq.push(['_trackSocial', 'facebook', 'like', href]) if _gaq?
|
17
|
+
|
18
|
+
FB.Event.subscribe "edge.remove", (href, widget) ->
|
19
|
+
_gaq.push(['_trackEvent', 'facebook', 'unlike', href]) if _gaq?
|
20
|
+
_gaq.push(['_trackSocial', 'facebook', 'unlike', href]) if _gaq?
|
21
|
+
|
21
22
|
$ ->
|
22
|
-
|
23
|
+
# Share button
|
24
|
+
# Usage: <a href="javascript: " rel="no-follow" data-fb-feed="http://your-link-to-share">share</a>
|
25
|
+
# title, description, picture etc is read from og-metadata
|
26
|
+
$('[data-fb-feed]').click (event) ->
|
27
|
+
obj =
|
28
|
+
method: 'feed'
|
29
|
+
link: $(this).data('fb-feed')
|
30
|
+
|
31
|
+
FB.ui obj, (resp) ->
|
32
|
+
if resp
|
33
|
+
_gaq.push(['_trackEvent', 'facebook', 'feed', window.location.protocol + '//' + window.location.hostname]) if _gaq?
|
34
|
+
_gaq.push(['_trackSocial', 'facebook', 'feed', window.location.protocol + '//' + window.location.hostname]) if _gaq?
|
35
|
+
|
36
|
+
# Login button
|
37
|
+
# Usage: <a href="javascript: " rel="no-follow" data-fb-login>login</a>
|
38
|
+
$('[data-fb-login]').click (event) ->
|
39
|
+
$btn = $(this)
|
23
40
|
event.preventDefault()
|
24
|
-
unless $
|
25
|
-
$
|
41
|
+
unless $btn.hasClass 'disabled'
|
42
|
+
$btn.addClass 'disabled'
|
26
43
|
FB.login (response) ->
|
27
44
|
if response.authResponse
|
28
45
|
$.ajax '/users',
|
@@ -34,7 +51,7 @@ $ ->
|
|
34
51
|
success: (response) ->
|
35
52
|
window.location = response.redirect
|
36
53
|
error: (event) ->
|
37
|
-
$
|
54
|
+
$btn.removeClass 'disabled'
|
38
55
|
alert "Er is iets mis gegaan, probeer het later nog eens!"
|
39
|
-
, scope: 'email'
|
56
|
+
, scope: 'email'
|
40
57
|
false
|
@@ -0,0 +1,21 @@
|
|
1
|
+
class FacebookController < ApplicationController
|
2
|
+
protect_from_forgery except: [:tab]
|
3
|
+
|
4
|
+
def tab
|
5
|
+
request = Facebook::SignedRequest.new params[:signed_request]
|
6
|
+
|
7
|
+
if request.data.present?
|
8
|
+
session[:fbid] = request.data[:user_id] if request.data[:user_id].present?
|
9
|
+
@show_fangate = !request.data[:page][:liked]
|
10
|
+
else
|
11
|
+
@show_fangate = false
|
12
|
+
redirect_to "http://www.facebook.com/#{ENV['FB_PAGE_NAME']}/app_#{ENV['FB_APP_ID']}" unless is_mobile_request?
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
def canvas
|
17
|
+
#canvas redirects to tab
|
18
|
+
redirect_url = "http://www.facebook.com/#{ENV['FB_PAGE_NAME']}/app_#{ENV['FB_APP_ID']}"
|
19
|
+
iframe_redirect_to redirect_url
|
20
|
+
end
|
21
|
+
end
|
@@ -4,11 +4,9 @@ class UsersController < ApplicationController
|
|
4
4
|
def create
|
5
5
|
@user = User.create_or_update_by_access_token user_params[:access_token]
|
6
6
|
|
7
|
-
#todo catch koala error if access_token invalid
|
8
|
-
@user.entry = Entry.new if @user.entry.nil?
|
9
7
|
if @user.save
|
10
|
-
session[:
|
11
|
-
render json: {
|
8
|
+
session[:fbid] = @user.fbid
|
9
|
+
render json: {user: @user, redirect: root_url}, status: :ok
|
12
10
|
else
|
13
11
|
render json: {}, status: :unprocessable_entity
|
14
12
|
end
|
@@ -12,5 +12,20 @@
|
|
12
12
|
<div id="fb-root"></div>
|
13
13
|
<%%= render 'flashes' -%>
|
14
14
|
<%%= yield %>
|
15
|
+
<script>
|
16
|
+
(function(d) {
|
17
|
+
var id, js, ref;
|
18
|
+
js = void 0;
|
19
|
+
id = "facebook-jssdk";
|
20
|
+
ref = d.getElementsByTagName("script")[0];
|
21
|
+
if (d.getElementById(id)) return;
|
22
|
+
js = d.createElement("script");
|
23
|
+
js.id = id;
|
24
|
+
js.async = true;
|
25
|
+
js.src = "//connect.facebook.net/nl_NL/all.js";
|
26
|
+
return ref.parentNode.insertBefore(js, ref);
|
27
|
+
})(document);
|
28
|
+
</script>
|
29
|
+
<%%= render partial: "analytics" if Rails.env.production? %>
|
15
30
|
</body>
|
16
31
|
</html>
|
@@ -0,0 +1 @@
|
|
1
|
+
--color
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'simplecov'
|
2
|
+
|
3
|
+
ENV["RAILS_ENV"] ||= 'test'
|
4
|
+
require File.expand_path("../../config/environment", __FILE__)
|
5
|
+
require 'rspec/rails'
|
6
|
+
require 'rspec/autorun'
|
7
|
+
|
8
|
+
include ActionDispatch::TestProcess
|
9
|
+
|
10
|
+
Dir[Rails.root.join("spec/support/**/*.rb")].each { |f| require f }
|
11
|
+
|
12
|
+
ActiveRecord::Migration.check_pending! if defined?(ActiveRecord::Migration)
|
13
|
+
|
14
|
+
RSpec.configure do |config|
|
15
|
+
config.use_transactional_fixtures = true
|
16
|
+
config.infer_base_class_for_anonymous_controllers = false
|
17
|
+
config.order = "random"
|
18
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
language: ruby
|
2
|
+
cache: bundler
|
3
|
+
rvm:
|
4
|
+
- 2.0.0
|
5
|
+
notifications:
|
6
|
+
email: false
|
7
|
+
irc:
|
8
|
+
channels:
|
9
|
+
- "chat.freenode.net#wirelab"
|
10
|
+
on_success: change
|
11
|
+
on_failure: always
|
12
|
+
template:
|
13
|
+
- "%{repository} (%{branch}): %{author} - %{message}"
|
14
|
+
script: "bundle exec rake db:create db:test:load spec"
|
15
|
+
env:
|
16
|
+
global:
|
17
|
+
- RAILS_ENV=test
|
18
|
+
- AUTH_USER=u
|
19
|
+
- AUTH_PASS=p
|
data/templates/wired_gitignore
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: wired
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Wirelab Creative
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-
|
11
|
+
date: 2013-12-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -28,14 +28,14 @@ dependencies:
|
|
28
28
|
name: bundler
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- - '>='
|
31
|
+
- - ! '>='
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: '1.1'
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- - '>='
|
38
|
+
- - ! '>='
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '1.1'
|
41
41
|
- !ruby/object:Gem::Dependency
|
@@ -88,7 +88,9 @@ files:
|
|
88
88
|
- lib/wired/version.rb
|
89
89
|
- templates/Gemfile_clean
|
90
90
|
- templates/README.md.erb
|
91
|
+
- templates/_analytics.html.erb
|
91
92
|
- templates/_flashes.html.erb
|
93
|
+
- templates/database.rake
|
92
94
|
- templates/database.yml.erb
|
93
95
|
- templates/email_validator.rb
|
94
96
|
- templates/facebook/_variables.css.scss
|
@@ -97,11 +99,15 @@ files:
|
|
97
99
|
- templates/facebook/cookie_fix.js.coffee
|
98
100
|
- templates/facebook/env
|
99
101
|
- templates/facebook/facebook.js.coffee
|
102
|
+
- templates/facebook/facebook_controller.rb
|
100
103
|
- templates/facebook/reset.css.scss
|
101
104
|
- templates/facebook/sessions_controller.rb
|
102
|
-
- templates/facebook/tab_controller.rb
|
103
105
|
- templates/facebook/users_controller.rb
|
104
106
|
- templates/layout.html.erb.erb
|
107
|
+
- templates/spec/rspec
|
108
|
+
- templates/spec/simplecov
|
109
|
+
- templates/spec/spec_helper.rb
|
110
|
+
- templates/spec/travis.yml
|
105
111
|
- templates/wired_gitignore
|
106
112
|
- wired.gemspec
|
107
113
|
homepage: https://github.com/wirelab/wired
|
@@ -115,17 +121,17 @@ require_paths:
|
|
115
121
|
- lib
|
116
122
|
required_ruby_version: !ruby/object:Gem::Requirement
|
117
123
|
requirements:
|
118
|
-
- - '>='
|
124
|
+
- - ! '>='
|
119
125
|
- !ruby/object:Gem::Version
|
120
126
|
version: '0'
|
121
127
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
122
128
|
requirements:
|
123
|
-
- - '>='
|
129
|
+
- - ! '>='
|
124
130
|
- !ruby/object:Gem::Version
|
125
131
|
version: '0'
|
126
132
|
requirements: []
|
127
133
|
rubyforge_project:
|
128
|
-
rubygems_version: 2.0.
|
134
|
+
rubygems_version: 2.0.3
|
129
135
|
signing_key:
|
130
136
|
specification_version: 4
|
131
137
|
summary: Wirelab Generator
|
@@ -1,48 +0,0 @@
|
|
1
|
-
class TabController < ApplicationController
|
2
|
-
include Mobylette::RespondToMobileRequests
|
3
|
-
protect_from_forgery except: [:home]
|
4
|
-
|
5
|
-
def home
|
6
|
-
@liked = false
|
7
|
-
if params[:signed_request]
|
8
|
-
set_fbid_session_if_authenticated_before_with_facebook
|
9
|
-
@show_fangate = !liked?
|
10
|
-
else
|
11
|
-
@show_fangate = false
|
12
|
-
redirect_to "http://www.facebook.com/#{ENV['FB_PAGE_NAME']}/app_#{ENV['FB_APP_ID']}" unless is_mobile_request?
|
13
|
-
end
|
14
|
-
end
|
15
|
-
|
16
|
-
private
|
17
|
-
def liked?
|
18
|
-
if params[:signed_request]
|
19
|
-
encoded_request = params[:signed_request]
|
20
|
-
json_request = decode_data(encoded_request)
|
21
|
-
signed_request = JSON.parse(json_request)
|
22
|
-
signed_request['page']['liked']
|
23
|
-
else
|
24
|
-
false
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
def set_fbid_session_if_authenticated_before_with_facebook
|
29
|
-
if params[:signed_request]
|
30
|
-
encoded_request = params[:signed_request]
|
31
|
-
json_request = decode_data(encoded_request)
|
32
|
-
signed_request = JSON.parse(json_request)
|
33
|
-
|
34
|
-
session[:fbid] = signed_request['user_id']
|
35
|
-
end
|
36
|
-
end
|
37
|
-
|
38
|
-
def base64_url_decode str
|
39
|
-
encoded_str = str.gsub('-','+').gsub('_','/')
|
40
|
-
encoded_str += '=' while !(encoded_str.size % 4).zero?
|
41
|
-
Base64.decode64(encoded_str)
|
42
|
-
end
|
43
|
-
|
44
|
-
def decode_data(signed_request)
|
45
|
-
encoded_sig, payload = signed_request.split('.')
|
46
|
-
data = base64_url_decode(payload)
|
47
|
-
end
|
48
|
-
end
|