Merge pull request #1229 from bhollis/metadata

Improvements to the /__middleman/ metadata pages
This commit is contained in:
Thomas Reynolds 2014-03-26 09:05:23 -07:00
commit dd9c05f433
10 changed files with 110 additions and 40 deletions

View file

@ -4,6 +4,7 @@ master
* Update Padrino to 0.12.0. Introduces BREAKING CHANGE for Haml. Helpers which take blocks used to require `-` instead of `=` to work correctly. Now, all helpers which output content should use `=`. See: http://www.padrinorb.com/blog/upgrading-padrino-from-0-11-x-to-0-12-0-guide * Update Padrino to 0.12.0. Introduces BREAKING CHANGE for Haml. Helpers which take blocks used to require `-` instead of `=` to work correctly. Now, all helpers which output content should use `=`. See: http://www.padrinorb.com/blog/upgrading-padrino-from-0-11-x-to-0-12-0-guide
* Depend on Erubis and remove support for specifying another ERb engine. * Depend on Erubis and remove support for specifying another ERb engine.
* Removed the ability to set the `sass_cache_path`. * Removed the ability to set the `sass_cache_path`.
* Improved /__middleman/ meta pages. For example, sitemap view now calls out ignored resources, prints data/options better, and shows which special locals are available on a page.
3.2.2 3.2.2
=== ===

View file

@ -25,6 +25,7 @@
.value { .value {
color: #002B36; color: #002B36;
white-space: pre-wrap;
} }
.description { .description {
@ -34,3 +35,15 @@
.extensions .settings { .extensions .settings {
margin-left: 1em; margin-left: 1em;
} }
.inactive {
color: #999999;
}
.inactive:after {
content: "Inactive";
font-weight: bold;
color: #999999;
margin-left: 10px;
font-size: .7em;
}

View file

@ -168,6 +168,7 @@ body {
padding-right: 1em; padding-right: 1em;
position: relative; position: relative;
margin-top: 2em; margin-top: 2em;
margin-bottom: 2em;
} }
.container:after { .container:after {
clear: both; clear: both;
@ -355,14 +356,29 @@ pre .tex .formula {
#main { #main {
display: inline; display: inline;
float: left; float: left;
font-size: 120%; font-size: 100%;
margin-left: 0; margin-left: 0;
margin-right: 1.20482%; margin-right: 1.20482%;
width: 100%; width: 100%;
} }
#main h1 { #main h1 {
font-size: 2em; font-size: 3em;
font-weight: bold;
margin-bottom: .5em;
} }
#main h2 { #main h2 {
font-size: 1.5em; font-size: 2em;
line-height: 1.2;
margin-bottom: 0.75em;
}
.nav-list {
list-style: none;
margin: 0;
padding: 0;
}
.nav-list a {
font-size: 1.4em;
font-weight: bold;
} }

View file

@ -27,6 +27,7 @@ summary > i {
.resource-details th, .resource-details td { .resource-details th, .resource-details td {
padding: 0; padding: 0;
vertical-align: top;
} }
.resource-details th { .resource-details th {
@ -40,6 +41,22 @@ summary > i {
font-family: "Arvo","andale mono","lucida console",monospace; font-family: "Arvo","andale mono","lucida console",monospace;
} }
.ignored > summary {
color: #999999;
}
.ignored i {
opacity: 0.4;
}
.ignored > summary:after {
content: "Ignored";
font-weight: bold;
color: #999999;
margin-left: 10px;
font-size: .7em;
}
details > summary:before { details > summary:before {
content: "" !important; content: "" !important;
display: inline-block; display: inline-block;

View file

@ -1,3 +1,5 @@
require 'pp'
module Middleman module Middleman
module MetaPages module MetaPages
# View class for a config entry # View class for a config entry
@ -13,22 +15,18 @@ module Middleman
content = '' content = ''
key_classes = ['key'] key_classes = ['key']
key_classes << 'modified' if @setting.value_set? key_classes << 'modified' if @setting.value_set?
content << content_tag(:span, @setting.key.inspect, :class => key_classes.join(' ')) content << content_tag(:span, @setting.key.pretty_inspect.strip, :class => key_classes.join(' '))
content << ' = ' content << ' = '
content << content_tag(:span, @setting.value.inspect, :class => 'value') content << content_tag(:span, @setting.value.pretty_inspect.strip, :class => 'value')
if @setting.default if @setting.default && @setting.value_set? && @setting.default != @setting.value
content << content_tag(:span, :class => 'default') do content << content_tag(:span, :class => 'default') do
if @setting.value_set? "(Default: #{@setting.default.inspect})"
"Default: #{@setting.default.inspect}"
else
'(Default)'
end
end end
end end
if @setting.description if @setting.description
content << content_tag(:p, :class => 'description') do content << content_tag(:p, :class => 'description') do
CGI::escapeHTML(@setting.description) @setting.description
end end
end end

View file

@ -15,7 +15,9 @@ module Middleman
end end
def render def render
content_tag :div, :class => 'resource-details' do classes = 'resource-details'
classes << ' ignored' if @resource.ignored?
content_tag :div, :class => classes do
content_tag :table do content_tag :table do
content = '' content = ''
resource_properties.each do |label, value| resource_properties.each do |label, value|
@ -33,24 +35,34 @@ module Middleman
# A hash of label to value for all the properties we want to display # A hash of label to value for all the properties we want to display
def resource_properties def resource_properties
props = { props = {}
'Path' => @resource.path, props['Path'] = @resource.path
'Build Path' => @resource.destination_path,
'URL' => content_tag(:a, @resource.url, :href => @resource.url), build_path = @resource.destination_path
'Source File' => @resource.source_file, build_path = 'Not built' if ignored?
} props['Build Path'] = build_path if @resource.path != build_path
props['URL'] = content_tag(:a, @resource.url, :href => @resource.url) unless ignored?
props['Source File'] = @resource.source_file.sub(/^#{Regexp.escape(ENV['MM_ROOT'] + '/')}/, '')
data = @resource.data data = @resource.data
props['Data'] = data unless data.empty? props['Data'] = data.inspect unless data.empty?
options = @resource.metadata[:options] meta = @resource.metadata
props['Options'] = options unless options.empty? options = meta[:options]
props['Options'] = options.inspect unless options.empty?
locals = meta[:locals].keys
props['Locals'] = locals.join(', ') unless locals.empty?
props props
end end
def ignored?
@resource.ignored?
end
def css_classes def css_classes
['resource'] ['resource'].concat(ignored? ? ['ignored'] : [])
end end
end end
end end

View file

@ -45,7 +45,11 @@ module Middleman
end end
def css_classes def css_classes
['tree'] ['tree'].concat(ignored? ? ['ignored'] : [])
end
def ignored?
@children.values.all?(&:ignored?)
end end
protected protected

View file

@ -13,7 +13,7 @@
<a href="/__middleman/">&laquo; back</a> <a href="/__middleman/">&laquo; back</a>
<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. <a href="http://middlemanapp.com/advanced/configuration/">Read more about configuring Middleman.</a></p>
<p> <p>
<a href="#core">Core configuration</a> <a href="#core">Core configuration</a>
@ -48,7 +48,7 @@
<% end %> <% end %>
<% registered_extensions.keys.each do |ext_name| %> <% registered_extensions.keys.each do |ext_name| %>
<li><span class="extension"><%= ext_name.inspect %></span> (Inactive)</li> <li><span class="extension inactive"><%= ext_name.inspect %></span></li>
<% end %> <% end %>
</ul> </ul>
</article> </article>

View file

@ -8,14 +8,24 @@
<body> <body>
<div class="container"> <div class="container">
<h1>Middleman Information</h1> <article id="main">
<h1>Middleman Information</h1>
<ul> <ul class="nav-list">
<li><a href="/__middleman/sitemap/">Sitemap</a></li> <li>
<li><a href="/__middleman/config/">Configuration</a></li> <a href="/__middleman/sitemap/">Sitemap</a>
<li><a href="http://middlemanapp.com">Middleman Guides</a></li> <p>The structure of your site as understood by Middleman.</p>
</ul> </li>
<li>
<a href="/__middleman/config/">Configuration</a>
<p>All available configuration options and their current values.</p>
</li>
<li>
<a href="http://middlemanapp.com">Middleman Guides</a>
<p>Documentation about Middleman's features.</p>
</li>
</ul>
</article>
</div> </div>
</body> </body>
</html> </html>

View file

@ -20,7 +20,7 @@
<h1>Middleman Sitemap</h1> <h1>Middleman Sitemap</h1>
<p>This page shows all of the pages in <p>This page shows all of the pages in
the <a href="http://middlemanapp.com/advanced/sitemap/">sitemap</a>, <a href="http://middlemanapp.com/advanced/sitemap/">the sitemap</a>,
Middleman's view of your site.</p> Middleman's view of your site.</p>
<%= sitemap_tree.render %> <%= sitemap_tree.render %>
@ -28,4 +28,3 @@
</div> </div>
</body> </body>
</html> </html>