inline_forms 1.6.67 → 1.6.68

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
- OTc5Zjk0NjkwMjYzMjVmYzE0MTRjMDhkMjNkMTAyNTc0ZjRlOWY0ZQ==
4
+ YmY0ZGZkYjBlY2JlZDFkMDk4YzJiMmNhNjI3NmI2ZjVkYjM1NjBhOA==
5
5
  data.tar.gz: !binary |-
6
- NDAxNjM3NzVlNGQ4MGExOTRlZjI0Y2ZlZTlmNzdiMmRkMzgxZmFmOA==
6
+ NmUyM2M4YmUyYjBiNjZmZjcwZDI5ZTg3MWIzNjBjYWY4MzhmZWEzMA==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- ZGU3M2E2YTY4YWY4MGI3NDE5YmE4NTMzZGU3NTNlNzUxOTNjYWRjMWQ1Mzgz
10
- Nzc5NGRmYWFmODc5Njg1ZTk5NWU2MWI4OTMwYmNhYWM1NWY3ZDcwMTczNTQz
11
- NmQxZThmODg2Y2UyZmJlOWJlZjZjMmJlZmNlOTc0NGVhY2M2Y2M=
9
+ N2M5MjM5YzJmMWNhYmJjMTMwYTY4MzA5MTM2ZTFmOTg0YmFjY2E5NWJmOGNk
10
+ ZTAzMDlhMzNjZGIyYzUxNTczNjk4ZjJiZTZmODAyNWNmMmM1NGRmNTg3OWUx
11
+ MmIwMjJkNTFjYzg1ZDlmNTU4NzczYzdiNzRmMWM2NjZkNjRjMWQ=
12
12
  data.tar.gz: !binary |-
13
- MTFjMzkzYjIyNjEzMTY0NDcwMTA4ZTFiMjMxNTEwNmQ2YWMzN2JhMzYzYWE0
14
- YThkYzhlYzEwNWM3YmQwYjQ0MDk3MWFiNzRlNGJjMGJkY2MwNWU2OGJiZTk5
15
- Njk4NDgwYzViMTUxOGZkMzBmOGM2MmNkOWU5OTlkNzA0MjM2YzE=
13
+ MGNhMDg5OTYyOWMxMTM4ZmIzZGQ1ZGUyNzM1OWNhMzEwY2QwOTAxNDM1MWU4
14
+ ODAzNDk3YTRiNWMzZGFlNTY1OTUxOTkzMDdlZTAyMTdjOWQ3ZTRjMzI4YmMy
15
+ YTFkZmRhOTdhYmFjZTY5YmNhNzM0NGI1ZjU3MjcxNWQ0ZDQyZjM=
data/bin/inline_forms CHANGED
@@ -1,33 +1,17 @@
1
1
  #!/usr/bin/env ruby
2
2
  module InlineForms
3
-
4
3
  require File.join(File.dirname(__FILE__), "../lib/inline_forms/version.rb")
5
4
 
6
- require 'rvm'
7
- if not RVM.current
8
- puts "ruby or rvm not found"
9
- exit 2
10
- end
11
-
12
5
  # what is this?
13
6
  Signal.trap("INT") { puts; exit }
14
7
 
15
8
  require 'thor'
16
-
17
9
  class Creator < Thor
18
10
  include Thor::Actions
19
11
 
20
- String.class_eval do
21
- def strip_heredoc_with_indent(indent=0)
22
- new_indent = ( self.empty? ? 0 : ( scan(/^[ \t]*(?=\S)/).min.size - indent ) )
23
- gsub(/^[ \t]{#{new_indent}}/, '')
24
- end
25
- end
26
-
27
12
  def self.source_root
28
13
  File.dirname(__FILE__)+"/.."
29
14
  end
30
-
31
15
  desc "create APP", "create an application with inline_forms v#{VERSION}"
32
16
  DATABASE_OPTIONS = %w(sqlite mysql)
33
17
  method_option :database, :aliases => "-d", :default => DATABASE_OPTIONS.first, :banner => DATABASE_OPTIONS.join('|'), :desc => 'specify development database'
@@ -35,8 +19,17 @@ module InlineForms
35
19
  method_option :example, :type => :boolean, :desc => 'install the example app. incompatible with --dry and uses sqlite as development database'
36
20
  method_option :email, :aliases => "-e", :default => "admin@example.com", :desc => 'specify admin email'
37
21
  method_option :password, :aliases => "-p", :default => "admin999", :desc => 'specify admin password'
22
+ method_option :runtest, :aliases => "\-\-run-test", :default => false, :desc => 'run tests'
23
+ method_option :skiprvm, :aliases => "\-\-no-rvm", :type => :boolean, :default => false, :desc => 'install inline_forms without RVM'
38
24
 
39
25
  def create(app_name)
26
+ def self.skiprvm
27
+ options[:skiprvm]
28
+ end
29
+
30
+ def self.runtest
31
+ options[:runtest]
32
+ end
40
33
 
41
34
  def self.dry_run?
42
35
  options[:dry]
@@ -87,16 +80,39 @@ module InlineForms
87
80
  exit 1
88
81
  end
89
82
 
83
+ # TODO: optioneel, detecteren dat er RVM er is als het niet zo is dan zonder RVM instaleren
84
+ # Maybe via the method.options (THOR)??
85
+ # using_rvm = false # for testing purpose only need to do this another way.
86
+ require 'rvm'
87
+ # if RVM is detected and the user has not disabled using rvm via command than use rvm else without
88
+ if RVM.current && !options[:skiprvm]
89
+ # Let the user know that he are installing the inline_forms with support of RVM
90
+ say "Installing inline_forms with RVM", :green
91
+ # which ruby version is currently activated?
92
+ ruby_version = (%x[rvm current]).gsub(/@.*/,'')
93
+ # Create a ruby rvm-file version based on the version detected
94
+ create_file "#{app_name}/.ruby-version", ruby_version
95
+ # Creat a ruby-gemset rvm-file based on the version detected
96
+ create_file "#{app_name}/.ruby-gemset", app_name
97
+ else
98
+ # Let the user know that he is installing inline_forms without RVM
99
+ say "Installing inline_forms without RVM", :green
100
+ end
101
+
90
102
  if dry_run?
91
103
  empty_directory(app_name)
92
104
  else
93
105
  empty_directory(app_name)
106
+
107
+ # need to pass all agruments for app template
108
+ options.each do | k,v |
109
+ ENV[k] = v.to_s
110
+ end
111
+ ENV['using_sqlite'] = using_sqlite?.to_s
112
+ ENV['install_example'] = install_example?.to_s
113
+ ENV['ruby_version'] = ruby_version
94
114
 
95
- ruby_version = (%x[rvm current]).gsub(/@.*/,'')
96
- create_file "#{app_name}/.ruby-version", ruby_version
97
- create_file "#{app_name}/.ruby-gemset", app_name
98
-
99
- app_template_file = File.join(File.dirname(__FILE__), 'inline_forms_app_template.rb')
115
+ app_template_file = File.join(File.dirname(__FILE__), 'inline_forms_app_template.rb')
100
116
 
101
117
  if ! run("rails _3.2.12_ new #{app_name} -m #{app_template_file} --skip-bundle --skip-gemfile --skip-test-unit")
102
118
  say "Rails could not create the app '#{app_name}', maybe because it is a reserved word...", :red
@@ -104,7 +120,6 @@ module InlineForms
104
120
  end
105
121
  end
106
122
  end
107
-
108
123
  Creator.start
109
124
  end
110
- end
125
+ end
@@ -1,322 +1,16 @@
1
- say "- Working directory is now #{`pwd`}"
2
- say "- RVM gemset is now #{%x[rvm current]}"
3
-
4
- create_file 'Gemfile', '# created by inline_forms\n'
5
- add_source 'https://rubygems.org'
6
- gem 'rails', '3.2.12'
7
- gem 'rake', '10.0.4'
8
- gem 'jquery-rails', '~> 2.3.0'
9
- gem 'jquery-ui-rails'
10
- gem 'capistrano'
11
- gem 'will_paginate', :git => 'git://github.com/acesuares/will_paginate.git'
12
- gem 'tabs_on_rails', :git => 'git://github.com/acesuares/tabs_on_rails.git', :branch => 'update_remote'
13
- gem 'ckeditor'
14
- gem 'cancan', :git => 'git://github.com/acesuares/cancan.git', :branch => '2.0'
15
- gem 'carrierwave'
16
- gem 'remotipart', '~> 1.0'
17
- gem 'paper_trail'
18
- gem 'devise'
19
- gem 'inline_forms'
20
- gem 'validation_hints'
21
- gem 'mini_magick'
22
- gem 'jquery-ui-rails'
23
- gem 'yaml_db'
24
- gem 'rails-i18n'
25
- gem 'i18n-active_record', :git => 'git://github.com/acesuares/i18n-active_record.git'
26
- gem 'unicorn'
27
- gem 'rvm'
28
- gem 'rvm-capistrano'
29
- gem 'foundation-rails'
30
-
31
- gem_group :development do
32
- gem 'sqlite3'
33
- gem 'rspec-rails'
34
- gem 'shoulda', '>= 0'
35
- gem 'bundler'
36
- gem 'jeweler'
37
- end
38
-
39
- gem_group :production do
40
- gem 'mysql2'
41
- gem 'therubyracer'
42
- gem 'uglifier', '>= 1.0.3'
43
- end
44
-
45
- gem_group :assets do
46
- gem 'sass-rails', '~> 3.2.3'
47
- gem 'coffee-rails', '~> 3.2.1'
48
- gem 'uglifier', '>= 1.0.3'
49
- gem 'compass-rails' # you need this or you get an err
50
- end
51
-
52
- say "- Running bundle..."
53
- run "bundle install"
54
-
55
- say "- Database setup: creating config/database.yml with development database #{database}"
56
- remove_file "config/database.yml" # the one that 'rails _3.2.12_ new' created
57
- if using_sqlite?
58
- create_file "config/database.yml", <<-END_DATABASEYML.strip_heredoc_with_indent
59
- development:
60
- adapter: sqlite3
61
- database: db/development.sqlite3
62
- pool: 5
63
- timeout: 5000
64
-
65
- END_DATABASEYML
1
+ require 'rvm'
2
+
3
+ if RVM.current && ENV['skiprvm'] !='true'
4
+ rvm_version = "#{ENV['ruby_version']}@#{app_name}"
5
+ RVM.chdir "../#{app_name}" do
6
+ say "Working directory is #{`pwd`}"
7
+ RVM.use_from_path! '.'
8
+ rvm_gemset = %x[rvm current]
9
+ say "RVM GEMSET is now #{rvm_gemset}"
10
+ say "Installing using gemset : #{RVM.current}", :green
11
+ end
66
12
  else
67
- create_file "config/database.yml", <<-END_DATABASEYML.strip_heredoc_with_indent
68
- development:
69
- adapter: mysql2
70
- database: #{app_name}_dev
71
- username: #{app_name}
72
- password: #{app_name}
73
-
74
- END_DATABASEYML
13
+ say "Installing without RVM", :green
75
14
  end
76
- append_file "config/database.yml", <<-END_DATABASEYML.strip_heredoc_with_indent
77
- production:
78
- adapter: mysql2
79
- database: #{app_name}_p
80
- username: #{app_name}
81
- password: #{app_name}444
82
- END_DATABASEYML
83
-
84
- say "- Devise install..."
85
- run "bundle exec rails g devise:install"
86
-
87
- say "- Devise User model install with added name and locale field..."
88
- run "bundle exec rails g devise User name:string locale:string"
89
-
90
- say "- Replace Devise route and add path_prefix..."
91
- gsub_file "config/routes.rb", /devise_for :users/, "devise_for :users, :path_prefix => 'auth'"
92
- insert_into_file "config/routes.rb", <<-ROUTE.strip_heredoc_with_indent(2), :after => "devise_for :users, :path_prefix => 'auth'\n"
93
- resources :users do
94
- post 'revert', :on => :member
95
- end
96
- ROUTE
97
-
98
- say "- Create User Controller..."
99
- create_file "app/controllers/users_controller.rb", <<-USERS_CONTROLLER.strip_heredoc_with_indent
100
- class UsersController < InlineFormsController
101
- set_tab :user
102
- end
103
- USERS_CONTROLLER
104
-
105
- say "- Recreate User Model..."
106
- remove_file "app/models/user.rb" # the one that 'devise:install' created
107
- create_file "app/models/user.rb", <<-USER_MODEL.strip_heredoc_with_indent
108
- class User < ActiveRecord::Base
109
-
110
- # devise options
111
- devise :database_authenticatable
112
- # devise :registerable # uncomment this if you want people to be able to register
113
- devise :recoverable
114
- devise :rememberable
115
- devise :trackable
116
- devise :validatable
117
- # devise :token_authenticatable
118
- # devise :confirmable,
119
- # devise :lockable
120
- # devise :timeoutable
121
- # devise :omniauthable
122
-
123
- # Setup accessible (or protected) attributes for your model
124
- attr_accessible :email, :password, :password_confirmation, :remember_me, :name, :locale
125
- attr_writer :inline_forms_attribute_list
126
-
127
- # validations
128
- validates :name, :presence => true
129
-
130
- # pagination
131
- attr_reader :per_page
132
- @per_page = 7
133
-
134
- has_paper_trail
135
-
136
- def _presentation
137
- "\#{name}"
138
- end
139
-
140
- def inline_forms_attribute_list
141
- @inline_forms_attribute_list ||= [
142
- [ :name , 'name', :text_field ],
143
- [ :email , 'email', :text_field ],
144
- [ :password , 'Nieuw wachtwoord', :devise_password_field ],
145
- [ :encrypted_password , 'encrypted_password', :info ],
146
- [ :reset_password_token , 'reset_password_token', :info ],
147
- [ :reset_password_sent_at , 'reset_password_sent_at', :info],
148
- [ :remember_created_at , 'remember_created_at', :info ],
149
- [ :sign_in_count , 'sign_in_count', :info ],
150
- [ :current_sign_in_at , 'current_sign_in_at', :info ],
151
- [ :last_sign_in_at , 'last_sign_in_at', :info ],
152
- [ :current_sign_in_ip , 'current_sign_in_ip', :info ],
153
- [ :last_sign_in_ip , 'last_sign_in_ip', :info ],
154
- [ :created_at , 'created_at', :info ],
155
- [ :updated_at , 'updated_at', :info ],
156
- ]
157
- end
158
-
159
- def self.not_accessible_through_html?
160
- false
161
- end
162
-
163
- def self.order_by_clause
164
- 'name'
165
- end
166
-
167
- end
168
- USER_MODEL
169
-
170
- say "- Install ckeditor..."
171
- generate "ckeditor", "install"
172
-
173
- say "- Mount Ckeditor::Engine to routes..."
174
- route "mount Ckeditor::Engine => '/ckeditor'"
175
-
176
- say "- Add ckeditor autoload_paths to application.rb..."
177
- application "config.autoload_paths += %W(\#{config.root}/app/models/ckeditor)"
178
-
179
- say "- Add ckeditor/init to application.js..."
180
- insert_into_file "app/assets/javascripts/application.js",
181
- "//= require ckeditor/init\n",
182
- :before => "//= require_tree .\n"
183
-
184
- say "- Create ckeditor config.js"
185
- copy_file "lib/app/assets/javascripts/ckeditor/config.js", "app/assets/javascripts/ckeditor/config.js"
186
-
187
- say "- Add remotipart to application.js..."
188
- insert_into_file "app/assets/javascripts/application.js", "//= require jquery.remotipart\n", :before => "//= require_tree .\n"
189
-
190
- say "- Paper_trail install..."
191
- generate "paper_trail", "install"
192
-
193
- say "- Installaing ZURB Foundation..."
194
- generate "foundation", "install"
195
-
196
- say "- Generate models and tables and views for translations..."
197
- generate "inline_forms", "InlineFormsLocale name:string inline_forms_translations:belongs_to _enabled:yes _presentation:\#{name}"
198
- generate "inline_forms", "InlineFormsKey name:string inline_forms_translations:has_many inline_forms_translations:associated _enabled:yes _presentation:\#{name}'"
199
- generate "inline_forms", "InlineFormsTranslation inline_forms_key:belongs_to inline_forms_locale:dropdown value:text interpolations:text is_proc:boolean _presentation:\#{value}'"
200
-
201
- sleep 1 # to get unique migration number
202
- create_file "db/migrate/" +
203
- Time.now.utc.strftime("%Y%m%d%H%M%S") +
204
- "_" +
205
- "inline_forms_create_view_for_translations.rb", <<-VIEW_MIGRATION.strip_heredoc_with_indent
206
- class InlineFormsCreateViewForTranslations < ActiveRecord::Migration
207
-
208
- def self.up
209
- execute 'CREATE VIEW translations
210
- AS
211
- SELECT L.name AS locale,
212
- K.name AS thekey,
213
- T.value AS value,
214
- T.interpolations AS interpolations,
215
- T.is_proc AS is_proc
216
- FROM inline_forms_keys K, inline_forms_locales L, inline_forms_translations T
217
- WHERE T.inline_forms_key_id = K.id AND T.inline_forms_locale_id = L.id '
218
- end
219
-
220
- def self.down
221
- execute 'DROP VIEW translations'
222
- end
223
-
224
- end
225
- VIEW_MIGRATION
226
-
227
- say "- Migrating Database (only when using sqlite)"
228
- run "bundle exec rake db:migrate" if using_sqlite?
229
-
230
- say "- Adding admin user with email: #{email}, password: #{password} to seeds.rb"
231
- append_to_file "db/seeds.rb", "User.create({ :email => '#{email}', :name => 'Admin', :password => '#{password}', :password_confirmation => '#{password}'}, :without_protection => true)"
232
-
233
- say "- Seeding the database (only when using sqlite)"
234
- run "bundle exec rake db:seed" if using_sqlite?
235
-
236
- say "- Creating header in app/views/inline_forms/_header.html.erb..."
237
- create_file "app/views/inline_forms/_header.html.erb", <<-END_HEADER.strip_heredoc_with_indent
238
- <div id='Header'>
239
- <div id='title'>
240
- #{app_name} v<%= inline_forms_version -%>
241
- </div>
242
- <% if current_user -%>
243
- <div id='logout'>
244
- <%= link_to \"Afmelden: \#{current_user.name}\", destroy_user_session_path, :method => :delete %>
245
- </div>
246
- <% end -%>
247
- <div style='clear: both;'></div>
248
- </div>
249
- END_HEADER
250
-
251
- say "- Recreating ApplicationHelper to set application_name and application_title..."
252
- remove_file "app/helpers/application_helper.rb" # the one that 'rails new' created
253
- create_file "app/helpers/application_helper.rb", <<-END_APPHELPER.strip_heredoc_with_indent
254
- module ApplicationHelper
255
- def application_name
256
- '#{app_name}'
257
- end
258
- def application_title
259
- '#{app_name}'
260
- end
261
- end
262
- END_APPHELPER
263
-
264
- say "- Recreating ApplicationController to add devise, cancan, I18n stuff..."
265
- remove_file "app/controllers/application_controller.rb" # the one that 'rails new' created
266
- create_file "app/controllers/application_controller.rb", <<-END_APPCONTROLLER.strip_heredoc_with_indent
267
- class ApplicationController < InlineFormsApplicationController
268
- protect_from_forgery
269
-
270
- # Comment next two lines if you don't want Devise authentication
271
- before_filter :authenticate_user!
272
- layout 'devise' if :devise_controller?
273
-
274
- # Comment next 6 lines if you want CanCan authorization
275
- enable_authorization :unless => :devise_controller?
276
-
277
- rescue_from CanCan::Unauthorized do |exception|
278
- sign_out :user if user_signed_in?
279
- redirect_to new_user_session_path, :alert => exception.message
280
- end
281
-
282
- # Uncomment next line if you want I18n (based on subdomain)
283
- # before_filter :set_locale
284
-
285
- # Uncomment next line and specify default locale
286
- # I18n.default_locale = :en
287
-
288
- # Uncomment next line and specify available locales
289
- # I18n.available_locales = [ :en, :nl, :pp ]
290
-
291
- # Uncomment next nine line if you want locale based on subdomain, like 'it.example.com, de.example.com'
292
- # def set_locale
293
- # I18n.locale = extract_locale_from_subdomain || I18n.default_locale
294
- # end
295
- #
296
- # def extract_locale_from_subdomain
297
- # locale = request.subdomains.first
298
- # return nil if locale.nil?
299
- # I18n.available_locales.include?(locale.to_sym) ? locale.to_s : nil
300
- # end
301
- end
302
- END_APPCONTROLLER
303
-
304
- say "- Creating Ability model so that the user with id = 1 can access all..."
305
- create_file "app/models/ability.rb", <<-END_ABILITY.strip_heredoc_with_indent
306
- class Ability
307
- include CanCan::Ability
308
-
309
- def initialize(user)
310
- # See the wiki for details: https://github.com/ryanb/cancan/wiki/Defining-Abilities
311
-
312
- user ||= user.new # guest user
313
-
314
- if user.id == 1 #quick hack
315
- can :access, :all
316
- else
317
- # put restrictions for other users here
318
- end
319
- end
320
- end
321
- END_ABILITY
322
15
 
16
+ apply(File.join(File.dirname(__FILE__), 'inline_forms_installer_core.rb'))
@@ -0,0 +1,423 @@
1
+ create_file 'Gemfile', '# created by inline_forms\n' # TODO include version
2
+
3
+ add_source 'https://rubygems.org'
4
+
5
+ gem 'rails', '3.2.12'
6
+ gem 'rake', '10.0.4'
7
+ gem 'jquery-rails', '~> 2.3.0'
8
+ gem 'jquery-ui-sass-rails'
9
+ gem 'capistrano'
10
+ gem 'will_paginate', :git => 'git://github.com/acesuares/will_paginate.git'
11
+ gem 'tabs_on_rails', :git => 'git://github.com/acesuares/tabs_on_rails.git', :branch => 'update_remote'
12
+ gem 'ckeditor'
13
+ gem 'cancan', :git => 'git://github.com/acesuares/cancan.git', :branch => '2.0'
14
+ gem 'carrierwave'
15
+ gem 'remotipart', '~> 1.0'
16
+ gem 'paper_trail'
17
+ gem 'devise'
18
+ gem 'inline_forms', '~> 1.6.0'
19
+ gem 'validation_hints'
20
+ gem 'mini_magick'
21
+ gem 'rails-i18n'
22
+ gem 'i18n-active_record', :git => 'git://github.com/acesuares/i18n-active_record.git'
23
+ gem 'unicorn'
24
+ gem 'rvm'
25
+ gem 'rvm-capistrano'
26
+ gem 'foundation-rails'
27
+ gem 'foundation-icons-sass-rails'
28
+ gem 'mysql2'
29
+
30
+ gem_group :development do
31
+ gem 'yaml_db'
32
+ gem 'seed_dump', git: 'git://github.com/acesuares/seed_dump.git'
33
+ gem 'switch_user'
34
+
35
+ gem "sqlite3"
36
+
37
+ gem "rspec-rails"
38
+ gem "shoulda", ">= 0"
39
+ gem "bundler"
40
+ gem "jeweler"
41
+ gem "capybara"
42
+ gem "factory_girl"
43
+ gem "factory_girl_rails"
44
+ gem "rspec"
45
+ end
46
+
47
+ gem_group :production do
48
+ gem 'therubyracer'
49
+ gem 'uglifier', '>= 1.0.3'
50
+ end
51
+
52
+ gem_group :assets do
53
+ gem 'sass-rails', '~> 3.2.3'
54
+ gem 'coffee-rails', '~> 3.2.1'
55
+ gem 'compass-rails' # you need this or you get an err
56
+ end
57
+
58
+ say "- Running bundle..."
59
+ run "bundle install"
60
+
61
+ say "- Database setup: creating config/database.yml with development database #{ENV['database']}"
62
+ remove_file "config/database.yml" # the one that 'rails _3.2.13_ new' created
63
+ if ENV['using_sqlite'] == 'true'
64
+ create_file "config/database.yml", <<-END_DATABASEYML.strip_heredoc
65
+ development:
66
+ adapter: sqlite3
67
+ database: db/development.sqlite3
68
+ pool: 5
69
+ timeout: 5000
70
+
71
+ END_DATABASEYML
72
+ else
73
+ create_file "config/database.yml", <<-END_DATABASEYML.strip_heredoc
74
+ development:
75
+ adapter: mysql2
76
+ database: #{app_name}_dev
77
+ username: #{app_name}
78
+ password: #{app_name}
79
+
80
+ END_DATABASEYML
81
+ end
82
+ append_file "config/database.yml", <<-END_DATABASEYML.strip_heredoc
83
+ production:
84
+ adapter: mysql2
85
+ database: #{app_name}_prod
86
+ username: #{app_name}
87
+ password: #{app_name}444
88
+ END_DATABASEYML
89
+
90
+ say "- Devise install..."
91
+ run "bundle exec rails g devise:install"
92
+
93
+ say "- Devise User model install with added name and locale field..."
94
+ run "bundle exec rails g devise User name:string locale:string"
95
+
96
+ say "- Replace Devise route and add path_prefix..."
97
+ gsub_file "config/routes.rb", /devise_for :users/, "devise_for :users, :path_prefix => 'auth'"
98
+ insert_into_file "config/routes.rb", <<-ROUTE.strip_heredoc, :after => "devise_for :users, :path_prefix => 'auth'\n"
99
+ resources :users do
100
+ post 'revert', :on => :member
101
+ end
102
+ ROUTE
103
+
104
+ say "- Create User Controller..."
105
+ create_file "app/controllers/users_controller.rb", <<-USERS_CONTROLLER.strip_heredoc
106
+ class UsersController < InlineFormsController
107
+ set_tab :user
108
+ end
109
+ USERS_CONTROLLER
110
+
111
+ say "- Recreate User Model..."
112
+ remove_file "app/models/user.rb" # the one that 'devise:install' created
113
+ create_file "app/models/user.rb", <<-USER_MODEL.strip_heredoc
114
+ class User < ActiveRecord::Base
115
+
116
+ # devise options
117
+ devise :database_authenticatable
118
+ # devise :registerable # uncomment this if you want people to be able to register
119
+ devise :recoverable
120
+ devise :rememberable
121
+ devise :trackable
122
+ devise :validatable
123
+ # devise :token_authenticatable
124
+ # devise :confirmable,
125
+ # devise :lockable
126
+ # devise :timeoutable
127
+ # devise :omniauthable
128
+
129
+ # Setup accessible (or protected) attributes for your model
130
+ attr_accessible :email, :password, :password_confirmation, :remember_me, :name, :locale
131
+ attr_writer :inline_forms_attribute_list
132
+
133
+ # validations
134
+ validates :name, :presence => true
135
+
136
+ # pagination
137
+ attr_reader :per_page
138
+ @per_page = 7
139
+
140
+ has_paper_trail
141
+
142
+ def _presentation
143
+ "\#{name}"
144
+ end
145
+
146
+ def inline_forms_attribute_list
147
+ @inline_forms_attribute_list ||= [
148
+ [ :name , 'name', :text_field ],
149
+ [ :email , 'email', :text_field ],
150
+ [ :password , 'Nieuw wachtwoord', :devise_password_field ],
151
+ [ :encrypted_password , 'encrypted_password', :info ],
152
+ [ :reset_password_token , 'reset_password_token', :info ],
153
+ [ :reset_password_sent_at , 'reset_password_sent_at', :info],
154
+ [ :remember_created_at , 'remember_created_at', :info ],
155
+ [ :sign_in_count , 'sign_in_count', :info ],
156
+ [ :current_sign_in_at , 'current_sign_in_at', :info ],
157
+ [ :last_sign_in_at , 'last_sign_in_at', :info ],
158
+ [ :current_sign_in_ip , 'current_sign_in_ip', :info ],
159
+ [ :last_sign_in_ip , 'last_sign_in_ip', :info ],
160
+ [ :created_at , 'created_at', :info ],
161
+ [ :updated_at , 'updated_at', :info ],
162
+ ]
163
+ end
164
+
165
+ def self.not_accessible_through_html?
166
+ false
167
+ end
168
+
169
+ def self.order_by_clause
170
+ 'name'
171
+ end
172
+
173
+ end
174
+ USER_MODEL
175
+
176
+ say "- Install ckeditor..."
177
+ generate "ckeditor:install --backend=carrierwave"
178
+
179
+ say "- Mount Ckeditor::Engine to routes..."
180
+ route "mount Ckeditor::Engine => '/ckeditor'"
181
+
182
+ say "- Add ckeditor autoload_paths to application.rb..."
183
+ application "config.autoload_paths += %W(\#{config.root}/app/models/ckeditor)"
184
+
185
+ say "- Add ckeditor/init to application.js..."
186
+ insert_into_file "app/assets/javascripts/application.js",
187
+ "//= require ckeditor/init\n",
188
+ :before => "//= require_tree .\n"
189
+
190
+ say "- Create ckeditor config.js"
191
+ copy_file File.join(File.dirname(File.expand_path(__FILE__)) + '/../lib/app/assets/javascripts/ckeditor/config.js'), "app/assets/javascripts/ckeditor/config.js"
192
+
193
+ say "- Add remotipart to application.js..."
194
+ insert_into_file "app/assets/javascripts/application.js", "//= require jquery.remotipart\n", :before => "//= require_tree .\n"
195
+
196
+ say "- Paper_trail install..."
197
+ generate "paper_trail:install"
198
+
199
+ say "- Generate models and tables and views for translations..."
200
+ # using generate this way http://api.rubyonrails.org/classes/Rails/Generators/Actions.html#method-i-generate
201
+ # run "bundle install"
202
+ say "- Installaing ZURB Foundation..."
203
+ generate "foundation:install"
204
+
205
+ say "- Generate models and tables and views for translations..."
206
+ generate "inline_forms", "InlineFormsLocale name:string inline_forms_translations:belongs_to _enabled:yes _presentation:\#{name}"
207
+ generate "inline_forms", "InlineFormsKey name:string inline_forms_translations:has_many inline_forms_translations:associated _enabled:yes _presentation:\#{name}"
208
+ generate "inline_forms", "InlineFormsTranslation inline_forms_key:belongs_to inline_forms_locale:dropdown value:text interpolations:text is_proc:boolean _presentation:\#{value}"
209
+ sleep 1 # to get unique migration number
210
+ create_file "db/migrate/" +
211
+ Time.now.utc.strftime("%Y%m%d%H%M%S") +
212
+ "_" +
213
+ "inline_forms_create_view_for_translations.rb", <<-VIEW_MIGRATION.strip_heredoc
214
+ class InlineFormsCreateViewForTranslations < ActiveRecord::Migration
215
+ def self.up
216
+ execute 'CREATE VIEW translations
217
+ AS
218
+ SELECT L.name AS locale,
219
+ K.name AS thekey,
220
+ T.value AS value,
221
+ T.interpolations AS interpolations,
222
+ T.is_proc AS is_proc
223
+ FROM inline_forms_keys K, inline_forms_locales L, inline_forms_translations T
224
+ WHERE T.inline_forms_key_id = K.id AND T.inline_forms_locale_id = L.id '
225
+ end
226
+ def self.down
227
+ execute 'DROP VIEW translations'
228
+ end
229
+ end
230
+ VIEW_MIGRATION
231
+
232
+ say "- Migrating Database (only when using sqlite)"
233
+ run "bundle exec rake db:migrate" if ENV['using_sqlite'] == 'true'
234
+
235
+ say "- Adding admin user with email: #{ENV['email']}, password: #{ENV['password']} to seeds.rb"
236
+ append_to_file "db/seeds.rb", "User.create({ :email => '#{ENV['email']}', :name => 'Admin', :password => '#{ENV['password']}', :password_confirmation => '#{ENV['password']}'}, :without_protection => true)"
237
+
238
+ say "- Seeding the database (only when using sqlite)"
239
+ run "bundle exec rake db:seed" if ENV['using_sqlite'] == 'true'
240
+
241
+ say "- Creating header in app/views/inline_forms/_header.html.erb..."
242
+ create_file "app/views/inline_forms/_header.html.erb", <<-END_HEADER.strip_heredoc
243
+ <div id='Header'>
244
+ <div id='title'>
245
+ #{app_name} v<%= inline_forms_version -%>
246
+ </div>
247
+ <% if current_user -%>
248
+ <div id='logout'>
249
+ <%= link_to \"Afmelden: \#{current_user.name}\", destroy_user_session_path, :method => :delete %>
250
+ </div>
251
+ <% end -%>
252
+ <div style='clear: both;'></div>
253
+ </div>
254
+ END_HEADER
255
+
256
+ say "- Recreating ApplicationHelper to set application_name and application_title..."
257
+ remove_file "app/helpers/application_helper.rb" # the one that 'rails new' created
258
+ create_file "app/helpers/application_helper.rb", <<-END_APPHELPER.strip_heredoc
259
+ module ApplicationHelper
260
+ def application_name
261
+ '#{app_name}'
262
+ end
263
+ def application_title
264
+ '#{app_name}'
265
+ end
266
+ end
267
+ END_APPHELPER
268
+
269
+ say "- Recreating ApplicationController to add devise, cancan, I18n stuff..."
270
+ remove_file "app/controllers/application_controller.rb" # the one that 'rails new' created
271
+ create_file "app/controllers/application_controller.rb", <<-END_APPCONTROLLER.strip_heredoc
272
+ class ApplicationController < InlineFormsApplicationController
273
+ protect_from_forgery
274
+
275
+ # Comment next two lines if you don't want Devise authentication
276
+ before_filter :authenticate_user!
277
+ layout 'devise' if :devise_controller?
278
+
279
+ # Comment next 6 lines if you want CanCan authorization
280
+ enable_authorization :unless => :devise_controller?
281
+
282
+ rescue_from CanCan::Unauthorized do |exception|
283
+ sign_out :user if user_signed_in?
284
+ redirect_to new_user_session_path, :alert => exception.message
285
+ end
286
+
287
+ # Uncomment next line if you want I18n (based on subdomain)
288
+ # before_filter :set_locale
289
+
290
+ # Uncomment next line and specify default locale
291
+ # I18n.default_locale = :en
292
+
293
+ # Uncomment next line and specify available locales
294
+ # I18n.available_locales = [ :en, :nl, :pp ]
295
+
296
+ # Uncomment next nine line if you want locale based on subdomain, like 'it.example.com, de.example.com'
297
+ # def set_locale
298
+ # I18n.locale = extract_locale_from_subdomain || I18n.default_locale
299
+ # end
300
+ #
301
+ # def extract_locale_from_subdomain
302
+ # locale = request.subdomains.first
303
+ # return nil if locale.nil?
304
+ # I18n.available_locales.include?(locale.to_sym) ? locale.to_s : nil
305
+ # end
306
+ end
307
+ END_APPCONTROLLER
308
+
309
+ say "- Creating Ability model so that the user with id = 1 can access all..."
310
+ create_file "app/models/ability.rb", <<-END_ABILITY.strip_heredoc
311
+ class Ability
312
+ include CanCan::Ability
313
+
314
+ def initialize(user)
315
+ # See the wiki for details: https://github.com/ryanb/cancan/wiki/Defining-Abilities
316
+
317
+ user ||= user.new # guest user
318
+
319
+ if user.id == 1 #quick hack
320
+ can :access, :all
321
+ else
322
+ # put restrictions for other users here
323
+ end
324
+ end
325
+ end
326
+ END_ABILITY
327
+
328
+ say "- Generating test files", :green
329
+ # run "bundle exec rspec:install" # TODO: I need do this or simply copy the files in the spec folder ?
330
+ create_file "spec/spec_helper.rb", <<-END_TEST_HELPER.strip_heredoc
331
+ # This file is copied to spec/ when you run 'rails generate rspec:install'
332
+ ENV["RAILS_ENV"] ||= 'development' # this need to be changed to test ???
333
+ require File.expand_path("../../config/environment", __FILE__)
334
+ require 'capybara/rspec'
335
+ require 'rspec/rails'
336
+ require 'rspec/autorun'
337
+ require 'carrierwave/test/matchers'
338
+
339
+
340
+ # Requires supporting ruby files with custom matchers and macros, etc,
341
+ # in spec/support/ and its subdirectories.
342
+ Dir[Rails.root.join("spec/support/**/*.rb")].each { |f| require f }
343
+
344
+ RSpec.configure do |config|
345
+ config.include FactoryGirl::Syntax::Methods
346
+ # ## Mock Framework
347
+ #
348
+ # If you prefer to use mocha, flexmock or RR, uncomment the appropriate line:
349
+ #
350
+ # config.mock_with :mocha
351
+ # config.mock_with :flexmock
352
+ # config.mock_with :rr
353
+
354
+ # Remove this line if you're not using ActiveRecord or ActiveRecord fixtures
355
+ config.fixture_path = Rails.root + "/spec/fixtures"
356
+
357
+ # If you're not using ActiveRecord, or you'd prefer not to run each of your
358
+ # examples within a transaction, remove the following line or assign false
359
+ # instead of true.
360
+ config.use_transactional_fixtures = true
361
+
362
+ # If true, the base class of anonymous controllers will be inferred
363
+ # automatically. This will be the default behavior in future versions of
364
+ # rspec-rails.
365
+ config.infer_base_class_for_anonymous_controllers = false
366
+
367
+ # Run specs in random order to surface order dependencies. If you find an
368
+ # order dependency and want to debug it, you can fix the order by providing
369
+ # the seed, which is printed after each run.
370
+ # --seed 1234
371
+ config.order = "random"
372
+ end
373
+ END_TEST_HELPER
374
+ say 'copy test image into rspec folder'
375
+ copy_file File.join(File.dirname(File.expand_path(__FILE__)) + '/../lib/otherstuff/fixtures/rails.png'), "spec/fixtures/images/rails.png"
376
+ say '- Creating factory_girl file'
377
+ create_file "spec/factories/inline_forms.rb", <<-END_FACTORY_GIRL.strip_heredoc
378
+ FactoryGirl.define do
379
+ factory :apartment do
380
+ name "Luxe House in Bandabou 147A" #string
381
+ title "A dream house in a dream place" # string
382
+ description "A beatiful House at the edge of the <strong>sea</strong>" #text
383
+ end
384
+ factory :large_text do
385
+ name "Luxe House in Bandabou 147A" #string
386
+ title "A dream house in a dream place" # string
387
+ description "A beatiful House at the edge of the <strong>sea</strong>" #text
388
+ end
389
+ end
390
+ END_FACTORY_GIRL
391
+ remove_file 'spec/factories/users.rb'
392
+ remove_file 'spec/models/user_spec.rb'
393
+ if ENV['install_example'] == 'true'
394
+ say "\nInstalling example application..."
395
+ run 'bundle exec rails g inline_forms Photo name:string caption:string image:image_field description:text apartment:belongs_to _presentation:\'#{name}\'' # FIXME temporary changed because ckeditor is playing dirty
396
+ run 'bundle exec rails generate uploader Image'
397
+ run 'bundle exec rails g inline_forms Apartment name:string title:string description:text photos:has_many photos:associated _enabled:yes _presentation:\'#{name}\'' # FIXME temporary changed because ckeditor is playing dirty
398
+ run 'bundle exec rake db:migrate'
399
+ say '-Adding example test'
400
+ create_file "spec/models/#{app_name}_example.rb", <<-END_EXAMPLE_TEST.strip_heredoc
401
+ require "spec_helper"
402
+ describe Apartment do
403
+ it "insert an appartment and retrieve it" do
404
+ appartment_data = create(:apartment)
405
+ first = Apartment.first.id
406
+ expect(Apartment.first.id).to eq(first)
407
+ end
408
+ end
409
+ END_EXAMPLE_TEST
410
+ # run tests
411
+ if ENV['runtest'] == 'true' # Not Dry
412
+ run "rspec"
413
+ end
414
+ say "\nDone! Now point your browser to http://localhost:3000/apartments !", :yellow
415
+ say "\nPress ctlr-C to quit...", :yellow
416
+ run 'bundle exec rails s'
417
+ else
418
+ say "\nDone! Now make your tables with 'bundle exec rails g inline_forms ...", :yellow
419
+ # run tests
420
+ if ENV['runtest'] == 'true'
421
+ run "rspec"
422
+ end
423
+ end
@@ -1,4 +1,4 @@
1
1
  # -*- encoding : utf-8 -*-
2
2
  module InlineForms
3
- VERSION = "1.6.67"
3
+ VERSION = "1.6.68"
4
4
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: inline_forms
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.6.67
4
+ version: 1.6.68
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ace Suares
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-04-03 00:00:00.000000000 Z
11
+ date: 2014-04-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rvm
@@ -157,6 +157,7 @@ email:
157
157
  executables:
158
158
  - inline_forms
159
159
  - inline_forms_app_template.rb
160
+ - inline_forms_installer_core.rb
160
161
  extensions: []
161
162
  extra_rdoc_files: []
162
163
  files:
@@ -169,6 +170,7 @@ files:
169
170
  - Rakefile
170
171
  - bin/inline_forms
171
172
  - bin/inline_forms_app_template.rb
173
+ - bin/inline_forms_installer_core.rb
172
174
  - inline_forms.gemspec
173
175
  - lib/app/assets/images/devise_footer_left.png
174
176
  - lib/app/assets/images/devise_footer_right.png