class Jekyll::Site

Monkey patch for the Jekyll Site class.

Attributes

all_hooks[RW]

Instance variable to store the various page_hook plugins that are loaded.

doc_hooks[RW]

Instance variable to store the various page_hook plugins that are loaded.

page_hooks[RW]

Instance variable to store the various page_hook plugins that are loaded.

post_hooks[RW]

Instance variable to store the various page_hook plugins that are loaded.

site_hooks[RW]

Instance variable to store the various page_hook plugins that are loaded.

Public Instance Methods

load_hooks() click to toggle source

Instantiates all of the hook plugins. This is basically a duplication of the other loaders in Site#setup.

# File lib/octopress-hooks.rb, line 151
def load_hooks
  self.site_hooks = instantiate_subclasses(Octopress::Hooks::Site) || []
  self.page_hooks = instantiate_subclasses(Octopress::Hooks::Page) || []
  self.post_hooks = instantiate_subclasses(Octopress::Hooks::Post) || []
  self.doc_hooks  = instantiate_subclasses(Octopress::Hooks::Document) || []
  self.all_hooks  = instantiate_subclasses(Octopress::Hooks::All) || []
end
old_read()
Alias for: read
old_render()
Alias for: render
old_reset()
Alias for: reset
old_site_payload()
Alias for: site_payload
old_write()
Alias for: write
read() click to toggle source
# File lib/octopress-hooks.rb, line 176
def read
  site_hooks.each do |hook|
    hook.pre_read(self)
  end

  old_read

  site_hooks.each do |hook|
    hook.post_read(self)
  end
end
Also aliased as: old_read
render() click to toggle source

Allows site hooks to get access to the site before the render method is called

Returns nothing

# File lib/octopress-hooks.rb, line 192
def render
  site_hooks.each do |hook|
    hook.pre_render(self)
  end

  old_render
end
Also aliased as: old_render
reset() click to toggle source

Load hooks before read to ensure that Post and Page hooks can be triggered during initialization

# File lib/octopress-hooks.rb, line 168
def reset
  old_reset
  load_hooks
  site_hooks.each do |hook|
    hook.reset(self)
  end
end
Also aliased as: old_reset
site_payload() click to toggle source

Allows site hooks to merge data into the site payload

Returns the patched site payload

# File lib/octopress-hooks.rb, line 203
def site_payload
  @cached_payload = begin
    payload = old_site_payload

    site_hooks.each do |hook|
      p = hook.merge_payload(payload, self)
      next unless p && p.is_a?(Hash)
      payload = Jekyll::Utils.deep_merge_hashes(payload, p)
    end
    payload
  end
end
Also aliased as: old_site_payload
write() click to toggle source

Trigger site hooks after site has been written

Returns nothing

# File lib/octopress-hooks.rb, line 219
def write
  old_write

  site_hooks.each do |hook|
    hook.post_write(self)
  end
end
Also aliased as: old_write