The Artima Developer Community
Sponsored Link

Ruby Buzz Forum
Generating the item list

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Adam Green

Posts: 102
Nickname: darwinian
Registered: Dec, 2005

Adam Green is the author of Ruby.Darwinianweb.com
Generating the item list Posted: Jan 10, 2006 6:11 PM
Reply to this message Reply

This post originated from an RSS feed registered with Ruby Buzz by Adam Green.
Original Post: Generating the item list
Feed Title: ruby.darwinianweb.com
Feed URL: http://www.nemesis-one.com/rss.xml
Feed Description: Adam Green's Ruby development site
Latest Ruby Buzz Posts
Latest Ruby Buzz Posts by Adam Green
Latest Posts From ruby.darwinianweb.com

Advertisement
The feed items from the internal feed are used to generate a string of HTML when merged with the item template.

gen_items.rb

 #! /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

Read: Generating the item list

Topic: RSS aggregation seems to be working Previous Topic   Next Topic Topic: Yahoo! Widgets

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use