lib/octopress-docs/command.rb in octopress-docs-0.0.4 vs lib/octopress-docs/command.rb in octopress-docs-0.0.5
- old
+ new
@@ -34,11 +34,11 @@
def self.init_octopress_docs(options)
Octopress.config({
'config-file' => File.join(site_dir, '_octopress.yml'),
'override' => { 'docs_mode' => true }
})
- require_gems
+ require_plugins
options['source'] = site_dir
options['destination'] = File.join(site_dir, '_site')
options
end
@@ -57,18 +57,34 @@
def self.site_dir
Docs.gem_dir('docs')
end
- def self.require_gems
- file = File.join(Dir.pwd, '_config.yml')
- if File.exist? file
- config = YAML.safe_load(File.open(file))
- gems = config['gems']
- if gems && gems.is_a?(Array)
- gems.each {|g| require g }
+ def self.require_plugins
+ config = Octopress.site.config
+
+ if config['gems'].is_a?(Array)
+ config['gems'].each {|g| require g }
+ end
+
+ unless config['safe']
+ plugins_path.each do |plugins|
+ Dir[File.join(plugins, "**", "*.rb")].sort.each do |f|
+ require f
+ end
end
end
+
end
+
+ # Returns an Array of plugin search paths
+ def self.plugins_path
+ if (Octopress.site.config['plugins'] == Jekyll::Configuration::DEFAULTS['plugins'])
+ [Jekyll.sanitized_path(Octopress.site.source, Octopress.site.config['plugins'])]
+ else
+ Array(Octopress.site.config['plugins']).map { |d| File.expand_path(d) }
+ end
+ end
+
end
end
end