Class: Webgen::Tag::BreadcrumbTrail

Inherits:
Object
  • Object
show all
Includes:
Base, WebsiteAccess
Defined in:
lib/webgen/tag/breadcrumbtrail.rb

Overview

Generates a breadcrumb trail for the page. This is especially useful when pages are in deep hierarchies of directories.

Instance Method Summary collapse

Methods included from Base

#create_params_hash, #create_tag_params, #param, #set_params

Methods included from WebsiteAccess

included, website

Methods included from Loggable

#log, #puts

Constructor Details

#initializeBreadcrumbTrail

:nodoc:



12
13
14
# File 'lib/webgen/tag/breadcrumbtrail.rb', line 12

def initialize #:nodoc:
  website.blackboard.add_listener(:node_changed?, method(:node_changed?))
end

Instance Method Details

#call(tag, body, context) ⇒ Object

Create the breadcrumb trail.



17
18
19
20
21
22
23
24
# File 'lib/webgen/tag/breadcrumbtrail.rb', line 17

def call(tag, body, context)
  out = breadcrumb_trail_list(context.content_node)
  (context.dest_node.node_info[:tag_breadcrumb_trail] ||= {})[[@params.to_a.sort, context.content_node.alcn]] = out.map {|n| n.alcn}
  out = out.map {|n| context.dest_node.link_to(n, :lang => context.content_node.lang) }.
    join(param('tag.breadcrumbtrail.separator'))
  log(:debug) { "Breadcrumb trail for <#{context.content_node.alcn}>: #{out}" }
  out
end