Sha256: fda2144085bbfa5ae6bb1f395ac200a3b479c917ca57a32048d23d5083835624

Contents?: true

Size: 1.51 KB

Versions: 1

Compression:

Stored size: 1.51 KB

Contents

#!/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
      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)

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ghp-0.0.8 bin/ghp