#!/usr/bin/env ruby SASS_LOAD_PATHS = ['content/css'] if ENV['NANOC_ENV'] == "production" puts " > Running in PRODUCTION mode" else puts " > Running in DEVELOPMENT mode" end preprocess do if ENV['NANOC_ENV'] == "production" create_robots_txt create_webmaster_tools_authentications create_sitemap end end compile %r{^/(google|robots|assets)} do 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 if ENV['NANOC_ENV'] == "production" filter :shellcmd, :cmd => 'gzip' end end # Use screen.scss as the single entry point for styles, ignore everything else in /assets/css compile '/css/screen/' do filter :sass, load_paths: SASS_LOAD_PATHS end compile '/css/*' do end route '/css/screen/' do if ENV['NANOC_ENV'] == "production" fp = fingerprint(item[:filename]) else fp = '' end item.identifier.chop + fp + '.css' end compile '/js/*/' do filter :coffeescript if @item[:extension] == 'coffee' filter :concat_js if ENV['NANOC_ENV'] == "production" filter :uglify_js end end route '/js/*/' do if ENV['NANOC_ENV'] == "production" fp = fingerprint(item[:filename]) else fp = '' end item.identifier.chop + fp + '.js' end compile '/rss/' do filter :erb end compile '/posts/*' do filter :rdiscount filter :pygmentizer if ENV['NANOC_ENV'] == "production" filter :typogruby end layout 'post' layout 'default' if ENV['NANOC_ENV'] == "production" filter :cache_buster end end compile %r{^/(404)/$} do filter :haml, format: :html5, ugly: true layout 'default' if ENV['NANOC_ENV'] == "production" filter :cache_buster end end compile '/' do filter :haml, format: :html5, ugly: true layout 'default' if ENV['NANOC_ENV'] == "production" filter :cache_buster end 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 'page' layout 'default' if ENV['NANOC_ENV'] == "production" filter :cache_buster end 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 =~ /s[ca]ss/i if ENV['NANOC_ENV'] == "production" fp = cachebust?(item) ? fingerprint(item[:filename]) : '' else fp = '' end item.identifier.chop + fp + '.' + ext end 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 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