Class: Sibu::Site
Constant Summary
collapse
- DEFAULT_VERSION =
'fr'
Instance Method Summary
collapse
for_user
#child_element, #clone_element, #create_section, #delete_element, #delete_section, #element, #elements, #elt, #find_or_init, #section, #update_element
Instance Method Details
#alt_color ⇒ Object
25
26
27
|
# File 'app/models/sibu/site.rb', line 25
def alt_color
secondary_color.blank? ? site_template.secondary_color : secondary_color
end
|
#alt_font ⇒ Object
33
34
35
|
# File 'app/models/sibu/site.rb', line 33
def alt_font
secondary_font.blank? ? site_template.secondary_font : secondary_font
end
|
#deep_copy ⇒ Object
85
86
87
88
89
90
91
92
93
94
|
# File 'app/models/sibu/site.rb', line 85
def deep_copy
site_copy = deep_dup
pages.each do |p|
site_copy.name = name + ' - copie'
site_copy.domain = nil
site_copy.pages << p.deep_dup
end
site_copy
end
|
#init_pages(source) ⇒ Object
71
72
73
74
75
76
77
|
# File 'app/models/sibu/site.rb', line 71
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
79
80
81
82
83
|
# File 'app/models/sibu/site.rb', line 79
def init_sections(source)
site_data = Rails.application.config.sibu[:site_data][source]
self.sections = site_data.sections(self)
save!
end
|
#main_color ⇒ Object
21
22
23
|
# File 'app/models/sibu/site.rb', line 21
def main_color
primary_color.blank? ? site_template.primary_color : primary_color
end
|
#main_font ⇒ Object
29
30
31
|
# File 'app/models/sibu/site.rb', line 29
def main_font
primary_font.blank? ? site_template.primary_font : primary_font
end
|
#not_found ⇒ Object
41
42
43
|
# File 'app/models/sibu/site.rb', line 41
def not_found
"shared/#{site_template.path}/not_found"
end
|
#page(path) ⇒ Object
45
46
47
|
# File 'app/models/sibu/site.rb', line 45
def page(path)
pages.where(path: path).first
end
|
#page_by_id(page_id) ⇒ Object
49
50
51
|
# File 'app/models/sibu/site.rb', line 49
def page_by_id(page_id)
pages.where(id: page_id).first
end
|
#pages_path_by_id ⇒ Object
67
68
69
|
# File 'app/models/sibu/site.rb', line 67
def pages_path_by_id
Hash[pages.collect {|p| [p.id.to_s, p.path]}]
end
|
#save_and_init ⇒ Object
53
54
55
56
57
58
59
60
61
62
63
64
65
|
# File 'app/models/sibu/site.rb', line 53
def save_and_init
if valid?
self.sections = site_template.sections
site_template.pages.each do |p|
self.pages << Sibu::Page.new(p)
end
self.primary_color = site_template.primary_color
self.secondary_color = site_template.secondary_color
self.primary_font = site_template.primary_font
self.secondary_font = site_template.secondary_font
end
save
end
|
#section_template(section) ⇒ Object
37
38
39
|
# File 'app/models/sibu/site.rb', line 37
def section_template(section)
"#{site_template.path}/#{section["template"]}"
end
|
#style_url ⇒ Object
17
18
19
|
# File 'app/models/sibu/site.rb', line 17
def style_url
style ? style.url : site_template.path
end
|