class Smeagol::TOC
Create a JSON-based Table of Contents. This is used to create 'toc.json', which can be used via jQuery to create a dynamic index page.
Public Class Methods
new(ctrl, options={})
click to toggle source
# File lib/smeagol/helpers/toc.rb, line 11 def initialize(ctrl, options={}) @ctrl = ctrl @wiki = ctrl.wiki @version = options[:version] || 'master' @pages = options[:pages] require 'json' end
Public Instance Methods
build_toc()
click to toggle source
# File lib/smeagol/helpers/toc.rb, line 34 def build_toc json = {} pages.each do |page| data = {} data['title'] = page.title data['name'] = page.name data['href'] = page.href data['date'] = page.post_date if page.post_date data['author'] = page.author data['summary'] = page.summary json[page.name] = data end json end
pages()
click to toggle source
# File lib/smeagol/helpers/toc.rb, line 50 def pages @ctrl.views(@version).reject{ |v| Smeagol::Views::Form === v } end
to_json()
click to toggle source
# File lib/smeagol/helpers/toc.rb, line 21 def to_json toc.to_json end
Also aliased as: to_s
toc()
click to toggle source
# File lib/smeagol/helpers/toc.rb, line 29 def toc @toc ||= build_toc end