]> git.draconx.ca Git - homepage.git/blobdiff - lib/helpers.rb
Let's start a blog!
[homepage.git] / lib / helpers.rb
index acaa61289dd8352c66d6e1273773ef83c78eb893..df48f4c745d72de52464aea6da333e61e97e6df4 100644 (file)
 require 'nokogiri'
 
 use_helper Nanoc::Helpers::Breadcrumbs
+use_helper Nanoc::Helpers::Blogging
 
 Xmlns = {
     'xhtml' => 'http://www.w3.org/1999/xhtml'
 }.freeze
+$counters = {}
 
 def to_xhtml(subpath = "", item = @item)
     if item.identifier =~ '/index.*'
@@ -62,6 +64,13 @@ def item_longdesc(item)
     if p.empty? then nil else p[0].xpath('string(.)') end
 end
 
+def counter(name = :default, item = @item)
+    $counters[item] ||= {}
+    $counters[item][name] ||= 0
+
+    name.to_s.capitalize + " " + ($counters[item][name] += 1).to_s
+end
+
 def human_filesize(size)
     units = ["B", "KiB", "MiB", "GiB"]