2013-06-04 18:56:33 +02:00
|
|
|
if !defined?(::Padrino::Helpers)
|
2014-02-19 03:30:29 +01:00
|
|
|
require 'vendored-middleman-deps/padrino-core-0.12.0/lib/padrino-core/support_lite'
|
|
|
|
require 'vendored-middleman-deps/padrino-helpers-0.12.0/lib/padrino-helpers'
|
2013-06-04 18:48:01 +02:00
|
|
|
end
|
2013-05-12 22:55:24 +02:00
|
|
|
|
2012-10-13 23:28:08 +02:00
|
|
|
module Middleman
|
|
|
|
module MetaPages
|
|
|
|
# View class for a sitemap resource
|
|
|
|
class SitemapResource
|
2012-10-14 00:38:25 +02:00
|
|
|
include Padrino::Helpers::OutputHelpers
|
|
|
|
include Padrino::Helpers::TagHelpers
|
|
|
|
|
2012-10-13 23:28:08 +02:00
|
|
|
def initialize(resource)
|
|
|
|
@resource = resource
|
|
|
|
end
|
|
|
|
|
|
|
|
def render
|
2012-10-14 00:38:25 +02:00
|
|
|
content_tag :div, :class => 'resource-details' do
|
2013-04-14 03:01:58 +02:00
|
|
|
content_tag :table do
|
2013-12-28 01:26:31 +01:00
|
|
|
content = ''
|
2012-10-14 00:38:25 +02:00
|
|
|
resource_properties.each do |label, value|
|
2013-04-14 03:01:58 +02:00
|
|
|
content << content_tag(:tr) do
|
2013-12-28 01:26:31 +01:00
|
|
|
row_content = ''
|
2013-04-14 03:01:58 +02:00
|
|
|
row_content << content_tag(:th, label)
|
|
|
|
row_content << content_tag(:td, value)
|
2013-07-12 21:54:15 +02:00
|
|
|
row_content.html_safe
|
2013-04-14 03:01:58 +02:00
|
|
|
end
|
2012-10-14 00:38:25 +02:00
|
|
|
end
|
2013-07-12 21:54:15 +02:00
|
|
|
content.html_safe
|
2012-10-14 00:38:25 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
# A hash of label to value for all the properties we want to display
|
|
|
|
def resource_properties
|
2013-04-14 03:01:58 +02:00
|
|
|
props = {
|
2012-10-14 00:38:25 +02:00
|
|
|
'Path' => @resource.path,
|
2013-04-14 03:01:58 +02:00
|
|
|
'Build Path' => @resource.destination_path,
|
|
|
|
'URL' => content_tag(:a, @resource.url, :href => @resource.url),
|
2013-04-22 03:13:27 +02:00
|
|
|
'Source File' => @resource.source_file,
|
2012-10-14 00:38:25 +02:00
|
|
|
}
|
2013-04-14 03:01:58 +02:00
|
|
|
|
|
|
|
data = @resource.data
|
|
|
|
props['Data'] = data unless data.empty?
|
|
|
|
|
|
|
|
options = @resource.metadata[:options]
|
|
|
|
props['Options'] = options unless options.empty?
|
|
|
|
|
|
|
|
props
|
2012-10-14 00:38:25 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
def css_classes
|
|
|
|
['resource']
|
2012-10-13 23:28:08 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|