devroom.io/Rules

135 lines
2.4 KiB
Plaintext
Raw Normal View History

2013-03-22 21:03:45 +00:00
#!/usr/bin/env ruby
preprocess do
create_robots_txt
create_webmaster_tools_authentications
create_sitemap
end
2013-03-22 22:53:57 +00:00
compile %r{^/(google|robots|assets)} do
2013-03-22 22:53:57 +00:00
end
compile %r{/_.+/$} do
# don't filter partials
end
# Sitemap and htaccess do get filtered with erb, but get no layout.
compile %r{^/(sitemap|htaccess)/$} do
filter :erb
end
compile '/sitemap/', :rep => 'gzip' do
filter :erb
filter :shellcmd, :cmd => 'gzip'
end
2013-03-22 22:53:57 +00:00
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
2013-03-24 16:25:32 +00:00
compile '/rss/' do
filter :erb
end
2013-03-22 21:03:45 +00:00
compile '/posts/*' do
2013-03-24 15:10:43 +00:00
filter :kramdown
filter :pygmentizer
2013-03-22 21:03:45 +00:00
filter :typogruby
layout 'post'
2013-03-22 22:53:57 +00:00
layout 'default'
2013-03-24 15:10:43 +00:00
2013-03-22 22:53:57 +00:00
filter :cache_buster
2013-03-22 21:03:45 +00:00
end
compile %r{^/(404)/$} do
filter :haml, format: :html5, ugly: true
layout 'default'
filter :cache_buster
end
2013-03-22 21:03:45 +00:00
compile '*' do
unless item.binary?
2013-03-22 22:53:57 +00:00
case item[:extension]
when 'md'
filter :erb
filter :kramdown
when 'haml'
2013-03-24 15:10:43 +00:00
filter :haml, format: :html5, ugly: true
2013-03-22 22:53:57 +00:00
else
filter :erb
end
if %w(html haml md).include?(item[:extension])
layout 'default'
filter :cache_buster
end
end
end
route %r{/_.+/$} do
nil # don't route partials
end
route %r{^/(assets/.*|sitemap|robots|atom)/$} do
ext = item[:extension]
ext = 'js' if ext == 'coffee'
ext = 'css' if ext == 'scss'
fp = cachebust?(item) ? fingerprint(item[:filename]) : ''
item.identifier.chop + fp + '.' + ext
end
2013-03-22 22:53:57 +00:00
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
2013-03-24 16:25:32 +00:00
route '/rss/' do
'/rss.xml'
end
route '/htaccess/' do
'/.htaccess'
end
route '/sitemap/', :rep => 'gzip' do
'/sitemap.xml.gz'
end
route '/sitemap/' do
'/sitemap.xml'
end
route %r{^/(404)/$} do
item.identifier.chop + '.html'
end
2013-03-22 21:03:45 +00:00
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-24 15:10:43 +00:00
layout '*', :haml, :format => :html5, ugly: true