enhance wagon pull command: site's robot_txt attribue (#316), page's response_type attribute (#316), content entry's _visible attribute (#319)
did
committed Sep 26, 2016
commit 784bf6be6425554902ca47e560fb20de25021689
Showing 4
changed files with
10 additions
and 5 deletions
locomotive/wagon/commands/pull_sub_commands/concerns/assets_concern.rb b/lib/locomotive/wagon/commands/pull_sub_commands/concerns/assets_concern.rb
+2
-2
| @@ | @@ -6,7 +6,7 @@ module Locomotive::Wagon |
| module AssetsConcern | |
| - | REGEX = /(https?:\/\/\S+)?\/sites\/[0-9a-f]{24}\/(assets|pages|theme|content_entry[0-9a-f]{24})\/(([^;.]+)\/)*([a-zA-Z_\-0-9.%]+)\.([A-Za-z]{2,})(\?\w+)?/ |
| + | REGEX = /(https?:\/\/\S+)?\/sites\/[0-9a-f]{24}\/(assets|pages|theme|content_entry[0-9a-f]{24})\/(([^;.]+)\/)*([a-zA-Z_\-0-9.%]+)(\?\w+)?/ |
| # The content assets on the remote engine follows the format: /sites/<id>/assets/<type>/<file> | |
| # This method replaces these urls by their local representation. <type>/<file> | |
| @@ | @@ -17,7 +17,7 @@ module Locomotive::Wagon |
| return '' if content.blank? | |
| content.force_encoding('utf-8').gsub(REGEX) do |url| | |
| - | filename = "#{$5}.#{$6}" |
| + | filename = $5 |
| folder = case $2 | |
| when 'assets', 'pages' then File.join('samples', $2) | |
| when 'theme' then $4 | |
locomotive/wagon/commands/pull_sub_commands/pull_content_entries_command.rb b/lib/locomotive/wagon/commands/pull_sub_commands/pull_content_entries_command.rb
+2
-1
| @@ | @@ -27,7 +27,6 @@ module Locomotive::Wagon |
| def yaml_attributes(content_type, entry) | |
| fields = %w(_slug) + content_type.fields.map { |f| f['name'] } + %w(seo_title meta_description meta_keywords) | |
| localized_fields = (content_type.attributes['localized_names'] || []) + %w(_slug seo_title meta_description meta_keywords) | |
| - | fields_with_urls = content_type.attributes['urls_names'] |
| attributes = {} | |
| @@ | @@ -41,6 +40,8 @@ module Locomotive::Wagon |
| end | |
| end | |
| + | attributes['_visible'] = false unless entry[default_locale].attributes['_visible'] == true |
| + | |
| { entry[default_locale].attributes[content_type.label_field_name].to_s => clean_attributes(attributes) } | |
| end | |
locomotive/wagon/commands/pull_sub_commands/pull_pages_command.rb b/lib/locomotive/wagon/commands/pull_sub_commands/pull_pages_command.rb
+5
-1
| @@ | @@ -28,7 +28,11 @@ EOF |
| private | |
| def yaml_attributes(page, locale) | |
| - | attributes = page.attributes.slice('title', 'slug', 'handle', 'position', 'listed', 'published', 'redirect_url', 'is_layout', 'content_type', 'seo_title', 'meta_description', 'meta_keywords') |
| + | keys = ['title', 'slug', 'handle', 'position', 'listed', 'published', 'redirect_url', 'is_layout', 'content_type', 'seo_title', 'meta_description', 'meta_keywords'] |
| + | |
| + | keys << 'response_type' if page.attributes['response_type'] != 'text/html' |
| + | |
| + | attributes = page.attributes.slice(*keys) |
| if locale != default_locale | |
| attributes.delete_if { |k, _| %w(handle position listed published is_layout content_type).include?(k) } | |
locomotive/wagon/commands/pull_sub_commands/pull_site_command.rb b/lib/locomotive/wagon/commands/pull_sub_commands/pull_site_command.rb
+1
-1
| @@ | @@ -3,7 +3,7 @@ module Locomotive::Wagon |
| class PullSiteCommand < PullBaseCommand | |
| def _pull | |
| - | attributes = current_site.attributes.slice('name', 'locales', 'domains', 'timezone', 'seo_title', 'meta_keywords', 'meta_description', 'picture_thumbnail_url', 'metafields', 'metafields_schema', 'metafields_ui') |
| + | attributes = current_site.attributes.slice('name', 'locales', 'domains', 'timezone', 'seo_title', 'meta_keywords', 'meta_description', 'picture_thumbnail_url', 'metafields', 'metafields_schema', 'metafields_ui', 'robots_txt') |
| locales.each_with_index do |locale, index| | |
| if index == 0 | |