Class: Precious::Views::Page
Constant Summary
collapse
- VALID_COUNTER_STYLES =
['decimal', 'decimal-leading-zero', 'arabic-indic', 'armenian', 'upper-armenian',
'lower-armenian', 'bengali', 'cambodian', 'khmer', 'cjk-decimal', 'devanagari', 'georgian', 'gujarati', 'gurmukhi',
'hebrew', 'kannada', 'lao', 'malayalam', 'mongolian', 'myanmar', 'oriya', 'persian', 'lower-roman', 'upper-roman',
'tamil', 'telugu', 'thai', 'tibetan', 'lower-alpha', 'lower-latin', 'upper-alpha', 'upper-latin', 'cjk-earthly-branch',
'cjk-heavenly-stem', 'lower-greek', 'hiragana', 'hiragana-iroha', 'katakana', 'katakana-iroha', 'disc', 'circle', 'square',
'disclosure-open', 'disclosure-closed']
- DATE_FORMAT =
"%Y-%m-%d %H:%M:%S"
- DEFAULT_AUTHOR =
'you'
RouteHelpers::ROUTES
LocaleHelpers::NO_METHOD_MESSAGE, LocaleHelpers::YAML_VARIABLE_REGEXP
Instance Attribute Summary collapse
Attributes inherited from Layout
#name, #path
Instance Method Summary
collapse
Methods included from HasMath
#mathjax, #mathjax_config
Methods included from HasPage
#escaped_url_path, #format, #id, #path
Methods inherited from Layout
#base_url, #critic_markup, #css, #custom_css, #custom_js, #custom_path, #escaped_name, #has_path, #js, #mathjax_config_path, #mathjax_js, #partial, #per_page_uploads, #show_local_time
#first_path_available, #template_file, #template_priority_path, #template_priority_path=
included, #octicon, #rocticon, #rocticon_css
#clean_url, included, #page_route, parse_routes
included, #sprockets_asset_path, #sprockets_image_path, #sprockets_javascript_tag, #sprockets_stylesheet_tag
#t
Methods included from AppHelpers
#extract_page_dir
Instance Attribute Details
#content ⇒ Object
Returns the value of attribute content.
7
8
9
|
# File 'lib/gollum/views/page.rb', line 7
def content
@content
end
|
Returns the value of attribute footer.
7
8
9
|
# File 'lib/gollum/views/page.rb', line 7
def
@footer
end
|
Returns the value of attribute header.
7
8
9
|
# File 'lib/gollum/views/page.rb', line 7
def
@header
end
|
#historical ⇒ Object
Returns the value of attribute historical.
7
8
9
|
# File 'lib/gollum/views/page.rb', line 7
def historical
@historical
end
|
#page ⇒ Object
Returns the value of attribute page.
7
8
9
|
# File 'lib/gollum/views/page.rb', line 7
def page
@page
end
|
#preview ⇒ Object
Returns the value of attribute preview.
7
8
9
|
# File 'lib/gollum/views/page.rb', line 7
def preview
@preview
end
|
#version ⇒ Object
Returns the value of attribute version.
7
8
9
|
# File 'lib/gollum/views/page.rb', line 7
def version
@version
end
|
Instance Method Details
#allow_editing ⇒ Object
93
94
95
|
# File 'lib/gollum/views/page.rb', line 93
def allow_editing
@allow_editing
end
|
#allow_uploads ⇒ Object
97
98
99
|
# File 'lib/gollum/views/page.rb', line 97
def allow_uploads
@allow_uploads
end
|
#author ⇒ Object
45
46
47
48
49
|
# File 'lib/gollum/views/page.rb', line 45
def author
first = @version ? page.version : page.last_version
return DEFAULT_AUTHOR unless first
first.author.name.respond_to?(:force_encoding) ? first.author.name.force_encoding('UTF-8') : first.author.name
end
|
#bar_side ⇒ Object
135
136
137
|
# File 'lib/gollum/views/page.rb', line 135
def bar_side
@bar_side.to_s
end
|
#body_side ⇒ Object
139
140
141
|
# File 'lib/gollum/views/page.rb', line 139
def body_side
@bar_side == :right ? "left" : "right"
end
|
#breadcrumb ⇒ Object
28
29
30
31
32
33
34
35
36
37
38
39
|
# File 'lib/gollum/views/page.rb', line 28
def breadcrumb
path = Pathname.new(@page.url_path).parent
return '' if path.to_s == '.'
breadcrumb = [%{<nav aria-label="Breadcrumb"><ol>}]
path.descend do |crumb|
element = "#{crumb.basename}"
next if element == @page.title
breadcrumb << %{<li class="breadcrumb-item"><a href="#{overview_path}/#{crumb}/">#{CGI.escapeHTML(element.to_s)}</a></li>}
end
breadcrumb << %{</ol></nav>}
breadcrumb.join("\n")
end
|
#date ⇒ Object
57
58
59
|
# File 'lib/gollum/views/page.rb', line 57
def date
date_full.strftime(DATE_FORMAT)
end
|
65
66
67
|
# File 'lib/gollum/views/page.rb', line 65
def date_format
DATE_FORMAT
end
|
#date_full ⇒ Object
51
52
53
54
55
|
# File 'lib/gollum/views/page.rb', line 51
def date_full
first = @version ? page.version : page.last_version
return Time.now unless first
first.authored_date
end
|
#datetime ⇒ Object
61
62
63
|
# File 'lib/gollum/views/page.rb', line 61
def datetime
date_full.utc.iso8601
end
|
#editable ⇒ Object
73
74
75
|
# File 'lib/gollum/views/page.rb', line 73
def editable
@editable
end
|
127
128
129
|
# File 'lib/gollum/views/page.rb', line 127
def
&& @footer.formatted_data
end
|
131
132
133
|
# File 'lib/gollum/views/page.rb', line 131
def
&& @footer.format.to_s
end
|
#full_url_path ⇒ Object
180
181
182
|
# File 'lib/gollum/views/page.rb', line 180
def full_url_path
page_route(@page.escaped_url_path)
end
|
118
119
120
121
122
123
124
125
|
# File 'lib/gollum/views/page.rb', line 118
def
if @footer
@footer.formatted_data.strip.empty? ? false : true
else
@footer = (@page. || false)
!!@footer
end
end
|
101
102
103
104
105
106
107
108
|
# File 'lib/gollum/views/page.rb', line 101
def
if @header
@header.formatted_data.strip.empty? ? false : true
else
@header = (@page. || false)
!!@header
end
end
|
147
148
149
150
151
152
153
154
|
# File 'lib/gollum/views/page.rb', line 147
def
if @sidebar
@sidebar.formatted_data.strip.empty? ? false : true
else
@sidebar = (@page. || false)
!!@sidebar
end
end
|
#has_toc ⇒ Object
164
165
166
|
# File 'lib/gollum/views/page.rb', line 164
def has_toc
!@toc_content.nil?
end
|
110
111
112
|
# File 'lib/gollum/views/page.rb', line 110
def
&& @header.formatted_data
end
|
203
204
205
|
# File 'lib/gollum/views/page.rb', line 203
def
!!metadata['header_enum']
end
|
207
208
209
210
211
|
# File 'lib/gollum/views/page.rb', line 207
def
if
VALID_COUNTER_STYLES.include?(metadata['header_enum']) ? metadata['header_enum'] : 'decimal'
end
end
|
114
115
116
|
# File 'lib/gollum/views/page.rb', line 114
def
&& @header.format.to_s
end
|
#history ⇒ Object
81
82
83
|
# File 'lib/gollum/views/page.rb', line 81
def history
true
end
|
#latest_changes ⇒ Object
85
86
87
|
# File 'lib/gollum/views/page.rb', line 85
def latest_changes
true
end
|
#left_bar ⇒ Object
143
144
145
|
# File 'lib/gollum/views/page.rb', line 143
def left_bar
@bar_side == :left
end
|
Access to embedded metadata.
Returns Hash.
187
188
189
|
# File 'lib/gollum/views/page.rb', line 187
def metadata
@page.metadata
end
|
#navbar? ⇒ Boolean
176
177
178
|
# File 'lib/gollum/views/page.rb', line 176
def navbar?
@navbar
end
|
#noindex ⇒ Object
69
70
71
|
# File 'lib/gollum/views/page.rb', line 69
def noindex
@version ? true : false
end
|
#overview ⇒ Object
89
90
91
|
# File 'lib/gollum/views/page.rb', line 89
def overview
true
end
|
24
25
26
|
# File 'lib/gollum/views/page.rb', line 24
def
title
end
|
Access to embedded metadata.
Examples
{{#rendered_metadata}}{{name}}{{/rendered_metadata}}
Returns HTML table.
198
199
200
201
|
# File 'lib/gollum/views/page.rb', line 198
def rendered_metadata
return '' unless page.display_metadata? && !metadata.empty?
@rendered_metadata ||= table(metadata)
end
|
#search ⇒ Object
77
78
79
|
# File 'lib/gollum/views/page.rb', line 77
def search
true
end
|
156
157
158
|
# File 'lib/gollum/views/page.rb', line 156
def
&& @sidebar.formatted_data
end
|
160
161
162
|
# File 'lib/gollum/views/page.rb', line 160
def
&& @sidebar.format.to_s
end
|
#title ⇒ Object
19
20
21
22
|
# File 'lib/gollum/views/page.rb', line 19
def title
h1 = @h1_title ? (@content) : false
h1 || @page.url_path_title end
|
#toc_content ⇒ Object
168
169
170
|
# File 'lib/gollum/views/page.rb', line 168
def toc_content
@toc_content
end
|
#use_identicon ⇒ Object
172
173
174
|
# File 'lib/gollum/views/page.rb', line 172
def use_identicon
@page.wiki.user_icons == 'identicon'
end
|