#!/usr/bin/env ruby # encoding: utf-8 # taken from nanoc version 3.5.0b2 # load Markdown parser require 'redcarpet' # Load nanoc require 'nanoc' require 'nanoc/cli' include Nanoc::Helpers::Rendering module Nanoc class Site def load_code_snippets @code_snippets_loaded ||= false return if @code_snippets_loaded @code_snippets_loaded = true # Get code snippets @code_snippets = Dir['lib/nanoc/**/*.rb'].sort.map do |filename| Nanoc::CodeSnippet.new( File.read(filename), filename ) end # Execute code snippets @code_snippets.each { |cs| cs.load } end end end module Nanoc::DataSources module Filesystem def get_ghp_config Dir.chdir(File.expand_path('../..', __FILE__).strip) { Nanoc::Site.new('.').config } end def pathfind_file(in_dir = ".") (["./lib"] + $:).collect {|x| File.join(File.expand_path("..", x), in_dir) }.select {|x| File.directory? x }.each do |found_dir| yield found_dir end end def items ghp_config = get_ghp_config alt_content = ghp_config[:alt_content] || "content" acc = [ ] pathfind_file(alt_content) do |alt_dir| acc += load_objects(alt_dir, 'item', Nanoc::Item) end acc end def layouts ghp_config = get_ghp_config alt_layouts = ghp_config[:alt_layouts] || "layouts" acc = [] pathfind_file(alt_layouts) do |alt_dir| acc += load_objects(alt_dir, 'layout', Nanoc::Layout) end acc end end end # Run base Nanoc::CLI.run(ARGV)