#! /usr/bin/ruby
require 'get_param'
require 'gen_items'
require 'gen_feedlist'
require "open-uri"
require "rexml/document"
include REXML
# Read the page template into memory.
pagestr = File.read("page.html")
# Replace the template tokens with the proper data.
pagestr = pagestr.gsub("<*sitetitle*>", get_param("rubyriver.yml","sitetitle"))
pagestr = pagestr.gsub("<*publishedfeed*>", get_param("rubyriver.yml","publishedfeed"))
pagestr = pagestr.gsub("<*sitedescription*>", get_param("rubyriver.yml","sitedescription"))
pagestr = pagestr.gsub("<*content*>", gen_items)
pagestr = pagestr.gsub("<*feedlist*>", gen_feedlist)
# Write the filled template out as the home page.
pagefile = File.new(get_param("rubyriver.yml","webdir")+"index.html", "w+")
pagefile.puts(pagestr)
pagefile.close
# Copy the current RSS file into the home directory.
feedname = get_param("rubyriver.yml","publishedfeed") + ".xml"
require 'ftools'
File.copy(feedname,get_param("rubyriver.yml","webdir") + feedname)