#! /usr/bin/ruby
# Create an HTML string from the current feed items.
# This will appear in the RubyRiver content area.
def gen_items
# Read the entire RSS file into memory.
doc = Document.new(File.read(get_param("rubyriver.yml","internalfeed")+".xml"))
# Read the item template into memory. templatestr = File.read("item.html")
# Extract each RSS item.
# Merge with the item template to create a string of HTML.
itemstr = "" doc.elements.each('rubyriver/channel/item') do |item| currentitemstr = templatestr
currentitemstr = currentitemstr.gsub("<*itemlink*>", item.elements['link'].text)
currentitemstr = currentitemstr.gsub("<*itemtitle*>", item.elements['title'].text)
currentitemstr = currentitemstr.gsub("<*feedlink*>", item.elements['feedlink'].text)
currentitemstr = currentitemstr.gsub("<*feedtitle*>", item.elements['feedtitle'].text)
currentitemstr = currentitemstr.gsub("<*itemdate*>", item.elements['pubDate'].text[0..21])
currentitemstr = currentitemstr.gsub("<*description*>", item.elements['description'].text)
itemstr += currentitemstr
end
return itemstr
end