Class: TextileManual

Inherits:
Middleman::Extension
  • Object
show all
Defined in:
lib/textile_manual/extension.rb

Overview

Extension namespace

Defined Under Namespace

Classes: ProxyDescriptor

Instance Method Summary collapse

Constructor Details

#initialize(app, options_hash = {}, &block) ⇒ TextileManual

Returns a new instance of TextileManual.



8
9
10
11
12
13
14
15
16
# File 'lib/textile_manual/extension.rb', line 8

def initialize(app, options_hash={}, &block)
  # Call super to build options from the options_hash
  super
  add_extension_dirs

  @sitemap = app.sitemap

  @base_path = options.path
end

Instance Method Details

#add_extension_dirsObject



35
36
37
38
# File 'lib/textile_manual/extension.rb', line 35

def add_extension_dirs
  app.files.watch :source, path: File.join(File.dirname(__FILE__), '../../source'), priority: 1
  app.files.watch :data, path: File.join(File.dirname(__FILE__), '../../data'), priority: 1
end

#manipulate_resource_list(resources) ⇒ Object

A Sitemap Manipulator



23
24
25
26
27
28
29
30
31
32
33
# File 'lib/textile_manual/extension.rb', line 23

def manipulate_resource_list(resources)
  new_resources = textile_data.map do |slug, contents|
    build_proxy_resource(link(slug), contents)
  end

  new_resources << root_resource

  new_resources.reduce(resources) do |sum, r|
    r.execute_descriptor(app, sum)
  end
end

#textile_dataObject



18
19
20
# File 'lib/textile_manual/extension.rb', line 18

def textile_data
  app.data.textile
end