Merge pull request #904 from bhollis/master
Cache the filtered resource list
This commit is contained in:
commit
38b3d5155d
|
@ -68,11 +68,14 @@ module Middleman
|
||||||
@ignored_callbacks << Proc.new {|p| File.fnmatch(path_clean, p) }
|
@ignored_callbacks << Proc.new {|p| File.fnmatch(path_clean, p) }
|
||||||
else
|
else
|
||||||
# Add a specific-path ignore unless that path is already covered
|
# Add a specific-path ignore unless that path is already covered
|
||||||
@ignored_callbacks << Proc.new {|p| p == path_clean } unless ignored?(path_clean)
|
return if ignored?(path_clean)
|
||||||
|
@ignored_callbacks << Proc.new {|p| p == path_clean }
|
||||||
end
|
end
|
||||||
elsif block_given?
|
elsif block_given?
|
||||||
@ignored_callbacks << block
|
@ignored_callbacks << block
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@app.sitemap.invalidate_resources_not_ignored_cache!
|
||||||
end
|
end
|
||||||
|
|
||||||
# Whether a path is ignored
|
# Whether a path is ignored
|
||||||
|
|
|
@ -90,11 +90,17 @@ module Middleman
|
||||||
if include_ignored
|
if include_ignored
|
||||||
@resources
|
@resources
|
||||||
else
|
else
|
||||||
@resources.reject(&:ignored?)
|
@resources_not_ignored ||= @resources.reject(&:ignored?)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Invalidate our cached view of resource that are not ingnored. If your extension
|
||||||
|
# adds ways to ignore files, you should call this to make sure #resources works right.
|
||||||
|
def invalidate_resources_not_ignored_cache!
|
||||||
|
@resources_not_ignored = nil
|
||||||
|
end
|
||||||
|
|
||||||
# Register a handler to provide metadata on a file path
|
# Register a handler to provide metadata on a file path
|
||||||
# @param [Regexp] matcher
|
# @param [Regexp] matcher
|
||||||
# @return [Array<Array<Proc, Regexp>>]
|
# @return [Array<Array<Proc, Regexp>>]
|
||||||
|
@ -213,6 +219,8 @@ module Middleman
|
||||||
|
|
||||||
newres
|
newres
|
||||||
end
|
end
|
||||||
|
|
||||||
|
invalidate_resources_not_ignored_cache!
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue