#! /usr/local/bin/ruby

require "rss/maker"

rss = RSS::Maker.make("1.0") do |maker|
  maker.channel.about = "http://chem.tf.chiba-u.jp/"
  maker.channel.title = "更新履歴"
  maker.channel.description = "共生応用化学科　Webサイト　更新履歴"
  maker.channel.link = "http://chem.tf.chiba-u.jp/"
  maker.channel.language = 'ja'
  File.open("whats.txt") do |f|
    while date=f.gets
      next if /^#|^$/ =~ date
      y=date[0,4].to_i;m=date[4,2].to_i;d=date[6,2].to_i
      title=f.gets.chomp
      link=f.gets.chomp
      desc=f.gets.chomp
      item = maker.items.new_item
      item.link = "http://chem.tf.chiba-u.jp/kousin.rhtml#"+date.chomp
      item.title = title
      if desc == ""
         item.description = link
      end
      item.date = Time.parse(y.to_s+'/'+m.to_s+'/'+d.to_s+" 09:00")
    end
  end
end

puts "Content-type: text/xml; charset=utf-8\n\n"
puts rss


