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
84 def content(node)
85   context = Webgen::Context.new(@website)
86   context.render_block(:name => "#{node['version']}_template", :node => 'first',
87                        :chain => [node, node.resolve("/templates/feed.template", node.lang, true), node].compact)
88 end
create_nodes(path, blocks) click to toggle source

Create the feed nodes.

   # File lib/webgen/path_handler/feed.rb
57 def create_nodes(path, blocks)
58   if MANDATORY_INFOS.any? {|t| path.meta_info[t].nil?}
59     raise Webgen::NodeCreationError.new("At least one of #{MANDATORY_INFOS.join('/')} is missing",
60                                         "path_handler.feed", path)
61   end
62   if @website.config['website.base_url'].empty?
63     raise Webgen::NodeCreationError.new("The configuration option 'website.base_url' needs to be set",
64                                         "path_handler.feed", path)
65   end
66   if !['atom', 'rss'].include?(path['version'])
67     raise Webgen::NodeCreationError.new("Invalid version '#{path['version']}' for feed path specified, only atom and rss allowed",
68                                         "path_handler.feed", path)
69   end
70 
71   path.ext = path['version']
72   path['dest_path'] ||= '<parent><basename>(.<lang>)<ext>'
73   path['cn'] ||= '<basename><ext>'
74   path['node_class'] = Node.to_s
75   create_node(path) do |node|
76     set_blocks(node, blocks)
77     node.meta_info['link'] ||= node.parent.alcn
78     @website.ext.item_tracker.add(node, :nodes, :node_finder_option_set,
79                                   {:opts => node['entries'], :ref_alcn => node.alcn}, :content)
80   end
81 end