wired 0.0.3 → 0.0.4

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 CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- YTc0OThkNDhkNGVmMTI4ZjFjOGRmNGY4OTcwN2Y4NjU4OWUxNjVkNA==
4
+ OTBlZjBiYTBhYWM0NzBkNjhkNzcyZWM2ODJiMDIzMGY4MzhkMDFmOQ==
5
5
  data.tar.gz: !binary |-
6
- YWJlNjA5MzdjZTI2NzBiOTJlZmYyMTdlYWMzNjQ1MzNkZDdkM2NkZQ==
6
+ M2Y2NDRjMGY1NjFmMDVkOTgzZmU3NDk1YmY0ZTlhOTllNWY1Nzg0OA==
7
7
  !binary "U0hBNTEy":
8
8
  metadata.gz: !binary |-
9
- MTI0MTQ1NTA2MzJlMDZkNmI4Zjc3NWRhZDFjMjc1ZDAxN2I4MWZhN2IwOTJk
10
- ZmIyNzU0NzA2ZGM0MTU4ZjliNmJkZTAwOWMwNTI2MTk5ZGU2ZWEzOTgzZDhj
11
- NzVlMGUwMWFiNjc3Yjg5MjVhMmIzNTYwZjljNjM4ZDM3M2EwNDY=
9
+ YjBmMmM2YjAyMTZkYWMwYWE4ZTUwYmMxZDc2MjllYWQ2MDQ2MjY1MjFhZTY0
10
+ YjJkOTc4ZjdhOTFhOTViNzQ5YzE0ZmVmNTJmNjNhMzY2Njc0ODFiNTM3ODMz
11
+ MTAzZGQ0ZTNhZGVkNThiYmIwZTlkMGVkMjE4MTliYjgzODE4NDE=
12
12
  data.tar.gz: !binary |-
13
- ZjU2OGNkNzAzN2NjZjVlYzEwYzRmOGUyMGUzYzgwZTE1MjJkZTRjYTQ4NGVl
14
- ZmZlNmMxODJmMWM2YjE5OGQ0MDY0NmFmODAxZjMxYjc0OGU3ZjI4NjJlNTI4
15
- YjFlMjNiYjdiNDQ3ZTM1MzdmMTExNTA4NzQ2MzliYjZhOGYwZGM=
13
+ YzI5MmJlM2YzNjU2ZjEwNTU3YmRjNGE3MGM1M2YwM2MwNWI0MzI2ZWYzYTRk
14
+ ZGIxODljNTU2YWIyMWRjM2I2OTJlMjY3MWRkNmQ3ZTMwOGUwM2RhM2QwOTIz
15
+ NjQ0ZmIwMmYxNDcwN2EyNDFmODEyNjhiMWQyZTFlZDE1MTgyNDA=
data/README.md CHANGED
@@ -4,6 +4,16 @@ About
4
4
  ---
5
5
  This gem is for internal use and heavily based on (you might even say mostly copy-pasted from) Suspenders, if you found this gem you will probably want to check them out: [Suspenders by Thoughtbot](http://github.com/thoughtbot/suspenders).
6
6
 
7
+ Requirements
8
+ ---
9
+ * [Heroku toolbelt](https://toolbelt.heroku.com)
10
+ * [Hub](https://github.com/defunkt/hub)
11
+
7
12
  Installation
8
13
  ---
9
- gem install wired
14
+ `gem install wired`
15
+
16
+ Usage
17
+ ---
18
+ `wired app_name`
19
+
@@ -1,6 +1,12 @@
1
1
  module Wired
2
2
  class AppBuilder < Rails::AppBuilder
3
3
  include Wired::Actions
4
+
5
+ def readme
6
+ template 'README.md.erb', 'README.md'
7
+ remove_dir 'doc'
8
+ end
9
+
4
10
  def remove_public_index
5
11
  remove_file 'public/index.html'
6
12
  end
@@ -49,5 +55,124 @@ module Wired
49
55
  RUBY
50
56
  inject_into_class 'config/application.rb', 'Application', config
51
57
  end
58
+
59
+ def customize_error_pages
60
+ meta_tags =<<-EOS
61
+ <meta charset='utf-8' />
62
+ EOS
63
+
64
+ %w(500 404 422).each do |page|
65
+ inject_into_file "public/#{page}.html", meta_tags, :after => "<head>\n"
66
+ replace_in_file "public/#{page}.html", /<!--.+-->\n/, ''
67
+ end
68
+ end
69
+
70
+ def remove_routes_comment_lines
71
+ replace_in_file 'config/routes.rb',
72
+ /Application\.routes\.draw do.*end/m,
73
+ "Application.routes.draw do\nend"
74
+ end
75
+
76
+ def gitignore_files
77
+ concat_file 'wired_gitignore', '.gitignore'
78
+ [
79
+ 'app/models',
80
+ 'app/assets/images',
81
+ 'app/views/pages',
82
+ 'db/migrate',
83
+ 'log',
84
+ 'spec/support',
85
+ 'spec/lib',
86
+ 'spec/models',
87
+ 'spec/views',
88
+ 'spec/controllers',
89
+ 'spec/helpers',
90
+ 'spec/support/matchers',
91
+ 'spec/support/mixins',
92
+ 'spec/support/shared_examples'
93
+ ].each do |dir|
94
+ empty_directory_with_gitkeep dir
95
+ end
96
+ end
97
+
98
+ def setup_git
99
+ run 'git init'
100
+ run "hub create -p wirelab/#{app_name}"
101
+ run "git add ."
102
+ run "git commit -m 'initial commit'"
103
+ run "git checkout -b develop"
104
+ run "git push --all"
105
+ end
106
+
107
+ def powder_link
108
+ run 'powder link'
109
+ end
110
+
111
+ def update_readme_for_facebook
112
+ append_file "README.md", "* FB_APP_ID\n* FB_PAGE_NAME"
113
+ facebook_readme =<<-FACEBOOK
114
+ # Facebook Apps
115
+ * [Production](https://developers.facebook.com/apps/FB_APP_ID) _FB_APP_ID_
116
+ * [Acceptance](https://developers.facebook.com/apps/) _FB_APP_ID_
117
+ * [Staging](https://developers.facebook.com/apps/FB_APP_ID) _FB_APP_ID_
118
+ * [Development](https://developers.facebook.com/apps/FB_APP_ID) _FB_APP_ID_
119
+
120
+ ***
121
+
122
+ FACEBOOK
123
+ inject_into_file "README.md", facebook_readme, :before => "# Variables\n"
124
+ end
125
+
126
+ def add_facebook_routes
127
+ facebook_routes =<<-ROUTES
128
+ root :to => 'tab#home'
129
+ match "fangate" => "tab#fangate", as: 'fangate'
130
+
131
+ #safari cookie fix
132
+ get 'cookie' => 'application#cookie', as: 'cookie'
133
+
134
+ #admin
135
+ get 'admin/export' => 'admin#export'
136
+ ROUTES
137
+ inject_into_file "config/routes.rb", facebook_routes, :before => "end"
138
+ end
139
+
140
+ def add_facebook_controllers
141
+ copy_file 'facebook/tab_controller.rb', 'app/controllers/tab_controller.rb'
142
+ copy_file 'facebook/export_controller.rb', 'app/controllers/export_controller.rb'
143
+ end
144
+
145
+ def create_facebook_views
146
+ empty_directory 'app/views/tab'
147
+ %w(fangate home).each do |page|
148
+ File.open("app/views/tab/#{page}.html.erb", 'w') { |file| file.write(page) }
149
+ end
150
+ end
151
+
152
+ def add_safari_cookie_fix
153
+ facebook_cookie_fix =<<-COOKIE_FIX
154
+ before_filter :safari_cookie_fix
155
+
156
+ def cookie
157
+ #safari third party cookie fix
158
+ end
159
+
160
+ private
161
+
162
+ def safari_cookie_fix
163
+ cookies[:safari_cookie_fix] = "cookie" #safari third party cookie fix
164
+ end
165
+ COOKIE_FIX
166
+ inject_into_file "app/controllers/application_controller.rb", facebook_cookie_fix, :before => "end"
167
+ copy_file 'facebook/safari-cookie-fix.js.coffee', 'app/assets/javascripts/safari-cookie-fix.js.coffee'
168
+ end
169
+
170
+ def create_heroku_apps
171
+ %w(staging acceptance production).each do |env|
172
+ run "heroku create #{app_name}-#{env} --remote=#{env}"
173
+ run "heroku sharing:add algemeen@wirelab.nl --remote=#{env}"
174
+ run "heroku sharing:transfer algemeen@wirelab.nl --remote=#{env}"
175
+ end
176
+ end
52
177
  end
53
178
  end
@@ -3,8 +3,7 @@ require 'rails/generators/rails/app/app_generator'
3
3
 
4
4
  module Wired
5
5
  class AppGenerator < Rails::Generators::AppGenerator
6
- class_option :skip_test_unit, :type => :boolean, :aliases => '-T', :default => true,
7
- :desc => 'Skip Test::Unit files'
6
+ @@type = ""
8
7
 
9
8
  def finish_template
10
9
  invoke :wired_customization
@@ -17,14 +16,50 @@ module Wired
17
16
  invoke :create_wired_views
18
17
  invoke :setup_database
19
18
  invoke :configure_app
20
- #invoke :setup_stylesheets
21
- #invoke :copy_miscellaneous_files
22
- #invoke :customize_error_pages
23
- #invoke :remove_routes_comment_lines
24
- #invoke :setup_git
25
- #invoke :create_heroku_apps
26
- #invoke :create_github_repo
19
+ invoke :customize_error_pages
20
+ invoke :remove_routes_comment_lines
21
+ invoke :application_setup
22
+ invoke :setup_git
23
+ invoke :create_heroku_apps
27
24
  invoke :outro
25
+ invoke :todo
26
+ end
27
+
28
+ def application_setup
29
+ build :powder_link
30
+
31
+ choices = ["facebook", "teaser"]
32
+ type = ask "Applicationtype? (#{choices.join ', '})"
33
+ if choices.include? type
34
+ @@type = type
35
+ case type
36
+ when "facebook"
37
+ say "Setting up a Facebook application"
38
+ invoke :facebook_setup
39
+ when "teaser"
40
+ say "Setting up a teaser with email registration"
41
+ #invoke :teaser_setup
42
+ end
43
+ else
44
+ say "Applicationtype should be one of: #{choices.join ', '}"
45
+ invoke :application_setup
46
+ end
47
+ end
48
+
49
+ def facebook_setup
50
+ if @@type == "facebook"
51
+ build :update_readme_for_facebook
52
+ build :add_facebook_routes
53
+ build :add_facebook_controllers
54
+ build :create_facebook_views
55
+ build :add_safari_cookie_fix
56
+ end
57
+ end
58
+
59
+ def teaser_setup
60
+ if @@type == "teaser"
61
+ say "There's no teaser setup yet"
62
+ end
28
63
  end
29
64
 
30
65
  def remove_files_we_dont_need
@@ -57,8 +92,43 @@ module Wired
57
92
  build :add_email_validator
58
93
  end
59
94
 
95
+ def copy_miscellaneous_files
96
+ build :copy_miscellaneous_files
97
+ end
98
+
99
+ def customize_error_pages
100
+ say 'Customizing the 500/404/422 pages'
101
+ build :customize_error_pages
102
+ end
103
+
104
+ def remove_routes_comment_lines
105
+ build :remove_routes_comment_lines
106
+ end
107
+
108
+ def setup_git
109
+ say 'Setting up git'
110
+ build :gitignore_files
111
+ build :setup_git
112
+ end
113
+
114
+ def create_heroku_apps
115
+ say 'Creating Heroku apps'
116
+ build :create_heroku_apps
117
+ end
118
+
60
119
  def outro
61
- say 'Wired up!'
120
+ say " _ _ _ ___ ___ _ ___ ___ \n | || || || - > | __>| | / - \\| - >\n | || || \\ | __>| |_ | | || _ \\\n |_/\\_||_||_|\\_\\|___>|___||_|_||___/\n"
121
+ end
122
+
123
+ def todo
124
+ say "\n ------TODO------"
125
+ case @@type
126
+ when "facebook"
127
+ say "* Create Facebook apps on https://developers.facebook.com"
128
+ say "* Update FB_APP_ID env variables locally, on Heroku and in the readme"
129
+ when "teaser"
130
+ say "* Build entire app"
131
+ end
62
132
  end
63
133
 
64
134
  def run_bundle
@@ -70,9 +140,5 @@ module Wired
70
140
  def get_builder_class
71
141
  Wired::AppBuilder
72
142
  end
73
-
74
- def using_active_record?
75
- !options[:skip_active_record]
76
- end
77
143
  end
78
144
  end
data/lib/wired/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Wired
2
- VERSION = '0.0.3'
2
+ VERSION = '0.0.4'
3
3
  end
@@ -22,3 +22,4 @@ end
22
22
  gem 'asset_sync'
23
23
  gem 'mobylette'
24
24
  gem 'simple_form'
25
+ gem 'flutie'
@@ -0,0 +1,17 @@
1
+ # Description
2
+
3
+ ***
4
+
5
+ # Environments
6
+ * [Production](http://<%= app_name %>.herokuapp.com) _git@heroku.com:<%= app_name %>.git_
7
+ * [Acceptance](http://<%= app_name %>-acceptance.herokuapp.com) _git@heroku.com:<%= app_name %>-acceptance.git_
8
+ * [Staging](http://<%= app_name %>-staging.herokuapp.com) _git@heroku.com:<%= app_name %>-staging.git_
9
+
10
+ ***
11
+
12
+ # Variables
13
+ * AWS_ACCESS_KEY_ID
14
+ * AWS_SECRET_ACCESS_KEY
15
+ * ASSET_HOST
16
+ * FOG_DIRECTORY
17
+ * FOG_PROVIDER
@@ -0,0 +1,13 @@
1
+ class ExportController < ApplicationController
2
+ before_filter :authenticate
3
+ def index
4
+ render 'export', layout: false
5
+ end
6
+
7
+ private
8
+ def authenticate
9
+ authenticate_or_request_with_http_basic do |username, password|
10
+ username == 'USER_NAME' && password == 'PASSWORD'
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,4 @@
1
+ $ ->
2
+ if !/msie/.test(navigator.userAgent.toLowerCase())
3
+ if document.cookie.indexOf("safari_cookie_fix") == -1
4
+ top.window.location = "/cookie"
@@ -0,0 +1,37 @@
1
+ class TabController < ApplicationController
2
+ include Mobylette::RespondToMobileRequests
3
+
4
+ def home
5
+ if params[:signed_request]
6
+ redirect_to :fangate unless liked?
7
+ else
8
+ redirect_to "http://www.facebook.com/#{ENV['FB_PAGE_NAME']}/app_#{ENV['FB_APP_ID']}" unless is_mobile_view?
9
+ end
10
+ end
11
+
12
+ def fangate
13
+ end
14
+
15
+ private
16
+ def liked?
17
+ if params[:signed_request]
18
+ encoded_request = params[:signed_request]
19
+ json_request = decode_data(encoded_request)
20
+ signed_request = JSON.parse(json_request)
21
+ signed_request['page']['liked']
22
+ else
23
+ false
24
+ end
25
+ end
26
+
27
+ def base64_url_decode str
28
+ encoded_str = str.gsub('-','+').gsub('_','/')
29
+ encoded_str += '=' while !(encoded_str.size % 4).zero?
30
+ Base64.decode64(encoded_str)
31
+ end
32
+
33
+ def decode_data(signed_request)
34
+ encoded_sig, payload = signed_request.split('.')
35
+ data = base64_url_decode(payload)
36
+ end
37
+ end
@@ -0,0 +1,3 @@
1
+ .env
2
+ .powenv
3
+ public/system
data/wired.gemspec CHANGED
@@ -8,7 +8,7 @@ Gem::Specification.new do |s|
8
8
  s.version = Wired::VERSION
9
9
  s.date = Date.today.strftime('%Y-%m-%d')
10
10
  s.summary = 'Wirelab Generator'
11
- s.description = 'A Wirelab application generator'
11
+ s.description = 'The Wirelab application generator'
12
12
  s.authors = ['Wirelab Creative']
13
13
  s.email = 'bart@wirelab.nl'
14
14
  s.homepage = 'https://github.com/Wirelab/wired'
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.0.3
4
+ version: 0.0.4
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-03-29 00:00:00.000000000 Z
11
+ date: 2013-04-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -52,7 +52,7 @@ dependencies:
52
52
  - - ~>
53
53
  - !ruby/object:Gem::Version
54
54
  version: 1.10.5
55
- description: A Wirelab application generator
55
+ description: The Wirelab application generator
56
56
  email: bart@wirelab.nl
57
57
  executables:
58
58
  - wired
@@ -68,10 +68,15 @@ files:
68
68
  - lib/wired/generators/app_generator.rb
69
69
  - lib/wired/version.rb
70
70
  - templates/Gemfile_clean
71
+ - templates/README.md.erb
71
72
  - templates/_flashes.html.erb
72
73
  - templates/database.yml.erb
73
74
  - templates/email_validator.rb
75
+ - templates/facebook/export_controller.rb
76
+ - templates/facebook/safari-cookie-fix.js.coffee
77
+ - templates/facebook/tab_controller.rb
74
78
  - templates/layout.html.erb.erb
79
+ - templates/wired_gitignore
75
80
  - wired.gemspec
76
81
  homepage: https://github.com/Wirelab/wired
77
82
  licenses: []