Sha256: a25e1f7b85a25452a6075605075fb5ac71492626357a9ab68aed0c8229b4fe9c

Contents?: true

Size: 1.96 KB

Versions: 142

Compression:

Stored size: 1.96 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
    # These filters don't play nice with complete HTML files
    when "html" && !(item[:layout] == "none" || item[:layout] == "None")
      filter :colorize_syntax, 
             default_colorizer: :coderay,
             coderay: {css: :style}
      filter :codeblocks
    end
    unless ["xml", "js", "css", "json"].include?(item[:extension]) || item[:layout] == "none" || item[:layout] == "None"
      item[:layout] = "bootstrap" if item[:layout] == "bootstrap3"
      filter :bootstrap
      layout item[:layout] || 'bootstrap'
      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", "css", "json"].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

142 entries across 142 versions & 1 rubygems

Version Path
origen-0.7.16 templates/nanoc/Rules
origen-0.7.15 templates/nanoc/Rules