require 'drb/drb'
require 'div'
require 'singleton'

class News < Div::Div
  include Singleton

  @erb_fname = nil

  RWIKI_URI = 'druby://localhost:8470'
  RWIKI_BASE = '/~mas/rwiki/rw-cgi.rb'

  def initialize
    @session = nil
    @div_class = type.to_s
    @div_id = self.id.to_s
    @action = nil
    rwiki = DRbObject.new(nil, RWIKI_URI)
    @pg = rwiki.page('News')
    @cache = nil
    @expire = Time.now
  end

  def to_html(context)
    if @expire < Time.now
      @cache =  @pg.body_html({'base'=>RWIKI_BASE})
      @expire = Time.now + 180
    end
    @cache
  end
end

