Class: Webgen::PathHandler::Feed
- Inherits:
-
Object
- Object
- Webgen::PathHandler::Feed
- Defined in:
- lib/webgen/path_handler/feed.rb
Overview
Path handler for creating atom and/or rss feeds.
When customizing a feed template one can use the following utiltity methods:
-
#feed_entries
-
#feed_link
-
#entry_content
Have a look at the default feed templates to see them in action.
Defined Under Namespace
Classes: Node
Constant Summary collapse
- MANDATORY_INFOS =
The mandatory keys that need to be set in a feed file.
%W[author entries]
Constants included from Base
Base::DEST_PATH_PARENT_SEGMENTS, Base::DEST_PATH_SEGMENTS
Instance Method Summary collapse
-
#content(node) ⇒ Object
Return the rendered feed represented by
node
. -
#create_nodes(path, blocks) ⇒ Object
Create the feed nodes.
Methods included from PageUtils
#create_node, #parse_meta_info!
Methods included from Base
#initialize, #parse_meta_info!
Instance Method Details
#content(node) ⇒ Object
Return the rendered feed represented by node
.
85 86 87 88 89 |
# File 'lib/webgen/path_handler/feed.rb', line 85 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) ⇒ Object
Create the feed nodes.
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 |
# File 'lib/webgen/path_handler/feed.rb', line 58 def create_nodes(path, blocks) if MANDATORY_INFOS.any? {|t| path.[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.['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 |