Class: Sibu::Site
Instance Method Summary
collapse
#child_element, #clone_element, #create_section, #delete_element, #delete_section, #element, #elements, #elt, #find_or_init, #section, #update_element
Instance Method Details
#init_pages(source) ⇒ Object
44
45
46
47
48
49
50
|
# File 'app/models/sibu/site.rb', line 44
def init_pages(source)
site_data = Rails.application.config.sibu[:site_data][source]
site_data.pages.each do |p|
self.pages << Sibu::Page.new(p)
end
save!
end
|
#init_sections(source) ⇒ Object
52
53
54
55
56
|
# File 'app/models/sibu/site.rb', line 52
def init_sections(source)
site_data = Rails.application.config.sibu[:site_data][source]
self.sections = site_data.sections(self)
save!
end
|
#not_found ⇒ Object
18
19
20
|
# File 'app/models/sibu/site.rb', line 18
def not_found
"shared/#{site_template.path}/not_found"
end
|
#page(path) ⇒ Object
22
23
24
|
# File 'app/models/sibu/site.rb', line 22
def page(path)
pages.where(path: path).first
end
|
#page_by_id(page_id) ⇒ Object
26
27
28
|
# File 'app/models/sibu/site.rb', line 26
def page_by_id(page_id)
pages.where(id: page_id).first
end
|
#pages_path_by_id ⇒ Object
40
41
42
|
# File 'app/models/sibu/site.rb', line 40
def pages_path_by_id
Hash[pages.collect {|p| [p.id.to_s, p.path]}]
end
|
#save_and_init ⇒ Object
30
31
32
33
34
35
36
37
38
|
# File 'app/models/sibu/site.rb', line 30
def save_and_init
if valid?
self.sections = site_template.sections
site_template.pages.each do |p|
self.pages << Sibu::Page.new(p)
end
end
save
end
|
#section_template(section) ⇒ Object
14
15
16
|
# File 'app/models/sibu/site.rb', line 14
def section_template(section)
"#{site_template.path}/#{section["template"]}"
end
|