diff --git a/app/models/content_instance.rb b/app/models/content_instance.rb index 5e794e9c..47c3b30a 100644 --- a/app/models/content_instance.rb +++ b/app/models/content_instance.rb @@ -69,7 +69,7 @@ class ContentInstance protected def set_slug - self._slug = self.highlighted_field_value.clone if self._slug.blank? && self.highlighted_field_value.present? + self._slug = self.highlighted_field_value.dup if self._slug.blank? && self.highlighted_field_value.present? self._slug.permalink! if self._slug.present? end diff --git a/lib/locomotive/export.rb b/lib/locomotive/export.rb index 7d41f3a4..9eb0c4fd 100644 --- a/lib/locomotive/export.rb +++ b/lib/locomotive/export.rb @@ -63,7 +63,7 @@ module Locomotive end def create_target_folder - FileUtils.rmdir(@target_folder) + FileUtils.rm_rf(@target_folder) FileUtils.mkdir_p(@target_folder) %w(app/content_types app/views/snippets app/views/pages config data public).each do |f| FileUtils.mkdir_p(File.join(@target_folder, f)) @@ -105,13 +105,15 @@ module Locomotive def copy_content_types @site.content_types.each do |content_type| - attributes = self.extract_attributes(content_type, %w(name description slug order_by order_direction highlighted_field_name group_by_field_name api_enabled)) + attributes = self.extract_attributes(content_type, %w(name description slug order_by order_direction group_by_field_name api_enabled)) + + attributes['highlighted_field_name'] = content_type.highlighted_field._alias # custom_fields fields = [] content_type.content_custom_fields.each do |field| fields << { - field._alias => self.extract_attributes(field, %w(label kind hint target)) + field._alias => self.extract_attributes(field, %w(label kind hint target required)) } end @@ -166,6 +168,10 @@ module Locomotive unless page.redirect? attributes.delete('redirect_url') + if page.templatized? + attributes['content_type'] = page.content_type.slug + end + # add editable elements page.editable_elements.each do |element| next if element.disabled? || (element.from_parent && element.default_content == element.content) @@ -279,7 +285,7 @@ module Locomotive content.send(field.safe_alias.to_sym) end) - hash[field._alias] = value + hash[field._alias] = value unless value.blank? end data << { content.highlighted_field_value => hash } diff --git a/lib/locomotive/import/content_types.rb b/lib/locomotive/import/content_types.rb index 4192eec8..b656ca60 100644 --- a/lib/locomotive/import/content_types.rb +++ b/lib/locomotive/import/content_types.rb @@ -130,6 +130,8 @@ module Locomotive content.send("#{name}=", value) end + content.send(:set_slug) + content.save(:validate => false) contents_with_associations << [content, associations] unless associations.empty? diff --git a/lib/locomotive/liquid/tags/editable/base.rb b/lib/locomotive/liquid/tags/editable/base.rb index efd214c8..cc6781f7 100644 --- a/lib/locomotive/liquid/tags/editable/base.rb +++ b/lib/locomotive/liquid/tags/editable/base.rb @@ -70,7 +70,7 @@ module Locomotive end def render_default_content(context) - render_all(@nodelist, context) + render_all(@nodelist, context).join(' ') end end diff --git a/spec/lib/locomotive/export_spec.rb b/spec/lib/locomotive/export_spec.rb index d2cf4c0f..5059b11b 100644 --- a/spec/lib/locomotive/export_spec.rb +++ b/spec/lib/locomotive/export_spec.rb @@ -31,7 +31,7 @@ describe Locomotive::Export do it 'stores the list of highlighted values in a has_many relationship' do @team_data.first.values.first['projects'].size.should == 2 @team_data.first.values.first['projects'].should == ['Project #1', 'Project #2'] - @team_data.last.values.first['projects'].should == [] + @team_data.last.values.first['projects'].should be_nil end it 'stores a highlighted value in a has_one relationship' do