queue sitemap changes until after first run
This commit is contained in:
parent
d72200dc5e
commit
36df6300cd
2 changed files with 30 additions and 2 deletions
|
@ -47,7 +47,7 @@ module Middleman::CoreExtensions::Routing
|
||||||
options[:layout] = layout if options[:layout].nil?
|
options[:layout] = layout if options[:layout].nil?
|
||||||
|
|
||||||
if options.has_key?(:proxy)
|
if options.has_key?(:proxy)
|
||||||
sitemap.set_path(url, options[:proxy])
|
reroute(url, options[:proxy])
|
||||||
|
|
||||||
if options.has_key?(:ignore) && options[:ignore]
|
if options.has_key?(:ignore) && options[:ignore]
|
||||||
ignore(options[:proxy])
|
ignore(options[:proxy])
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
require 'find'
|
require 'find'
|
||||||
|
require 'hooks'
|
||||||
|
|
||||||
module Middleman::CoreExtensions::Sitemap
|
module Middleman::CoreExtensions::Sitemap
|
||||||
class << self
|
class << self
|
||||||
|
@ -27,16 +28,36 @@ module Middleman::CoreExtensions::Sitemap
|
||||||
module ClassMethods
|
module ClassMethods
|
||||||
# Keep a path from building
|
# Keep a path from building
|
||||||
def ignore(path)
|
def ignore(path)
|
||||||
sitemap.ignore_path(path)
|
action = Proc.new { ignore_path(path) }
|
||||||
|
|
||||||
|
if sitemap.setup?
|
||||||
|
action.call
|
||||||
|
else
|
||||||
|
sitemap.class.after_setup(&action)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def reroute(url, target)
|
||||||
|
action = Proc.new { set_path(url, target) }
|
||||||
|
|
||||||
|
if sitemap.setup?
|
||||||
|
action.call
|
||||||
|
else
|
||||||
|
sitemap.class.after_setup(&action)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
class SitemapStore
|
class SitemapStore
|
||||||
|
include ::Hooks
|
||||||
|
define_hook :after_setup
|
||||||
|
|
||||||
def initialize
|
def initialize
|
||||||
@map = {}
|
@map = {}
|
||||||
@ignored_paths = false
|
@ignored_paths = false
|
||||||
@generic_paths = false
|
@generic_paths = false
|
||||||
@proxied_paths = false
|
@proxied_paths = false
|
||||||
|
@is_setup = false
|
||||||
end
|
end
|
||||||
|
|
||||||
def setup(app)
|
def setup(app)
|
||||||
|
@ -44,6 +65,13 @@ module Middleman::CoreExtensions::Sitemap
|
||||||
@source = File.expand_path(@app.views, @app.root)
|
@source = File.expand_path(@app.views, @app.root)
|
||||||
|
|
||||||
build_static_map
|
build_static_map
|
||||||
|
|
||||||
|
run_hook :after_setup
|
||||||
|
@is_setup = true
|
||||||
|
end
|
||||||
|
|
||||||
|
def setup?
|
||||||
|
@is_setup
|
||||||
end
|
end
|
||||||
|
|
||||||
# Check to see if we know about a specific path
|
# Check to see if we know about a specific path
|
||||||
|
|
Loading…
Reference in a new issue