class Middleman::MetaPages::SitemapResource

View class for a sitemap resource

def css_classes

def css_classes
  ['resource'].concat(ignored? ? ['ignored'] : [])
end

def ignored?

def ignored?
  @resource.ignored?
end

def initialize(resource)

def initialize(resource)
  @resource = resource
end

def render

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

def resource_properties

A hash of label to value for all the properties we want to display
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.inspect unless data.empty?
  options = @resource.options
  props['Options'] = options.inspect unless options.empty?
  locals = @resource.locals.keys
  props['Locals'] = locals.join(', ') unless locals.empty?
  props
end