Class: Middleman::MetaPages::SitemapResource

Inherits:
Object
  • Object
show all
Includes:
Padrino::Helpers::OutputHelpers, Padrino::Helpers::TagHelpers
Defined in:
lib/middleman-core/meta_pages/sitemap_resource.rb

Overview

View class for a sitemap resource

Constant Summary

Constants included from Padrino::Helpers::TagHelpers

Padrino::Helpers::TagHelpers::BOOLEAN_ATTRIBUTES, Padrino::Helpers::TagHelpers::DATA_ATTRIBUTES, Padrino::Helpers::TagHelpers::ESCAPE_REGEXP, Padrino::Helpers::TagHelpers::ESCAPE_VALUES, Padrino::Helpers::TagHelpers::NEWLINE

Instance Method Summary collapse

Methods included from Padrino::Helpers::TagHelpers

#content_tag, #input_tag, #safe_content_tag, #tag

Methods included from Padrino::Helpers::OutputHelpers

#block_is_template?, #capture_html, #concat_content, #concat_safe_content, #content_for, #content_for?, handlers, included, register, #yield_content

Constructor Details

#initialize(resource) ⇒ SitemapResource

Returns a new instance of SitemapResource.



13
14
15
# File 'lib/middleman-core/meta_pages/sitemap_resource.rb', line 13

def initialize(resource)
  @resource = resource
end

Instance Method Details

#css_classesObject



52
53
54
# File 'lib/middleman-core/meta_pages/sitemap_resource.rb', line 52

def css_classes
  ['resource']
end

#renderObject



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/middleman-core/meta_pages/sitemap_resource.rb', line 17

def render
   :div, :class => 'resource-details' do
     :table do
      content = ""
      resource_properties.each do |label, value|
        content << (:tr) do
          row_content = ""
          row_content << (:th, label)
          row_content << (:td, value)
          row_content.html_safe
        end
      end
      content.html_safe
    end
  end
end

#resource_propertiesObject

A hash of label to value for all the properties we want to display



35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/middleman-core/meta_pages/sitemap_resource.rb', line 35

def resource_properties
  props = {
    'Path' => @resource.path,
    'Build Path' => @resource.destination_path,
    'URL' => (:a, @resource.url, :href => @resource.url),
    'Source File' => @resource.source_file,
  }

  data = @resource.data
  props['Data'] = data unless data.empty?

  options = @resource.[:options]
  props['Options'] = options unless options.empty?

  props
end