inline_forms 1.6.70 → 2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (53) hide show
  1. data/.gitignore +42 -0
  2. data/bin/inline_forms +419 -40
  3. data/inline_forms.gemspec +1 -1
  4. data/lib/app/assets/images/add.png +0 -0
  5. data/lib/app/assets/images/close.png +0 -0
  6. data/lib/app/assets/images/tooltip-bubble-down-left.png +0 -0
  7. data/lib/app/assets/images/tooltip-bubble-down-right.png +0 -0
  8. data/lib/app/assets/images/tooltip-bubble-up-left.png +0 -0
  9. data/lib/app/assets/images/tooltip-bubble-up-right.png +0 -0
  10. data/lib/app/assets/images/trash.png +0 -0
  11. data/lib/app/assets/javascripts/ckeditor/config.js +40 -39
  12. data/lib/app/assets/javascripts/inline_forms.js +32 -12
  13. data/lib/app/assets/javascripts/inline_forms_application.js +1 -7
  14. data/lib/app/assets/javascripts/jquery.qtip.js +3395 -0
  15. data/lib/app/assets/stylesheets/inline_forms.css +399 -5
  16. data/lib/app/assets/stylesheets/inline_forms_application.css +3 -3
  17. data/lib/app/assets/stylesheets/jquery.qtip.css +567 -0
  18. data/lib/app/controllers/inline_forms_application_controller.rb +2 -1
  19. data/lib/app/controllers/inline_forms_controller.rb +2 -2
  20. data/lib/app/helpers/form_elements/check_list.rb +14 -7
  21. data/lib/app/helpers/form_elements/date.rb +8 -3
  22. data/lib/app/helpers/form_elements/dropdown.rb +1 -1
  23. data/lib/app/helpers/form_elements/dropdown_with_values.rb +1 -1
  24. data/lib/app/helpers/form_elements/plain_text_area.rb +1 -1
  25. data/lib/app/helpers/form_elements/radio_button.rb +6 -5
  26. data/lib/app/helpers/form_elements/slider_with_values.rb +1 -1
  27. data/lib/app/helpers/form_elements/text_area.rb +10 -12
  28. data/lib/app/helpers/form_elements/text_area_without_ckeditor.rb +1 -1
  29. data/lib/app/helpers/form_elements/text_field.rb +2 -2
  30. data/lib/app/helpers/inline_forms_helper.rb +37 -32
  31. data/lib/app/views/inline_forms/_close.html.erb +2 -12
  32. data/lib/app/views/inline_forms/_edit.html.erb +21 -54
  33. data/lib/app/views/inline_forms/_header.html.erb +1 -0
  34. data/lib/app/views/inline_forms/_list.html.erb +24 -28
  35. data/lib/app/views/inline_forms/_new.html.erb +50 -52
  36. data/lib/app/views/inline_forms/_show.html.erb +39 -83
  37. data/lib/app/views/layouts/devise.html.erb +14 -4
  38. data/lib/app/views/layouts/inline_forms.html.erb +23 -15
  39. data/lib/inline_forms/version.rb +1 -1
  40. metadata +41 -23
  41. checksums.yaml +0 -15
  42. data/bin/inline_forms_app_template.rb +0 -16
  43. data/bin/inline_forms_installer_core.rb +0 -423
  44. data/lib/app/helpers/form_elements/decimal_field.rb +0 -15
  45. data/lib/app/helpers/form_elements/dropdown_with_other.rb +0 -153
  46. data/lib/app/helpers/form_elements/info_list.rb +0 -22
  47. data/lib/app/helpers/form_elements/integer_field.rb +0 -15
  48. data/lib/app/helpers/form_elements/kansen_slider.rb +0 -89
  49. data/lib/app/helpers/form_elements/month_year_picker.rb +0 -33
  50. data/lib/app/helpers/form_elements/move.rb +0 -17
  51. data/lib/app/views/inline_forms/_flash.html.erb +0 -13
  52. data/lib/app/views/inline_forms/_new_nested.html.erb +0 -43
  53. data/lib/app/views/inline_forms/_tree.html.erb +0 -46
data/.gitignore ADDED
@@ -0,0 +1,42 @@
1
+ # rcov generated
2
+ coverage
3
+
4
+ # rdoc generated
5
+ rdoc
6
+
7
+ # yard generated
8
+ doc
9
+ .yardoc
10
+
11
+ # bundler
12
+ .bundle
13
+
14
+ # jeweler generated
15
+ pkg
16
+
17
+ # Have editor/IDE/OS specific files you need to ignore? Consider using a global gitignore:
18
+ #
19
+ # * Create a file at ~/.gitignore
20
+ # * Include files you want ignored
21
+ # * Run: git config --global core.excludesfile ~/.gitignore
22
+ #
23
+ # After doing this, these files will be ignored in all your git projects,
24
+ # saving you from having to 'pollute' every project you touch with them
25
+ #
26
+ # Not sure what to needs to be ignored for particular editors/OSes? Here's some ideas to get you started. (Remember, remove the leading # of the line)
27
+ #
28
+ # For MacOS:
29
+ #
30
+ #.DS_Store
31
+ #
32
+ # For TextMate
33
+ #*.tmproj
34
+ #tmtags
35
+ #
36
+ # For emacs:
37
+ #*~
38
+ #\#*
39
+ #.\#*
40
+ #
41
+ # For vim:
42
+ #*.swp
data/bin/inline_forms CHANGED
@@ -1,17 +1,33 @@
1
1
  #!/usr/bin/env ruby
2
2
  module InlineForms
3
+
3
4
  require File.join(File.dirname(__FILE__), "../lib/inline_forms/version.rb")
4
5
 
6
+ require 'rvm'
7
+ if not RVM.current
8
+ puts "ruby or rvm not found"
9
+ exit 2
10
+ end
11
+
5
12
  # what is this?
6
13
  Signal.trap("INT") { puts; exit }
7
14
 
8
15
  require 'thor'
16
+
9
17
  class Creator < Thor
10
18
  include Thor::Actions
11
19
 
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
+
12
27
  def self.source_root
13
28
  File.dirname(__FILE__)+"/.."
14
29
  end
30
+
15
31
  desc "create APP", "create an application with inline_forms v#{VERSION}"
16
32
  DATABASE_OPTIONS = %w(sqlite mysql)
17
33
  method_option :database, :aliases => "-d", :default => DATABASE_OPTIONS.first, :banner => DATABASE_OPTIONS.join('|'), :desc => 'specify development database'
@@ -19,17 +35,8 @@ module InlineForms
19
35
  method_option :example, :type => :boolean, :desc => 'install the example app. incompatible with --dry and uses sqlite as development database'
20
36
  method_option :email, :aliases => "-e", :default => "admin@example.com", :desc => 'specify admin email'
21
37
  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'
24
38
 
25
39
  def create(app_name)
26
- def self.skiprvm
27
- options[:skiprvm]
28
- end
29
-
30
- def self.runtest
31
- options[:runtest]
32
- end
33
40
 
34
41
  def self.dry_run?
35
42
  options[:dry]
@@ -80,46 +87,418 @@ module InlineForms
80
87
  exit 1
81
88
  end
82
89
 
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
-
102
90
  if dry_run?
103
91
  empty_directory(app_name)
104
92
  else
105
- empty_directory(app_name)
93
+ if ! run("rails _3.2.12_ new #{app_name} --skip-bundle --skip-gemfile --skip-test-unit")
94
+ say "Rails could not create the app '#{app_name}', maybe because it is a reserved word...", :red
95
+ exit 1
96
+ end
97
+ end
98
+
99
+ ruby_version = (%x[rvm current]).gsub(/@.*/,'')
100
+ create_file "#{app_name}/.ruby-version", "#{ruby_version.chop}@#{app_name}"
101
+
102
+ say "chdir: '#{app_name}'...", :green
103
+ RVM.chdir(app_name) do
104
+ RVM.gemset_use! app_name
105
+ say "- Working directory is now #{`pwd`}"
106
+ say "- RVM gemset is now #{%x[rvm current]}"
107
+
108
+ create_file "#{app_name}/Gemfile", <<-END_GEMFILE.strip_heredoc_with_indent
109
+ # generated by inline_forms v#{VERSION}
110
+
111
+ source 'http://rubygems.org'
112
+
113
+ gem 'rails', '3.2.12'
114
+ gem 'rake', '10.0.4'
115
+ gem 'jquery-rails', '~> 2.3.0'
116
+ gem 'jquery-ui-rails'
117
+ gem 'capistrano'
118
+ gem 'will_paginate', :git => 'git://github.com/acesuares/will_paginate.git'
119
+ gem 'tabs_on_rails', :git => 'git://github.com/acesuares/tabs_on_rails.git', :branch => 'update_remote'
120
+ gem 'ckeditor'
121
+ gem 'cancan', :git => 'git://github.com/acesuares/cancan.git', :branch => '2.0'
122
+ gem 'carrierwave'
123
+ gem 'remotipart', '~> 1.0'
124
+ gem 'paper_trail'
125
+ gem 'devise'
126
+ gem 'inline_forms'
127
+ gem 'validation_hints'
128
+ gem 'mini_magick'
129
+ gem 'jquery-ui-rails'
130
+ gem 'yaml_db'
131
+ gem 'rails-i18n'
132
+ gem 'i18n-active_record', :git => 'git://github.com/acesuares/i18n-active_record.git'
133
+ gem 'unicorn'
134
+ gem 'rvm'
135
+ gem 'rvm-capistrano'
136
+
137
+ # Include everything needed to run rake, tests, features, etc.
138
+ group :development do
139
+ gem 'sqlite3'
140
+ gem 'rspec-rails'
141
+ gem 'shoulda', '>= 0'
142
+ gem 'bundler'
143
+ gem 'jeweler'
144
+ # gem 'rcov', '>= 0'
145
+ end
146
+
147
+ # these are just for production
148
+ group :production do
149
+ gem 'mysql2'
150
+ gem 'therubyracer'
151
+ gem 'uglifier', '>= 1.0.3'
152
+ end
153
+
154
+ group :assets do
155
+ gem 'sass-rails', '~> 3.2.3'
156
+ gem 'coffee-rails', '~> 3.2.1'
157
+ gem 'uglifier', '>= 1.0.3'
158
+ gem 'compass-rails' # you need this or you get an err
159
+ gem 'zurb-foundation', '~> 4.0.0'
160
+ end
161
+ END_GEMFILE
162
+
163
+ say "- Running bundle..."
164
+ run("bundle") unless dry_run?
165
+
166
+ say "- Database setup: creating config/database.yml with development database #{database}"
167
+ remove_file "#{app_name}/config/database.yml" # the one that 'rails _3.2.12_ new' created
168
+ if using_sqlite?
169
+ create_file "#{app_name}/config/database.yml", <<-END_DATABASEYML.strip_heredoc_with_indent
170
+ development:
171
+ adapter: sqlite3
172
+ database: db/development.sqlite3
173
+ pool: 5
174
+ timeout: 5000
175
+
176
+ END_DATABASEYML
177
+ else
178
+ create_file "#{app_name}/config/database.yml", <<-END_DATABASEYML.strip_heredoc_with_indent
179
+ development:
180
+ adapter: mysql2
181
+ database: #{app_name}_dev
182
+ username: #{app_name}
183
+ password: #{app_name}
184
+
185
+ END_DATABASEYML
186
+ end
187
+ append_file "#{app_name}/config/database.yml", <<-END_DATABASEYML.strip_heredoc_with_indent
188
+ production:
189
+ adapter: mysql2
190
+ database: #{app_name}_p
191
+ username: #{app_name}
192
+ password: #{app_name}444
193
+ END_DATABASEYML
194
+
195
+ say "- Devise install..."
196
+ run "bundle exec rails g devise:install" unless dry_run?
197
+
198
+ say "- Devise User model install with added name and locale field..."
199
+ run "bundle exec rails g devise User name:string locale:string" unless dry_run?
200
+
201
+ say "- Replace Devise route and add path_prefix..."
202
+ gsub_file "#{app_name}/config/routes.rb", /devise_for :users/, "devise_for :users, :path_prefix => 'auth'"
203
+ insert_into_file "#{app_name}/config/routes.rb", <<-ROUTE.strip_heredoc_with_indent(2), :after => "devise_for :users, :path_prefix => 'auth'\n"
204
+ resources :users do
205
+ post 'revert', :on => :member
206
+ end
207
+ ROUTE
208
+
209
+ say "- Mount Ckeditor::Engine to routes..."
210
+ insert_into_file "#{app_name}/config/routes.rb", 'mount Ckeditor::Engine => "/ckeditor"'
211
+
212
+ say "- Create User Controller..."
213
+ create_file "#{app_name}/app/controllers/users_controller.rb", <<-USERS_CONTROLLER.strip_heredoc_with_indent
214
+ class UsersController < InlineFormsController
215
+ set_tab :user
216
+ end
217
+ USERS_CONTROLLER
218
+
219
+ say "- Recreate User Model..."
220
+ remove_file "#{app_name}/app/models/user.rb" # the one that 'devise:install' created
221
+ create_file "#{app_name}/app/models/user.rb", <<-USER_MODEL.strip_heredoc_with_indent
222
+ class User < ActiveRecord::Base
223
+
224
+ # devise options
225
+ devise :database_authenticatable
226
+ # devise :registerable # uncomment this if you want people to be able to register
227
+ devise :recoverable
228
+ devise :rememberable
229
+ devise :trackable
230
+ devise :validatable
231
+ # devise :token_authenticatable
232
+ # devise :confirmable,
233
+ # devise :lockable
234
+ # devise :timeoutable
235
+ # devise :omniauthable
236
+
237
+ # Setup accessible (or protected) attributes for your model
238
+ attr_accessible :email, :password, :password_confirmation, :remember_me, :name, :locale
239
+ attr_writer :inline_forms_attribute_list
240
+
241
+ # validations
242
+ validates :name, :presence => true
243
+
244
+ # pagination
245
+ attr_reader :per_page
246
+ @per_page = 7
247
+
248
+ has_paper_trail
249
+
250
+ def _presentation
251
+ "\#{name}"
252
+ end
253
+
254
+ def inline_forms_attribute_list
255
+ @inline_forms_attribute_list ||= [
256
+ [ :name , 'name', :text_field ],
257
+ [ :email , 'email', :text_field ],
258
+ [ :password , 'Nieuw wachtwoord', :devise_password_field ],
259
+ [ :encrypted_password , 'encrypted_password', :info ],
260
+ [ :reset_password_token , 'reset_password_token', :info ],
261
+ [ :reset_password_sent_at , 'reset_password_sent_at', :info],
262
+ [ :remember_created_at , 'remember_created_at', :info ],
263
+ [ :sign_in_count , 'sign_in_count', :info ],
264
+ [ :current_sign_in_at , 'current_sign_in_at', :info ],
265
+ [ :last_sign_in_at , 'last_sign_in_at', :info ],
266
+ [ :current_sign_in_ip , 'current_sign_in_ip', :info ],
267
+ [ :last_sign_in_ip , 'last_sign_in_ip', :info ],
268
+ [ :created_at , 'created_at', :info ],
269
+ [ :updated_at , 'updated_at', :info ],
270
+ ]
271
+ end
272
+
273
+ def self.not_accessible_through_html?
274
+ false
275
+ end
276
+
277
+ def self.order_by_clause
278
+ 'name'
279
+ end
280
+
281
+ end
282
+ USER_MODEL
283
+
284
+ say "- Install ckeditor/carrierwave..."
285
+
286
+ run "bundle exec rails generate ckeditor:install --orm=active_record --backend=carrierwave" unless dry_run?
287
+
288
+ say "- Create ckeditor config.js"
289
+ copy_file "lib/app/assets/javascripts/ckeditor/config.js", "#{app_name}/app/assets/javascripts/ckeditor/config.js"
290
+
291
+ say "- Add remotipart to application.js..."
292
+ create_file "#{app_name}/app/assets/javascripts/application.js", "//= require_tree .\n" if dry_run?
293
+ insert_into_file "#{app_name}/app/assets/javascripts/application.js", "//= require jquery.remotipart\n", :before => "//= require_tree .\n"
294
+
295
+ say "- Add ckeditor to application.js..."
296
+ insert_into_file "#{app_name}/app/assets/javascripts/application.js", "//= require ckeditor/init\n", :before => "//= require_tree .\n"
297
+
298
+ say "- Paper_trail install..."
299
+ run "bundle exec rails g paper_trail:install" unless dry_run?
300
+
301
+ say "- Installaing ZURB Foundation..."
302
+ run "bundle exec rails g foundation:install"
303
+
304
+ say "- Generate models and tables and views for translations..."
305
+ run 'bundle exec rails g inline_forms InlineFormsLocale name:string inline_forms_translations:belongs_to _enabled:yes _presentation:\'#{name}\''
306
+ run 'bundle exec rails g inline_forms InlineFormsKey name:string inline_forms_translations:has_many inline_forms_translations:associated _enabled:yes _presentation:\'#{name}\''
307
+ run 'bundle exec rails g inline_forms InlineFormsTranslation inline_forms_key:belongs_to inline_forms_locale:dropdown value:text interpolations:text is_proc:boolean _presentation:\'#{value}\''
308
+
309
+ sleep 1 # to get unique migration number
310
+ create_file "#{app_name}/db/migrate/" +
311
+ Time.now.utc.strftime("%Y%m%d%H%M%S") +
312
+ "_" +
313
+ "inline_forms_create_view_for_translations.rb", <<-VIEW_MIGRATION.strip_heredoc_with_indent
314
+ class InlineFormsCreateViewForTranslations < ActiveRecord::Migration
315
+
316
+ def self.up
317
+ execute 'CREATE VIEW translations
318
+ AS
319
+ SELECT L.name AS locale,
320
+ K.name AS thekey,
321
+ T.value AS value,
322
+ T.interpolations AS interpolations,
323
+ T.is_proc AS is_proc
324
+ FROM inline_forms_keys K, inline_forms_locales L, inline_forms_translations T
325
+ WHERE T.inline_forms_key_id = K.id AND T.inline_forms_locale_id = L.id '
326
+ end
327
+
328
+ def self.down
329
+ execute 'DROP VIEW translations'
330
+ end
331
+
332
+ end
333
+ VIEW_MIGRATION
106
334
 
107
- # need to pass all agruments for app template
108
- options.each do | k,v |
109
- ENV[k] = v.to_s
335
+ say "- Migrating Database"
336
+ run "bundle exec rake db:migrate" unless (dry_run? || !using_sqlite?)
337
+
338
+ say "- Adding admin user with email: #{email}, password: #{password} to seeds.rb"
339
+ append_to_file "#{app_name}/db/seeds.rb", "User.new({ :email => '#{email}', :name => 'Admin', :password => '#{password}', :password_confirmation => '#{password}'}).save"
340
+
341
+ say "- Seeding the database"
342
+ run "bundle exec rake db:seed" unless (dry_run? || !using_sqlite?)
343
+
344
+ say "- Creating header in app/views/inline_forms/_header.html.erb..."
345
+ create_file "#{app_name}/app/views/inline_forms/_header.html.erb", <<-END_HEADER.strip_heredoc_with_indent
346
+ <div id='Header'>
347
+ <div id='title'>
348
+ #{app_name} v<%= inline_forms_version -%>
349
+ </div>
350
+ <% if current_user -%>
351
+ <div id='logout'>
352
+ <%= link_to \"Afmelden: \#{current_user.name}\", destroy_user_session_path, :method => :delete %>
353
+ </div>
354
+ <% end -%>
355
+ <div style='clear: both;'></div>
356
+ </div>
357
+ END_HEADER
358
+
359
+ say "- Recreating ApplicationHelper to set application_name and application_title..."
360
+ remove_file "#{app_name}/app/helpers/application_helper.rb" # the one that 'rails new' created
361
+ create_file "#{app_name}/app/helpers/application_helper.rb", <<-END_APPHELPER.strip_heredoc_with_indent
362
+ module ApplicationHelper
363
+ def application_name
364
+ '#{app_name}'
365
+ end
366
+ def application_title
367
+ '#{app_name}'
368
+ end
369
+ end
370
+ END_APPHELPER
371
+
372
+ say "- Recreating ApplicationController to add devise, cancan, I18n stuff..."
373
+ remove_file "#{app_name}/app/controllers/application_controller.rb" # the one that 'rails new' created
374
+ create_file "#{app_name}/app/controllers/application_controller.rb", <<-END_APPCONTROLLER.strip_heredoc_with_indent
375
+ class ApplicationController < InlineFormsApplicationController
376
+ protect_from_forgery
377
+
378
+ # Comment next two lines if you don't want Devise authentication
379
+ before_filter :authenticate_user!
380
+ layout 'devise' if :devise_controller?
381
+
382
+ # Comment next 6 lines if you want CanCan authorization
383
+ enable_authorization :unless => :devise_controller?
384
+
385
+ rescue_from CanCan::Unauthorized do |exception|
386
+ sign_out :user if user_signed_in?
387
+ redirect_to new_user_session_path, :alert => exception.message
388
+ end
389
+
390
+ # Uncomment next line if you want I18n (based on subdomain)
391
+ # before_filter :set_locale
392
+
393
+ # Uncomment next line and specify default locale
394
+ # I18n.default_locale = :en
395
+
396
+ # Uncomment next line and specify available locales
397
+ # I18n.available_locales = [ :en, :nl, :pp ]
398
+
399
+ # Uncomment next nine line if you want locale based on subdomain, like 'it.example.com, de.example.com'
400
+ # def set_locale
401
+ # I18n.locale = extract_locale_from_subdomain || I18n.default_locale
402
+ # end
403
+ #
404
+ # def extract_locale_from_subdomain
405
+ # locale = request.subdomains.first
406
+ # return nil if locale.nil?
407
+ # I18n.available_locales.include?(locale.to_sym) ? locale.to_s : nil
408
+ # end
409
+ end
410
+ END_APPCONTROLLER
411
+
412
+ say "- Creating Ability model so that the user with id = 1 can access all..."
413
+ create_file "#{app_name}/app/models/ability.rb", <<-END_ABILITY.strip_heredoc_with_indent
414
+ class Ability
415
+ include CanCan::Ability
416
+
417
+ def initialize(user)
418
+ # See the wiki for details: https://github.com/ryanb/cancan/wiki/Defining-Abilities
419
+
420
+ user ||= user.new # guest user
421
+
422
+ if user.id == 1 #quick hack
423
+ can :access, :all
424
+ else
425
+ # put restrictions for other users here
426
+ end
427
+ end
428
+ end
429
+ END_ABILITY
430
+
431
+ # create environments/production.rb if it's a dry run
432
+ create_file "#{app_name}/config/environments/production.rb", " # config.assets.precompile += %w( search.js )\nend\n" if dry_run?
433
+
434
+ say "- Injecting precompile assets stuff in environments/production.rb..."
435
+ insert_into_file "#{app_name}/config/environments/production.rb",
436
+ " config.assets.precompile += %w(inline_forms_application.js inline_forms_application.css devise.css)\n",
437
+ :after => " # config.assets.precompile += %w( search.js )\n"
438
+
439
+ say "- Injecting devise mailer stuff in environments/production.rb..."
440
+ insert_into_file "#{app_name}/config/environments/production.rb", <<-DEVISE_MAILER_STUFF.strip_heredoc_with_indent(2), :before => "end\n"
441
+
442
+ # for devise
443
+ config.action_mailer.default_url_options = { :protocol => 'https', :host => 'YOURHOSTNAME' }
444
+ config.action_mailer.delivery_method = :smtp
445
+ config.action_mailer.smtp_settings = {
446
+ :address => 'YOURMAILSERVER',
447
+ :enable_starttls_auto => true,
448
+ :password => 'YOURPASSWORD',
449
+ :user_name => 'YOURUSERNAME'
450
+ }
451
+
452
+ DEVISE_MAILER_STUFF
453
+
454
+ say "- Setting autoload paths for ckeditor..."
455
+ insert_into_file "#{app_name}/config/application.rb", ' config.autoload_paths += %W(#{config.root}/app/models/ckeditor)\n', :after => "modules you want to be autoloadable.\n" unless dry_run?
456
+
457
+ create_file "#{app_name}/config/initializers/ckeditor.rb" unless dry_run?
458
+ insert_into_file "#{app_name}/config/initializers/ckeditor.rb", <<-CKEDITOR_INITIALIZER_FOR_CANCAN.strip_heredoc_with_indent(2)
459
+ Ckeditor.setup do |config|
460
+ config.authorize_with :cancan
110
461
  end
111
- ENV['using_sqlite'] = using_sqlite?.to_s
112
- ENV['install_example'] = install_example?.to_s
113
- ENV['ruby_version'] = ruby_version
114
462
 
115
- app_template_file = File.join(File.dirname(__FILE__), 'inline_forms_app_template.rb')
463
+ CKEDITOR_INITIALIZER_FOR_CANCAN
116
464
 
117
- if ! run("rails _3.2.12_ new #{app_name} -m #{app_template_file} --skip-bundle --skip-gemfile --skip-test-unit")
118
- say "Rails could not create the app '#{app_name}', maybe because it is a reserved word...", :red
119
- exit 1
465
+ say "- Capify..."
466
+ run 'capify .'
467
+ remove_file "#{app_name}/config/deploy.rb" # remove the file capify created!
468
+ copy_file "lib/generators/templates/deploy.rb", "#{app_name}/config/deploy.rb"
469
+
470
+ say "- Unicorn Config..."
471
+ copy_file "lib/generators/templates/unicorn.rb", "#{app_name}/config/unicorn.rb"
472
+
473
+ say "- Initializing git..."
474
+ run 'git init'
475
+ create_file "#{app_name}/.gitignore", "/tmp\n" if dry_run?
476
+ insert_into_file "#{app_name}/.gitignore", <<-GITIGNORE.strip_heredoc_with_indent, :after => "/tmp\n"
477
+ # netbeans
478
+ nbproject
479
+ # remotipart uploads
480
+ public/uploads
481
+ GITIGNORE
482
+
483
+ run 'git add .'
484
+ run 'git commit -a -m " * Initial"'
485
+
486
+ if install_example?
487
+ say "\nInstalling example application..."
488
+ run 'bundle exec rails g inline_forms Picture name:string caption:string image:image_field description:text apartment:belongs_to _presentation:\'#{name}\''
489
+ run 'bundle exec rails generate uploader Image'
490
+ run 'bundle exec rails g inline_forms Apartment name:string title:string description:text pictures:has_many pictures:associated _enabled:yes _presentation:\'#{name}\''
491
+ run 'bundle exec rake db:migrate'
492
+ say "\nDone! Now point your browser to http://localhost:3000/apartments !", :yellow
493
+ say "\nPress ctlr-C to quit...", :yellow
494
+ run 'bundle exec rails s'
495
+ else
496
+ say "\nDone! Now make your tables with 'bundle exec rails g inline_forms ...", :yellow
497
+ #say "- Don't forget: edit .rvmrc, config/{routes.rb, deploy.rb}, .git/config, delete public/index.html\n"
120
498
  end
499
+
121
500
  end
122
501
  end
123
502
  Creator.start
124
503
  end
125
- end
504
+ end