Merge pull request #776 from bhollis/config_meta
Add a metadata page for inspecting configuration.
This commit is contained in:
commit
c48ac06526
|
@ -142,7 +142,7 @@ module Middleman
|
||||||
cache.clear
|
cache.clear
|
||||||
|
|
||||||
# Setup the default values from calls to set before initialization
|
# Setup the default values from calls to set before initialization
|
||||||
self.class.superclass.config.to_h.each { |k,v| self.class.config.define_setting(k,v) }
|
self.class.config.load_settings(self.class.superclass.config.all_settings)
|
||||||
|
|
||||||
# Evaluate a passed block if given
|
# Evaluate a passed block if given
|
||||||
instance_exec(&block) if block_given?
|
instance_exec(&block) if block_given?
|
||||||
|
|
|
@ -171,12 +171,20 @@ module Middleman
|
||||||
def dup
|
def dup
|
||||||
copy = ConfigurationManager.new
|
copy = ConfigurationManager.new
|
||||||
@settings.each do |key, setting|
|
@settings.each do |key, setting|
|
||||||
copy_setting = copy.define_setting setting.key, setting.default, setting.description
|
copy_setting = copy.define_setting(setting.key, setting.default, setting.description)
|
||||||
copy_setting.value = setting.value if setting.value_set?
|
copy_setting.value = setting.value if setting.value_set?
|
||||||
end
|
end
|
||||||
copy
|
copy
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Load in a list of settings
|
||||||
|
def load_settings(other_settings)
|
||||||
|
other_settings.each do |setting|
|
||||||
|
new_setting = define_setting(setting.key, setting.default, setting.description)
|
||||||
|
new_setting.value = setting.value if setting.value_set?
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def to_h
|
def to_h
|
||||||
hash = {}
|
hash = {}
|
||||||
@settings.each do |key, setting|
|
@settings.each do |key, setting|
|
||||||
|
|
|
@ -27,6 +27,10 @@ module Middleman
|
||||||
map '/sitemap' do
|
map '/sitemap' do
|
||||||
run meta_pages.method(:sitemap)
|
run meta_pages.method(:sitemap)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
map '/config' do
|
||||||
|
run meta_pages.method(:config)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -52,6 +56,11 @@ module Middleman
|
||||||
template('sitemap.html.erb', :sitemap_tree => sitemap_tree)
|
template('sitemap.html.erb', :sitemap_tree => sitemap_tree)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Inspect configuration
|
||||||
|
def config(env)
|
||||||
|
template('config.html.erb', :config => @middleman.config)
|
||||||
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
# Render a template with the given name and locals
|
# Render a template with the given name and locals
|
||||||
|
|
|
@ -0,0 +1,32 @@
|
||||||
|
<!doctype html>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
|
||||||
|
<title>Middleman Config</title>
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
<h1>Middleman Config</h1>
|
||||||
|
<a href="../">More meta pages</a>
|
||||||
|
|
||||||
|
<ul>
|
||||||
|
<% config.all_settings.each do |setting| %>
|
||||||
|
<li>
|
||||||
|
<b><%= setting.key %></b>:
|
||||||
|
<%= setting.value.inspect %>
|
||||||
|
<% if setting.value_set? %>
|
||||||
|
<br>
|
||||||
|
Default: <%= setting.default.inspect %>
|
||||||
|
<% else %>
|
||||||
|
(Default)
|
||||||
|
<% end %>
|
||||||
|
<br>
|
||||||
|
<i><%= setting.description %></i>
|
||||||
|
</li>
|
||||||
|
<% end %>
|
||||||
|
</ul>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
|
|
||||||
|
|
|
@ -13,6 +13,7 @@
|
||||||
|
|
||||||
<ul>
|
<ul>
|
||||||
<li><a href="sitemap/">Sitemap</a></li>
|
<li><a href="sitemap/">Sitemap</a></li>
|
||||||
|
<li><a href="config/">Configuration</a></li>
|
||||||
</ul>
|
</ul>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
Loading…
Reference in a new issue