(???) !/usr/pkg/bin/ruby
(???) equire 'rss'
(???) equire 'open-uri'
(???) equire 'socket'
tem_num = 10
(PNG) age_num = ARGV[1].to_i
(???) ss_url = ARGV[0].to_s
(???) ss_file = ""
(???) Check to see what protocol we are using
f (rss_url[0..6] == "http://")
(???) begin
(???) open(rss_url) do |f|
(???) rss_file = f.read
(???) end
(???) rescue Errno::ENOENT
(???) end
(???) lsif (rss_url[0..8] == "gopher://")
(???) url = rss_url
(???) urldup = url.dup
(???) urldup.slice!(0,9)
(???)
(???) # Split the url into the host name and port and url selector
(???) url_arr = urldup.split('/')
(???) host = url_arr[0]
(???) url_arr.delete_at(0)
(???) port_arr = host.split(':')
(???) new_host = port_arr[0]
(???) # See if there is a port number provided, if not make it 70
(???) if (port_arr[1] == nil)
(???) port = 70
(???) else
(???) port = port_arr[1]
(???) end
(???)
(???)
(???) # Test to see if the first part of the url is an itemtype, if so, delete it
(???) if (url_arr[0] =~ /^([0-9]|[g-i]|I|s|T|p)/ && url_arr[0].length == 1)
(???) url_arr.delete_at(0)
(???) end
(???)
(???) # Merge the url together with slashes
(???) path = url_arr.join('/')
(???) ## Variables to use later: new_host, port, path
(???) # Download the rss file
(???) socket = TCPSocket.open(new_host, port)
(???) socket.print("#{path}\r\n")
(???) rss_file = socket.read
(???) rss_file = rss_file.strip
(???) socket.close
(???)
(???)
(???) lsif (rss_url[0..7] == "https://")
(???) lse
(???) rss_url = "http://" + rss_url
(???) begin
(???) open(rss_url) do |f|
(???) rss_file = f.read
(???) end
(???) rescue Errno::ENOENT
(???) end
(???) nd
(???) ss = RSS::Parser.parse(rss_file)
f (rss == nil)
(???) lse
(???) # Output the feed title and website URL
(???)
(???) item_pg_num = 1
(???) # Print the content of the feed
(???) rss.items.each do |item|
(???) while( page_num*item_num > item_pg_num )
(???)
(???) # Check to see it the link given is gopher or http
(???) if(item.link[0..3] == "http")
(???)
(???) # If it's http, print a nice link
(???)
(???) elsif(item.link[0..5] == "gopher")
(???)
(???) # If it's gopher break the path down into link_path, link_host, link_port, and link_itemtype
(???) item.link.slice!(0,9)
(???) link_url_arr = item.link.split('/')
(???) link_host = url_arr[0]
(???) link_url_arr.delete_at(0)
(???) link_port_arr = host.split(':')
(???) link_new_host = port_arr[0]
(???)
(???) if (link_port_arr[1] == nil)
(???) link_port = 70
(???) else
(???) link_port = link_port_arr[1]
(???) end
(???)
(???) if (link_url_arr[0] =~ /^([0-9]|[g-i]|I|s|T|p)/ && link_url_arr[0].length == 1)
(???) link_itemtype = link_url_arr[0]
(???) link_url_arr.delete_at(0)
(???) end
(???) link_path = link_url_arr.join('/')
(???)
(???) # Finally, just print the link already!
(???) end
(???)
(???)
(???) # Get rid of all that nasty html
(???) new_desc = item.description.gsub(/<.*>/, '')
(???) new_desc = new_desc.gsub(" ", ' ')
(???) new_desc = new_desc.gsub("—", '-')
(???) new_desc = new_desc.strip
(???) #new_desc = new_desc.split(" ")
(???) item_pg_num = item_pg_num + 1
(???) end
(???) end
(???) nd
(???) Print footer