Sha256: 32daee879f853498b9ce73762f4a7a6ee0677ac4ec971d815afaf902f6f9892d

Contents?: true

Size: 944 Bytes

Versions: 3

Compression:

Stored size: 944 Bytes

Contents

module Orthor
  class Site
    class << self
      include Orthor::Collections
      include Orthor::HttpCaching
      include Orthor::MetaData

      dsl_accessor :layout
      attr_accessor :current_template

      def define(&blk)
        @feeds, @categories, @pages, @static_pages, @queries = [], [], [], [], []
        layout(:orthor_layout)
        cache_for 0
        keywords ""
        description ""

        class_eval &blk
      end

      def with_template(name, &blk)
        raise ArgumentError, "block required" unless block_given?
        @current_template = name
        class_eval &blk
        @current_template = nil
      end

      def find_resource_by_path(path)
        Orthor::Site.resources.detect { |r| r.path == path }
      end

      def find_resource_by_page_path(path, id)
        Orthor::Site.resources.detect { |r| r.is_a?(Orthor::Category) && r.page_path.gsub(":id", id) == path }
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
orthorings-0.4.2 lib/orthor/site.rb
orthorings-0.4.1 lib/orthor/site.rb
orthorings-0.4.0 lib/orthor/site.rb