2013-03-22 21:03:45 +00:00
|
|
|
#!/usr/bin/env ruby
|
|
|
|
|
2013-03-22 22:53:57 +00:00
|
|
|
BYPASS_FILES = %w(404.html crossdomain.xml humans.txt robots.txt) unless defined?(BYPASS_FILES)
|
|
|
|
|
|
|
|
BYPASS_FILES.each do |file|
|
|
|
|
compile("/#{file.sub /\..+/, ''}/") do
|
|
|
|
# don't filter bypass files
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
compile %r{/_.+/$} do
|
|
|
|
# don't filter partials
|
|
|
|
end
|
|
|
|
|
|
|
|
compile '/css/*/' do
|
|
|
|
# filter :sass, syntax: :scss, load_paths: SASS_LOAD_PATHS
|
2013-03-24 13:27:51 +00:00
|
|
|
filter :sass, Compass.sass_engine_options
|
2013-03-22 21:03:45 +00:00
|
|
|
end
|
|
|
|
|
2013-03-22 22:53:57 +00:00
|
|
|
compile '/js/*/' do
|
|
|
|
filter :concat_js
|
|
|
|
filter :uglify_js
|
2013-03-22 21:03:45 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
compile '/posts/*' do
|
|
|
|
filter :kramdown, auto_ids: false, coderay_line_numbers: nil, coderay_tab_width: 2
|
|
|
|
filter :typogruby
|
|
|
|
layout 'post'
|
2013-03-22 22:53:57 +00:00
|
|
|
layout 'default'
|
|
|
|
filter :cache_buster
|
2013-03-22 21:03:45 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
compile '*' do
|
|
|
|
unless item.binary?
|
2013-03-22 22:53:57 +00:00
|
|
|
case item[:extension]
|
|
|
|
when 'md'
|
|
|
|
filter :erb
|
|
|
|
filter :kramdown
|
|
|
|
when 'haml'
|
|
|
|
filter :haml, format: :html5
|
|
|
|
else
|
|
|
|
filter :erb
|
|
|
|
end
|
|
|
|
|
|
|
|
if %w(html haml md).include?(item[:extension])
|
|
|
|
layout 'default'
|
|
|
|
filter :cache_buster
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
BYPASS_FILES.each do |file|
|
|
|
|
route("/#{file.sub /\..+/, ''}/") do
|
|
|
|
"/#{file}" # route bypass files as is
|
2013-03-22 21:03:45 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2013-03-22 22:53:57 +00:00
|
|
|
route %r{/_.+/$} do
|
|
|
|
nil # don't route partials
|
|
|
|
end
|
|
|
|
|
|
|
|
route '/css/*/' do
|
|
|
|
fp = fingerprint(item[:filename])
|
|
|
|
item.identifier.chop + fp + '.css'
|
2013-03-22 21:03:45 +00:00
|
|
|
end
|
|
|
|
|
2013-03-22 22:53:57 +00:00
|
|
|
route '/js/*/' do
|
|
|
|
fp = fingerprint(item[:filename])
|
|
|
|
item.identifier.chop + fp + '.js'
|
2013-03-22 21:03:45 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
route '/posts/*' do
|
|
|
|
y, m, d, slug = /([0-9]+)\-([0-9]+)\-([0-9]+)\-([^\/]+)/.match(item.identifier).captures
|
|
|
|
"/#{y}/#{m}/#{d}/#{slug}/index.html"
|
|
|
|
end
|
|
|
|
|
|
|
|
route '*' do
|
|
|
|
if item.binary?
|
|
|
|
# Write item with identifier /foo/ to /foo.ext
|
|
|
|
item.identifier.chop + '.' + item[:extension]
|
|
|
|
else
|
|
|
|
# Write item with identifier /foo/ to /foo/index.html
|
|
|
|
item.identifier + 'index.html'
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2013-03-22 22:53:57 +00:00
|
|
|
layout '*', :haml, :format => :html5
|