Object
Generates a menu that can be configured extensively.
Generate the menu.
# File lib/webgen/tag/menu.rb, line 56 def call(tag, body, context) tree = specific_menu_tree_for(context.content_node) (context.dest_node.node_info[:tag_menu_menus] ||= {})[[@params.to_a.sort, context.content_node.alcn]] = (tree ? tree.to_lcn_list : nil) if !tree || tree.children.empty? '' elsif param('tag.menu.nested') create_output_nested(context, tree) else create_output_not_nested(context, tree) end end
Create the nested HTML menu of the tree using the provided context.
# File lib/webgen/tag/menu.rb, line 136 def create_output_nested(context, tree, level = 1) out = "<ul>" tree.children.each do |child| menu = child.children.length > 0 ? create_output_nested(context, child, level + 1) : '' style, link = menu_item_details(context.dest_node, child.node, context.content_node.lang, level) out << "<li #{style}>#{link}" out << menu out << "</li>" end out << "</ul>" out end
Create the not nested HTML menu of the tree using the provided context.
# File lib/webgen/tag/menu.rb, line 151 def create_output_not_nested(context, tree, level = 1) submenu = '' out = "<ul>" tree.children.each do |child| submenu << (child.children.length > 0 ? create_output_not_nested(context, child, level + 1) : '') style, link = menu_item_details(context.dest_node, child.node, context.content_node.lang, level) out << "<li #{style}>#{link}</li>" end out << "</ul>" out << submenu out end
Check if the menus for node have changed.
# File lib/webgen/tag/menu.rb, line 75 def node_changed?(node) return if !node.node_info[:tag_menu_menus] node.node_info[:tag_menu_menus].each do |(params, cn_alcn), cached_tree| cn = node.tree[cn_alcn] menu_tree = menu_tree_for_lang(cn.lang, cn.tree.root) set_params(params.to_hash) tree = build_specific_menu_tree(cn, menu_tree) tree_list = tree.to_lcn_list if tree set_params({}) if (tree.nil? && !cached_tree.nil?) || (tree_list && tree_list != cached_tree) || (tree_list && tree_list.flatten.any? do |alcn| (n = node.tree[alcn]) && (r = n.routing_node(cn.lang)) && r != node && r.meta_info_changed? end) node.flag(:dirty) break end end end
Generated with the Darkfish Rdoc Generator 2.