inline_forms 2.23 → 3.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.
Files changed (51) hide show
  1. checksums.yaml +9 -9
  2. data/.gitignore +5 -0
  3. data/bin/inline_forms +41 -414
  4. data/bin/inline_forms_app_template.rb +16 -0
  5. data/bin/inline_forms_installer_core.rb +423 -0
  6. data/lib/app/assets/javascripts/inline_forms.js +12 -32
  7. data/lib/app/assets/javascripts/inline_forms_application.js +7 -1
  8. data/lib/app/assets/stylesheets/inline_forms.css +5 -399
  9. data/lib/app/assets/stylesheets/inline_forms_application.css +3 -3
  10. data/lib/app/controllers/inline_forms_application_controller.rb +1 -2
  11. data/lib/app/controllers/inline_forms_controller.rb +2 -2
  12. data/lib/app/helpers/form_elements/check_list.rb +7 -14
  13. data/lib/app/helpers/form_elements/date.rb +3 -8
  14. data/lib/app/helpers/form_elements/decimal_field.rb +15 -0
  15. data/lib/app/helpers/form_elements/dropdown.rb +1 -1
  16. data/lib/app/helpers/form_elements/dropdown_with_other.rb +153 -0
  17. data/lib/app/helpers/form_elements/dropdown_with_values.rb +1 -1
  18. data/lib/app/helpers/form_elements/info_list.rb +22 -0
  19. data/lib/app/helpers/form_elements/integer_field.rb +15 -0
  20. data/lib/app/helpers/form_elements/kansen_slider.rb +89 -0
  21. data/lib/app/helpers/form_elements/month_year_picker.rb +33 -0
  22. data/lib/app/helpers/form_elements/move.rb +17 -0
  23. data/lib/app/helpers/form_elements/plain_text_area.rb +1 -1
  24. data/lib/app/helpers/form_elements/radio_button.rb +5 -6
  25. data/lib/app/helpers/form_elements/slider_with_values.rb +1 -1
  26. data/lib/app/helpers/form_elements/text_area.rb +12 -10
  27. data/lib/app/helpers/form_elements/text_area_without_ckeditor.rb +1 -1
  28. data/lib/app/helpers/form_elements/text_field.rb +2 -2
  29. data/lib/app/helpers/inline_forms_helper.rb +32 -37
  30. data/lib/app/views/inline_forms/_close.html.erb +12 -2
  31. data/lib/app/views/inline_forms/_edit.html.erb +54 -21
  32. data/lib/app/views/inline_forms/_flash.html.erb +13 -0
  33. data/lib/app/views/inline_forms/_list.html.erb +28 -24
  34. data/lib/app/views/inline_forms/_new.html.erb +52 -60
  35. data/lib/app/views/inline_forms/_new_nested.html.erb +43 -0
  36. data/lib/app/views/inline_forms/_show.html.erb +83 -39
  37. data/lib/app/views/inline_forms/_tree.html.erb +46 -0
  38. data/lib/app/views/layouts/devise.html.erb +4 -14
  39. data/lib/app/views/layouts/inline_forms.html.erb +15 -23
  40. data/lib/inline_forms/version.rb +1 -1
  41. metadata +17 -13
  42. data/lib/app/assets/images/add.png +0 -0
  43. data/lib/app/assets/images/close.png +0 -0
  44. data/lib/app/assets/images/tooltip-bubble-down-left.png +0 -0
  45. data/lib/app/assets/images/tooltip-bubble-down-right.png +0 -0
  46. data/lib/app/assets/images/tooltip-bubble-up-left.png +0 -0
  47. data/lib/app/assets/images/tooltip-bubble-up-right.png +0 -0
  48. data/lib/app/assets/images/trash.png +0 -0
  49. data/lib/app/assets/javascripts/jquery.qtip.js +0 -3395
  50. data/lib/app/assets/stylesheets/jquery.qtip.css +0 -567
  51. data/lib/app/views/inline_forms/_header.html.erb +0 -1
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- MTU2ZmZiNTYxMGU3ODJlNWIzZWYwZjNiY2NhYmNlNWIyYWY3NDViMQ==
4
+ ODIwYWFkZGM0NTgwODE0NGRhNmFlNTliMjE3MDQ3YTEzMTc0YmRkYg==
5
5
  data.tar.gz: !binary |-
6
- ZTNjM2E5MTI5ZTcwNjFkZGY0NDBmM2E3M2RjOWNlOTc3YTEwN2JjNw==
7
- !binary "U0hBNTEy":
6
+ MjU0NTk0NzgwNjJlMDRjNGM3NDU3YWQxZDJhZjVlZTRmNzUwMzYxMA==
7
+ SHA512:
8
8
  metadata.gz: !binary |-
9
- MTU3ODU1NmRjZGExMmVkMzRiNzE1ZWU0NzdmMWE2ODM5MDFhYmQ5ZmI3NDM0
10
- ZDI4MDc4ODc0MDM2NWFhNDIxMWVmMDkxYzg1YWE4Njc4MzI4ZDcxMjI5ODli
11
- ZDlkMjAxMzhkNzUxZDQzMWViOWExNjI2NmY5MzIzMDhhYjVmNDU=
9
+ ZjU1ZDI5MjA1YzBhMTIxMWYyNzA1MzlkZjdhOTdkMDcwOTdhZmUxNDcyMDcx
10
+ NmQyZDdiOGI2YTY2ZjY2ZjQzMzUyM2Q2YTU5YzEwYjcxNWVlM2VmNDJmNDAz
11
+ OTQxYjcyNWQyNjUyNzUwOThkNDRjYTA2NTM5MDQ1ZjY1MDNlZjk=
12
12
  data.tar.gz: !binary |-
13
- MzhjYjFiODhjNjA1OGZhYThmZmMwYmE5NjM1YjU2MGQ5ZWU2NmZhMTE2MTE1
14
- OTkxMWMyODhmZjdkOTUwNDUyNDMzMWYwYWIxNWVjOTlhZDYxNzNlZWNiY2Ux
15
- NTE5ZWIyNjljNjNlMGIxMWJmN2JjY2QxNGNkNzQ1YjEzZDNlMTk=
13
+ MDEyN2RlMGM0MjQ2YjgxMTBhMDRhMmY3ZmY0YWZkOGJjOTM1MTFjZDlmZDdl
14
+ MDNhYjA5MDk5M2RlMWM3ZWFkZDkxNTk1ZmU2NWYwZTFiNjA5NWU3NThkMTFl
15
+ NTdkZDQ5MTE4MmYyMmNkNmMzNGRjMjdmMjQ2NWM1ZjVmMDVkNDI=
data/.gitignore CHANGED
@@ -40,3 +40,8 @@ pkg
40
40
  #
41
41
  # For vim:
42
42
  #*.swp
43
+ .project
44
+ .ruby-version
45
+ .ruby-gemset
46
+ .gitignore
47
+ bin/LETOVER
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,412 +80,46 @@ module InlineForms
87
80
  exit 1
88
81
  end
89
82
 
90
- if dry_run?
91
- empty_directory(app_name)
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
92
97
  else
93
- if ! run("rails 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
98
+ # Let the user know that he is installing inline_forms without RVM
99
+ say "Installing inline_forms without RVM", :green
97
100
  end
98
101
 
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', '~> 3.0.0'
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", "\nmount Ckeditor::Engine => \"/ckeditor\"\n", :after => "routes.draw do\n"
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
- # run "bundle exec rails generate ckeditor:install --orm=active_record --backend=carrierwave" unless dry_run?
286
-
287
- say "- Create ckeditor config.js"
288
- copy_file "lib/app/assets/javascripts/ckeditor/config.js", "#{app_name}/app/assets/javascripts/ckeditor/config.js"
289
-
290
- say "- Add remotipart to application.js..."
291
- create_file "#{app_name}/app/assets/javascripts/application.js", "//= require_tree .\n" if dry_run?
292
- insert_into_file "#{app_name}/app/assets/javascripts/application.js", "//= require jquery.remotipart\n", :before => "//= require_tree .\n"
293
-
294
- say "- Add ckeditor to application.js..."
295
- insert_into_file "#{app_name}/app/assets/javascripts/application.js", "//= require ckeditor/init\n", :before => "//= require_tree .\n"
296
-
297
- say "- Paper_trail install..."
298
- run "bundle exec rails g paper_trail:install" unless dry_run?
299
-
300
- say "- Installaing ZURB Foundation..."
301
- run "bundle exec rails g foundation:install"
302
-
303
- say "- Generate models and tables and views for translations..."
304
- run 'bundle exec rails g inline_forms InlineFormsLocale name:string inline_forms_translations:belongs_to _enabled:yes _presentation:\'#{name}\''
305
- run 'bundle exec rails g inline_forms InlineFormsKey name:string inline_forms_translations:has_many inline_forms_translations:associated _enabled:yes _presentation:\'#{name}\''
306
- 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}\''
307
-
308
- sleep 1 # to get unique migration number
309
- create_file "#{app_name}/db/migrate/" +
310
- Time.now.utc.strftime("%Y%m%d%H%M%S") +
311
- "_" +
312
- "inline_forms_create_view_for_translations.rb", <<-VIEW_MIGRATION.strip_heredoc_with_indent
313
- class InlineFormsCreateViewForTranslations < ActiveRecord::Migration
314
-
315
- def self.up
316
- execute 'CREATE VIEW translations
317
- AS
318
- SELECT L.name AS locale,
319
- K.name AS thekey,
320
- T.value AS value,
321
- T.interpolations AS interpolations,
322
- T.is_proc AS is_proc
323
- FROM inline_forms_keys K, inline_forms_locales L, inline_forms_translations T
324
- WHERE T.inline_forms_key_id = K.id AND T.inline_forms_locale_id = L.id '
325
- end
326
-
327
- def self.down
328
- execute 'DROP VIEW translations'
329
- end
330
-
331
- end
332
- VIEW_MIGRATION
102
+ if dry_run?
103
+ empty_directory(app_name)
104
+ else
105
+ empty_directory(app_name)
333
106
 
334
- say "- Migrating Database"
335
- run "bundle exec rake db:migrate" unless (dry_run? || !using_sqlite?)
336
-
337
- say "- Adding admin user with email: #{email}, password: #{password} to seeds.rb"
338
- append_to_file "#{app_name}/db/seeds.rb", "User.new({ :email => '#{email}', :name => 'Admin', :password => '#{password}', :password_confirmation => '#{password}'}).save"
339
-
340
- say "- Seeding the database"
341
- run "bundle exec rake db:seed" unless (dry_run? || !using_sqlite?)
342
-
343
- say "- Creating header in app/views/inline_forms/_header.html.erb..."
344
- create_file "#{app_name}/app/views/inline_forms/_header.html.erb", <<-END_HEADER.strip_heredoc_with_indent
345
- <div id='Header'>
346
- <div id='title'>
347
- #{app_name} v<%= inline_forms_version -%>
348
- </div>
349
- <% if current_user -%>
350
- <div id='logout'>
351
- <%= link_to \"Afmelden: \#{current_user.name}\", destroy_user_session_path, :method => :delete %>
352
- </div>
353
- <% end -%>
354
- <div style='clear: both;'></div>
355
- </div>
356
- END_HEADER
357
-
358
- say "- Recreating ApplicationHelper to set application_name and application_title..."
359
- remove_file "#{app_name}/app/helpers/application_helper.rb" # the one that 'rails new' created
360
- create_file "#{app_name}/app/helpers/application_helper.rb", <<-END_APPHELPER.strip_heredoc_with_indent
361
- module ApplicationHelper
362
- def application_name
363
- '#{app_name}'
364
- end
365
- def application_title
366
- '#{app_name}'
367
- end
368
- end
369
- END_APPHELPER
370
-
371
- say "- Recreating ApplicationController to add devise, cancan, I18n stuff..."
372
- remove_file "#{app_name}/app/controllers/application_controller.rb" # the one that 'rails new' created
373
- create_file "#{app_name}/app/controllers/application_controller.rb", <<-END_APPCONTROLLER.strip_heredoc_with_indent
374
- class ApplicationController < InlineFormsApplicationController
375
- protect_from_forgery
376
-
377
- # Comment next two lines if you don't want Devise authentication
378
- before_filter :authenticate_user!
379
- layout 'devise' if :devise_controller?
380
-
381
- # Comment next 6 lines if you want CanCan authorization
382
- enable_authorization :unless => :devise_controller?
383
-
384
- rescue_from CanCan::Unauthorized do |exception|
385
- sign_out :user if user_signed_in?
386
- redirect_to new_user_session_path, :alert => exception.message
387
- end
388
-
389
- # Uncomment next line if you want I18n (based on subdomain)
390
- # before_filter :set_locale
391
-
392
- # Uncomment next line and specify default locale
393
- # I18n.default_locale = :en
394
-
395
- # Uncomment next line and specify available locales
396
- # I18n.available_locales = [ :en, :nl, :pp ]
397
-
398
- # Uncomment next nine line if you want locale based on subdomain, like 'it.example.com, de.example.com'
399
- # def set_locale
400
- # I18n.locale = extract_locale_from_subdomain || I18n.default_locale
401
- # end
402
- #
403
- # def extract_locale_from_subdomain
404
- # locale = request.subdomains.first
405
- # return nil if locale.nil?
406
- # I18n.available_locales.include?(locale.to_sym) ? locale.to_s : nil
407
- # end
408
- end
409
- END_APPCONTROLLER
410
-
411
- say "- Creating Ability model so that the user with id = 1 can access all..."
412
- create_file "#{app_name}/app/models/ability.rb", <<-END_ABILITY.strip_heredoc_with_indent
413
- class Ability
414
- include CanCan::Ability
415
-
416
- def initialize(user)
417
- # See the wiki for details: https://github.com/ryanb/cancan/wiki/Defining-Abilities
418
-
419
- user ||= user.new # guest user
420
-
421
- if user.id == 1 #quick hack
422
- can :access, :all
423
- else
424
- # put restrictions for other users here
425
- end
426
- end
427
- end
428
- END_ABILITY
429
-
430
- # create environments/production.rb if it's a dry run
431
- create_file "#{app_name}/config/environments/production.rb", " # config.assets.precompile += %w( search.js )\nend\n" if dry_run?
432
-
433
- say "- Injecting precompile assets stuff in environments/production.rb..."
434
- insert_into_file "#{app_name}/config/environments/production.rb",
435
- " config.assets.precompile += %w(inline_forms_application.js inline_forms_application.css devise.css)\n",
436
- :after => " # config.assets.precompile += %w( search.js )\n"
437
-
438
- say "- Injecting devise mailer stuff in environments/production.rb..."
439
- insert_into_file "#{app_name}/config/environments/production.rb", <<-DEVISE_MAILER_STUFF.strip_heredoc_with_indent(2), :before => "end\n"
440
-
441
- # for devise
442
- config.action_mailer.default_url_options = { :protocol => 'https', :host => 'YOURHOSTNAME' }
443
- config.action_mailer.delivery_method = :smtp
444
- config.action_mailer.smtp_settings = {
445
- :address => 'YOURMAILSERVER',
446
- :enable_starttls_auto => true,
447
- :password => 'YOURPASSWORD',
448
- :user_name => 'YOURUSERNAME'
449
- }
450
-
451
- DEVISE_MAILER_STUFF
452
-
453
- say "- Setting autoload paths for ckeditor..."
454
- 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?
455
-
456
- say "- Adding cancan authorization to ckeditor"
457
- gsub_file "#{app_name}/config/initializers/ckeditor.rb", "# config.authorize_with :cancan", "config.authorize_with :cancan" if File.exists?("#{app_name}/config/initializers/ckeditor.rb")
458
-
459
- say "- Capify..."
460
- run 'capify .'
461
- remove_file "#{app_name}/config/deploy.rb" # remove the file capify created!
462
- copy_file "lib/generators/templates/deploy.rb", "#{app_name}/config/deploy.rb"
463
-
464
- say "- Unicorn Config..."
465
- copy_file "lib/generators/templates/unicorn.rb", "#{app_name}/config/unicorn.rb"
466
-
467
- say "- Initializing git..."
468
- run 'git init'
469
- create_file "#{app_name}/.gitignore", "/tmp\n" if dry_run?
470
- insert_into_file "#{app_name}/.gitignore", <<-GITIGNORE.strip_heredoc_with_indent, :after => "/tmp\n"
471
- # netbeans
472
- nbproject
473
- # remotipart uploads
474
- public/uploads
475
- GITIGNORE
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
476
114
 
477
- run 'git add .'
478
- run 'git commit -a -m " * Initial"'
115
+ app_template_file = File.join(File.dirname(__FILE__), 'inline_forms_app_template.rb')
479
116
 
480
- if install_example?
481
- say "\nInstalling example application..."
482
- run 'bundle exec rails g inline_forms Picture name:string caption:string image:image_field description:text apartment:belongs_to _presentation:\'#{name}\''
483
- run 'bundle exec rails generate uploader Image'
484
- run 'bundle exec rails g inline_forms Apartment name:string title:string description:text pictures:has_many pictures:associated _enabled:yes _presentation:\'#{name}\''
485
- run 'bundle exec rake db:migrate'
486
- say "\nDone! Now point your browser to http://localhost:3000/apartments !", :yellow
487
- say "\nPress ctlr-C to quit...", :yellow
488
- run 'bundle exec rails s'
489
- else
490
- say "\nDone! Now make your tables with 'bundle exec rails g inline_forms ...", :yellow
491
- #say "- Don't forget: edit .rvmrc, config/{routes.rb, deploy.rb}, .git/config, delete public/index.html\n"
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
492
120
  end
493
-
494
121
  end
495
122
  end
496
123
  Creator.start
497
124
  end
498
- end
125
+ end