Fix extension configs meta page to correctly handle multiple instance extensions like blog

This commit is contained in:
Ben Hollis 2013-11-24 21:45:06 -08:00
parent 5604fa1a8b
commit fc20a761de
2 changed files with 28 additions and 16 deletions

View file

@ -60,18 +60,28 @@ module Middleman
# Inspect configuration
def config(env)
global_config = @middleman.inst.config.all_settings.map {|c| ConfigSetting.new(c) }
extension_config = Hash[@middleman.inst.extensions.map do |ext_name, extension|
opts = if extension.is_a?(::Middleman::Extension)
extension.options.all_settings.map {|c| ConfigSetting.new(c) }
else
nil
end
[ext_name, opts]
end]
extension_config = {}
template('config.html.erb',
@middleman.inst.extensions.each do |ext_name, extension|
if extension.is_a?(Hash)
# Multiple instance extension
if extension.size == 1
extension_config[ext_name] = extension_options(extension.values.first)
else
extension.each do |inst, ext|
extension_config["#{ext_name} (#{inst})"] = extension_options(ext)
end
end
elsif extension.is_a?(::Middleman::Extension)
extension_config[ext_name] = extension_options(extension)
else
extension_config[ext_name] = nil
end
end
template('config.html.erb',
:global_config => global_config,
:extension_config => extension_config,
:extension_config => extension_config,
:registered_extensions => Middleman::Extensions.registered.dup)
end
@ -88,6 +98,10 @@ module Middleman
def response(content)
[ 200, {"Content-Type" => "text/html"}, Array(content) ]
end
def extension_options(extension)
extension.options.all_settings.map {|c| ConfigSetting.new(c) }
end
end
end
end

View file

@ -14,7 +14,7 @@
<h1>Middleman Configuration</h1>
<p>This page shows the current configuration of your Middleman application.</p>
<p>
<a href="#core">Core configuration</a>
| <a href="#extensions">Extensions</a>
@ -32,10 +32,10 @@
<% extension_config.each do |ext_name, configs| %>
<li>
<% registered_extensions.delete(ext_name) %>
<span class="extension active"><%= ext_name.inspect %></span>
<span class="extension active">:<%= ext_name %></span>
<% if configs && !configs.empty? %>
<ul class="settings">
<% configs.each do |setting| %>
@ -55,5 +55,3 @@
</div>
</body>
</html>