Parent

Class/Module Index [+]

Quicksearch

Webgen::SourceHandler::Sitemap

Source handler for creating an XML sitemap based on the specification of sitemaps.org.

Uses Webgen::Common::Sitemap to generate the needed sitemap tree and to check if a sitemap has changed.

Public Instance Methods

alcns(node) click to toggle source

Return the alcns of the sitemap node as a flat list.

# File lib/webgen/sourcehandler/sitemap.rb, line 42
def alcns(node)
  website.blackboard.invoke(:create_sitemap, node, node.lang, options_for_node(node)).to_lcn_list.flatten
end
content(node) click to toggle source

Return the rendered feed represented by node.

# File lib/webgen/sourcehandler/sitemap.rb, line 31
def content(node)
  if node.node_info[:sitemap].blocks.has_key?('template')
    node.node_info[:sitemap].blocks['template'].render(Webgen::Context.new(:chain => [node])).content
  else
    chain = [node.resolve("/templates/sitemap.template"), node]
    node.node_info[:used_nodes] << chain.first.alcn
    chain.first.node_info[:page].blocks['content'].render(Webgen::Context.new(:chain => chain)).content
  end
end
create_node(path) click to toggle source

Create an XML sitemap from path.

# File lib/webgen/sourcehandler/sitemap.rb, line 17
def create_node(path)
  page = page_from_path(path)
  path.ext = 'xml'
  if path.meta_info['site_url'].nil?
    raise Webgen::NodeCreationError.new("Needed information site_url is missing",
                                        self.class.name, path)
  end

  super(path) do |node|
    node.node_info[:sitemap] = page
  end
end

Private Instance Methods

options_for_node(node) click to toggle source

Return a hash with the sitemap-creation-options set on the node.

# File lib/webgen/sourcehandler/sitemap.rb, line 51
def options_for_node(node)
  options = {}
  node.meta_info.each {|k,v| options[k] = v if k =~ /\./}
  options
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.