Never been to TextSnippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world (or not, you can keep them private!)

« Newer Snippets
Older Snippets »
3 total  XML / RSS feed 

simple Ruby RSS reader

// fetch & parse RSS into an object

require 'rss/2.0'
require 'open-uri'

class RssReader

  def parseFeed (url, length)
    feed_url = url
    output = "";
    open(feed_url) do |http|
      response = http.read
      result = RSS::Parser.parse(response, false)
      output = "<span class=\"feedTitle\">#{result.channel.title}</span><br /><ul>" 
      result.items.each_with_index do |item, i|
        output += "<li><a href=\"#{item.link}\">#{item.title}</a></li>" if ++i < length  
      end 
      output += "</ul>" 
    end
    return output
  end

end

Refresh rate in Vienna

Change the default refresh rate in seconds for the Vienna RSS reader to whatever you want. Anything less than 1800 seconds might be considered bad netiquette, but it's useful if you're only subscribed to internal feeds (e.g., activeCollab, Connector).

defaults write uk.co.opencommunity.vienna2 CheckFrequencyInSeconds 60

Photoblogging with Textpattern: rss feeds

Add this to textpattern/publish/rss.php somewhere around line 62 (in 4.0.2), or after "$Body = (!trim($Body)) ? $thisarticle['body'] : $Body;":
// hack to get pictures to syndicate
if ($a['Section'] == "photo")
{
$img_url = hu."images/".$a['Image'].'.jpg';
$Body = doSpecial('<a href="'.permlinkurl($a).'"><img src="'.$img_url.'" alt="the latest and greatest" /></a>');
}
// /hack
« Newer Snippets
Older Snippets »
3 total  XML / RSS feed