Merge pull request #904 from bhollis/master
Cache the filtered resource list
This commit is contained in:
commit
38b3d5155d
2 changed files with 13 additions and 2 deletions
|
@ -68,11 +68,14 @@ module Middleman
|
|||
@ignored_callbacks << Proc.new {|p| File.fnmatch(path_clean, p) }
|
||||
else
|
||||
# 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
|
||||
elsif block_given?
|
||||
@ignored_callbacks << block
|
||||
end
|
||||
|
||||
@app.sitemap.invalidate_resources_not_ignored_cache!
|
||||
end
|
||||
|
||||
# Whether a path is ignored
|
||||
|
|
|
@ -90,11 +90,17 @@ module Middleman
|
|||
if include_ignored
|
||||
@resources
|
||||
else
|
||||
@resources.reject(&:ignored?)
|
||||
@resources_not_ignored ||= @resources.reject(&:ignored?)
|
||||
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
|
||||
# @param [Regexp] matcher
|
||||
# @return [Array<Array<Proc, Regexp>>]
|
||||
|
@ -213,6 +219,8 @@ module Middleman
|
|||
|
||||
newres
|
||||
end
|
||||
|
||||
invalidate_resources_not_ignored_cache!
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in a new issue