active_scaffold 3.0.26 → 3.1.3
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +1 -1
- data/{frontends/default → app/assets}/images/add.gif +0 -0
- data/{frontends/default → app/assets}/images/arrow_down.gif +0 -0
- data/{frontends/default → app/assets}/images/arrow_up.gif +0 -0
- data/{frontends/default → app/assets}/images/close.gif +0 -0
- data/{frontends/default → app/assets}/images/close_touch.png +0 -0
- data/{frontends/default → app/assets}/images/config.png +0 -0
- data/{frontends/default → app/assets}/images/cross.png +0 -0
- data/{frontends/default → app/assets}/images/gears.png +0 -0
- data/{frontends/default → app/assets}/images/indicator-small.gif +0 -0
- data/{frontends/default → app/assets}/images/indicator.gif +0 -0
- data/{frontends/default → app/assets}/images/magnifier.png +0 -0
- data/app/assets/javascripts/active_scaffold.js.erb +16 -0
- data/{frontends/default → app/assets}/javascripts/jquery/active_scaffold.js +16 -28
- data/app/assets/javascripts/jquery/active_scaffold.js~ +1036 -0
- data/{lib/active_scaffold/bridges/date_picker/public/javascripts/date_picker_bridge.js → app/assets/javascripts/jquery/date_picker_bridge.js.erb} +3 -1
- data/{frontends/default → app/assets}/javascripts/jquery/jquery.editinplace.js +0 -0
- data/app/assets/javascripts/prototype/active_scaffold.js +1033 -0
- data/{frontends/default/javascripts/prototype/active_scaffold.js → app/assets/javascripts/prototype/active_scaffold.js~} +1 -0
- data/{frontends/default → app/assets}/javascripts/prototype/dhtml_history.js +0 -0
- data/{frontends/default → app/assets}/javascripts/prototype/form_enhancements.js +0 -0
- data/{frontends/default → app/assets}/javascripts/prototype/rico_corner.js +0 -0
- data/{frontends/default/stylesheets/stylesheet-ie.css → app/assets/stylesheets/active_scaffold-ie.css} +0 -0
- data/{frontends/default/stylesheets/stylesheet.css → app/assets/stylesheets/active_scaffold.css.erb} +29 -24
- data/{lib/active_scaffold/locale → config/locales}/de.yml +3 -0
- data/{lib/active_scaffold/locale → config/locales}/en.yml +3 -0
- data/{lib/active_scaffold/locale → config/locales}/es.yml +5 -0
- data/{lib/active_scaffold/locale → config/locales}/fr.yml +3 -0
- data/{lib/active_scaffold/locale → config/locales}/hu.yml +13 -2
- data/{lib/active_scaffold/locale → config/locales}/ja.yml +9 -0
- data/{lib/active_scaffold/locale → config/locales}/ru.yml +3 -0
- data/frontends/default/views/_form.html.erb +1 -1
- data/frontends/default/views/_form_association.html.erb +1 -5
- data/frontends/default/views/_horizontal_subform.html.erb +7 -4
- data/frontends/default/views/_horizontal_subform.html.erb~ +2 -5
- data/frontends/default/views/_horizontal_subform_footer.html.erb +0 -0
- data/frontends/default/views/_horizontal_subform_header.html.erb +1 -1
- data/frontends/default/views/_horizontal_subform_header.html.erb~ +1 -1
- data/frontends/default/views/_horizontal_subform_record.html.erb~ +1 -1
- data/frontends/default/views/_list_actions.html.erb +1 -1
- data/frontends/default/views/_list_messages.html.erb +1 -3
- data/frontends/default/views/_render_field.js.erb +20 -0
- data/frontends/default/views/_row.html.erb +3 -9
- data/frontends/default/views/_show.html.erb +2 -2
- data/frontends/default/views/add_existing.js.erb +20 -0
- data/frontends/default/views/destroy.js.erb +24 -0
- data/frontends/default/views/{edit_associated.js.rjs → edit_associated.js.erb} +3 -2
- data/frontends/default/views/form_messages.js.erb +1 -0
- data/frontends/default/views/list.js.erb +1 -0
- data/frontends/default/views/mark.js.rjs +6 -0
- data/frontends/default/views/on_action_update.js.erb +13 -0
- data/frontends/default/views/{on_create.js.erb~ → on_create.js.erb} +0 -0
- data/frontends/default/views/on_mark_all.js.erb +12 -0
- data/frontends/default/views/{on_update.js.erb~ → on_update.js.erb} +0 -0
- data/frontends/default/views/render_field.js.erb +1 -0
- data/frontends/default/views/search.html.erb +1 -1
- data/frontends/default/views/{update_column.js.erb~ → update_column.js.erb} +3 -3
- data/frontends/default/views/update_row.js.erb +1 -0
- data/lib/active_scaffold.rb +22 -46
- data/lib/active_scaffold/actions/core.rb +14 -6
- data/lib/active_scaffold/actions/core.rb~ +3 -3
- data/lib/active_scaffold/actions/create.rb +2 -5
- data/lib/active_scaffold/actions/create.rb~ +3 -2
- data/lib/active_scaffold/actions/delete.rb +1 -0
- data/lib/active_scaffold/actions/field_search.rb +1 -1
- data/lib/active_scaffold/actions/list.rb +10 -6
- data/lib/active_scaffold/actions/list.rb~ +3 -3
- data/lib/active_scaffold/actions/mark.rb +8 -8
- data/lib/active_scaffold/actions/nested.rb +2 -9
- data/lib/active_scaffold/actions/nested.rb~ +5 -7
- data/lib/active_scaffold/actions/search.rb +2 -1
- data/lib/active_scaffold/actions/subform.rb +1 -5
- data/lib/active_scaffold/actions/update.rb +1 -4
- data/lib/active_scaffold/actions/update.rb~ +5 -5
- data/lib/active_scaffold/attribute_params.rb +15 -26
- data/lib/active_scaffold/attribute_params.rb~ +1 -2
- data/lib/active_scaffold/bridges.rb +61 -0
- data/lib/active_scaffold/bridges/ancestry.rb +5 -0
- data/lib/active_scaffold/bridges/ancestry/{lib/ancestry_bridge.rb → ancestry_bridge.rb} +3 -3
- data/lib/active_scaffold/bridges/{calendar_date_select/bridge.rb → calendar_date_select.rb} +13 -5
- data/lib/active_scaffold/bridges/calendar_date_select/{lib/as_cds_bridge.rb → as_cds_bridge.rb} +4 -20
- data/lib/active_scaffold/bridges/cancan.rb +15 -0
- data/lib/active_scaffold/bridges/cancan/{lib/cancan_bridge.rb → cancan_bridge.rb} +2 -2
- data/lib/active_scaffold/bridges/carrierwave.rb +12 -0
- data/lib/active_scaffold/bridges/carrierwave/carrierwave_bridge.rb +31 -0
- data/lib/active_scaffold/bridges/carrierwave/carrierwave_bridge_helpers.rb +10 -0
- data/lib/active_scaffold/bridges/carrierwave/{lib/form_ui.rb → form_ui.rb} +0 -0
- data/lib/active_scaffold/bridges/carrierwave/{lib/list_ui.rb → list_ui.rb} +1 -1
- data/lib/active_scaffold/bridges/country_helper.rb +9 -0
- data/lib/active_scaffold/bridges/country_helper/{lib/country_helper_bridge.rb → country_helper_bridge.rb} +5 -5
- data/lib/active_scaffold/bridges/date_picker.rb +23 -0
- data/lib/active_scaffold/bridges/date_picker/ext.rb +54 -0
- data/lib/active_scaffold/bridges/date_picker/helper.rb +188 -0
- data/lib/active_scaffold/bridges/dragonfly.rb +9 -0
- data/lib/active_scaffold/bridges/dragonfly/dragonfly_bridge.rb +34 -0
- data/lib/active_scaffold/bridges/dragonfly/dragonfly_bridge_helpers.rb +10 -0
- data/lib/active_scaffold/bridges/dragonfly/{lib/form_ui.rb → form_ui.rb} +0 -0
- data/lib/active_scaffold/bridges/dragonfly/{lib/list_ui.rb → list_ui.rb} +2 -2
- data/lib/active_scaffold/bridges/file_column.rb +11 -0
- data/lib/active_scaffold/bridges/file_column/{lib/as_file_column_bridge.rb → as_file_column_bridge.rb} +2 -2
- data/lib/active_scaffold/bridges/file_column/file_column_helpers.rb +57 -0
- data/lib/active_scaffold/bridges/file_column/{lib/form_ui.rb → form_ui.rb} +2 -2
- data/lib/active_scaffold/bridges/file_column/{lib/list_ui.rb → list_ui.rb} +0 -0
- data/lib/active_scaffold/bridges/paperclip.rb +12 -0
- data/lib/active_scaffold/bridges/paperclip/{lib/form_ui.rb → form_ui.rb} +0 -0
- data/lib/active_scaffold/bridges/paperclip/{lib/list_ui.rb → list_ui.rb} +3 -3
- data/lib/active_scaffold/bridges/paperclip/paperclip_bridge.rb +36 -0
- data/lib/active_scaffold/bridges/paperclip/paperclip_bridge_helpers.rb +24 -0
- data/lib/active_scaffold/bridges/record_select.rb +11 -0
- data/lib/active_scaffold/bridges/record_select/{lib/record_select_bridge.rb → helpers.rb} +5 -16
- data/lib/active_scaffold/bridges/record_select/helpers.rb~ +9 -14
- data/lib/active_scaffold/bridges/semantic_attributes.rb +5 -0
- data/lib/active_scaffold/bridges/semantic_attributes/{lib/semantic_attributes_bridge.rb → column.rb} +3 -3
- data/lib/active_scaffold/bridges/tiny_mce.rb +5 -0
- data/lib/active_scaffold/bridges/tiny_mce/{lib/tiny_mce_bridge.rb → helpers.rb} +16 -8
- data/lib/active_scaffold/config/base.rb +9 -1
- data/lib/active_scaffold/config/core.rb +1 -1
- data/lib/active_scaffold/config/create.rb +3 -10
- data/lib/active_scaffold/config/delete.rb +1 -2
- data/lib/active_scaffold/config/field_search.rb +1 -2
- data/lib/active_scaffold/config/form.rb +2 -6
- data/lib/active_scaffold/config/list.rb +8 -2
- data/lib/active_scaffold/config/nested.rb +2 -6
- data/lib/active_scaffold/config/search.rb +6 -2
- data/lib/active_scaffold/config/show.rb +1 -4
- data/lib/active_scaffold/config/subform.rb +1 -1
- data/lib/active_scaffold/config/update.rb +1 -6
- data/lib/active_scaffold/data_structures/action_columns.rb +3 -0
- data/lib/active_scaffold/data_structures/action_link.rb +14 -10
- data/lib/active_scaffold/data_structures/bridge.rb +22 -0
- data/lib/active_scaffold/data_structures/column.rb +36 -4
- data/lib/active_scaffold/data_structures/nested_info.rb +4 -4
- data/lib/active_scaffold/data_structures/set.rb +1 -6
- data/lib/active_scaffold/data_structures/sorting.rb +2 -2
- data/lib/active_scaffold/engine.rb +4 -0
- data/lib/active_scaffold/extensions/action_controller_rendering.rb +2 -2
- data/lib/active_scaffold/extensions/action_controller_rendering.rb~ +1 -1
- data/lib/active_scaffold/extensions/action_view_rendering.rb +90 -93
- data/lib/active_scaffold/extensions/action_view_rendering.rb~ +1 -13
- data/lib/active_scaffold/extensions/active_association_reflection.rb +16 -7
- data/lib/active_scaffold/extensions/cache_association.rb +16 -0
- data/lib/active_scaffold/extensions/reverse_associations.rb +15 -13
- data/lib/active_scaffold/extensions/unsaved_associated.rb +1 -1
- data/lib/active_scaffold/finder.rb +40 -23
- data/lib/active_scaffold/finder.rb~ +3 -11
- data/lib/active_scaffold/helpers/association_helpers.rb +1 -1
- data/lib/active_scaffold/helpers/controller_helpers.rb +9 -1
- data/lib/active_scaffold/helpers/controller_helpers.rb~ +12 -5
- data/lib/active_scaffold/helpers/form_column_helpers.rb +20 -21
- data/lib/active_scaffold/helpers/form_column_helpers.rb~ +2 -1
- data/lib/active_scaffold/helpers/id_helpers.rb +5 -5
- data/lib/active_scaffold/helpers/list_column_helpers.rb +14 -24
- data/lib/active_scaffold/helpers/list_column_helpers.rb~ +15 -20
- data/lib/active_scaffold/helpers/search_column_helpers.rb +10 -1
- data/lib/active_scaffold/helpers/search_column_helpers.rb~ +1 -1
- data/lib/active_scaffold/helpers/view_helpers.rb +14 -40
- data/lib/active_scaffold/helpers/view_helpers.rb~ +3 -3
- data/lib/active_scaffold/version.rb +2 -2
- data/lib/active_scaffold_env.rb +0 -2
- data/test/bridges/active_scaffold_dependent_protect_test.rb +34 -0
- data/test/bridges/bridge_test.rb +43 -0
- data/test/bridges/company.rb +81 -0
- data/test/bridges/paperclip_test.rb +68 -0
- data/test/bridges/tiny_mce_test.rb +27 -0
- data/test/bridges/unobtrusive_date_picker_test.rb +49 -0
- data/test/bridges/validation_reflection_test.rb +57 -0
- data/test/config/base_test.rb +1 -1
- data/test/config/core_test.rb +58 -0
- data/test/config/create_test.rb +8 -5
- data/test/config/delete_test.rb +33 -0
- data/test/config/field_search_test.rb +47 -0
- data/test/config/list_test.rb +64 -9
- data/test/config/nested_test.rb +62 -0
- data/test/config/search_test.rb +60 -0
- data/test/config/show_test.rb +5 -5
- data/test/config/subform_test.rb +17 -0
- data/test/config/update_test.rb +27 -4
- data/test/helpers/list_column_helpers_test.rb +16 -5
- data/test/helpers/pagination_helpers_test.rb +4 -0
- data/test/misc/attribute_params_test.rb +37 -1
- data/test/misc/finder_test.rb +0 -1
- data/test/misc/lang_test.rb +2 -3
- data/test/mock_app/public/javascripts/active_scaffold/default/active_scaffold.js +2 -2
- data/test/mock_app/public/stylesheets/active_scaffold/default/stylesheet.css +13 -7
- metadata +137 -154
- data/frontends/default/views/_list_with_header.html.erb~ +0 -32
- data/frontends/default/views/_render_field.js.rjs +0 -14
- data/frontends/default/views/_show.html.erb~ +0 -8
- data/frontends/default/views/_update_form.html.erb~ +0 -6
- data/frontends/default/views/add_existing.js.erb~ +0 -18
- data/frontends/default/views/add_existing.js.rjs +0 -17
- data/frontends/default/views/destroy.js.rjs +0 -23
- data/frontends/default/views/form_messages.js.rjs +0 -1
- data/frontends/default/views/list.js.rjs +0 -1
- data/frontends/default/views/on_action_update.js.rjs +0 -10
- data/frontends/default/views/on_create.js.rjs +0 -41
- data/frontends/default/views/on_mark_all.js.rjs +0 -12
- data/frontends/default/views/on_update.js.rjs +0 -28
- data/frontends/default/views/render_field.js.rjs +0 -1
- data/frontends/default/views/update_column.js.rjs +0 -13
- data/frontends/default/views/update_row.js.rjs +0 -1
- data/lib/active_scaffold.rb~ +0 -362
- data/lib/active_scaffold/bridges/ancestry/bridge.rb +0 -5
- data/lib/active_scaffold/bridges/bridge.rb +0 -59
- data/lib/active_scaffold/bridges/cancan/bridge.rb +0 -12
- data/lib/active_scaffold/bridges/carrierwave/bridge.rb +0 -9
- data/lib/active_scaffold/bridges/carrierwave/lib/carrierwave_bridge.rb +0 -33
- data/lib/active_scaffold/bridges/carrierwave/lib/carrierwave_bridge_helpers.rb +0 -12
- data/lib/active_scaffold/bridges/country_helper/bridge.rb +0 -9
- data/lib/active_scaffold/bridges/date_picker/bridge.rb +0 -24
- data/lib/active_scaffold/bridges/date_picker/lib/datepicker_bridge.rb +0 -234
- data/lib/active_scaffold/bridges/dragonfly/bridge.rb +0 -9
- data/lib/active_scaffold/bridges/dragonfly/lib/dragonfly_bridge.rb +0 -36
- data/lib/active_scaffold/bridges/dragonfly/lib/dragonfly_bridge_helpers.rb +0 -12
- data/lib/active_scaffold/bridges/file_column/bridge.rb +0 -11
- data/lib/active_scaffold/bridges/file_column/lib/file_column_helpers.rb +0 -59
- data/lib/active_scaffold/bridges/paperclip/bridge.rb +0 -12
- data/lib/active_scaffold/bridges/paperclip/lib/paperclip_bridge.rb +0 -38
- data/lib/active_scaffold/bridges/paperclip/lib/paperclip_bridge_helpers.rb +0 -26
- data/lib/active_scaffold/bridges/record_select/bridge.rb +0 -5
- data/lib/active_scaffold/bridges/semantic_attributes/bridge.rb +0 -5
- data/lib/active_scaffold/bridges/shared/date_bridge.rb~ +0 -209
- data/lib/active_scaffold/bridges/tiny_mce/bridge.rb +0 -5
- data/lib/active_scaffold/bridges/validation_reflection/bridge.rb +0 -8
- data/lib/active_scaffold/bridges/validation_reflection/lib/validation_reflection_bridge.rb +0 -21
- data/lib/active_scaffold/config/base.rb~ +0 -70
- data/lib/active_scaffold/config/nested.rb~ +0 -41
- data/lib/active_scaffold/constraints.rb~ +0 -186
- data/lib/active_scaffold/data_structures/action_link.rb~ +0 -179
- data/lib/active_scaffold/data_structures/nested_info.rb~ +0 -123
- data/lib/active_scaffold/extensions/action_view_resolver.rb +0 -7
- data/lib/active_scaffold/extensions/active_association_reflection.rb~ +0 -22
- data/lib/active_scaffold/extensions/unsaved_associated.rb~ +0 -62
- data/lib/active_scaffold_assets.rb +0 -45
- data/lib/generators/active_scaffold_setup/USAGE +0 -10
- data/lib/generators/active_scaffold_setup/active_scaffold_setup_generator.rb +0 -59
@@ -1,22 +0,0 @@
|
|
1
|
-
# Bugfix: building an sti model from an association fails
|
2
|
-
# https://rails.lighthouseapp.com/projects/8994-ruby-on-rails/tickets/6306-collection-associations-build-method-not-supported-for-sti
|
3
|
-
# https://github.com/rails/rails/issues/815
|
4
|
-
# https://github.com/rails/rails/pull/1686
|
5
|
-
ActiveRecord::Reflection::AssociationReflection.class_eval do
|
6
|
-
def klass_with_sti(*opts)
|
7
|
-
sti_col = klass.inheritance_column
|
8
|
-
if (h = opts.first).is_a? Hash and (passed_type = ( h[sti_col] || h[sti_col.to_sym] )) and (new_klass = active_record.send(:compute_type, passed_type)) < klass
|
9
|
-
new_klass
|
10
|
-
else
|
11
|
-
klass
|
12
|
-
end
|
13
|
-
end
|
14
|
-
def build_association(*opts, &block)
|
15
|
-
self.original_build_association_called = true
|
16
|
-
klass_with_sti(*opts).new(*opts, &block)
|
17
|
-
end
|
18
|
-
def create_association(*opts, &block)
|
19
|
-
self.original_build_association_called = true
|
20
|
-
klass_with_sti(*opts).create(*opts, &block)
|
21
|
-
end
|
22
|
-
end
|
@@ -1,62 +0,0 @@
|
|
1
|
-
# save and validation support for associations.
|
2
|
-
class ActiveRecord::Base
|
3
|
-
def associated_valid?(path = [])
|
4
|
-
return true if path.include?(self) # prevent recursion (if associated and parent are new records)
|
5
|
-
path << self
|
6
|
-
# using [].all? syntax to avoid a short-circuit
|
7
|
-
with_unsaved_associated { |a| debugger; [a.valid?, a.associated_valid?(path)].all? {|v| v == true} }
|
8
|
-
end
|
9
|
-
|
10
|
-
def save_associated
|
11
|
-
with_unsaved_associated { |a| a.save and a.save_associated }
|
12
|
-
end
|
13
|
-
|
14
|
-
def save_associated!
|
15
|
-
save_associated or raise(ActiveRecord::RecordNotSaved)
|
16
|
-
end
|
17
|
-
|
18
|
-
def no_errors_in_associated?
|
19
|
-
with_unsaved_associated {|a| a.errors.count == 0 and a.no_errors_in_associated?}
|
20
|
-
end
|
21
|
-
|
22
|
-
protected
|
23
|
-
|
24
|
-
# Provide an override to allow the model to restrict which associations are considered
|
25
|
-
# by ActiveScaffolds update mechanism. This allows the model to restrict things like
|
26
|
-
# Acts-As-Versioned versions associations being traversed.
|
27
|
-
#
|
28
|
-
# By defining the method :scaffold_update_nofollow returning an array of associations
|
29
|
-
# these associations will not be traversed.
|
30
|
-
# By defining the method :scaffold_update_follow returning an array of associations,
|
31
|
-
# only those associations will be traversed.
|
32
|
-
#
|
33
|
-
# Otherwise the default behaviour of traversing all associations will be preserved.
|
34
|
-
def associations_for_update
|
35
|
-
if self.respond_to?( :scaffold_update_nofollow )
|
36
|
-
self.class.reflect_on_all_associations.reject { |association| self.scaffold_update_nofollow.include?( association.name ) }
|
37
|
-
elsif self.respond_to?( :scaffold_update_follow )
|
38
|
-
self.class.reflect_on_all_associations.select { |association| self.scaffold_update_follow.include?( association.name ) }
|
39
|
-
else
|
40
|
-
self.class.reflect_on_all_associations
|
41
|
-
end
|
42
|
-
end
|
43
|
-
|
44
|
-
private
|
45
|
-
|
46
|
-
# yields every associated object that has been instantiated and is flagged as unsaved.
|
47
|
-
# returns false if any yield returns false.
|
48
|
-
# returns true otherwise, even when none of the associations have been instantiated. build wrapper methods accordingly.
|
49
|
-
def with_unsaved_associated
|
50
|
-
associations_for_update.all? do |association|
|
51
|
-
association_proxy = send(association.name)
|
52
|
-
if association_proxy
|
53
|
-
records = association_proxy
|
54
|
-
records = [records] unless records.is_a? Array # convert singular associations into collections for ease of use
|
55
|
-
debugger
|
56
|
-
records.select {|r| r.unsaved? and not r.readonly?}.all? {|r| yield r} # must use select instead of find_all, which Rails overrides on association proxies for db access
|
57
|
-
else
|
58
|
-
true
|
59
|
-
end
|
60
|
-
end
|
61
|
-
end
|
62
|
-
end
|
@@ -1,45 +0,0 @@
|
|
1
|
-
class ActiveScaffoldAssets
|
2
|
-
|
3
|
-
def self.copy_to_public(from, options = {})
|
4
|
-
unless defined?(ACTIVE_SCAFFOLD_INSTALL_ASSETS) && ACTIVE_SCAFFOLD_INSTALL_ASSETS == false
|
5
|
-
copy_files("/public", "/public", from)
|
6
|
-
available_frontends = Dir[File.join(from, 'frontends', '*')].collect { |d| File.basename d }
|
7
|
-
[:stylesheets, :javascripts, :images].each do |asset_type|
|
8
|
-
copy_asset_type(from, available_frontends, asset_type, options)
|
9
|
-
end
|
10
|
-
end
|
11
|
-
end
|
12
|
-
|
13
|
-
protected
|
14
|
-
|
15
|
-
def self.copy_asset_type(from, available_frontends, asset_type, options = {})
|
16
|
-
path = "/public/#{asset_type}/active_scaffold"
|
17
|
-
copy_files(path, path, from)
|
18
|
-
|
19
|
-
File.open(File.join(Rails.root, path, 'DO_NOT_EDIT'), 'w') do |f|
|
20
|
-
f.puts "Any changes made to files in sub-folders will be lost."
|
21
|
-
f.puts "See http://activescaffold.com/tutorials/faq#custom-css."
|
22
|
-
end
|
23
|
-
|
24
|
-
available_frontends.each do |frontend|
|
25
|
-
if asset_type == :javascripts
|
26
|
-
file_mask = '*.js'
|
27
|
-
source = "/frontends/#{frontend}/#{asset_type}/#{ActiveScaffold.js_framework}"
|
28
|
-
else
|
29
|
-
file_mask = '*.*'
|
30
|
-
source = "/frontends/#{frontend}/#{asset_type}"
|
31
|
-
end
|
32
|
-
destination = "/public/#{asset_type}/active_scaffold/#{frontend}"
|
33
|
-
copy_files(source, destination, from, file_mask, options)
|
34
|
-
end
|
35
|
-
end
|
36
|
-
|
37
|
-
def self.copy_files(source_path, destination_path, directory, file_mask = '*.*', options = {})
|
38
|
-
source, destination = File.join(directory, source_path), File.join(Rails.root, destination_path)
|
39
|
-
FileUtils.mkdir_p(destination) unless File.exist?(destination)
|
40
|
-
Dir.glob('*.so')
|
41
|
-
|
42
|
-
FileUtils.rm Dir.glob("#{destination}/*") if options[:clean_up_destination]
|
43
|
-
FileUtils.cp_r(Dir.glob("#{source}/#{file_mask}"), destination)
|
44
|
-
end
|
45
|
-
end
|
@@ -1,10 +0,0 @@
|
|
1
|
-
Description:
|
2
|
-
Setup a new Rails 3 Application with active_scaffold.
|
3
|
-
Pass 'jquery' in case you would like to use it instead of prototype
|
4
|
-
|
5
|
-
This installs required plugins and configures active_scaffold to use
|
6
|
-
specified js lib and application layout file to include all required
|
7
|
-
assets
|
8
|
-
|
9
|
-
Example:
|
10
|
-
`rails generate active_scaffold_setup jquery`
|
@@ -1,59 +0,0 @@
|
|
1
|
-
module Rails
|
2
|
-
module Generators
|
3
|
-
class ActiveScaffoldSetupGenerator < Rails::Generators::Base #metagenerator
|
4
|
-
argument :js_lib, :type => :string, :default => 'prototype', :desc => 'js_lib for activescaffold (prototype|jquery)'
|
5
|
-
|
6
|
-
def self.source_root
|
7
|
-
@source_root ||= File.join(File.dirname(__FILE__), 'templates')
|
8
|
-
end
|
9
|
-
|
10
|
-
def install_plugins
|
11
|
-
if defined?(ACTIVE_SCAFFOLD_PLUGIN)
|
12
|
-
plugin 'verification', :git => 'git://github.com/rails/verification.git'
|
13
|
-
plugin 'render_component', :git => 'git://github.com/vhochstein/render_component.git'
|
14
|
-
end
|
15
|
-
if js_lib == 'prototype'
|
16
|
-
get "https://github.com/vhochstein/prototype-ujs/raw/master/src/rails.js", "public/javascripts/rails.js"
|
17
|
-
elsif js_lib == 'jquery'
|
18
|
-
get "https://github.com/vhochstein/jquery-ujs/raw/master/src/rails.js", "public/javascripts/rails_jquery.js"
|
19
|
-
get "https://github.com/vhochstein/jQuery-Timepicker-Addon/raw/master/jquery-ui-timepicker-addon.js", "public/javascripts/jquery-ui-timepicker-addon.js"
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
|
-
def configure_active_scaffold
|
24
|
-
return unless js_lib == 'jquery'
|
25
|
-
if defined?(ACTIVE_SCAFFOLD_PLUGIN)
|
26
|
-
content = "ActiveSupport.on_load(:active_scaffold) { self.js_framework = :jquery }"
|
27
|
-
else
|
28
|
-
content = "ActiveScaffold.js_framework = :jquery"
|
29
|
-
end
|
30
|
-
create_file "config/initializers/active_scaffold.rb", content
|
31
|
-
end
|
32
|
-
|
33
|
-
def configure_application_layout
|
34
|
-
if js_lib == 'prototype'
|
35
|
-
inject_into_file "app/views/layouts/application.html.erb",
|
36
|
-
" <%= active_scaffold_includes %>\n",
|
37
|
-
:after => "<%= javascript_include_tag :defaults %>\n"
|
38
|
-
elsif js_lib == 'jquery'
|
39
|
-
inject_into_file "app/views/layouts/application.html.erb",
|
40
|
-
" <%= stylesheet_link_tag 'http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.9/themes/ui-lightness/jquery-ui.css' %>
|
41
|
-
<%= javascript_include_tag 'http://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.js' %>
|
42
|
-
<%= javascript_include_tag 'rails_jquery.js' %>
|
43
|
-
<%= javascript_include_tag 'http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.9/jquery-ui.js' %>
|
44
|
-
<%= javascript_include_tag 'jquery-ui-timepicker-addon.js' %>
|
45
|
-
<%= javascript_include_tag 'application.js' %>
|
46
|
-
<%= active_scaffold_includes %>\n",
|
47
|
-
:after => "<%= javascript_include_tag :defaults %>\n"
|
48
|
-
|
49
|
-
inject_into_file "config/locales/en.yml",
|
50
|
-
" time:
|
51
|
-
formats:
|
52
|
-
default: \"%a, %d %b %Y %H:%M:%S\"",
|
53
|
-
:after => "hello: \"Hello world\"\n"
|
54
|
-
gsub_file 'app/views/layouts/application.html.erb', /<%= javascript_include_tag :defaults/, '<%# javascript_include_tag :defaults'
|
55
|
-
end
|
56
|
-
end
|
57
|
-
end
|
58
|
-
end
|
59
|
-
end
|