Class: Gollum::Macro::GlobalTOC

Inherits:
Gollum::Macro show all
Defined in:
lib/gollum-lib/macro/global_toc.rb

Instance Method Summary collapse

Methods inherited from Gollum::Macro

#initialize, instance

Constructor Details

This class inherits a constructor from Gollum::Macro

Instance Method Details

#render(title = "Global Table of Contents") ⇒ Object



4
5
6
7
8
9
10
# File 'lib/gollum-lib/macro/global_toc.rb', line 4

def render(title = "Global Table of Contents")
  if @wiki.pages.size > 0
    prepath = @wiki.base_path.sub(/\/$/, '')
    result  = '<ul>' + @wiki.pages.map { |p| "<li><a href=\"#{CGI::escapeHTML(prepath + "/" + p.escaped_url_path)}\">#{CGI::escapeHTML(p.url_path)}</a></li>" }.join + '</ul>'
  end
  "<div class=\"toc\"><div class=\"toc-title\">#{title}</div>#{result}</div>"
end