mirror of
https://github.com/middleman/middleman.git
synced 2022-11-09 12:20:27 -05:00
Merge pull request #776 from bhollis/config_meta
Add a metadata page for inspecting configuration.
This commit is contained in:
commit
c48ac06526
5 changed files with 53 additions and 3 deletions
|
@ -142,7 +142,7 @@ module Middleman
|
|||
cache.clear
|
||||
|
||||
# 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
|
||||
instance_exec(&block) if block_given?
|
||||
|
|
|
@ -171,12 +171,20 @@ module Middleman
|
|||
def dup
|
||||
copy = ConfigurationManager.new
|
||||
@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?
|
||||
end
|
||||
copy
|
||||
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
|
||||
hash = {}
|
||||
@settings.each do |key, setting|
|
||||
|
|
|
@ -27,6 +27,10 @@ module Middleman
|
|||
map '/sitemap' do
|
||||
run meta_pages.method(:sitemap)
|
||||
end
|
||||
|
||||
map '/config' do
|
||||
run meta_pages.method(:config)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -52,6 +56,11 @@ module Middleman
|
|||
template('sitemap.html.erb', :sitemap_tree => sitemap_tree)
|
||||
end
|
||||
|
||||
# Inspect configuration
|
||||
def config(env)
|
||||
template('config.html.erb', :config => @middleman.config)
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
# 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>
|
||||
<li><a href="sitemap/">Sitemap</a></li>
|
||||
<li><a href="config/">Configuration</a></li>
|
||||
</ul>
|
||||
</body>
|
||||
</html>
|
||||
|
|
Loading…
Reference in a new issue