lib/webgen/sourcehandler/metainfo.rb in gettalong-webgen-0.5.8.20090507 vs lib/webgen/sourcehandler/metainfo.rb in gettalong-webgen-0.5.9.20090620

- old
+ new

@@ -20,33 +20,33 @@ website.blackboard.add_listener(:before_node_deleted, method(:before_node_deleted)) website.blackboard.add_listener(:after_node_created, method(:after_node_created)) self.nodes ||= [] end - # Create a meta info node from +parent+ and +path+. - def create_node(parent, path) + # Create a meta info node from +path+. + def create_node(path) page = page_from_path(path) - super(parent, path) do |node| + super(path) do |node| [[:mi_paths, 'paths'], [:mi_alcn, 'alcn']].each do |mi_key, block_name| node.node_info[mi_key] = {} if page.blocks.has_key?(block_name) && (data = YAML::load(page.blocks[block_name].content)) data.each do |key, value| - key = Webgen::Common.absolute_path(key, parent.absolute_lcn) + key = Webgen::Path.make_absolute(path.parent_path, key) node.node_info[mi_key][key] = value end end end mark_all_matched_dirty(node, :no_old_data) - website.cache.permanent[[:sh_metainfo_node_mi, node.absolute_lcn]] = { + website.cache.permanent[[:sh_metainfo_node_mi, node.alcn]] = { :mi_paths => node.node_info[:mi_paths], :mi_alcn => node.node_info[:mi_alcn] } self.nodes << node unless self.nodes.include?(node) - self.nodes = self.nodes.sort_by {|n| n.absolute_lcn} + self.nodes = self.nodes.sort_by {|n| n.alcn} end end def nodes #:nodoc: website.cache.permanent[CKEY] @@ -60,11 +60,11 @@ private ####### # Return +true+ if any meta information for +node+ provided by +mi_node+ has changed. def meta_info_changed?(mi_node, node, option = nil) - cached = website.cache.permanent[[:sh_metainfo_node_mi, mi_node.absolute_lcn]] + cached = website.cache.permanent[[:sh_metainfo_node_mi, mi_node.alcn]] (mi_node.node_info[:mi_paths].any? do |pattern, mi| Webgen::Path.match(node.node_info[:creation_path], pattern) && (option == :force || (!cached && option == :no_old_data) || mi != cached[:mi_paths][pattern]) end || mi_node.node_info[:mi_alcn].any? do |pattern, mi| node =~ pattern && (option == :force || (!cached && option == :no_old_data) || mi != cached[:mi_alcn][pattern]) @@ -85,11 +85,11 @@ n.flag(:dirty_meta_info) if meta_info_changed?(node, n, option) end end # Update the meta info of matched path before a node is created. - def before_node_created(parent, path) + def before_node_created(path) self.nodes.each do |node| node.node_info[:mi_paths].each do |pattern, mi| path.meta_info.update(mi) if Webgen::Path.match(path, pattern) end end @@ -117,10 +117,10 @@ # Delete the meta info node +node+ from the internal array. def before_node_deleted(node) return unless node.node_info[:processor] == self.class.name mark_all_matched_dirty(node, :force) - website.cache.permanent.delete([:sh_metainfo_node_mi, node.absolute_lcn]) + website.cache.permanent.delete([:sh_metainfo_node_mi, node.alcn]) self.nodes.delete(node) end end