Fix extension configs meta page to correctly handle multiple instance extensions like blog
This commit is contained in:
parent
5604fa1a8b
commit
fc20a761de
2 changed files with 28 additions and 16 deletions
|
@ -60,18 +60,28 @@ 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) }
|
|
||||||
else
|
|
||||||
nil
|
|
||||||
end
|
|
||||||
[ext_name, opts]
|
|
||||||
end]
|
|
||||||
|
|
||||||
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,
|
:global_config => global_config,
|
||||||
:extension_config => extension_config,
|
:extension_config => extension_config,
|
||||||
:registered_extensions => Middleman::Extensions.registered.dup)
|
:registered_extensions => Middleman::Extensions.registered.dup)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -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
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
<h1>Middleman Configuration</h1>
|
<h1>Middleman Configuration</h1>
|
||||||
|
|
||||||
<p>This page shows the current configuration of your Middleman application.</p>
|
<p>This page shows the current configuration of your Middleman application.</p>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
<a href="#core">Core configuration</a>
|
<a href="#core">Core configuration</a>
|
||||||
| <a href="#extensions">Extensions</a>
|
| <a href="#extensions">Extensions</a>
|
||||||
|
@ -32,10 +32,10 @@
|
||||||
<% extension_config.each do |ext_name, configs| %>
|
<% extension_config.each do |ext_name, configs| %>
|
||||||
<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? %>
|
||||||
<ul class="settings">
|
<ul class="settings">
|
||||||
<% configs.each do |setting| %>
|
<% configs.each do |setting| %>
|
||||||
|
@ -55,5 +55,3 @@
|
||||||
</div>
|
</div>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue