Class: Middleman::OrgExtension

Inherits:
Extension
  • Object
show all
Defined in:
lib/middleman-org/extension.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

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

Returns a new instance of OrgExtension.



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/middleman-org/extension.rb', line 15

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

  # Require libraries only when activated
  require 'org-ruby'
  require 'middleman-org/org_data'

  options.root = File.join(options.prefix, options.root) if options.prefix

  app.after_configuration do
    template_extensions org: :html
  end

  # set up your extension
  # puts options.my_option
end

Instance Attribute Details

#dataObject (readonly)

option :resources, ‘resources’, ‘folder name for resources’



12
13
14
# File 'lib/middleman-org/extension.rb', line 12

def data
  @data
end

Instance Method Details

#after_configurationObject



33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/middleman-org/extension.rb', line 33

def after_configuration
  ::Middleman::Org.controller = self

  # Make sure ActiveSupport's TimeZone stuff has something to work with,
  # allowing people to set their desired time zone via Time.zone or
  # set :time_zone
  Time.zone = app.config[:time_zone] if app.config[:time_zone]
  time_zone = Time.zone || 'UTC'
  zone_default = Time.find_zone!(time_zone)
  unless zone_default
    raise 'Value assigned to time_zone not recognized.'
  end
  Time.zone_default = zone_default

  @data = Org::OrgData.new(@app, self, options)
  @app.sitemap.register_resource_list_manipulator(:"org_articles", @data, false)
end