Clean up styling a bit, add extension hooks
This commit is contained in:
parent
142abe027e
commit
a00d507de3
2
middleman-core/lib/middleman-core/meta_pages/assets/jquery-1.8.2.min.js
vendored
Normal file
2
middleman-core/lib/middleman-core/meta_pages/assets/jquery-1.8.2.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
6
middleman-core/lib/middleman-core/meta_pages/assets/jquery.details-1.6.min.js
vendored
Normal file
6
middleman-core/lib/middleman-core/meta_pages/assets/jquery.details-1.6.min.js
vendored
Normal file
|
@ -0,0 +1,6 @@
|
|||
(function(b){var d="open"in document.createElement("details"),e;b.fn.details=function(a){"open"===a&&(d?this.prop("open",!0):this.trigger("open"));"close"===a&&(d?this.prop("open",!1):this.trigger("close"));"init"===a&&e(b(this));if(!a){if(!d)return this.hasClass("open");var c=!1;this.each(function(){if(this.open)return c=!0,!1});return c}};e=function(a){a=a.not(".details-inited").addClass("details-inited");a.filter(".animated").each(function(){var a=b(this),d=a.children("summary").remove(),e=b("<div>").addClass("details-wrapper").append(a.children());
|
||||
a.append(e).prepend(d)});d||(a.each(function(){var a=b(this);a.children("summary").length||a.prepend("<summary>Details</summary>")}).children("summary").filter(":not(tabindex)").attr("tabindex",0).end().end().contents(":not(summary)").filter(function(){return 3===this.nodeType&&/[^\t\n\r ]/.test(this.data)}).wrap("<span>").end().end().filter(":not([open])").prop("open",!1).end().filter("[open]").addClass("open").prop("open",!0).end(),b.browser.msie&&9>b.browser.msie&&a.filter(":not(.open)").children().not("summary").hide())};
|
||||
b(function(){b("body").on("open.details","details.animated",function(){var a=b(this),c=a.children(".details-wrapper");c.hide();setTimeout(function(){c.slideDown(a.data("animation-speed"))},0)}).on("close.details","details.animated",function(){var a=b(this),c=a.children(".details-wrapper");setTimeout(function(){a.prop("open",!0).addClass("open");c.slideUp(a.data("animation-speed"),function(){a.prop("open",!1).removeClass("open")})},0)});if(d)b("body").on("click","summary",function(){var a=b(this).parent();
|
||||
a.prop("open")?a.trigger("close"):a.trigger("open")});else if(b("html").addClass("no-details"),b("head").prepend('<style>details{display:block}summary{cursor:pointer}details>summary::before{content:"\u25ba"}details.open>summary::before{content:"\u25bc"}details:not(.open)>:not(summary){display:none}</style>'),b("body").on("open.details","details",function(a){b(this).addClass("open").trigger("change.details");a.stopPropagation()}).on("close.details","details",function(a){b(this).removeClass("open").trigger("change.details");
|
||||
a.stopPropagation()}).on("toggle.details","details",function(a){var c=b(this);c.hasClass("open")?c.trigger("close"):c.trigger("open");a.stopPropagation()}).on("click","summary",function(){b(this).parent().trigger("toggle")}).on("keyup","summary",function(a){(32===a.keyCode||13===a.keyCode&&!b.browser.opera)&&b(this).parent().trigger("toggle")}),b.browser.msie&&9>b.browser.msie)b("body").on("open.details","details",function(){b(this).children().not("summary").show()}).on("close.details","details",
|
||||
function(){b(this).children().not("summary").hide()});e(b("details"))})})(jQuery);
|
|
@ -0,0 +1,15 @@
|
|||
summary {
|
||||
display: block;
|
||||
}
|
||||
|
||||
details > details {
|
||||
margin-left: 15px;
|
||||
}
|
||||
|
||||
details.resource > summary {
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.resource-details {
|
||||
margin-left: 15px;
|
||||
}
|
|
@ -1 +0,0 @@
|
|||
alert("foo");
|
|
@ -2,12 +2,39 @@ module Middleman
|
|||
module MetaPages
|
||||
# View class for a sitemap resource
|
||||
class SitemapResource
|
||||
include Padrino::Helpers::OutputHelpers
|
||||
include Padrino::Helpers::TagHelpers
|
||||
|
||||
def initialize(resource)
|
||||
@resource = resource
|
||||
end
|
||||
|
||||
def render
|
||||
"<p>#{@resource.destination_path}</p>"
|
||||
content_tag :div, :class => 'resource-details' do
|
||||
content_tag :dl do
|
||||
content = ""
|
||||
resource_properties.each do |label, value|
|
||||
content << content_tag(:dt, label)
|
||||
content << content_tag(:dd, value)
|
||||
end
|
||||
content
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# A hash of label to value for all the properties we want to display
|
||||
def resource_properties
|
||||
{
|
||||
'Path' => @resource.path,
|
||||
'Output Path' => File.join(@resource.app.build_dir, @resource.destination_path),
|
||||
'Url' => content_tag(:a, @resource.url, :href => @resource.url),
|
||||
#'Metadata' => @resource.metadata,
|
||||
'Source' => @resource.source_file
|
||||
}
|
||||
end
|
||||
|
||||
def css_classes
|
||||
['resource']
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -15,25 +15,30 @@ module Middleman
|
|||
def render
|
||||
content = ""
|
||||
@children.keys.sort_by(&:downcase).each do |path_part|
|
||||
content << "<details>"
|
||||
content << "<summary>"
|
||||
content << path_part
|
||||
content << "</summary>"
|
||||
|
||||
subtree = @children[path_part]
|
||||
content << "<details class='#{subtree.css_classes.join(' ')}'>"
|
||||
content << "<summary>#{path_part}</summary>"
|
||||
content << subtree.render
|
||||
content << "</details>"
|
||||
end
|
||||
content
|
||||
end
|
||||
|
||||
def css_classes
|
||||
['tree']
|
||||
end
|
||||
|
||||
protected
|
||||
|
||||
def add_path(path_parts, resource)
|
||||
first_part = path_parts.first
|
||||
|
||||
if path_parts.size == 1
|
||||
@children[first_part] = SitemapResource.new(resource)
|
||||
sitemap_class = SitemapResource
|
||||
# Allow special sitemap resources to use custom metadata view calsses
|
||||
sitemap_class = resource.meta_pages_class if resource.respond_to? :meta_pages_class
|
||||
|
||||
@children[first_part] = sitemap_class.new(resource)
|
||||
else
|
||||
@children[first_part] ||= SitemapTree.new
|
||||
@children[first_part].add_path(path_parts[1..-1], resource)
|
||||
|
|
|
@ -4,6 +4,10 @@
|
|||
<meta charset="utf-8">
|
||||
|
||||
<title>Middleman Sitemap</title>
|
||||
|
||||
<link type="text/css" rel="stylesheet" href="../assets/sitemap.css">
|
||||
<script src="../assets/jquery-1.8.2.min.js"></script>
|
||||
<script src="../assets/jquery.details-1.6.min.js"></script>
|
||||
<script src="../assets/sitemap.js"></script>
|
||||
</head>
|
||||
|
||||
|
|
Loading…
Reference in a new issue