Class: Gumdrop::Site

Inherits:
Object
  • Object
show all
Extended by:
Callbacks
Defined in:
lib/gumdrop/site.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Callbacks

callback

Constructor Details

#initialize(sitefile, opts = {}) ⇒ Site

Returns a new instance of Site.



47
48
49
50
51
52
53
# File 'lib/gumdrop/site.rb', line 47

def initialize(sitefile, opts={})
  @sitefile  = File.expand_path sitefile
  @root_path = File.dirname @sitefile
  @opts      = opts
  @last_run  = nil
  reset_all()
end

Instance Attribute Details

#blacklistObject (readonly)

Returns the value of attribute blacklist.



20
21
22
# File 'lib/gumdrop/site.rb', line 20

def blacklist
  @blacklist
end

#configObject (readonly)

Returns the value of attribute config.



20
21
22
# File 'lib/gumdrop/site.rb', line 20

def config
  @config
end

#content_filtersObject (readonly)

Returns the value of attribute content_filters.



20
21
22
# File 'lib/gumdrop/site.rb', line 20

def content_filters
  @content_filters
end

#dataObject (readonly)

Returns the value of attribute data.



20
21
22
# File 'lib/gumdrop/site.rb', line 20

def data
  @data
end

#generatorsObject (readonly)

Returns the value of attribute generators.



20
21
22
# File 'lib/gumdrop/site.rb', line 20

def generators
  @generators
end

#greylistObject (readonly)

Returns the value of attribute greylist.



20
21
22
# File 'lib/gumdrop/site.rb', line 20

def greylist
  @greylist
end

#last_runObject (readonly)

Returns the value of attribute last_run.



20
21
22
# File 'lib/gumdrop/site.rb', line 20

def last_run
  @last_run
end

#layoutsObject (readonly)

Returns the value of attribute layouts.



20
21
22
# File 'lib/gumdrop/site.rb', line 20

def layouts
  @layouts
end

#node_treeObject (readonly)

Returns the value of attribute node_tree.



20
21
22
# File 'lib/gumdrop/site.rb', line 20

def node_tree
  @node_tree
end

#optsObject (readonly)

Returns the value of attribute opts.



20
21
22
# File 'lib/gumdrop/site.rb', line 20

def opts
  @opts
end

#partialsObject (readonly)

Returns the value of attribute partials.



20
21
22
# File 'lib/gumdrop/site.rb', line 20

def partials
  @partials
end

#redirectsObject (readonly)

Returns the value of attribute redirects.



20
21
22
# File 'lib/gumdrop/site.rb', line 20

def redirects
  @redirects
end

#root_pathObject (readonly)

Returns the value of attribute root_path.



20
21
22
# File 'lib/gumdrop/site.rb', line 20

def root_path
  @root_path
end

#sitefileObject (readonly)

Returns the value of attribute sitefile.



20
21
22
# File 'lib/gumdrop/site.rb', line 20

def sitefile
  @sitefile
end

#src_pathObject (readonly)

Returns the value of attribute src_path.



20
21
22
# File 'lib/gumdrop/site.rb', line 20

def src_path
  @src_path
end

Instance Method Details

#buildObject



89
90
91
92
93
94
95
96
# File 'lib/gumdrop/site.rb', line 89

def build
  on_start(self)
  scan()
  render()
  @last_run= Time.now
  on_end(self)
  self
end

#contents(*args) ⇒ Object



55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
# File 'lib/gumdrop/site.rb', line 55

def contents(*args)
  opts= args.extract_options!
  pattern= args[0] || nil
  if pattern.nil?
    if opts[:as] == :hash
      @node_tree
    else
      @node_tree.values
    end
  else
    nodes = opts[:as] == :hash ? {} : []
    @node_tree.keys.each do |path|
      if path_match path, pattern
        if opts[:as] == :hash
          nodes[path]= @node_tree[path]
        else
          nodes << @node_tree[path]
        end
      end
    end
    nodes
  end
end

#render_contextObject

FIXME: Should a new Context be created for every page? For now

it's a single context for whole site


112
113
114
115
# File 'lib/gumdrop/site.rb', line 112

def render_context
  @context ||= Context.new self
  @context
end

#report(msg, level = :info) ⇒ Object



98
99
100
101
102
103
104
105
106
107
108
# File 'lib/gumdrop/site.rb', line 98

def report(msg, level=:info)
  case level
    when :info
      @log.info msg
    when :warning
      @log.warn msg
  else
    puts msg
    @log.error msg
  end
end

#rescanObject



79
80
81
82
83
84
85
86
87
# File 'lib/gumdrop/site.rb', line 79

def rescan
  on_start(self)
  reset_all()
  scan()
  @last_run= Time.now
  # TODO: should on_before_render and on_render be called for rescan()?
  on_end(self)
  self
end