Class: ComfortableMexicanSofa::Seeds::Page::Exporter
- Defined in:
- lib/comfortable_mexican_sofa/seeds/page/exporter.rb
Instance Attribute Summary
Attributes inherited from Exporter
Instance Method Summary collapse
- #export! ⇒ Object
-
#initialize(from, to = from) ⇒ Exporter
constructor
A new instance of Exporter.
Constructor Details
#initialize(from, to = from) ⇒ Exporter
Returns a new instance of Exporter.
6 7 8 9 |
# File 'lib/comfortable_mexican_sofa/seeds/page/exporter.rb', line 6 def initialize(from, to = from) super self.path = ::File.join(ComfortableMexicanSofa.config.seeds_path, to, "pages/") end |
Instance Method Details
#export! ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/comfortable_mexican_sofa/seeds/page/exporter.rb', line 11 def export! prepare_folder!(path) site.pages.each do |page| page.slug = "index" if page.slug.blank? page_path = File.join(path, page.ancestors.reverse.map { |p| p.slug.blank? ? "index" : p.slug }, page.slug) FileUtils.mkdir_p(page_path) path = ::File.join(page_path, "content.html") data = [] attrs = { "label" => page.label, "layout" => page.layout.try(:identifier), "target_page" => page.target_page.try(:full_path), "categories" => page.categories.map(&:label), "is_published" => page.is_published, "position" => page.position }.to_yaml data << { header: "attributes", content: attrs } data += fragments_data(page, page_path) write_file_content(path, data) = "[CMS SEEDS] Exported Page \t #{page.full_path}" ComfortableMexicanSofa.logger.info() export_translations(page, page_path) end end |