EmacsWikiFeedConverter

These are CGI scripts. Setup in your local WWW server.

Up-to-date RSS feed

To reduce server load, the RSS feed is cached. Therefore the RSS feed is delayed by a few hours. But the text feed is up to date.

Because my favorite RSS/Atom aggregator cannot handle TXT feeds, I created TXT → RSS converter script.

#!/usr/local/bin/ruby
require 'rss/2.0'
require 'time'
require 'open-uri'

def parse(block)
  hash = {}
  block.split(/\n/).map{|line| k, v = line.split(/: /,2); hash[k]=v}
  hash
end

text = open("http://www.emacswiki.org/cgi-bin/wiki?action=rc;raw=1").read
header, *items = text.split(/\n\n/)

feed = RSS::Rss.new("2.0")

header = parse(header)

chan = RSS::Rss::Channel::new
chan.title=header["title"]
chan.description = header["description"]
chan.link = header["link"]

feed.channel = chan

for i in items
  i = parse(i)
  item = RSS::Rss::Channel::Item.new
  item.title = i["title"]
  item.link = i["link"]
  author = item.author = i["generator"]
  item.description = (i["description"] || "") + "<br><br>(by #{author})"
  item.date = Time.parse(i["last-modified"])
  
  feed.channel.items << item
end

puts "Content-Type: application/xml"
puts
puts feed

rubikitch

Up-to-date RSS feed with minor edits

Replace

http://www.emacswiki.org/cgi-bin/wiki?action=rc;raw=1

with

http://www.emacswiki.org/cgi-bin/wiki?action=rc;days=7;all=0;showedit=1;raw=1

in above script.

rubikitch

I don’t understand. Are you parsing the HTML? Why are you not using the TXT feed with the showedit=1 parameter?

http://www.emacswiki.org/cgi-bin/wiki?action=rc;days=7;all=0;showedit=1;raw=1

AlexSchroeder

Yes, that script parses the HTML. I simply did not know TXT feed with minor edits. thanks.

rubikitch


CategoryEmacsWikiSite