summaryrefslogtreecommitdiff
path: root/helpers/wiki_helpers.rb
blob: 95e82686cc4b6eeb1765be7472d20a0a4b935810 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
require 'date'
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

    [
      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")
    ]

  end

  def link_to_wiki(name)
    url = WikiPageUrl.expand({page: name}).to_s
    link_to escape_html(name), url
  end

end