Ignore unnecessary ignores and use destination_path in url

This commit is contained in:
Ben Hollis 2012-04-17 23:55:28 -07:00
parent cf66ddf206
commit a0712224c6
2 changed files with 9 additions and 4 deletions

View file

@ -46,6 +46,8 @@ module Middleman::Sitemap::Extensions
# @param [String, Regexp] path, path glob expression, or path regex
# @return [void]
def ignore(path=nil, &block)
original_callback_size = @ignored_callbacks.size
if path.is_a? Regexp
@ignored_callbacks << Proc.new {|p| p =~ path }
elsif path.is_a? String
@ -53,13 +55,16 @@ module Middleman::Sitemap::Extensions
if path_clean.include?("*") # It's a glob
@ignored_callbacks << Proc.new {|p| File.fnmatch(path_clean, p) }
else
@ignored_callbacks << Proc.new {|p| p == path_clean }
# Add a specific-path ignore unless that path is already covered
@ignored_callbacks << Proc.new {|p| p == path_clean } unless ignored?(path_clean)
end
elsif block_given?
@ignored_callbacks << block
end
@app.sitemap.rebuild_resource_list!(:added_ignore_rule)
if @ignored_callbacks.size > original_callback_size
@app.sitemap.rebuild_resource_list!(:added_ignore_rule)
end
end
# Whether a path is ignored
@ -78,4 +83,4 @@ module Middleman::Sitemap::Extensions
end
end
end
end
end

View file

@ -114,7 +114,7 @@ module Middleman::Sitemap
# just foo. Best for linking.
# @return [String]
def url
'/' + path.sub(/#{Regexp.escape(app.index_file)}$/, '')
'/' + destination_path.sub(/#{Regexp.escape(app.index_file)}$/, '')
end
# Get the relative path from the source