Class: Cms::PageTemplate

Inherits:
DynamicView
  • Object
show all
Defined in:
app/models/cms/page_template.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from DynamicView

base_path, default_body, #display_name, engine, #file_name, find_by_file_name, form_name, new_with_defaults, #remove_file_from_disk, resource_name, #set_publish_on_save, write_all_to_disk!, #write_file_to_disk

Class Method Details

.display_name(file_name) ⇒ Object



18
19
20
21
# File 'app/models/cms/page_template.rb', line 18

def self.display_name(file_name)
  name, format, handler = file_name.split('.')
  "#{name.titleize} (#{format}/#{handler})"
end

.file_pathObject



14
15
16
# File 'app/models/cms/page_template.rb', line 14

def self.file_path
  File.join(base_path, relative_path)
end

.optionsObject

This is a combination of file system page templates and database page templates



33
34
35
36
37
# File 'app/models/cms/page_template.rb', line 33

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

.path_elementsObject



27
28
29
# File 'app/models/cms/page_template.rb', line 27

def self.path_elements
  [Cms::PageTemplate]
end

.relative_pathObject



10
11
12
# File 'app/models/cms/page_template.rb', line 10

def self.relative_path
  File.join("layouts", "templates")
end

.resource_collection_nameObject



23
24
25
# File 'app/models/cms/page_template.rb', line 23

def self.resource_collection_name
  "page_template"
end

Instance Method Details

#file_pathObject



6
7
8
# File 'app/models/cms/page_template.rb', line 6

def file_path
  File.join(self.class.file_path, file_name)
end