From 4605ffc39887ea78bd4a3d6a1e96c6588b668a0d Mon Sep 17 00:00:00 2001 From: Ben Hollis Date: Wed, 26 Mar 2014 00:12:10 -0700 Subject: [PATCH] Improvements to the /__middleman/ metadata pages. Includes formatting/styling changes to clarify the data being presented as well as align styling with middlemanapp.com. Also adds features and fixes to the sitemap view to show ignored files differently, hide redundant information, print data/options as a hash instead of as array pairs, and to list out available locals defined on a page. --- CHANGELOG.md | 1 + .../meta_pages/assets/config.css | 13 +++++++ .../middleman-core/meta_pages/assets/meta.css | 22 ++++++++++-- .../meta_pages/assets/sitemap.css | 19 ++++++++++- .../meta_pages/config_setting.rb | 16 ++++----- .../meta_pages/sitemap_resource.rb | 34 +++++++++++++------ .../middleman-core/meta_pages/sitemap_tree.rb | 6 +++- .../meta_pages/templates/config.html.erb | 4 +-- .../meta_pages/templates/index.html.erb | 26 +++++++++----- .../meta_pages/templates/sitemap.html.erb | 9 +++-- 10 files changed, 110 insertions(+), 40 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b755cbe8..f30ab2cd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 * Depend on Erubis and remove support for specifying another ERb engine. * 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 === diff --git a/middleman-core/lib/middleman-core/meta_pages/assets/config.css b/middleman-core/lib/middleman-core/meta_pages/assets/config.css index 5d673ace..10a9e3cc 100644 --- a/middleman-core/lib/middleman-core/meta_pages/assets/config.css +++ b/middleman-core/lib/middleman-core/meta_pages/assets/config.css @@ -25,6 +25,7 @@ .value { color: #002B36; + white-space: pre-wrap; } .description { @@ -33,4 +34,16 @@ .extensions .settings { margin-left: 1em; +} + +.inactive { + color: #999999; +} + +.inactive:after { + content: "Inactive"; + font-weight: bold; + color: #999999; + margin-left: 10px; + font-size: .7em; } \ No newline at end of file diff --git a/middleman-core/lib/middleman-core/meta_pages/assets/meta.css b/middleman-core/lib/middleman-core/meta_pages/assets/meta.css index dd862ac4..94b473ca 100644 --- a/middleman-core/lib/middleman-core/meta_pages/assets/meta.css +++ b/middleman-core/lib/middleman-core/meta_pages/assets/meta.css @@ -168,6 +168,7 @@ body { padding-right: 1em; position: relative; margin-top: 2em; + margin-bottom: 2em; } .container:after { clear: both; @@ -355,14 +356,29 @@ pre .tex .formula { #main { display: inline; float: left; - font-size: 120%; + font-size: 100%; margin-left: 0; margin-right: 1.20482%; width: 100%; } #main h1 { - font-size: 2em; + font-size: 3em; + font-weight: bold; + margin-bottom: .5em; } #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; +} \ No newline at end of file diff --git a/middleman-core/lib/middleman-core/meta_pages/assets/sitemap.css b/middleman-core/lib/middleman-core/meta_pages/assets/sitemap.css index 408cae8b..2bc0f504 100644 --- a/middleman-core/lib/middleman-core/meta_pages/assets/sitemap.css +++ b/middleman-core/lib/middleman-core/meta_pages/assets/sitemap.css @@ -9,7 +9,7 @@ details > details { } details.resource > summary { - + } .resource-details { @@ -27,6 +27,7 @@ summary > i { .resource-details th, .resource-details td { padding: 0; + vertical-align: top; } .resource-details th { @@ -40,6 +41,22 @@ summary > i { 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 { content: "" !important; display: inline-block; diff --git a/middleman-core/lib/middleman-core/meta_pages/config_setting.rb b/middleman-core/lib/middleman-core/meta_pages/config_setting.rb index 360eda67..3fd223e3 100644 --- a/middleman-core/lib/middleman-core/meta_pages/config_setting.rb +++ b/middleman-core/lib/middleman-core/meta_pages/config_setting.rb @@ -1,3 +1,5 @@ +require 'pp' + module Middleman module MetaPages # View class for a config entry @@ -13,22 +15,18 @@ module Middleman content = '' key_classes = ['key'] 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_tag(:span, @setting.value.inspect, :class => 'value') - if @setting.default + content << content_tag(:span, @setting.value.pretty_inspect.strip, :class => 'value') + if @setting.default && @setting.value_set? && @setting.default != @setting.value content << content_tag(:span, :class => 'default') do - if @setting.value_set? - "Default: #{@setting.default.inspect}" - else - '(Default)' - end + "(Default: #{@setting.default.inspect})" end end if @setting.description content << content_tag(:p, :class => 'description') do - CGI::escapeHTML(@setting.description) + @setting.description end end diff --git a/middleman-core/lib/middleman-core/meta_pages/sitemap_resource.rb b/middleman-core/lib/middleman-core/meta_pages/sitemap_resource.rb index 3c753c3c..f912505b 100644 --- a/middleman-core/lib/middleman-core/meta_pages/sitemap_resource.rb +++ b/middleman-core/lib/middleman-core/meta_pages/sitemap_resource.rb @@ -15,7 +15,9 @@ module Middleman end 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 = '' 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 def resource_properties - props = { - 'Path' => @resource.path, - 'Build Path' => @resource.destination_path, - 'URL' => content_tag(:a, @resource.url, :href => @resource.url), - 'Source File' => @resource.source_file, - } + props = {} + props['Path'] = @resource.path + + build_path = @resource.destination_path + 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 - props['Data'] = data unless data.empty? + props['Data'] = data.inspect unless data.empty? - options = @resource.metadata[:options] - props['Options'] = options unless options.empty? + meta = @resource.metadata + options = meta[:options] + props['Options'] = options.inspect unless options.empty? + + locals = meta[:locals].keys + props['Locals'] = locals.join(', ') unless locals.empty? props end + def ignored? + @resource.ignored? + end + def css_classes - ['resource'] + ['resource'].concat(ignored? ? ['ignored'] : []) end end end diff --git a/middleman-core/lib/middleman-core/meta_pages/sitemap_tree.rb b/middleman-core/lib/middleman-core/meta_pages/sitemap_tree.rb index 21dd4d51..68bae977 100644 --- a/middleman-core/lib/middleman-core/meta_pages/sitemap_tree.rb +++ b/middleman-core/lib/middleman-core/meta_pages/sitemap_tree.rb @@ -45,7 +45,11 @@ module Middleman end def css_classes - ['tree'] + ['tree'].concat(ignored? ? ['ignored'] : []) + end + + def ignored? + @children.values.all?(&:ignored?) end protected diff --git a/middleman-core/lib/middleman-core/meta_pages/templates/config.html.erb b/middleman-core/lib/middleman-core/meta_pages/templates/config.html.erb index 68595772..44e55388 100644 --- a/middleman-core/lib/middleman-core/meta_pages/templates/config.html.erb +++ b/middleman-core/lib/middleman-core/meta_pages/templates/config.html.erb @@ -13,7 +13,7 @@ « back

Middleman Configuration

-

This page shows the current configuration of your Middleman application.

+

This page shows the current configuration of your Middleman application. Read more about configuring Middleman.

Core configuration @@ -48,7 +48,7 @@ <% end %> <% registered_extensions.keys.each do |ext_name| %> -

  • <%= ext_name.inspect %> (Inactive)
  • +
  • <%= ext_name.inspect %>
  • <% end %> diff --git a/middleman-core/lib/middleman-core/meta_pages/templates/index.html.erb b/middleman-core/lib/middleman-core/meta_pages/templates/index.html.erb index aa1ac9e6..65041ac7 100644 --- a/middleman-core/lib/middleman-core/meta_pages/templates/index.html.erb +++ b/middleman-core/lib/middleman-core/meta_pages/templates/index.html.erb @@ -5,17 +5,27 @@ Middleman Info - +
    -

    Middleman Information

    +
    - diff --git a/middleman-core/lib/middleman-core/meta_pages/templates/sitemap.html.erb b/middleman-core/lib/middleman-core/meta_pages/templates/sitemap.html.erb index e8a32d6e..940ac9bd 100644 --- a/middleman-core/lib/middleman-core/meta_pages/templates/sitemap.html.erb +++ b/middleman-core/lib/middleman-core/meta_pages/templates/sitemap.html.erb @@ -2,17 +2,17 @@ - + Middleman Sitemap - + - +
    @@ -20,7 +20,7 @@

    Middleman Sitemap

    This page shows all of the pages in - the sitemap, + the sitemap, Middleman's view of your site.

    <%= sitemap_tree.render %> @@ -28,4 +28,3 @@
    -