Class: PageTemplate
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from DynamicView
base_path, #display_name, #file_name, find_by_file_name, inherited, new_with_defaults, #remove_file_from_disk, #set_publish_on_save, write_all_to_disk!, #write_file_to_disk
Class Method Details
.default_body ⇒ Object
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
# File 'app/models/page_template.rb', line 17
def self.default_body
html = <<HTML
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
<title><%= page_title %></title>
<%= yield :html_head %>
</head>
<body>
<%= cms_toolbar %>
<%= container :main %>
</body>
</html>
HTML
html
end
|
.display_name(file_name) ⇒ Object
35
36
37
38
|
# File 'app/models/page_template.rb', line 35
def self.display_name(file_name)
name, format, handler = file_name.split('.')
"#{name.titleize} (#{format}/#{handler})"
end
|
.file_path ⇒ Object
13
14
15
|
# File 'app/models/page_template.rb', line 13
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
42
43
44
45
46
|
# File 'app/models/page_template.rb', line 42
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
9
10
11
|
# File 'app/models/page_template.rb', line 9
def self.relative_path
File.join("layouts", "templates")
end
|
Instance Method Details
#file_path ⇒ Object
5
6
7
|
# File 'app/models/page_template.rb', line 5
def file_path
File.join(self.class.file_path, file_name)
end
|