Merge pull request #528 from rumpuslabs/sitemap_patches

Sitemap patches
This commit is contained in:
Thomas Reynolds 2012-07-11 10:43:20 -07:00
commit 5c9a5c9849
2 changed files with 14 additions and 15 deletions

View file

@ -57,15 +57,13 @@ module Middleman
path_meta = store.metadata_for_path(path).dup path_meta = store.metadata_for_path(path).dup
if path_meta.has_key?(:blocks) if path_meta.has_key?(:blocks)
result[:blocks] << path_meta[:blocks] result[:blocks] << path_meta.delete(:blocks)
path_meta.delete(:blocks)
end end
result.deep_merge!(path_meta) result.deep_merge!(path_meta)
local_meta = @local_metadata.dup local_meta = @local_metadata.dup
if local_meta.has_key?(:blocks) if local_meta.has_key?(:blocks)
result[:blocks] << local_meta[:blocks] result[:blocks] << local_meta.delete(:blocks)
local_meta.delete(:blocks)
end end
result.deep_merge!(local_meta) result.deep_merge!(local_meta)
@ -78,8 +76,7 @@ module Middleman
# @param [Hash] metadata A metadata block like provides_metadata_for_path takes # @param [Hash] metadata A metadata block like provides_metadata_for_path takes
def add_metadata(metadata={}, &block) def add_metadata(metadata={}, &block)
if metadata.has_key?(:blocks) if metadata.has_key?(:blocks)
@local_metadata[:blocks] << metadata[:blocks] @local_metadata[:blocks] << metadata.delete(:blocks)
metadata.delete(:blocks)
end end
@local_metadata.deep_merge!(metadata) @local_metadata.deep_merge!(metadata)
@local_metadata[:blocks] << block if block_given? @local_metadata[:blocks] << block if block_given?

View file

@ -47,15 +47,17 @@ module Middleman
# @return [void] # @return [void]
def rebuild_resource_list!(reason=nil) def rebuild_resource_list!(reason=nil)
@resources = @resource_list_manipulators.inject([]) do |result, (_, inst)| @resources = @resource_list_manipulators.inject([]) do |result, (_, inst)|
inst.manipulate_resource_list(result) newres = inst.manipulate_resource_list(result)
end
# Reset lookup cache # Reset lookup cache
@_lookup_cache = { :path => {}, :destination_path => {} } @_lookup_cache = { :path => {}, :destination_path => {} }
@resources.each do |resource| newres.each do |resource|
@_lookup_cache[:path][resource.path] = resource @_lookup_cache[:path][resource.path] = resource
@_lookup_cache[:destination_path][resource.destination_path] = resource @_lookup_cache[:destination_path][resource.destination_path] = resource
end end
newres
end
end end
# Find a resource given its original path # Find a resource given its original path