Sha256: 0d39a81292dd897cfa6b97f4b415ceb6eb9523f5674ba6254ef95e2c5c299829

Contents?: true

Size: 1.32 KB

Versions: 5

Compression:

Stored size: 1.32 KB

Contents

require 'middleman-tansu/drawer'
require 'middleman-tansu/helpers'

module Middleman
  module Tansu
    # A Extension class of Middleman
    #
    # In config.rb:
    #   activate :tansu
    class Extension < ::Middleman::Extension
      option :exclude_path, %w(sitemap.xml), 'Path list that you don not  want to see'
      option :templates_dir, 'templates', 'Path of template directory in source direcotry'
      option :index_template_name, 'index.html', 'Name of index template'
      option :default_document, 'index.html', 'Name of default document. When you use IIS, set "default.html"'

      # Helpers for use within templates and layouts.
      self.defined_helpers = [::Middleman::Tansu::Helpers]

      def initialize(app, options_hash = {}, &block)
        super
        app.config.tansu = {
          exclude_path: options[:exclude_path],
          templates_dir: options[:templates_dir],
          default_document: options[:default_document]
        }
      end

      def after_configuration
        exclude_path = options.exclude_path || []
        Drawer.new(app, options, exclude_path).empty.each do |path|
          app.proxy(File.join(path, options[:default_document]),
                    File.join('/', options.templates_dir, options.index_template_name),
                    ignore: true)
        end
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
middleman-tansu-0.1.4 lib/middleman-tansu/extension.rb
middleman-tansu-0.1.3 lib/middleman-tansu/extension.rb
middleman-tansu-0.1.2 lib/middleman-tansu/extension.rb
middleman-tansu-0.1.1 lib/middleman-tansu/extension.rb
middleman-tansu-0.1.0 lib/middleman-tansu/extension.rb