[dev-context] Re: texshow-web rss feed added

Patrick Gundlach patrick at gundla.ch
Thu Oct 21 18:51:27 CEST 2004


Hello Hans,

> interesting, i was considering to add something like that to the
> website, but could not figure out what the exact approach is; for
> instance how do you determine what goes into the feed? Is that per
> day?

Last 10 entries. Allowed in rss 0.91 are 15 entries max. As soon as a
user edits a comment (or alike) a log entry gets written to a file. I
publish the last 10 lines. See also for rss spec:

http://channel.netscape.com/publish/help/mnn20/quickstart.html



I did a quick hack in \startofftopic ruby

-------------------------------------------------- rsstest.rb
require 'rss'

feed=Rss.new

puts feed.rss {
  feed.title { "rsstest " } +
  feed.description { "my description" } + 
  feed.link { "some link" } +
  feed.language { "en" } +
  feed.item { 
      feed.title { "itemtitle" } +
      feed.link { "item link" } +
      feed.description { "item description"}
  }
}
-------------------------------------------------- rss.rb
class Rss 
  def initialize
  end
  def rss
    string = %Q{<?xml version="1.0"?>
<rss version="0.91">
<channel>}
    string += yield.to_s if block_given?
    string +="</channel>\n</rss>\n"
  end
  def item
    string =" <item>"
    string += yield.to_s if block_given?
    string +="</item>\n"
  end
  def description
    string =" <description>"
    string += yield.to_s if block_given?
    string +="</description>\n"
  end

  def title
    string =" <title>"
    string += yield.to_s if block_given?
    string +="</title>\n"
  end
  def link
    string =" <link>"
    string += yield.to_s if block_given?
    string +="</link>\n"
  end
  def language
    string =" <language>"
    string += yield.to_s if block_given?
    string +="</language>\n"
  end

end

--------------------------------------------------


which can (of course) be done much smarter, but this was very quick...

\stopofftopic


Patrick

-- 
ConTeXt wiki: http://contextgarden.net


More information about the dev-context mailing list