Object
Generates a menu that can be configured extensively.
Generate the menu.
# File lib/webgen/tag/menu.rb, line 57 57: def call(tag, body, context) 58: tree = specific_menu_tree_for(context.content_node) 59: 60: (context.dest_node.node_info[:tag_menu_menus] ||= {})[[@params.to_a.sort, context.content_node.alcn]] = (tree ? tree.to_lcn_list : nil) 61: 62: if !tree || tree.children.empty? 63: '' 64: elsif param('tag.menu.nested') 65: create_output_nested(context, tree) 66: else 67: create_output_not_nested(context, tree) 68: end 69: end
Create the nested HTML menu of the tree using the provided context.
# File lib/webgen/tag/menu.rb, line 137 137: def create_output_nested(context, tree, level = 1) 138: out = "<ul>" 139: tree.children.each do |child| 140: menu = child.children.length > 0 ? create_output_nested(context, child, level + 1) : '' 141: style, link = menu_item_details(context.dest_node, child.node, context.content_node.lang, level) 142: 143: out << "<li #{style}>#{link}" 144: out << menu 145: out << "</li>" 146: end 147: out << "</ul>" 148: out 149: end
Create the not nested HTML menu of the tree using the provided context.
# File lib/webgen/tag/menu.rb, line 152 152: def create_output_not_nested(context, tree, level = 1) 153: submenu = '' 154: out = "<ul>" 155: tree.children.each do |child| 156: submenu << (child.children.length > 0 ? create_output_not_nested(context, child, level + 1) : '') 157: style, link = menu_item_details(context.dest_node, child.node, context.content_node.lang, level) 158: 159: out << "<li #{style}>#{link}</li>" 160: end 161: out << "</ul>" 162: out << submenu 163: out 164: end
Check if the menus for node have changed.
# File lib/webgen/tag/menu.rb, line 76 76: def node_changed?(node) 77: return if !node.node_info[:tag_menu_menus] 78: 79: node.node_info[:tag_menu_menus].each do |(params, cn_alcn), cached_tree| 80: cn = node.tree[cn_alcn] 81: menu_tree = menu_tree_for_lang(cn.lang, cn.tree.root) 82: 83: set_params(params.to_hash) 84: tree = build_specific_menu_tree(cn, menu_tree) 85: tree_list = tree.to_lcn_list if tree 86: set_params({}) 87: 88: if (tree.nil? && !cached_tree.nil?) || (tree_list && tree_list != cached_tree) || 89: (tree_list && tree_list.flatten.any? do |alcn| 90: (n = node.tree[alcn]) && (r = n.routing_node(cn.lang)) && r != node && r.meta_info_changed? 91: end) 92: node.flag(:dirty) 93: break 94: end 95: end 96: end
Disabled; run with --debug to generate this.
Generated with the Darkfish Rdoc Generator 1.1.6.