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,14 +60,24 @@ module Middleman
# Inspect configuration # Inspect configuration
def config(env) def config(env)
global_config = @middleman.inst.config.all_settings.map {|c| ConfigSetting.new(c) } global_config = @middleman.inst.config.all_settings.map {|c| ConfigSetting.new(c) }
extension_config = Hash[@middleman.inst.extensions.map do |ext_name, extension| extension_config = {}
opts = if extension.is_a?(::Middleman::Extension)
extension.options.all_settings.map {|c| ConfigSetting.new(c) } @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 else
nil 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 end
[ext_name, opts]
end]
template('config.html.erb', template('config.html.erb',
:global_config => global_config, :global_config => global_config,
@ -88,6 +98,10 @@ module Middleman
def response(content) def response(content)
[ 200, {"Content-Type" => "text/html"}, Array(content) ] [ 200, {"Content-Type" => "text/html"}, Array(content) ]
end end
def extension_options(extension)
extension.options.all_settings.map {|c| ConfigSetting.new(c) }
end
end end
end end
end end

View file

@ -33,7 +33,7 @@
<li> <li>
<% registered_extensions.delete(ext_name) %> <% registered_extensions.delete(ext_name) %>
<span class="extension active"><%= ext_name.inspect %></span> <span class="extension active">:<%= ext_name %></span>
<% if configs && !configs.empty? %> <% if configs && !configs.empty? %>
@ -55,5 +55,3 @@
</div> </div>
</body> </body>
</html> </html>