Class: Sibu::Page
Class Method Summary
collapse
Instance Method Summary
collapse
#child_element, #clone_element, #create_section, #delete_element, #delete_section, #element, #elements, #elt, #find_or_init, #section, #update_element
Class Method Details
.lookup(domain_name, page_path) ⇒ Object
12
13
14
15
|
# File 'app/models/sibu/page.rb', line 12
def self.lookup(domain_name, page_path)
joins(:site).where("sibu_sites.domain = ? AND ((sibu_sites.version = ? AND sibu_pages.path = ?) OR sibu_pages.path = LTRIM(REPLACE(?, sibu_sites.version, ''), '/'))",
domain_name, Sibu::Site::DEFAULT_VERSION, page_path, page_path).first
end
|
Instance Method Details
#deep_copy ⇒ Object
34
35
36
37
38
|
# File 'app/models/sibu/page.rb', line 34
def deep_copy
new_page = deep_dup
new_page.name = name + ' - copie'
new_page
end
|
#save_and_init ⇒ Object
17
18
19
20
21
22
23
|
# File 'app/models/sibu/page.rb', line 17
def save_and_init
if valid?
template_defaults = site.site_template.pages.first
self.sections = template_defaults[:sections] if template_defaults
end
save
end
|
#site_template ⇒ Object
30
31
32
|
# File 'app/models/sibu/page.rb', line 30
def site_template
site.site_template
end
|
#update_path ⇒ Object
Todo : fix me (is_home flag ?)
26
27
28
|
# File 'app/models/sibu/page.rb', line 26
def update_path
self.path = name.parameterize if self.path.blank? && name != 'Accueil'
end
|