Fixup after rebase
This commit is contained in:
parent
bf4310697d
commit
a1fe810a50
|
@ -16,7 +16,7 @@ class NeighborFrontmatter < ::Middleman::Extension
|
|||
opts[:renderer_options].symbolize_keys! if opts.key?(:renderer_options)
|
||||
ignored = fmdata.delete(:ignored)
|
||||
resource.add_metadata options: opts, page: fmdata
|
||||
resource.ignore! if ignored == true && !resource.proxy?
|
||||
resource.ignore! if ignored == true && !resource.is_a?(::Middleman::Sitemap::ProxyResource)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -21,7 +21,7 @@ class NeighborFrontmatter < ::Middleman::Extension
|
|||
opts[:renderer_options].symbolize_keys! if opts.key?(:renderer_options)
|
||||
ignored = fmdata.delete(:ignored)
|
||||
resource.add_metadata options: opts, page: fmdata
|
||||
resource.ignore! if ignored == true && !resource.proxy?
|
||||
resource.ignore! if ignored == true && !resource.is_a?(::Middleman::Sitemap::ProxyResource)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -92,7 +92,7 @@ module Middleman::CoreExtensions
|
|||
|
||||
data = {}
|
||||
|
||||
return [data, nil] if !app.files.exists?(full_path) || ::Middleman::Util.binary?(full_path)
|
||||
return [data, nil] if !file_watcher.exists?(full_path) || ::Middleman::Util.binary?(full_path)
|
||||
|
||||
content = File.read(full_path)
|
||||
|
||||
|
|
|
@ -119,8 +119,7 @@ module Middleman
|
|||
resource
|
||||
end
|
||||
|
||||
# rubocop:disable AccessorMethodName
|
||||
def get_source_file
|
||||
def source_file
|
||||
target_resource.source_file
|
||||
end
|
||||
|
||||
|
@ -130,17 +129,6 @@ module Middleman
|
|||
|
||||
target_resource.content_type
|
||||
end
|
||||
|
||||
# Whether the Resource is ignored
|
||||
# @return [Boolean]
|
||||
def ignored?
|
||||
return true if @ignored
|
||||
|
||||
# Ignore based on the source path (without template extensions)
|
||||
return true if @app.sitemap.ignored?(path)
|
||||
|
||||
false
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -19,23 +19,15 @@ module Middleman
|
|||
# @return [String]
|
||||
attr_accessor :destination_path
|
||||
|
||||
# The on-disk source file for this resource, if there is one
|
||||
# @return [String]
|
||||
attr_reader :source_file
|
||||
|
||||
# The path to use when requesting this resource. Normally it's
|
||||
# the same as {#destination_path} but it can be overridden in subclasses.
|
||||
# @return [String]
|
||||
alias_method :request_path, :destination_path
|
||||
|
||||
# Get the on-disk source file for this resource
|
||||
# @return [String]
|
||||
def source_file
|
||||
if @source_file
|
||||
@source_file
|
||||
elsif proxy?
|
||||
proxied_to_resource.source_file
|
||||
else
|
||||
nil
|
||||
end
|
||||
end
|
||||
|
||||
# Initialize resource with parent store and URL
|
||||
# @param [Middleman::Sitemap::Store] store
|
||||
# @param [String] path
|
||||
|
@ -54,13 +46,6 @@ module Middleman
|
|||
@metadata = { options: {}, locals: {}, page: {} }
|
||||
end
|
||||
|
||||
# Set the on-disk source file for this resource
|
||||
# @return [String]
|
||||
def source_file
|
||||
# TODO: Make this work when get_source_file doesn't exist
|
||||
@source_file || get_source_file
|
||||
end
|
||||
|
||||
# Whether this resource has a template file
|
||||
# @return [Boolean]
|
||||
def template?
|
||||
|
@ -164,56 +149,13 @@ module Middleman
|
|||
# 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}/", ''))
|
||||
!self.is_a?(ProxyResource) && @app.sitemap.ignored?(source_file.sub("#{@app.source_dir}/", ''))
|
||||
end
|
||||
|
||||
# The preferred MIME content type for this resource based on extension or metadata
|
||||
# @return [String] MIME type for this resource
|
||||
def content_type
|
||||
mime_type = options[:content_type] || ::Rack::Mime.mime_type(ext, nil)
|
||||
return mime_type if mime_type
|
||||
|
||||
if proxy?
|
||||
proxied_to_resource.content_type
|
||||
else
|
||||
nil
|
||||
end
|
||||
end
|
||||
|
||||
# Whether this page is a proxy
|
||||
# @return [Boolean]
|
||||
def proxy?
|
||||
@proxied_to
|
||||
end
|
||||
|
||||
# Set this page to proxy to a target path
|
||||
# @param [String] target
|
||||
# @return [void]
|
||||
def proxy_to(target)
|
||||
target = ::Middleman::Util.normalize_path(target)
|
||||
raise "You can't proxy #{path} to itself!" if target == path
|
||||
@proxied_to = target
|
||||
end
|
||||
|
||||
# The path of the page this page is proxied to, or nil if it's not proxied.
|
||||
# @return [String]
|
||||
attr_reader :proxied_to
|
||||
|
||||
# The resource for the page this page is proxied to. Throws an exception
|
||||
# if there is no resource.
|
||||
# @return [Sitemap::Resource]
|
||||
def proxied_to_resource
|
||||
proxy_resource = @store.find_resource_by_path(proxied_to)
|
||||
|
||||
unless proxy_resource
|
||||
raise "Path #{path} proxies to unknown file #{proxied_to}:#{@store.resources.map(&:path)}"
|
||||
end
|
||||
|
||||
if proxy_resource.proxy?
|
||||
raise "You can't proxy #{path} to #{proxied_to} which is itself a proxy."
|
||||
end
|
||||
|
||||
proxy_resource
|
||||
options[:content_type] || ::Rack::Mime.mime_type(ext, nil)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue