small bug with js, migration generator is better
Oleg
committed Nov 25, 2010
commit d59da37035292e1a17aca5eb140c55bcec02ce8d
Showing 4
changed files with
13 additions
and 5 deletions
app/views/cms_admin/pages/_form.html.erb
+1
-1
| @@ | @@ -9,7 +9,7 @@ |
| <%= form.text_field :slug, :id => 'slug' %> | |
| <% end %> | |
| <% if (options = CmsLayout.options_for_select(@cms_site)).present? %> | |
| - | <%= form.select :cms_layout_id, options, {}, 'data-page-id' => @cms_page.id.to_i, 'data-path-prefix' => ComfortableMexicanSofa.config.admin_route_prefix, :label => 'Layout' %> |
| + | <%= form.select :cms_layout_id, options, {}, 'data-page-id' => @cms_page.id.to_i, :label => 'Layout' %> |
| <% end %> | |
| <% if (options = CmsPage.options_for_select(@cms_site, @cms_page)).present? %> | |
| <%= form.select :parent_id, options %> | |
generators/cms_generator.rb b/lib/generators/cms_generator.rb
+9
-1
| @@ | @@ -6,7 +6,15 @@ class CmsGenerator < Rails::Generators::Base |
| source_root File.expand_path('../../..', __FILE__) | |
| def generate_migration | |
| - | migration_template 'db/migrate/01_create_cms.rb', 'db/migrate/create_cms.rb' |
| + | destination = File.expand_path('db/migrate/01_create_cms.rb', self.destination_root) |
| + | migration_dir = File.dirname(destination) |
| + | destination = self.class.migration_exists?(migration_dir, 'create_cms') |
| + | |
| + | if destination |
| + | puts "\e[0m\e[31mFound existing cms_create.rb migration. Remove it if you want to regenerate.\e[0m" |
| + | else |
| + | migration_template 'db/migrate/01_create_cms.rb', 'db/migrate/create_cms.rb' |
| + | end |
| end | |
| def generate_initialization | |
public/javascripts/comfortable_mexican_sofa/cms.js
+3
-2
| @@ | @@ -1,5 +1,6 @@ |
| $.CMS = function(){ | |
| var current_path = window.location.pathname; | |
| + | var admin_path_prefix = current_path.split('/')[1] |
| $(document).ready(function(){ | |
| @@ | @@ -35,7 +36,7 @@ $.CMS = function(){ |
| load_page_blocks: function(){ | |
| $('select#cms_page_cms_layout_id').bind('change.cms', function() { | |
| $.ajax({ | |
| - | url: ['/' + $(this).attr('data-path-prefix'), 'pages', $(this).attr('data-page-id'), 'form_blocks'].join('/'), |
| + | url: ['/' + admin_path_prefix, 'pages', $(this).attr('data-page-id'), 'form_blocks'].join('/'), |
| data: ({ | |
| layout_id: $(this).val() | |
| }), | |
| @@ | @@ -93,7 +94,7 @@ $.CMS = function(){ |
| unique_names: true, | |
| multipart: true, | |
| multipart_params: { authenticity_token: auth_token, format: 'js' }, | |
| - | url: '/cms-admin/uploads' |
| + | url: '/' + admin_path_prefix + '/uploads' |
| }); | |
| uploader.init(); | |
| uploader.bind('FilesAdded', function(up, files) { | |
test/functional/cms_admin/pages_controller_test.rb
+0
-1
| @@ | @@ -24,7 +24,6 @@ class CmsAdmin::PagesControllerTest < ActionController::TestCase |
| assert_template :new | |
| assert_select 'form[action=/cms-admin/pages]' | |
| - | assert_select 'select[data-path-prefix=cms-admin]' |
| end | |
| def test_get_new_with_field_datetime | |