nim-by-example/Rules
Flaviu Tamas 89c4bb2625 Fix deploy
2016-11-07 15:45:37 -05:00

72 lines
2.1 KiB
Ruby
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/usr/bin/env ruby
# A few helpful tips about the Rules file:
#
# * The string given to #compile and #route are matching patterns for
# identifiers--not for paths. Therefore, you can’t match on extension.
#
# * The order of rules is important: for each item, only the first matching
# rule is applied.
#
# * Item identifiers start and end with a slash (e.g. “/about/” for the file
# “content/about.html”). To select all children, grandchildren, … of an
# item, use the pattern “/about/*/”; “/about/*” will also select the parent,
# because “*” matches zero or more characters.
compile '/assets/css/*' do
filter :erb
filter :rainpress if File.basename(item[:content_filename], ".*") == 'all'
end
compile '/assets/js/*' do
filter :erb
:uglify_js if File.basename(item[:content_filename], ".*") == 'all'
end
compile '/content/*' do
if item.identifier.to_s == '/content/toc/'
filter :kramdown
layout 'blank'
elsif item.identifier.to_s == '/content/footer/'
layout 'blank'
elsif item[:extension] == 'md'
filter :kramdown, {:input => 'GFM'}
filter :colorize_syntax, :default_colorizer => :pygmentize
filter :relativize_paths, :type => :html
layout 'default'
else
filter :erb
layout 'default'
end
end
route '/assets/css/*' do
# if not debug mode, only let all.css through
unless @config[:debug]
item.identifier.to_s.chop + '.css' if File.basename(item[:content_filename], ".*") == 'all'
else
item.identifier.to_s.chop + '.css'
end
end
route '/assets/js/*' do
# if not debug mode, only let all.js through
unless @config[:debug]
item.identifier.to_s.chop + '.js' if File.basename(item[:content_filename], ".*") == 'all'
else
item.identifier.to_s.chop + '.js'
end
end
route '/content/*' do
if item.binary?
# Write item with identifier /foo/ to /foo.ext
item.identifier.to_s.sub("/content", "").chop + '.' + item[:extension]
else
# Write item with identifier /foo/ to /foo/index.html
item.identifier.to_s.sub("/content", "") + 'index.html'
end
end
layout '*', :erb