Get rid of raw_data

This commit is contained in:
Ben Hollis 2014-04-27 23:21:12 -07:00
parent 5c04c2f42b
commit adfad92f8f
7 changed files with 36 additions and 71 deletions

View file

@ -5,8 +5,8 @@ module Middleman::Sitemap::Extensions
module ContentType
# The preferred MIME content type for this resource
def content_type
# Allow explcitly setting content type from page/proxy options
meta_type = metadata[:options][:content_type]
# Allow explcitly setting content type from page/proxy options or frontmatter
meta_type = options[:content_type]
return meta_type if meta_type
# Look up mime type based on extension

View file

@ -51,10 +51,12 @@ module Middleman
# Whether the Resource is ignored
# @return [Boolean]
def ignored?
@app.sitemap.ignored?(path) ||
(!proxy? &&
@app.sitemap.ignored?(source_file.sub("#{@app.source_dir}/", ''))
)
# Check frontmatter/data
return true if !proxy? && data[:ignored] == true
# Ignore based on the source path (without template extensions)
return true if @app.sitemap.ignored?(path)
# This allows files to be ignored by their source file name (with template extensions)
!proxy? && @app.sitemap.ignored?(source_file.sub("#{@app.source_dir}/", ''))
end
end
end

View file

@ -75,18 +75,10 @@ module Middleman
end
end
# def request_path
# @request_path
# end
def binary?
false
end
def raw_data
{}
end
def ignored?
false
end

View file

@ -63,16 +63,10 @@ module Middleman
return output.call if output
end
attr_reader :request_path
def binary?
false
end
def raw_data
{}
end
def ignored?
false
end

View file

@ -52,6 +52,16 @@ module Middleman
!::Tilt[source_file].nil?
end
# Merge in new metadata specific to this resource.
# @param [Hash] meta A metadata block with keys :options, :locals, :page.
# Options are generally rendering/sitemap options
# Locals are local variables for rendering this resource's template
# Page are data that is exposed through this resource's data member.
# Note: It is named 'page' for backwards compatibility with older MM.
def add_metadata(meta={})
@local_metadata.deep_merge!(meta)
end
# Get the metadata for both the current source_file and the current path
# @return [Hash]
def metadata
@ -62,18 +72,21 @@ module Middleman
# Data about this resource, populated from frontmatter or extensions.
# @return [HashWithIndifferentAccess]
def data
# TODO: Upconvert/freeze at this point?
metadata[:page]
# TODO: Should this really be a HashWithIndifferentAccess?
::Middleman::Util.recursively_enhance(metadata[:page]).freeze
end
# Merge in new metadata specific to this resource.
# @param [Hash] meta A metadata block with keys :options, :locals, :page.
# Options are generally rendering/sitemap options
# Locals are local variables for rendering this resource's template
# Page are data that is exposed through this resource's data member.
# Note: It is named 'page' for backwards compatibility with older MM.
def add_metadata(meta={})
@local_metadata.deep_merge!(meta)
# Options about how this resource is rendered, such as its :layout,
# :renderer_options, and whether or not to use :directory_indexes.
# @return [Hash]
def options
metadata[:options]
end
# Local variable mappings that are used when rendering the template for this resource.
# @return [Hash]
def locals
metadata[:locals]
end
# Extension of the path (i.e. '.js')