From a1e8c6fc94297741b1ee00e821b3bf9d4d51e189 Mon Sep 17 00:00:00 2001 From: Lars Henrik Mai Date: Sat, 25 Oct 2014 17:33:47 +0200 Subject: use data for tweets and wiki changes --- helpers/wiki_helpers.rb | 29 ++++++++++++++++++++--------- 1 file changed, 20 insertions(+), 9 deletions(-) (limited to 'helpers/wiki_helpers.rb') diff --git a/helpers/wiki_helpers.rb b/helpers/wiki_helpers.rb index 95e8268..4984095 100644 --- a/helpers/wiki_helpers.rb +++ b/helpers/wiki_helpers.rb @@ -3,21 +3,32 @@ require 'addressable/template' module WikiHelpers - RecentChangesItem = Struct.new(:username, :page, :datetime, :changelog) - WikiPageUrl = Addressable::Template.new("http://sublab.org/wiki/ikiwiki.cgi{?page}&do=goto") - def wiki_changes(count=3) - # mockup for now + 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 - [ - RecentChangesItem.new("Woruman", "techniksprechstunde", DateTime.parse("2014-04-11 21:25:54")), - RecentChangesItem.new("drnerd", "techniksprechstunde", DateTime.parse("2014-04-10 20:09:44")), - RecentChangesItem.new("jackrandom", "coreboot-x201", DateTime.parse("2014-04-08 12:52:15"), "USB Boot patch now obsolete") - ] + 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 -- cgit v1.2.1