Class: Precious::Views::Page

Inherits:
Layout
  • Object
show all
Includes:
HasMath, HasPage
Defined in:
lib/gollum/views/page.rb

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'

Constants included from RouteHelpers

RouteHelpers::ROUTES

Constants included from LocaleHelpers

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

Methods included from TemplateCascade

#first_path_available, #template_file, #template_priority_path, #template_priority_path=

Methods included from OcticonHelpers

included, #octicon, #rocticon, #rocticon_css

Methods included from RouteHelpers

#clean_url, included, #page_route, parse_routes

Methods included from SprocketsHelpers

included, #sprockets_asset_path, #sprockets_image_path, #sprockets_javascript_tag, #sprockets_stylesheet_tag

Methods included from LocaleHelpers

#t

Methods included from AppHelpers

#extract_page_dir

Instance Attribute Details

#contentObject (readonly)

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
  @footer
end

#headerObject (readonly)

Returns the value of attribute header.



7
8
9
# File 'lib/gollum/views/page.rb', line 7

def header
  @header
end

#historicalObject (readonly)

Returns the value of attribute historical.



7
8
9
# File 'lib/gollum/views/page.rb', line 7

def historical
  @historical
end

#pageObject (readonly)

Returns the value of attribute page.



7
8
9
# File 'lib/gollum/views/page.rb', line 7

def page
  @page
end

#previewObject (readonly)

Returns the value of attribute preview.



7
8
9
# File 'lib/gollum/views/page.rb', line 7

def preview
  @preview
end

#versionObject (readonly)

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_editingObject



93
94
95
# File 'lib/gollum/views/page.rb', line 93

def allow_editing
  @allow_editing
end

#allow_uploadsObject



97
98
99
# File 'lib/gollum/views/page.rb', line 97

def allow_uploads
  @allow_uploads
end

#authorObject



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_sideObject



135
136
137
# File 'lib/gollum/views/page.rb', line 135

def bar_side
  @bar_side.to_s
end

#body_sideObject



139
140
141
# File 'lib/gollum/views/page.rb', line 139

def body_side
  @bar_side == :right ? "left" : "right"
end


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

#dateObject



57
58
59
# File 'lib/gollum/views/page.rb', line 57

def date
  date_full.strftime(DATE_FORMAT)
end

#date_formatObject



65
66
67
# File 'lib/gollum/views/page.rb', line 65

def date_format
  DATE_FORMAT
end

#date_fullObject



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

#datetimeObject



61
62
63
# File 'lib/gollum/views/page.rb', line 61

def datetime
  date_full.utc.iso8601
end

#editableObject



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_content
  has_footer && @footer.formatted_data
end


131
132
133
# File 'lib/gollum/views/page.rb', line 131

def footer_format
  has_footer && @footer.format.to_s
end

#full_url_pathObject



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 has_footer
  if @footer
    @footer.formatted_data.strip.empty? ? false : true
  else
    @footer = (@page.footer || false)
    !!@footer
  end
end

#has_headerObject



101
102
103
104
105
106
107
108
# File 'lib/gollum/views/page.rb', line 101

def has_header
  if @header
    @header.formatted_data.strip.empty? ? false : true
  else
    @header = (@page.header || false)
    !!@header
  end
end

#has_sidebarObject



147
148
149
150
151
152
153
154
# File 'lib/gollum/views/page.rb', line 147

def has_sidebar
  if @sidebar
    @sidebar.formatted_data.strip.empty? ? false : true
  else
    @sidebar = (@page.sidebar || false)
    !!@sidebar
  end
end

#has_tocObject



164
165
166
# File 'lib/gollum/views/page.rb', line 164

def has_toc
  !@toc_content.nil?
end

#header_contentObject



110
111
112
# File 'lib/gollum/views/page.rb', line 110

def header_content
  has_header && @header.formatted_data
end

#header_enum?Boolean

Returns:

  • (Boolean)


203
204
205
# File 'lib/gollum/views/page.rb', line 203

def header_enum?
  !!['header_enum']
end

#header_enum_styleObject



207
208
209
210
211
# File 'lib/gollum/views/page.rb', line 207

def header_enum_style
  if header_enum?
    VALID_COUNTER_STYLES.include?(['header_enum']) ? ['header_enum'] : 'decimal'
  end
end

#header_formatObject



114
115
116
# File 'lib/gollum/views/page.rb', line 114

def header_format
  has_header && @header.format.to_s
end

#historyObject



81
82
83
# File 'lib/gollum/views/page.rb', line 81

def history
  true
end

#latest_changesObject



85
86
87
# File 'lib/gollum/views/page.rb', line 85

def latest_changes
  true
end

#left_barObject



143
144
145
# File 'lib/gollum/views/page.rb', line 143

def left_bar
  @bar_side == :left
end

#metadataObject

Access to embedded metadata.

Returns Hash.



187
188
189
# File 'lib/gollum/views/page.rb', line 187

def 
  @page.
end

Returns:

  • (Boolean)


176
177
178
# File 'lib/gollum/views/page.rb', line 176

def navbar?
  @navbar
end

#noindexObject



69
70
71
# File 'lib/gollum/views/page.rb', line 69

def noindex
  @version ? true : false
end

#overviewObject



89
90
91
# File 'lib/gollum/views/page.rb', line 89

def overview
  true
end

#page_headerObject



24
25
26
# File 'lib/gollum/views/page.rb', line 24

def page_header
  title
end

#rendered_metadataObject

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 
  return '' unless page.display_metadata? && !.empty?
  @rendered_metadata ||= table()
end

#searchObject



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_content
  has_sidebar && @sidebar.formatted_data
end


160
161
162
# File 'lib/gollum/views/page.rb', line 160

def sidebar_format
  has_sidebar && @sidebar.format.to_s
end

#titleObject



19
20
21
22
# File 'lib/gollum/views/page.rb', line 19

def title
  h1 = @h1_title ? page_header_from_content(@content) : false
  h1 || @page.url_path_title # url_path_title is the metadata title if present, otherwise the filename-based title
end

#toc_contentObject



168
169
170
# File 'lib/gollum/views/page.rb', line 168

def toc_content
  @toc_content
end

#use_identiconObject



172
173
174
# File 'lib/gollum/views/page.rb', line 172

def use_identicon
  @page.wiki.user_icons == 'identicon'
end