Cop
This commit is contained in:
parent
5f8beba4b3
commit
d82ac590db
42 changed files with 229 additions and 237 deletions
|
@ -23,9 +23,9 @@ module Middleman
|
|||
# Ignore based on the source path (without template extensions)
|
||||
if ignored?(r.path)
|
||||
r.ignore!
|
||||
else
|
||||
elsif !r.is_a?(ProxyResource) && r.file_descriptor && ignored?(r.file_descriptor[:relative_path].to_s)
|
||||
# This allows files to be ignored by their source file name (with template extensions)
|
||||
r.ignore! if !r.is_a?(ProxyResource) && r.file_descriptor && ignored?(r.file_descriptor[:relative_path].to_s)
|
||||
r.ignore!
|
||||
end
|
||||
|
||||
r
|
||||
|
|
|
@ -23,14 +23,14 @@ module Middleman
|
|||
resources + ::Middleman::Util.glob_directory(File.join(from, '**/*'))
|
||||
.reject { |path| File.directory?(path) }
|
||||
.map do |path|
|
||||
target_path = Pathname(path).relative_path_from(Pathname(from).parent).to_s
|
||||
target_path = Pathname(path).relative_path_from(Pathname(from).parent).to_s
|
||||
|
||||
::Middleman::Sitemap::Resource.new(
|
||||
app.sitemap,
|
||||
renameProc.call(target_path, path),
|
||||
path
|
||||
)
|
||||
end
|
||||
::Middleman::Sitemap::Resource.new(
|
||||
app.sitemap,
|
||||
renameProc.call(target_path, path),
|
||||
path
|
||||
)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -113,7 +113,7 @@ module Middleman
|
|||
def to_s
|
||||
"#<#{self.class} path=#{@path} target=#{@target}>"
|
||||
end
|
||||
alias_method :inspect, :to_s
|
||||
alias inspect to_s
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -28,7 +28,7 @@ module Middleman
|
|||
# Setup a redirect from a path to a target
|
||||
# @param [String] path
|
||||
# @param [Hash] opts The :to value gives a target path
|
||||
Contract String, ({ to: Or[String, ::Middleman::Sitemap::Resource] }), Maybe[Proc] => RedirectDescriptor
|
||||
Contract String, { to: Or[String, ::Middleman::Sitemap::Resource] }, Maybe[Proc] => RedirectDescriptor
|
||||
def redirect(path, opts={}, &block)
|
||||
RedirectDescriptor.new(path, opts[:to], block_given? ? block : nil)
|
||||
end
|
||||
|
|
|
@ -44,14 +44,14 @@ module Middleman
|
|||
def children
|
||||
return [] unless directory_index?
|
||||
|
||||
if eponymous_directory?
|
||||
base_path = eponymous_directory_path
|
||||
prefix = %r{^#{base_path.sub("/", "\\/")}}
|
||||
base_path = if eponymous_directory?
|
||||
eponymous_directory_path
|
||||
else
|
||||
base_path = path.sub("#{@app.config[:index_file]}", '')
|
||||
prefix = %r{^#{base_path.sub("/", "\\/")}}
|
||||
path.sub(@app.config[:index_file].to_s, '')
|
||||
end
|
||||
|
||||
prefix = %r{^#{base_path.sub("/", "\\/")}}
|
||||
|
||||
@store.resources.select do |sub_resource|
|
||||
if sub_resource.path == path || sub_resource.path !~ prefix
|
||||
false
|
||||
|
|
|
@ -29,9 +29,9 @@ module Middleman
|
|||
# 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
|
||||
alias request_path destination_path
|
||||
|
||||
METADATA_HASH = ({ options: Maybe[Hash], locals: Maybe[Hash], page: Maybe[Hash] })
|
||||
METADATA_HASH = { options: Maybe[Hash], locals: Maybe[Hash], page: Maybe[Hash] }.freeze
|
||||
|
||||
# The metadata for this resource
|
||||
# @return [Hash]
|
||||
|
@ -53,10 +53,10 @@ module Middleman
|
|||
|
||||
source = Pathname(source) if source && source.is_a?(String)
|
||||
|
||||
if source && source.is_a?(Pathname)
|
||||
@file_descriptor = ::Middleman::SourceFile.new(source.relative_path_from(@app.source_dir), source, @app.source_dir, Set.new([:source]))
|
||||
@file_descriptor = if source && source.is_a?(Pathname)
|
||||
::Middleman::SourceFile.new(source.relative_path_from(@app.source_dir), source, @app.source_dir, Set.new([:source]))
|
||||
else
|
||||
@file_descriptor = source
|
||||
source
|
||||
end
|
||||
|
||||
@destination_path = @path
|
||||
|
@ -130,16 +130,16 @@ module Middleman
|
|||
return ::Middleman::FileRenderer.new(@app, file_descriptor[:full_path].to_s).template_data_for_file unless template?
|
||||
|
||||
# ::Middleman::Util.instrument 'render.resource', path: file_descriptor[:full_path].to_s, destination_path: destination_path do
|
||||
md = metadata
|
||||
opts = md[:options].deep_merge(opts)
|
||||
locs = md[:locals].deep_merge(locs)
|
||||
locs[:current_path] ||= destination_path
|
||||
md = metadata
|
||||
opts = md[:options].deep_merge(opts)
|
||||
locs = md[:locals].deep_merge(locs)
|
||||
locs[:current_path] ||= destination_path
|
||||
|
||||
# Certain output file types don't use layouts
|
||||
opts[:layout] = false if !opts.key?(:layout) && ext != '.html'
|
||||
# Certain output file types don't use layouts
|
||||
opts[:layout] = false if !opts.key?(:layout) && ext != '.html'
|
||||
|
||||
renderer = ::Middleman::TemplateRenderer.new(@app, file_descriptor[:full_path].to_s)
|
||||
renderer.render(locs, opts)
|
||||
renderer = ::Middleman::TemplateRenderer.new(@app, file_descriptor[:full_path].to_s)
|
||||
renderer.render(locs, opts)
|
||||
# end
|
||||
end
|
||||
|
||||
|
@ -189,7 +189,7 @@ module Middleman
|
|||
def to_s
|
||||
"#<#{self.class} path=#{@path}>"
|
||||
end
|
||||
alias_method :inspect, :to_s # Ruby 2.0 calls inspect for NoMethodError instead of to_s
|
||||
alias inspect to_s # Ruby 2.0 calls inspect for NoMethodError instead of to_s
|
||||
end
|
||||
|
||||
class StringResource < Resource
|
||||
|
|
|
@ -201,7 +201,7 @@ module Middleman
|
|||
@lock.synchronize do
|
||||
return unless @needs_sitemap_rebuild
|
||||
|
||||
::Middleman::Util.instrument "sitemap.update", reasons: @rebuild_reasons.uniq do
|
||||
::Middleman::Util.instrument 'sitemap.update', reasons: @rebuild_reasons.uniq do
|
||||
@needs_sitemap_rebuild = false
|
||||
|
||||
@app.logger.debug '== Rebuilding resource list'
|
||||
|
@ -209,7 +209,7 @@ module Middleman
|
|||
@resources = []
|
||||
|
||||
@resource_list_manipulators.each do |m|
|
||||
::Middleman::Util.instrument "sitemap.manipulator", name: m[:name] do
|
||||
::Middleman::Util.instrument 'sitemap.manipulator', name: m[:name] do
|
||||
@app.logger.debug "== Running manipulator: #{m[:name]}"
|
||||
@resources = m[:manipulator].send(m[:custom_name] || :manipulate_resource_list, @resources)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue