Class: Smeagol::Views::Page
- Inherits:
-
Base
- Object
- Mustache
- Base
- Smeagol::Views::Page
show all
- Defined in:
- lib/smeagol/views/page.rb
Direct Known Subclasses
Post
Instance Attribute Summary
Attributes inherited from Base
#file, #version, #wiki
Instance Method Summary
collapse
Methods inherited from Base
#base_path, #custom_layout, #custom_layout?, #default_layout, #filename, #initialize, #layout, #menu_html, #metadata, #name, #posts, #ribbon_html, #ribbon_url, #settings, #setup_template_path, #source_url, #standard_layout, #tagline, #tracking_id, #wiki_title
Instance Method Details
#author ⇒ Object
The last author of this page.
31
32
33
|
# File 'lib/smeagol/views/page.rb', line 31
def author
page.version.author.name
end
|
#commit_date ⇒ Object
The last edit date of this page.
41
42
43
|
# File 'lib/smeagol/views/page.rb', line 41
def commit_date
page.version.authored_date.strftime(settings.date_format)
end
|
#content ⇒ Object
The HTML formatted content of the page.
20
21
22
|
# File 'lib/smeagol/views/page.rb', line 20
def content
page.formatted_data
end
|
#date ⇒ Object
The last edit date of this page.
36
37
38
|
# File 'lib/smeagol/views/page.rb', line 36
def date
post_date || commit_date
end
|
117
118
119
|
# File 'lib/smeagol/views/page.rb', line 117
def
&& @footer.formatted_data
end
|
121
122
123
|
# File 'lib/smeagol/views/page.rb', line 121
def
&& @footer.format.to_s
end
|
112
113
114
115
|
# File 'lib/smeagol/views/page.rb', line 112
def
@footer = (@page. || false) if @footer.nil?
!!@footer
end
|
99
100
101
102
|
# File 'lib/smeagol/views/page.rb', line 99
def
@header = (@page. || false) if @header.nil?
!!@header
end
|
125
126
127
128
|
# File 'lib/smeagol/views/page.rb', line 125
def
@sidebar = (@page. || false) if @sidebar.nil?
!!@sidebar
end
|
#has_toc ⇒ Object
138
139
140
|
# File 'lib/smeagol/views/page.rb', line 138
def has_toc
!@toc_content.nil?
end
|
104
105
106
|
# File 'lib/smeagol/views/page.rb', line 104
def
&& @header.formatted_data
end
|
108
109
110
|
# File 'lib/smeagol/views/page.rb', line 108
def
&& @header.format.to_s
end
|
#href ⇒ Object
static href, used when generating static site.
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
|
# File 'lib/smeagol/views/page.rb', line 51
def href
dir = ::File.dirname(page.path)
name = slug(page.filename_stripped)
ext = ::File.extname(page.path)
if dir != '.'
::File.join(dir, name, 'index.html')
else
if name == settings.index 'index.html'
else
::File.join(name, 'index.html')
end
end
end
|
#mathjax ⇒ Object
146
147
148
|
# File 'lib/smeagol/views/page.rb', line 146
def mathjax
@mathjax
end
|
#not_home? ⇒ Boolean
A flag stating that this is not the home page.
46
47
48
|
# File 'lib/smeagol/views/page.rb', line 46
def not_home?
page.title != "Home" end
|
#post? ⇒ Boolean
95
96
97
|
# File 'lib/smeagol/views/page.rb', line 95
def post?
/^(\d\d\d\d-\d\d-\d\d)/.match(filename)
end
|
#post_date ⇒ Object
If the name of the page begins with a date, then it is the “post date” and is taken to be a blog entry, rather then an ordinary static page.
88
89
90
91
92
|
# File 'lib/smeagol/views/page.rb', line 88
def post_date
if md = /^(\d\d\d\d-\d\d-\d\d)/.match(filename)
Time.parse(md[1]).strftime(settings.date_format)
end
end
|
130
131
132
|
# File 'lib/smeagol/views/page.rb', line 130
def
&& @sidebar.formatted_data
end
|
134
135
136
|
# File 'lib/smeagol/views/page.rb', line 134
def
&& @sidebar.format.to_s
end
|
#slug(name) ⇒ String
This method is part of a private API.
You should avoid using this method if possible, as it may be removed or be changed in the future.
TODO:
Support configurable slugs.
Apply slug rules to name.
72
73
74
75
76
77
78
79
80
81
82
83
84
|
# File 'lib/smeagol/views/page.rb', line 72
def slug(name)
if /^\d\d+\-/ =~ name
dirs = []
parts = name.split('-')
while /^\d+$/ =~ parts.first
dirs << parts.shift
end
dirs << parts.join('-')
dirs.join('/')
else
name
end
end
|
#summary ⇒ Object
25
26
27
28
|
# File 'lib/smeagol/views/page.rb', line 25
def summary
i = content.index('</p>')
i ? content[0..i+3] : content end
|
#title ⇒ Object
Also known as:
page_title
12
13
14
|
# File 'lib/smeagol/views/page.rb', line 12
def title
page.title
end
|
#toc_content ⇒ Object
142
143
144
|
# File 'lib/smeagol/views/page.rb', line 142
def toc_content
@toc_content
end
|