Sha256: dc93d60b41666eb46e391f29106ff3e74a015fc1909f8d8aeb6ff906cec7e94c

Contents?: true

Size: 1.09 KB

Versions: 15

Compression:

Stored size: 1.09 KB

Contents

# -*- encoding: utf-8 -*-

module Webgen::Tag

  # Generates a sitemap. The sitemap contains the hierarchy of all pages on the web site.
  class Sitemap

    include Base
    include Webgen::WebsiteAccess

    # Create the sitemap.
    def call(tag, body, context)
      tree = website.blackboard.invoke(:create_sitemap, context.dest_node, context.content_node.lang, @params)
      (tree.children.empty? ? '' : output_sitemap(tree, context))
    end

    #######
    private
    #######

    # The modified tag base to support the easy specification of common.sitemap.* options.
    def tag_config_base
      'common.sitemap'
    end

    # Create the HTML representation of the sitemap nodes in +tree+ in respect to +context+.
    def output_sitemap(tree, context)
      out = "<ul>"
      tree.children.each do |child|
        sub = (child.children.length > 0 ? output_sitemap(child, context) : '')
        out << "<li>" + context.dest_node.link_to(child.node, :lang => child.node.lang || context.content_node.lang)
        out << sub
        out << "</li>"
      end
      out << "</ul>"
      out
    end

  end

end

Version data entries

15 entries across 15 versions & 3 rubygems

Version Path
gettalong-webgen-0.5.7.20090227 lib/webgen/tag/sitemap.rb
gettalong-webgen-0.5.8.20090507 lib/webgen/tag/sitemap.rb
gettalong-webgen-0.5.9.20090620 lib/webgen/tag/sitemap.rb
gettalong-webgen-0.5.9.20090626 lib/webgen/tag/sitemap.rb
thewoolleyman-webgen-0.5.8.20090419 lib/webgen/tag/sitemap.rb
webgen-0.5.17 lib/webgen/tag/sitemap.rb
webgen-0.5.15 lib/webgen/tag/sitemap.rb
webgen-0.5.14 lib/webgen/tag/sitemap.rb
webgen-0.5.13 lib/webgen/tag/sitemap.rb
webgen-0.5.12 lib/webgen/tag/sitemap.rb
webgen-0.5.11 lib/webgen/tag/sitemap.rb
webgen-0.5.10 lib/webgen/tag/sitemap.rb
webgen-0.5.9 lib/webgen/tag/sitemap.rb
webgen-0.5.7 lib/webgen/tag/sitemap.rb
webgen-0.5.8 lib/webgen/tag/sitemap.rb