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
43
44
45
46
47
48
49
|
# File 'app/models/sibu/site.rb', line 43
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
51
52
53
54
55
|
# File 'app/models/sibu/site.rb', line 51
def init_sections(source)
site_data = Rails.application.config.sibu[:site_data][source]
self.sections = site_data.sections(self)
save!
end
|
#not_found ⇒ Object
17
18
19
|
# File 'app/models/sibu/site.rb', line 17
def not_found
"shared/#{site_template.path}/not_found"
end
|
#page(path) ⇒ Object
21
22
23
|
# File 'app/models/sibu/site.rb', line 21
def page(path)
pages.where(path: path).first
end
|
#page_by_id(page_id) ⇒ Object
25
26
27
|
# File 'app/models/sibu/site.rb', line 25
def page_by_id(page_id)
pages.where(id: page_id).first
end
|
#pages_path_by_id ⇒ Object
39
40
41
|
# File 'app/models/sibu/site.rb', line 39
def pages_path_by_id
Hash[pages.collect {|p| [p.id.to_s, p.path]}]
end
|
#save_and_init ⇒ Object
29
30
31
32
33
34
35
36
37
|
# File 'app/models/sibu/site.rb', line 29
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
13
14
15
|
# File 'app/models/sibu/site.rb', line 13
def section_template(section)
"#{site_template.path}/#{section["template"]}"
end
|