Merge pull request #364 from bhollis/master
Ignore unnecessary ignores and use destination_path in url
This commit is contained in:
commit
129c2845f8
|
@ -46,6 +46,8 @@ module Middleman::Sitemap::Extensions
|
||||||
# @param [String, Regexp] path, path glob expression, or path regex
|
# @param [String, Regexp] path, path glob expression, or path regex
|
||||||
# @return [void]
|
# @return [void]
|
||||||
def ignore(path=nil, &block)
|
def ignore(path=nil, &block)
|
||||||
|
original_callback_size = @ignored_callbacks.size
|
||||||
|
|
||||||
if path.is_a? Regexp
|
if path.is_a? Regexp
|
||||||
@ignored_callbacks << Proc.new {|p| p =~ path }
|
@ignored_callbacks << Proc.new {|p| p =~ path }
|
||||||
elsif path.is_a? String
|
elsif path.is_a? String
|
||||||
|
@ -53,13 +55,16 @@ module Middleman::Sitemap::Extensions
|
||||||
if path_clean.include?("*") # It's a glob
|
if path_clean.include?("*") # It's a glob
|
||||||
@ignored_callbacks << Proc.new {|p| File.fnmatch(path_clean, p) }
|
@ignored_callbacks << Proc.new {|p| File.fnmatch(path_clean, p) }
|
||||||
else
|
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
|
end
|
||||||
elsif block_given?
|
elsif block_given?
|
||||||
@ignored_callbacks << block
|
@ignored_callbacks << block
|
||||||
end
|
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
|
end
|
||||||
|
|
||||||
# Whether a path is ignored
|
# Whether a path is ignored
|
||||||
|
|
|
@ -114,7 +114,7 @@ module Middleman::Sitemap
|
||||||
# just foo. Best for linking.
|
# just foo. Best for linking.
|
||||||
# @return [String]
|
# @return [String]
|
||||||
def url
|
def url
|
||||||
'/' + path.sub(/#{Regexp.escape(app.index_file)}$/, '')
|
'/' + destination_path.sub(/#{Regexp.escape(app.index_file)}$/, '')
|
||||||
end
|
end
|
||||||
|
|
||||||
# Get the relative path from the source
|
# Get the relative path from the source
|
||||||
|
|
Loading…
Reference in a new issue