2011-09-03 14:28:45 +02:00
|
|
|
# Helper functions for site-building.
|
2011-07-31 22:51:41 +02:00
|
|
|
|
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
|
2012-02-04 21:18:01 +01:00
|
|
|
|
|
|
|
def draft?
|
|
|
|
self[:techne] == :wip
|
|
|
|
end
|
2012-02-05 05:40:57 +01:00
|
|
|
|
|
|
|
def cognitive?
|
|
|
|
!self[:non_cognitive]
|
|
|
|
end
|
|
|
|
|
|
|
|
def article?
|
|
|
|
not self[:is_category] and not draft? and cognitive?
|
|
|
|
end
|
2011-07-31 22:51:41 +02:00
|
|
|
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-23 20:55:32 +02:00
|
|
|
def route_unchanged
|
|
|
|
item.identifier.chop + '.' + item[:extension]
|
2011-09-03 14:28:45 +02:00
|
|
|
end
|
2011-09-04 21:01:26 +02:00
|
|
|
|
2011-09-23 20:55:32 +02:00
|
|
|
class Nanoc3::Site
|
|
|
|
# only articles that actually get printed
|
|
|
|
attr_reader :printed_items
|
|
|
|
|
|
|
|
def find_printed_items
|
|
|
|
@printed_items = @items.select { |i| not i[:is_hidden] and not i.binary? }
|
|
|
|
end
|
2011-09-04 21:01:26 +02:00
|
|
|
end
|
2011-09-23 20:55:32 +02:00
|
|
|
|