Class: Orthor::Site

Inherits:
Object
  • Object
show all
Extended by:
Collections, HttpCaching, MetaData
Defined in:
lib/orthor/site.rb

Class Attribute Summary collapse

Attributes included from Collections

#categories, #feeds, #pages, #queries, #static_pages

Class Method Summary collapse

Methods included from HttpCaching

cache_for

Methods included from Collections

category, feed, page, query, resources, static_page

Class Attribute Details

.current_templateObject

Returns the value of attribute current_template.



9
10
11
# File 'lib/orthor/site.rb', line 9

def current_template
  @current_template
end

Class Method Details

.define(&blk) ⇒ Object



11
12
13
14
15
16
17
18
19
# File 'lib/orthor/site.rb', line 11

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

  class_eval &blk
end

.find_resource_by_page_path(path, id) ⇒ Object



32
33
34
# File 'lib/orthor/site.rb', line 32

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

.find_resource_by_path(path) ⇒ Object



28
29
30
# File 'lib/orthor/site.rb', line 28

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

.with_template(name, &blk) ⇒ Object

Raises:

  • (ArgumentError)


21
22
23
24
25
26
# File 'lib/orthor/site.rb', line 21

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