jcpunk / centos / centos.org

Forked from centos/centos.org 12 days ago
Clone

Blame Rules

e8ec7a
#!/usr/bin/env ruby
e8ec7a
e8ec7a
## Required Gems
e8ec7a
require 'compass'
e8ec7a
require 'susy'
e8ec7a
e8ec7a
### Compass configuration ####################################################
e8ec7a
Compass.add_project_configuration 'config.rb'
e8ec7a
sass_options = Compass.sass_engine_options
e8ec7a
e8ec7a
### Configuration ############################################################
e8ec7a
TypographicalImprovementFilter = :rubypants
e8ec7a
TypographicalImprovementFilterParams = {}
e8ec7a
e8ec7a
### Preprocessing ############################################################
e8ec7a
preprocess do
e8ec7a
  config[:nanoc_version_info] = `nanoc --version`.strip
e8ec7a
  config[:gem_version_info]   = `gem --version`.strip
e8ec7a
end
e8ec7a
e8ec7a
### Routing ##################################################################
e8ec7a
route '/static/*' do
e8ec7a
  # /static/foo.html/ → /foo.html
e8ec7a
  item.identifier[7..-2]
e8ec7a
end
e8ec7a
e8ec7a
route 'sitemap' do
e8ec7a
  item.identifier.chop + '.xml'
e8ec7a
end
e8ec7a
e8ec7a
e8ec7a
route '/assets/css/bootstrap/_*/' do
e8ec7a
  # Don't output partials, so return nil
e8ec7a
  nil
e8ec7a
end
e8ec7a
e8ec7a
route '/assets/css/*/' do
e8ec7a
  # path with version
e8ec7a
  '/assets/style' + '-v' + rep.item[:version].to_s + '.css'
e8ec7a
end
e8ec7a
e8ec7a
route '*' do
e8ec7a
  if item.binary?
e8ec7a
    item.identifier.chop + '.' + item[:extension]
e8ec7a
  elsif item[:is_partial] || item[:kind] == 'article'
e8ec7a
    # Don’t output partial items (e.g. sub-stylesheets)
e8ec7a
    nil
e8ec7a
  elsif item[:path]
e8ec7a
    item[:path]
e8ec7a
  else
e8ec7a
    # Place each file in its own directory
e8ec7a
    rep.item.identifier + 'index.html'
e8ec7a
  end
e8ec7a
end
e8ec7a
e8ec7a
e8ec7a
### Compilation ##############################################################
e8ec7a
e8ec7a
compile 'sitemap' do
e8ec7a
  filter :erb
e8ec7a
end
e8ec7a
e8ec7a
compile '/assets/css/bootstrap/_*/' do
e8ec7a
  # Don’t compile partials
e8ec7a
end
e8ec7a
e8ec7a
compile '/assets/css/*/' do
e8ec7a
  filter :sass, Compass.sass_engine_options
e8ec7a
  filter :relativize_paths, :type => :css
e8ec7a
  filter :rainpress
e8ec7a
end
e8ec7a
compile '/static/*' do
e8ec7a
end
e8ec7a
e8ec7a
compile '*' do 
e8ec7a
  if item.binary?
e8ec7a
    # ha, do nothing! :)
e8ec7a
  else
e8ec7a
    puts "item = #{item.identifier} -- extension = #{item[:extension]}"
e8ec7a
    case item[:extension]
e8ec7a
    when 'md'
e8ec7a
      filter :erb
e8ec7a
      filter :kramdown
e8ec7a
    when 'haml'
e8ec7a
      filter :erb
e8ec7a
      filter :haml
e8ec7a
    when 'js'
e8ec7a
      filter :erb
e8ec7a
      filter :uglify_js
e8ec7a
    when 'adoc'
e8ec7a
      filter :asciidoc
e8ec7a
    else
e8ec7a
      filter :erb
e8ec7a
    end
e8ec7a
  layout 'default-haml' unless item[:extension] == 'js' 
e8ec7a
  filter :add_ids_to_headers
e8ec7a
  filter TypographicalImprovementFilter, TypographicalImprovementFilterParams
e8ec7a
  end
e8ec7a
end
e8ec7a
### Layouting ################################################################
e8ec7a
e8ec7a
e8ec7a
layout '*', :haml