Class: Cms::PageTemplate
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from DynamicView
base_path, default_body, #display_name, #file_name, find_by_file_name, new_with_defaults, #set_defaults, #set_path, #set_publish_on_save, title, with_file_name
#non_permitted_params, #permitted_params
Class Method Details
.display_name(file_name) ⇒ Object
18
19
20
21
22
|
# File 'app/models/cms/page_template.rb', line 18
def self.display_name(file_name)
name, format, handler = file_name.split('.')
content_type = handler ? "#{format}/#{handler}" : "#{format}"
"#{name.titleize} (#{content_type})"
end
|
.file_path ⇒ Object
14
15
16
|
# File 'app/models/cms/page_template.rb', line 14
def self.file_path
File.join(base_path, relative_path)
end
|
.options ⇒ Object
This is a combination of file system page templates and database page templates
26
27
28
29
30
|
# File 'app/models/cms/page_template.rb', line 26
def self.options
file_system_templates = ActionController::Base.view_paths.map { |p| Dir["#{p}/#{relative_path}/*"] }.flatten.map { |f| File.basename(f) }
page_templates = file_system_templates + all.map { |t| t.file_name }
page_templates.map { |f| [display_name(f), f] }.sort.uniq
end
|
.relative_path ⇒ Object
10
11
12
|
# File 'app/models/cms/page_template.rb', line 10
def self.relative_path
File.join("layouts", "templates")
end
|
Instance Method Details
#file_path ⇒ Object
6
7
8
|
# File 'app/models/cms/page_template.rb', line 6
def file_path
File.join(self.class.file_path, file_name)
end
|
#hint ⇒ Object
Generates hint for editing
41
42
43
|
# File 'app/models/cms/page_template.rb', line 41
def hint
"No spaces allowed. Must start with lowercase letter."
end
|
#partial? ⇒ Boolean
32
33
34
|
# File 'app/models/cms/page_template.rb', line 32
def partial?
false
end
|
#placeholder ⇒ Object
36
37
38
|
# File 'app/models/cms/page_template.rb', line 36
def placeholder
"subpage"
end
|