Add children attribute in page entitty

arnaud sellenet committed Jun 17, 2014
commit b24302a7068a9d2d6eba289e617df1154297b658
Showing 3 changed files with 16 additions and 15 deletions
locomotive/steam/decorators/page_decorator.rb b/lib/locomotive/steam/decorators/page_decorator.rb +14 -0
@@ @@ -30,6 +30,20 @@ module Locomotive
)
)
end
+
+ # Return the Liquid template based on the raw_template property
+ # of the page. If the template is HAML or SLIM, then a pre-rendering to Liquid is done.
+ #
+ # @return [ String ] The liquid template or nil if not template has been provided
+ #
+ def source(locale)
+ @source ||= self.template[locale].source
+ end
+
+ def to_liquid
+ ::Locomotive::Steam::Liquid::Drops::Page.new(self)
+ end
+
end
end
end
locomotive/steam/entities/page.rb b/lib/locomotive/steam/entities/page.rb +1 -15
@@ @@ -8,7 +8,7 @@ module Locomotive
attributes :parent, :title, :slug, :fullpath, :redirect_url, :redirect_type,
:template, :handle, :listed, :searchable, :templatized, :content_type,
:published, :cache_strategy, :response_type, :position, :seo_title,
- :meta_keywords, :meta_description, :editable_elements, :site,
+ :meta_keywords, :meta_description, :editable_elements, :site, :children,
:site_id, :parent_id
## aliases ##
@@ @@ -115,20 +115,6 @@ module Locomotive
@source ||= {}
@source[locale] = content
end
-
- # Return the Liquid template based on the raw_template property
- # of the page. If the template is HAML or SLIM, then a pre-rendering to Liquid is done.
- #
- # @return [ String ] The liquid template or nil if not template has been provided
- #
- def source(locale)
- @source ||= self.template[locale].source
- end
-
- def to_liquid
- ::Locomotive::Steam::Liquid::Drops::Page.new(self)
- end
-
end
end
end
locomotive/steam/mapper.rb b/lib/locomotive/steam/mapper.rb +1 -0
@@ @@ -25,6 +25,7 @@ collection :pages do
attribute :site, association: {type: :belongs_to, key: :site_id, name: :sites}
attribute :content_type, association: {type: :belongs_to, key: :content_type_id, name: :content_types}
attribute :parent, association: {type: :belongs_to, key: :parent_id, name: :pages}
+ attribute :children, association: {type: :has_many, key: :parent_id, name: :pages}
attribute :title, localized: true
attribute :slug, localized: true
attribute :fullpath, localized: true