Top Level Namespace

Includes:
Log4r, Nanoc3::Helpers::Breadcrumbs

Defined Under Namespace

Modules: Uv Classes: Bayeux, BayeuxFilter, BayeuxHTMLGen, BayeuxLatexGen, BayeuxTextGen, PandocFilter, ParaBlock, Reference, SectionIDFilter, TreeWalker

Instance Method Summary collapse

Instance Method Details



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/helpers/breadcrumbs.rb', line 3

def breadcrumbs_list
  page_path = breadcrumbs_trail
  
  puts "==="
  @site.items.each{|item|
    puts "found: #{item.identifier}"
  }
  puts "==="
  
  # Walk the list of parent items
  puts "---"
  item = @item
  until item.nil? do
    puts "found: #{item.identifier}"
    item = item.parent
  end
  puts "---"
  
  html_list = Array.new
  html_item = String.new
  first_item = true
  
  # Work out the page path
  page_path.reverse_each{|path_item|
    if not path_item.nil? then
      if first_item then
        html_item = "<a href=\"#{path_to_url(path_item.attributes[:filename])}\" class=\"current\">" + path_item.attributes[:title] + "</a>"
        html_list << html_item
        
        first_item = false
      else
        html_item = "<a href=\"#{path_to_url(path_item.attributes[:filename])}\">" + path_item.attributes[:title] + "</a>"
        html_list << html_item
      end
    end
  }
  
  # Return the path
  return page_path(html_list)
end

#header_id(header_text) ⇒ Object

Return the header id, given a string of text



99
100
101
# File 'lib/filters/section_id.rb', line 99

def header_id(header_text)
  return header_text.gsub(" ", "_").downcase
end

#page_path(element_list) ⇒ Object



49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# File 'lib/helpers/breadcrumbs.rb', line 49

def page_path(element_list)
  path = ""
  first_item = true
  
  element_list.reverse_each{|element|
    if first_item then
      path << element
      
      first_item = false
    else
      path << "	&raquo; " << element
    end
  }
  
  return path
end

#path_to_url(path) ⇒ Object



44
45
46
47
# File 'lib/helpers/breadcrumbs.rb', line 44

def path_to_url(path)
  page_dir = File.dirname(path)
  return page_dir[13..page_dir.length] + "/" + "index.html"
end

#site_tocObject



7
8
9
10
11
# File 'lib/helpers/site_toc.rb', line 7

def site_toc
  engine = Haml::Engine.new(@site.config[:site_toc])
    
  return engine.render
end