Sha256: 5ad378fc1d297a30772a202bcdca2181a0772033bc0cdb62d7f77a8c9d951a22

Contents?: true

Size: 1.84 KB

Versions: 8

Compression:

Stored size: 1.84 KB

Contents

#!/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 cant 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 '/stylesheet/' do
  # dont filter or layout
end


compile '*' do
  if item.binary?
    # dont filter binary items
  else
    case item[:extension]
    when "md"
      # Create HTML from markdown:
      filter :kramdown, coderay_line_numbers: nil, entity_output: :as_input
      filter :codeblocks
    when "haml"
      filter :haml
    when "html"
      filter :colorize_syntax, 
             default_colorizer: :coderay,
             coderay: {css: :style}
      filter :codeblocks
    end
    unless ["xml", "js"].include?(item[:extension])
      if item[:layout] == "bootstrap" || item[:layout] == "bootstrap3" || !item[:layout]
        filter :bootstrap
        layout 'bootstrap'
      else
        fail "Unknown web page layout: #{item[:layout]}"
      end
      filter :search
    end
    if item[:zip] || item[:gzip]
      filter :gzip
    end
  end
end

route '/stylesheet/' do
  '/style.css'
end

route '*' do
  if item.binary? || ["xml", "js"].include?(item[:extension])
    # Write item with identifier /foo/ to /foo.ext
    item.identifier.chop + '.' + item[:extension]
  else
    # Write item with identifier /foo/ to /foo/index.html
    if item[:zip] || item[:gzip]
      item.identifier + 'index.html.gz'
    else
      item.identifier + 'index.html'
    end
  end
end

layout '*', :erb

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
origen-0.1.3 templates/nanoc/Rules
origen-0.1.2 templates/nanoc/Rules
origen-0.1.1 templates/nanoc/Rules
origen-0.1.0 templates/nanoc/Rules
origen-0.0.9 templates/nanoc/Rules
origen-0.0.8 templates/nanoc/Rules
origen-0.0.6 templates/nanoc/Rules
origen-0.0.5 templates/nanoc/Rules