lib/webgen/sourcehandler/feed.rb in gettalong-webgen-0.5.5.20081010 vs lib/webgen/sourcehandler/feed.rb in gettalong-webgen-0.5.5.20081012
- old
+ new
@@ -44,24 +44,22 @@
if node.node_info[:feed].blocks.has_key?(block_name)
node.node_info[:feed].blocks[block_name].
render(Webgen::ContentProcessor::Context.new(:chain => [node])).content
else
feed = (website.cache.volatile[:sourcehandler_feed] ||= {})[node.node_info[:src]] ||= build_feed_for(node)
- feed.feed_type = node.node_info[:feed_type]
- feed.build_xml
+ feed.build_xml(node.node_info[:feed_type], (node.node_info[:feed_type] == 'rss' ? node['rss_version'] || 2.0 : nil))
end
end
# Helper method for returning the entries for the feed node +node+.
def feed_entries(node)
nr_items = (node['number_of_entries'].to_i == 0 ? 10 : node['number_of_entries'].to_i)
patterns = [node['entries']].flatten.map {|pat| Pathname.new(pat =~ /^\// ? pat : File.join(node.parent.absolute_lcn, pat)).cleanpath.to_s}
node.tree.node_access[:alcn].values.
select {|node| patterns.any? {|pat| node =~ pat} && node.node_info[:page]}.
- sort {|a,b| a['modified_at'] <=> b['modified_at']}.
- reverse[0, nr_items]
+ sort {|a,b| a['modified_at'] <=> b['modified_at']}[0, nr_items]
end
#######
private
#######
@@ -83,16 +81,15 @@
feed.id = feed.link
feed.published = (node['created_at'].kind_of?(Time) ? node['created_at'] : Time.now)
feed.updated = Time.now
feed.generator = 'webgen - Webgen::SourceHandler::Feed'
- feed.icon = File.join(site_url, node.tree[node['icon']].path) if node['icon']
node.feed_entries.each do |entry|
item = FeedTools::FeedItem.new
item.title = entry['title']
item.link = File.join(site_url, entry.path)
- item.content = entry.node_info[:page].blocks['content'].render(Webgen::ContentProcessor::Context.new(:chain => [entry])).content
+ item.content = entry.node_info[:page].blocks[node['content_block_name'] || 'content'].render(Webgen::ContentProcessor::Context.new(:chain => [entry])).content
item.updated = entry['modified_at']
item.published = entry['created_at'] if entry['created_at'].kind_of?(Time)
if entry['author']
item.author = entry['author']
item.author.url = entry['author_url']