2013-03-22 22:53:57 +00:00
|
|
|
require 'bundler'
|
|
|
|
Bundler.require
|
|
|
|
|
|
|
|
# Don't reload this file for nanoc autocompile. Otherwise, nanoc will eventually
|
|
|
|
# throw an "ERROR SystemStackError: stack level too deep" exception.
|
|
|
|
unless defined? LOADED_DEFAULT_CONFIG
|
|
|
|
|
|
|
|
LOADED_DEFAULT_CONFIG = true
|
|
|
|
|
|
|
|
require 'compass'
|
|
|
|
Compass.add_project_configuration File.expand_path('../../compass-config.rb', __FILE__)
|
|
|
|
|
|
|
|
include Nanoc3::Helpers::Blogging
|
|
|
|
include Nanoc3::Helpers::Tagging
|
|
|
|
include Nanoc3::Helpers::HTMLEscape
|
|
|
|
include Nanoc3::Helpers::Rendering
|
|
|
|
include Nanoc3::Helpers::LinkTo
|
|
|
|
|
|
|
|
# cachebuster
|
|
|
|
require 'nanoc/cachebuster'
|
|
|
|
include Nanoc::Helpers::CacheBusting
|
|
|
|
|
|
|
|
# javascript concatenation
|
|
|
|
require 'nanoc/filters/javascript_concatenator'
|
|
|
|
|
|
|
|
def articles_by_year
|
|
|
|
hash = Hash.new { |h, k| h[k] = [] }
|
|
|
|
sorted_articles.inject(hash) do |output, article|
|
|
|
|
year = attribute_to_time(article[:created_at]).year
|
|
|
|
output[year] << article
|
|
|
|
output
|
|
|
|
end
|
2013-03-22 21:03:45 +00:00
|
|
|
end
|
|
|
|
|
2013-03-22 22:53:57 +00:00
|
|
|
module PostHelper
|
2013-03-24 15:18:00 +00:00
|
|
|
def get_short_date(post)
|
|
|
|
attribute_to_time(post[:created_at]).strftime('%d %b')
|
|
|
|
end
|
|
|
|
|
2013-03-22 22:53:57 +00:00
|
|
|
def get_pretty_date(post)
|
2013-03-24 15:18:00 +00:00
|
|
|
attribute_to_time(post[:created_at]).strftime('%-d %B, %Y')
|
2013-03-22 22:53:57 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def get_tags(post)
|
|
|
|
if post[:tags].nil? || post[:tags].empty?
|
|
|
|
"(not tagged)"
|
|
|
|
else
|
|
|
|
post[:tags].compact.map { |tag| tag.downcase }.sort.join(", ")
|
|
|
|
end
|
2013-03-22 21:03:45 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2013-03-22 22:53:57 +00:00
|
|
|
include PostHelper
|
|
|
|
end
|