2010-09-04 23:26:48 -04:00
|
|
|
module Middleman
|
|
|
|
module Features
|
|
|
|
# Top-level method to register a new feature
|
|
|
|
@@features = {}
|
|
|
|
def self.register(feature_name, feature_class=nil, options={})
|
|
|
|
@@features[feature_name] = feature_class
|
|
|
|
|
|
|
|
# Default to disabled, unless the class asks to auto-enable
|
|
|
|
activate_method = (options.has_key?(:auto_enable) && options[:auto_enable]) ? :enable : :disable
|
2010-09-05 22:28:38 -04:00
|
|
|
Middleman::Server.send(activate_method, feature_name)
|
2010-09-04 23:26:48 -04:00
|
|
|
end
|
|
|
|
|
2010-09-05 22:28:38 -04:00
|
|
|
# Initialize a feature
|
|
|
|
def self.run(feature_name, feature_config, scope)
|
2010-09-04 23:26:48 -04:00
|
|
|
feature_class = @@features[feature_name]
|
2010-09-05 22:28:38 -04:00
|
|
|
feature_class.new(scope, feature_config) unless feature_class.nil?
|
2010-09-04 23:26:48 -04:00
|
|
|
end
|
2010-09-05 02:45:19 -04:00
|
|
|
|
2010-09-05 22:28:38 -04:00
|
|
|
# Get a list of all features
|
2010-09-04 23:26:48 -04:00
|
|
|
def self.all
|
|
|
|
@@features
|
|
|
|
end
|
2010-09-05 02:45:19 -04:00
|
|
|
|
2010-09-04 23:26:48 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2010-09-05 02:45:19 -04:00
|
|
|
# livereload
|
2010-09-05 22:33:57 -04:00
|
|
|
%w(default_helpers
|
|
|
|
asset_host
|
2010-09-04 23:26:48 -04:00
|
|
|
automatic_image_sizes
|
|
|
|
cache_buster
|
|
|
|
minify_css
|
|
|
|
minify_javascript
|
|
|
|
relative_assets
|
|
|
|
slickmap
|
|
|
|
smush_pngs
|
|
|
|
ugly_haml).each do |feature|
|
|
|
|
|
|
|
|
require File.join("middleman/features", feature)
|
|
|
|
|
|
|
|
end
|