require 'date' require 'addressable/template' module WikiHelpers WikiPageUrl = Addressable::Template.new("http://sublab.org/wiki/ikiwiki.cgi{?page}&do=goto") class WikiChanges attr_reader :username, :page, :changelog def initialize(atts={}) @username = atts.fetch("username") @page = atts.fetch("page") @datetime = DateTime.parse(atts.fetch("datetime")) @changelog = atts.fetch("changelog", nil) end def datetime @datetime.strftime(CalendarHelpers::FORMATS[:log]) end end def wiki_changes data.wiki_changes.map do |atts| WikiChanges.new(atts) end end # TODO move to link helper module def link_to_wiki(name) url = WikiPageUrl.expand({page: name}).to_s link_to escape_html(name), url end end