Class: Middleman::MetaPages::SitemapResource
- Inherits:
-
Object
- Object
- Middleman::MetaPages::SitemapResource
- Includes:
- Padrino::Helpers::OutputHelpers, Padrino::Helpers::TagHelpers
- Defined in:
- lib/middleman-core/meta_pages/sitemap_resource.rb
Overview
View class for a sitemap resource
Instance Method Summary collapse
- #css_classes ⇒ Object
- #ignored? ⇒ Boolean
-
#initialize(resource) ⇒ SitemapResource
constructor
A new instance of SitemapResource.
- #render ⇒ Object
-
#resource_properties ⇒ Object
A hash of label to value for all the properties we want to display.
Constructor Details
#initialize(resource) ⇒ SitemapResource
Returns a new instance of SitemapResource.
12 13 14 |
# File 'lib/middleman-core/meta_pages/sitemap_resource.rb', line 12 def initialize(resource) @resource = resource end |
Instance Method Details
#css_classes ⇒ Object
62 63 64 |
# File 'lib/middleman-core/meta_pages/sitemap_resource.rb', line 62 def css_classes ['resource'].concat(ignored? ? ['ignored'] : []) end |
#ignored? ⇒ Boolean
58 59 60 |
# File 'lib/middleman-core/meta_pages/sitemap_resource.rb', line 58 def ignored? @resource.ignored? end |
#render ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/middleman-core/meta_pages/sitemap_resource.rb', line 16 def render 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| content << content_tag(:tr) do row_content = '' row_content << content_tag(:th, label) row_content << content_tag(:td, value) row_content.html_safe end end content.html_safe end end end |
#resource_properties ⇒ Object
A hash of label to value for all the properties we want to display
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/middleman-core/meta_pages/sitemap_resource.rb', line 36 def resource_properties 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.file_descriptor ? @resource.file_descriptor[:full_path].to_s.sub(/^#{Regexp.escape(ENV['MM_ROOT'] + '/')}/, '') : 'Dynamic' data = @resource.data props['Data'] = data.to_hash(symbolize_keys: true).inspect unless data.empty? = @resource. props['Options'] = .inspect unless .empty? locals = @resource.locals.keys props['Locals'] = locals.join(', ') unless locals.empty? props end |