10
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
|
# File 'lib/occams/seeds/page/exporter.rb', line 10
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)
message = "[CMS SEEDS] Exported Page \t #{page.full_path}"
Occams.logger.info(message)
export_translations(page, page_path)
end
end
|