Skip Menu |

This queue is for tickets about the HTML-Widgets-NavMenu CPAN distribution.

Report information
The Basics
Id: 42330
Status: rejected
Priority: 0/
Queue: HTML-Widgets-NavMenu

People
Owner: Nobody in particular
Requestors: knut-olav [...] hoven.ws
Cc:
AdminCc:

Bug Information
Severity: Wishlist
Broken in: 1.0201
Fixed in: (no value)



Subject: Support partial matches in URLs
The attached patch will highlight the navigation menu item matching partial URLs. Here, a partial match is a URL that begins with the same string as the URL to a configured menu item). Take the following example menu: - Administration - Users - Domains With this patch this will highlight the user link even for URLs such as http://example.com/admin/users/ola/edit, not only http://example.com/admin/users It also makes the currently highlighted menu item a link, useful to navigate back if matching a partial URL.
Subject: perl-HTML-Widgets-NavMenu.diff
Index: HTML/Widgets/NavMenu.pm =================================================================== --- HTML/Widgets/NavMenu.pm (revisjon 878) +++ HTML/Widgets/NavMenu.pm (arbeidskopi) @@ -99,6 +99,19 @@ ); } +sub item_matches_partial { + my $self = shift; + my $item = $self->top(); + my $url = $item->_node()->url(); + my $nav_menu = $self->nav_menu(); + return + ( + ($item->_accum_state()->{'host'} eq $nav_menu->current_host()) && + (defined($url) && (0 eq index $nav_menu->path_info(), $url)) + ); + +} + sub does_item_expand { my $self = shift; @@ -123,6 +136,10 @@ my @coords = @{$self->get_coords()}; $self->{'leading_path_coords'} = [ @coords]; } + elsif ($self->item_matches_partial()) + { + $self->top()->_node()->mark_as_current(); + } } sub node_end Index: HTML/Widgets/NavMenu/Iterator/NavMenu.pm =================================================================== --- HTML/Widgets/NavMenu/Iterator/NavMenu.pm (revisjon 878) +++ HTML/Widgets/NavMenu/Iterator/NavMenu.pm (arbeidskopi) @@ -80,7 +80,7 @@ { my $self = shift; my $node = shift; - return "<b>" . $node->text() . "</b>"; + return "<b>" . $self->get_a_tag() . "</b>"; } =head2 $self->get_link_tag()
Hi! On Mon Jan 12 09:58:23 2009, hovenko wrote: Show quoted text
> The attached patch will highlight the navigation menu item matching > partial URLs. > > Here, a partial match is a URL that begins with the same string as the > URL to a configured menu item). > > Take the following example menu: > > - Administration > - Users > - Domains > > With this patch this will highlight the user link even for URLs such > as http://example.com/admin/users/ola/edit, not only > http://example.com/admin/users > > It also makes the currently highlighted menu item a link, useful to > navigate back if matching a partial URL.
Thanks for the patch, and sorry for the late response. There are several problems with your patch: 1. It is not rooted at the distribution's base - I don't see the lib/ component there. This was relatively easy to fix. 2. It causes many existing tests in the trunk to fail: {{{{{{{ Failed Test Stat Wstat Total Fail Failed List of Failed ------------------------------------------------------------------------------- t/04nav-menu.t 21 5376 25 21 84.00% 1-16 19-20 23-25 t/10ul-classes.t 3 768 3 3 100.00% 1-3 t/15aspetersen-inherit.t 1 256 1 1 100.00% 1 Failed 3/21 test scripts, 85.71% okay. 25/347 subtests failed, 92.80% okay. }}}}}}} See: https://svn.berlios.de/svnroot/repos/web-cpan/nav-menu/trunk/module 3. I don't like its general philosophy. If you want a sub-branch to open, you can 'expand' or 'show' it. Otherwise, a link should be marked with bold only if it's the current link. With your link it will be a bolded link (still usually coloured in blue or whatever) which will be harder to distinguish. A better idea may be to add a class to the <li>'s leading to the expanded path so the web programmer can highlight them according to his discretion. I'd appreciate any input from you regarding this patch. Regards, -- Shlomi Fish
I didn't hear from the original poster in roughly two months, and the proposed patch breaks the tests and I don't like its general philosophy. So I'm closing it as rejected. Regards, Shlomi Fish