The Artima Developer Community
Sponsored Link

Ruby Buzz Forum
Generating the feed 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 feed list Posted: Jan 8, 2006 10:10 PM
Reply to this message Reply

This post originated from an RSS feed registered with Ruby Buzz by Adam Green.
Original Post: Generating the feed 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
A template isn't needed for the list of feeds that appears on the navbar. All I have to do is generate an HTML string and return it to the program that is generating the home page.

gen_feedlist.rb

 #! /usr/bin/ruby



# Create an HTML string from the current .OPML feedlist.
# This will appear on the RubyRiver navbar.
def gen_feedlist



# Read the .opml file into memory for XML parsing.
opmlfile = File.open(get_param("rubyriver.yml","feedlist"))
opmldoc = Document.new(opmlfile.read)
opmlfile.close



# Add the details for each feed to a single string.
feedstr = ""
opmldoc.elements.each("opml/body/outline/outline") do |item|



feedstr += '<a href="' + item.attributes["htmlUrl"] + '">' +
item.attributes["title"] + '</a> (' + '<a href="' +
item.attributes["xmlUrl"] + '">feed</a>)<br>'



end



return feedstr
end

Read: Generating the feed list

Topic: Ruby code get simpler over time Previous Topic   Next Topic Topic: The PDX.rb Podcast

Sponsored Links



Google
  Web Artima.com   

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