allow to use the page sections_content from Wagon as source of content

Didier Lafforgue committed May 31, 2018
commit b441902bddc29a3290356d8e916500828e9c2a8a
Showing 4 changed files with 16 additions and 1 deletions
locomotive/steam/adapters/filesystem/sanitizers/page.rb b/lib/locomotive/steam/adapters/filesystem/sanitizers/page.rb +9 -0
@@ @@ -37,6 +37,8 @@ module Locomotive::Steam
set_fullpath_for(page, locale)
use_default_locale_template_path(page, locale)
+
+ transform_sections_content(page, locale)
end
end
end
@@ @@ -137,6 +139,13 @@ module Locomotive::Steam
page[:target_klass_name] = "Locomotive::ContentEntry#{content_type}"
end
+ def transform_sections_content(page, locale)
+ if content = page[:sections_content][locale]
+ return unless content.is_a?(String)
+ page[:sections_content][locale] = JSON.parse(content)
+ end
+ end
+
def modify_if_parent_templatized(page, locale)
parent_templatized = @templatized_ids[page.parent_id]
locomotive/steam/entities/page.rb b/lib/locomotive/steam/entities/page.rb +1 -0
@@ @@ -21,6 +21,7 @@ module Locomotive::Steam
raw_template: nil,
source: nil,
editable_elements: {},
+ sections_content: [],
redirect: nil,
redirect_url: {},
redirect_type: nil,
locomotive/steam/liquid/tags/concerns/section.rb b/lib/locomotive/steam/liquid/tags/concerns/section.rb +2 -0
@@ @@ -44,6 +44,8 @@ module Locomotive::Steam::Liquid::Tags::Concerns
previous_node = nil
new_nodelist = []
+ return if root.nodelist.blank?
+
root.nodelist.each_with_index do |node, index|
if node.is_a?(::Liquid::Variable) && previous_node.is_a?(::Liquid::Token)
matches = node.raw.match(Locomotive::Steam::SECTIONS_SETTINGS_VARIABLE_REGEXP)
locomotive/steam/repositories/page_repository.rb b/lib/locomotive/steam/repositories/page_repository.rb +4 -1
@@ @@ -7,7 +7,10 @@ module Locomotive
# Entity mapping
mapping :pages, entity: Page do
- localized_attributes :title, :slug, :permalink, :source, :raw_template, :template_path, :redirect_url, :fullpath, :seo_title, :meta_description, :meta_keywords
+ localized_attributes :title, :slug, :permalink,
+ :source, :raw_template, :sections_content,
+ :template_path, :redirect_url, :fullpath,
+ :seo_title, :meta_description, :meta_keywords
embedded_association :editable_elements, EditableElementRepository
end