# Copyright 2007 Antoine Toulme # # This script is using the rss2svn lib with a WEBrick server. # It proposes a RSS feed. Note that the use of a golbal variable # makes it totally insecure. It's good to showcase the stuff, # but that's it! # If you have a better way to share a variable amongst threads, # please send me an email ;) require "rubygems" require "webrick" require "../lib/svn2rss.rb" include WEBrick server = HTTPServer.new(:Port => "8080") @url = "http://tempo.intalio.org/tempo" @feed_url = "http://localhost:8080" @feed_title = "Test" @feed_description = "Test" @language = "en" @managingEditor = "antoine@lunar-ocean.com" @webmaster = "antoine@lunar-ocean.com" class UpdateFeed < Thread attr_accessor :feed end $feed = " Currently building... http://localhost:8080 The feed is currently building. Come back in a few moments for fresh news! #{@language} #{Time.parse(Time.now.to_s).rfc822} #{Time.parse(Time.now.to_s).rfc822} http://cyber.law.harvard.edu/rss/rss.html svn2rss #{ENV['SVN2RSS_VERSION']} #{@managingEditor} #{@webmaster}" updateFeed = UpdateFeed.new { self.include Svn2rss while(true) do puts "in" entries = parseSvnLog(@url, 10) puts "entries parsed" $feed = createRSSFeed(entries, @feed_url, @feed_title, @feed_description, @language, @managingEditor, @webmaster) puts "in dere" puts feed sleep 3600 end } puts "out" class FeedServlet < HTTPServlet::AbstractServlet def do_GET(req, resp) puts "body" puts $feed resp.body = $feed resp['content-type'] = 'application/rss+xml' raise HTTPStatus::OK end alias do_POST do_GET end ['INT', 'TERM'].each { |signal| trap(signal){ updateFeed.terminate server.shutdown } } servlet = server.mount('/feed', FeedServlet) server.start()