90 lines
1.7 KiB
Ruby
90 lines
1.7 KiB
Ruby
#!/usr/bin/env ruby
|
|
|
|
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
|
|
filter :sass, Compass.sass_engine_options
|
|
end
|
|
|
|
compile '/js/*/' do
|
|
filter :concat_js
|
|
filter :uglify_js
|
|
end
|
|
|
|
compile '/posts/*' do
|
|
filter :kramdown
|
|
filter :pygmentizer
|
|
filter :typogruby
|
|
layout 'post'
|
|
layout 'default'
|
|
|
|
filter :cache_buster
|
|
end
|
|
|
|
compile '*' do
|
|
unless item.binary?
|
|
case item[:extension]
|
|
when 'md'
|
|
filter :erb
|
|
filter :kramdown
|
|
when 'haml'
|
|
filter :haml, format: :html5, ugly: true
|
|
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
|
|
end
|
|
end
|
|
|
|
route %r{/_.+/$} do
|
|
nil # don't route partials
|
|
end
|
|
|
|
route '/css/*/' do
|
|
fp = fingerprint(item[:filename])
|
|
item.identifier.chop + fp + '.css'
|
|
end
|
|
|
|
route '/js/*/' do
|
|
fp = fingerprint(item[:filename])
|
|
item.identifier.chop + fp + '.js'
|
|
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
|
|
|
|
layout '*', :haml, :format => :html5, ugly: true
|