automatically wire up sitemap manipulators, let extensions control their name, add self-registration method
This commit is contained in:
parent
10e1fd92d6
commit
65c8dda565
5 changed files with 66 additions and 87 deletions
|
@ -106,6 +106,7 @@ module Middleman
|
|||
class Extension
|
||||
class_attribute :supports_multiple_instances, :instance_reader => false, :instance_writer => false
|
||||
class_attribute :defined_helpers, :instance_reader => false, :instance_writer => false
|
||||
class_attribute :ext_name, :instance_reader => false, :instance_writer => false
|
||||
|
||||
class << self
|
||||
def config
|
||||
|
@ -123,6 +124,14 @@ module Middleman
|
|||
m.module_eval(&block)
|
||||
self.defined_helpers << m
|
||||
end
|
||||
|
||||
def extension_name
|
||||
self.ext_name || self.name.underscore.split("/").last.to_sym
|
||||
end
|
||||
|
||||
def register(n=self.extension_name)
|
||||
::Middleman::Extensions.register(n, self)
|
||||
end
|
||||
end
|
||||
|
||||
attr_accessor :app, :options
|
||||
|
@ -148,11 +157,15 @@ module Middleman
|
|||
end
|
||||
end
|
||||
|
||||
klass.after_configuration(&method(:after_configuration))
|
||||
end
|
||||
klass.after_configuration do
|
||||
if ext.respond_to?(:manipulate_resource_list)
|
||||
ext.app.sitemap.register_resource_list_manipulator(ext.class.extension_name, ext)
|
||||
end
|
||||
|
||||
def after_configuration
|
||||
nil
|
||||
if ext.respond_to?(:after_configuration)
|
||||
ext.after_configuration
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue