2011-09-03 14:28:45 +02:00
|
|
|
# Helper functions for site-building.
|
2011-07-31 22:51:41 +02:00
|
|
|
|
|
|
|
include Nanoc3::Helpers::Breadcrumbs
|
2011-09-04 14:30:09 +02:00
|
|
|
include Nanoc3::Helpers::Rendering
|
2011-07-31 22:51:41 +02:00
|
|
|
|
|
|
|
class Nanoc3::Item
|
2011-09-03 14:28:45 +02:00
|
|
|
def add_content content
|
|
|
|
@raw_content += "\n\n#{content}"
|
|
|
|
end
|
|
|
|
|
2011-07-31 22:51:41 +02:00
|
|
|
def add_references refs
|
2011-09-03 14:28:45 +02:00
|
|
|
add_content refs
|
2011-07-31 22:51:41 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
def name
|
|
|
|
identifier.split("/").last
|
|
|
|
end
|
|
|
|
end
|
2011-09-03 14:28:45 +02:00
|
|
|
|
|
|
|
def category name
|
2011-09-04 14:30:09 +02:00
|
|
|
render "category", :category => name
|
|
|
|
end
|
2011-09-03 14:28:45 +02:00
|
|
|
|
2011-09-04 14:30:09 +02:00
|
|
|
def techne status
|
|
|
|
case status
|
|
|
|
when :rough
|
|
|
|
"needs revisiting"
|
|
|
|
when :incomplete
|
|
|
|
"work in progress"
|
|
|
|
when :done
|
|
|
|
"finished"
|
|
|
|
else
|
|
|
|
status.to_s
|
2011-09-03 14:28:45 +02:00
|
|
|
end
|
2011-09-04 14:30:09 +02:00
|
|
|
end
|
2011-09-03 14:28:45 +02:00
|
|
|
|
2011-09-04 19:22:08 +02:00
|
|
|
def episteme_cat status
|
2011-09-04 14:30:09 +02:00
|
|
|
s = case status
|
|
|
|
when :broken
|
|
|
|
"partly believed"
|
|
|
|
when :discredited
|
2011-09-04 19:22:08 +02:00
|
|
|
"not believed"
|
2011-09-04 14:30:09 +02:00
|
|
|
else
|
|
|
|
status.to_s
|
|
|
|
end
|
|
|
|
"[#{s}][Epistemic State]{:.episteme}"
|
2011-09-03 14:28:45 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
# only articles that actually get printed
|
|
|
|
def printed_items
|
2011-09-03 17:29:00 +02:00
|
|
|
@items.select { |i| not i[:is_hidden] and not i.binary? }
|
2011-09-03 14:28:45 +02:00
|
|
|
end
|
2011-09-04 19:22:08 +02:00
|
|
|
|
|
|
|
# build rss feed
|
|
|
|
def rss_feed
|
|
|
|
require "rss/maker"
|
|
|
|
version = "2.0"
|
|
|
|
|
|
|
|
# find changelog
|
|
|
|
log = @items.find{|i| i.identifier.match %r{/changelog/}}
|
|
|
|
|
|
|
|
content = RSS::Maker.make(version) do |rss|
|
|
|
|
rss.channel.title = "Lies and Wonderland"
|
|
|
|
rss.channel.link = "http://muflax.com"
|
|
|
|
rss.channel.author = "mail@muflax.com"
|
|
|
|
rss.channel.description = "Lies and Wonderland"
|
|
|
|
rss.channel.date = log.mtime
|
|
|
|
rss.items.do_sort = true # sort items by date
|
|
|
|
|
|
|
|
changes(log).each do |change|
|
|
|
|
i = rss.items.new_item
|
|
|
|
i.title = "muflax hath written unto you..."
|
|
|
|
i.link = "http://muflax.com/changelog/"
|
|
|
|
i.date = Time.parse(change[:date])
|
|
|
|
i.description = change[:description]
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
content
|
|
|
|
end
|
|
|
|
|
|
|
|
# return changes based on changelog
|
|
|
|
def changes log
|
|
|
|
require 'nokogiri'
|
|
|
|
|
|
|
|
changes = []
|
|
|
|
|
|
|
|
# parse log
|
|
|
|
html_log = Nokogiri::HTML(log.compiled_content)
|
|
|
|
html_log.css("ul#changelog").each do |ul|
|
|
|
|
ul.css("li").each do |li|
|
|
|
|
change = {}
|
|
|
|
change[:description] = li.children.to_s.strip
|
|
|
|
change[:date] = li.content[%r{\d{4}/\d{2}/\d{2}}]
|
|
|
|
changes << change
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
changes
|
|
|
|
end
|