class Webgen::PathHandler::Feed

Path handler for creating atom and/or rss feeds.

When customizing a feed template one can use the following utiltity methods:

Have a look at the default feed templates to see them in action.

Constants

MANDATORY_INFOS

The mandatory keys that need to be set in a feed file.

Public Instance Methods

content(node) click to toggle source

Return the rendered feed represented by node.

# File lib/webgen/path_handler/feed.rb, line 84
def content(node)
  context = Webgen::Context.new(@website)
  context.render_block(:name => "#{node['version']}_template", :node => 'first',
                       :chain => [node, node.resolve("/templates/feed.template", node.lang, true), node].compact)
end
create_nodes(path, blocks) click to toggle source

Create the feed nodes.

# File lib/webgen/path_handler/feed.rb, line 57
def create_nodes(path, blocks)
  if MANDATORY_INFOS.any? {|t| path.meta_info[t].nil?}
    raise Webgen::NodeCreationError.new("At least one of #{MANDATORY_INFOS.join('/')} is missing",
                                        "path_handler.feed", path)
  end
  if @website.config['website.base_url'].empty?
    raise Webgen::NodeCreationError.new("The configuration option 'website.base_url' needs to be set",
                                        "path_handler.feed", path)
  end
  if !['atom', 'rss'].include?(path['version'])
    raise Webgen::NodeCreationError.new("Invalid version '#{path['version']}' for feed path specified, only atom and rss allowed",
                                        "path_handler.feed", path)
  end

  path.ext = path['version']
  path['dest_path'] ||= '<parent><basename>(.<lang>)<ext>'
  path['cn'] ||= '<basename><ext>'
  path['node_class'] = Node.to_s
  create_node(path) do |node|
    set_blocks(node, blocks)
    node.meta_info['link'] ||= node.parent.alcn
    @website.ext.item_tracker.add(node, :nodes, :node_finder_option_set,
                                  {:opts => node['entries'], :ref_alcn => node.alcn}, :content)
  end
end