class Smeagol::Views::Page

Public Instance Methods

author() click to toggle source

Public: The last author of this page.

# File lib/smeagol/views/page.rb, line 31
def author
  page.version.author.name
end
commit_date() click to toggle source

Public: The last edit date of this page.

# File lib/smeagol/views/page.rb, line 41
def commit_date
  page.version.authored_date.strftime(settings.date_format)
end
content() click to toggle source

Public: The HTML formatted content of the page.

# File lib/smeagol/views/page.rb, line 20
def content
  page.formatted_data
end
date() click to toggle source

Public: The last edit date of this page.

# File lib/smeagol/views/page.rb, line 36
def date
  post_date || commit_date
end
has_header() click to toggle source
# File lib/smeagol/views/page.rb, line 99
def has_header
  @header = (@page.header || false) if @header.nil?
  !!@header
end
has_sidebar() click to toggle source
# File lib/smeagol/views/page.rb, line 125
def has_sidebar
  @sidebar = (@page.sidebar || false) if @sidebar.nil?
  !!@sidebar
end
has_toc() click to toggle source
# File lib/smeagol/views/page.rb, line 138
def has_toc
  !@toc_content.nil?
end
header_content() click to toggle source
# File lib/smeagol/views/page.rb, line 104
def header_content
  has_header && @header.formatted_data
end
header_format() click to toggle source
# File lib/smeagol/views/page.rb, line 108
def header_format
  has_header && @header.format.to_s
end
href() click to toggle source

Public: static href, used when generating static site.

# 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 #|| 'Home'
      'index.html'
    else
      ::File.join(name, 'index.html')
    end
  end
end
mathjax() click to toggle source
# File lib/smeagol/views/page.rb, line 146
def mathjax
  @mathjax
end
not_home?() click to toggle source

Public: A flag stating that this is not the home page.

# File lib/smeagol/views/page.rb, line 46
def not_home?
  page.title != "Home"  # settings.index
end
page_title()

TODO: temporary alias

Alias for: title
post?() click to toggle source
# File lib/smeagol/views/page.rb, line 95
def post?
  /^(\d\d\d\d-\d\d-\d\d)/.match(filename)
end
post_date() click to toggle source

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.

# 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
sidebar_content() click to toggle source
sidebar_format() click to toggle source
slug(name) click to toggle source

Internal: Apply slug rules to name.

TODO: Support configurable slugs.

Returns [String] Sluggified name.

# 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() click to toggle source
# File lib/smeagol/views/page.rb, line 25
def summary
  i = content.index('</p>')
  i ? content[0..i+3] : content  # any other way if no i, 5 line limit?
end
title() click to toggle source

Public: The title of the page.

# File lib/smeagol/views/page.rb, line 12
def title
  page.title
end
Also aliased as: page_title
toc_content() click to toggle source
# File lib/smeagol/views/page.rb, line 142
def toc_content
  @toc_content
end