Don't let people (or messed up code) accidentally create sitemap pages through the page method
This commit is contained in:
parent
111d021630
commit
73350d6d05
|
@ -72,16 +72,24 @@ module Middleman::Sitemap
|
||||||
# @param [String] target
|
# @param [String] target
|
||||||
# @return [void]
|
# @return [void]
|
||||||
def proxy(path, target)
|
def proxy(path, target)
|
||||||
page(path).proxy_to(normalize_path(target))
|
add(path).proxy_to(normalize_path(target))
|
||||||
app.cache.remove(:proxied_paths)
|
app.cache.remove(:proxied_paths)
|
||||||
end
|
end
|
||||||
|
|
||||||
# Get a page instance for a given path
|
# Add a new page to the sitemap
|
||||||
|
# @param [String] path
|
||||||
|
# @return [Middleman::Sitemap::Page]
|
||||||
|
def add(path)
|
||||||
|
path = normalize_path(path)
|
||||||
|
@pages.fetch(path) { @pages[path] = ::Middleman::Sitemap::Page.new(self, path) }
|
||||||
|
end
|
||||||
|
|
||||||
|
# Get a page instance for a given path, or nil if that page doesn't exist in the sitemap
|
||||||
# @param [String] path
|
# @param [String] path
|
||||||
# @return [Middleman::Sitemap::Page]
|
# @return [Middleman::Sitemap::Page]
|
||||||
def page(path)
|
def page(path)
|
||||||
path = normalize_path(path)
|
path = normalize_path(path)
|
||||||
@pages.fetch(path) { @pages[path] = ::Middleman::Sitemap::Page.new(self, path) }
|
@pages[path]
|
||||||
end
|
end
|
||||||
|
|
||||||
# Find a page given its destination path
|
# Find a page given its destination path
|
||||||
|
@ -134,9 +142,7 @@ module Middleman::Sitemap
|
||||||
return false unless file.include?(prefix)
|
return false unless file.include?(prefix)
|
||||||
|
|
||||||
path = file.sub(prefix, "")
|
path = file.sub(prefix, "")
|
||||||
path = extensionless_path(path)
|
extensionless_path(path)
|
||||||
|
|
||||||
path
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# Update or add an on-disk file path
|
# Update or add an on-disk file path
|
||||||
|
@ -153,7 +159,7 @@ module Middleman::Sitemap
|
||||||
end
|
end
|
||||||
|
|
||||||
# Add generic path
|
# Add generic path
|
||||||
p = page(path)
|
p = add(path)
|
||||||
p.source_file = File.expand_path(file, @app.root)
|
p.source_file = File.expand_path(file, @app.root)
|
||||||
p.touch
|
p.touch
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue