HTML-Widgets-NavMenu-1.0702000755000764000764 012146726607 15632 5ustar00shlomifshlomif000000000000TODO000444000764000764 235512146726607 16405 0ustar00shlomifshlomif000000000000HTML-Widgets-NavMenu-1.0702Short-Term: ----------- * Make sure H::W::NM will associate the breadcrumbs trail with a category, if this category expands there. So, for example: http://www.shlomifish.org/philosophy/case-for-file-swapping/ will generate the breadcrumbs trail of: Shlomi Fish -> Philosophy. * Create a 'show' directive - like 'show_always' only with a predicate. Long-Term: ---------- * Add a way to manage sub-menu objects, where a navigation menu can refer to a sub-navigation menu. - Perhaps it should be done by simply adding a reference to the tree? * Make the module support URLs with CGI GET parameters properly. * Add support for more attributes other than class="" to the ul and li tags. - like id="" * Add a host-based regexp arbitrator to the predicate: { 'host_re' => { 't2' => "^home/", 'vipe' => "^home2/" } } * In HTML::Widgets::NavMenu::Tree::Node - make sure url_type accepts only its enum values. * Give an option to render a sub-set of the navigation-menu, starting at a certain coords/url-path. * Release on CPAN as version 0.8.0. - change the version in $VERSION. - document the changes in Changes. - update the readme. * Maybe make a way to implement a generic backend to the data using various kinds of databases/etc. TODO-Rejects000444000764000764 147612146726607 20005 0ustar00shlomifshlomif000000000000HTML-Widgets-NavMenu-1.0702* Refactor get_next_coords(). - I don't see too much point to it. It is working as it is, and it's only one function that doesn't affect the rest of the code. * Create a base class for classes with 'subs' functionality - like get_nth_sub, add_sub, num_subs, etc. Both ..::Node and ..::Item share it. - They have slightly different semantics, and besides - it's not too much duplicate code. It would be more trouble than it's worth. * Future direction: generate the tree once and then be able to render it for different path_info()/current_host() configurations. (and the generated tree re-used by all other members). - the problem is that the expand() operations and the expanded() flag depends on this combination. Thus, the generated tree is different for any path_info()/current_host(). Changes000444000764000764 1127312146726607 17227 0ustar00shlomifshlomif000000000000HTML-Widgets-NavMenu-1.0702Revision history for Perl extension Shlomif::NavMenu. 1.0702 2013-05-21 - Add t/cpan-changes.t - Correct this file. - Add scripts/bump-version-number.pl . 1.0701 2012-12-09 - Fix typo: https://rt.cpan.org/Ticket/Display.html?id=81840 - Thanks to GUIMARD and lintian. 1.0700 2012-12-09 - Add the li_id attribute to the tree's nodes to add an id="..." attribute to the
  • tags. 1.0603 2012-09-18 - Update the URLs to the repository, and sites. 1.0602 2012-09-17 - Get rid of trailing space. - Update the contact details. 1.0601 2012-09-05 - Moved away tag-release.pl to scripts/tag-release.pl so it won't be installed by default. - Moved away output.pl under examples. 1.0600 2011-04-16 - Add HTML::Widgets::NavMenu::JQueryTreeView for generating navigation menu that this jQuery plugin can handle well: - http://bassistance.de/jquery-plugins/jquery-plugin-treeview/ 1.0501 2010-11-14 - Now generating the Makefile.PL from the Build.PL using create_makefile_pl (less error-prone). 1.0500 2010-11-12 - Convert from Class::Accessor to Class::XSAccessor for extra speed. - Add the tag-release.pl file. 1.0400 2009-12-09 - Got rid of the dependency on Error.pm. - moved the HTML/ directory with the test scripts-support code from the root of the distribution to unde t/lib . 1.0302 2009-06-25 - Fixed some broken links and other inaccuracies in the POD of lib/HTML/Widgets/NavMenu.pm . 1.0301 2009-06-23 - Changed the 'license' in Build.PL from "bsd" to the more accurate "mit". - Added keywords and links to the META.yml. 1.0300 2009-06-14 - Refactoring: Made HTML::Widgets::NavMenu::Object a sub-class of Class::Accessor to remove many "use base" calls to it. - In progress - converting a flat %args hash (splatted into the @_) into a single $args hash-ref. - Removed a use lib "." from HTML::Widgets::NavMenu - it's a leftover statement that could be a subtle bug. - Refactoring: converted direct $self->{'field'} accesses to accessors. (from all the classes). - Fixed a bug with the HeaderRole where an empty

    About Me

    "); } sub _end_regular { my $self = shift; if ($self->top()->_num_subs() && $self->_is_expanded()) { $self->_add_tags(""); } $self->_add_tags("
  • "); } =head2 $self->node_should_recurse() Override to determine when one should recurse to the node. =cut sub node_should_recurse { my $self = shift; return $self->_is_expanded(); } =head2 $self->get_a_tag() Renders the HTML for the opening a-tag. =cut # Get the HTML tag. # sub get_a_tag { my $self = shift; my $item = $self->top(); my $node = $item->_node; my $tag ="title; $tag .= " href=\"" . escape_html( $self->nav_menu()->_get_url_to_item($item) ). "\""; if (defined($title)) { $tag .= " title=\"$title\""; } $tag .= ">" . $node->text() . ""; return $tag; } =head1 COPYRIGHT & LICENSE Copyright 2006 Shlomi Fish, all rights reserved. This program is released under the following license: MIT X11. =cut 1; Base.pm000444000764000764 512412146726607 25204 0ustar00shlomifshlomif000000000000HTML-Widgets-NavMenu-1.0702/lib/HTML/Widgets/NavMenu/Iteratorpackage HTML::Widgets::NavMenu::Iterator::Base; use strict; use warnings; use base qw(HTML::Widgets::NavMenu::Tree::Iterator); __PACKAGE__->mk_acc_ref([qw( _html nav_menu )]); =head1 NAME HTML::Widgets::NavMenu::Iterator::Base - base class for the iterator. =head1 SYNOPSIS For internal use only. =head1 METHODS =head2 nav_menu Internal use. =cut sub _init { my $self = shift; my $args = shift; $self->SUPER::_init($args); $self->nav_menu($args->{'nav_menu'}) or die "nav_menu not specified!"; $self->_html([]); return 0; } sub _add_tags { my $self = shift; push (@{$self->_html()}, @_); } sub _is_root { my $self = shift; return ($self->stack->len() == 1); } sub _is_top_separator { my $self = shift; return $self->top->_node->separator; } =head2 $self->get_initial_node() Gets the initial node. =cut sub get_initial_node { my $self = shift; return $self->nav_menu->_get_traversed_tree(); } =head2 $self->get_node_subs({ node => $node}) Gets the subs of the node. =cut sub get_node_subs { my ($self, $args) = @_; my $node = $args->{'node'}; return [ @{$node->subs()} ]; } =head2 $self->get_new_accum_state( { item => $item, node => $node } ) Gets the new accumulated state. =cut # TODO : This method is too long - refactor. sub get_new_accum_state { my ($self, $args) = @_; my $parent_item = $args->{'item'}; my $node = $args->{'node'}; my $prev_state; if (defined($parent_item)) { $prev_state = $parent_item->_accum_state(); } else { $prev_state = +{}; } my $show_always = 0; if (exists($prev_state->{'show_always'})) { $show_always = $prev_state->{'show_always'}; } if (defined($node->show_always())) { $show_always = $node->show_always(); } my $rec_url_type; if (exists($prev_state->{'rec_url_type'})) { $rec_url_type = $prev_state->{'rec_url_type'}; } if (defined($node->rec_url_type())) { $rec_url_type = $node->rec_url_type(); } return { 'host' => ($node->host() ? $node->host() : $prev_state->{'host'}), 'show_always' => $show_always, 'rec_url_type' => $rec_url_type, }; } =head2 my $array_ref = $self->get_results() Returns an array reference with the resultant HTML. =cut sub get_results { my $self = shift; return [ @{$self->_html()} ]; } =head1 COPYRIGHT & LICENSE Copyright 2006 Shlomi Fish, all rights reserved. This program is released under the following license: MIT X11. =cut 1; NavMenu.pm000444000764000764 1040312146726607 25717 0ustar00shlomifshlomif000000000000HTML-Widgets-NavMenu-1.0702/lib/HTML/Widgets/NavMenu/Iteratorpackage HTML::Widgets::NavMenu::Iterator::NavMenu; use strict; use warnings; use base qw(HTML::Widgets::NavMenu::Iterator::Html); use HTML::Widgets::NavMenu::EscapeHtml; __PACKAGE__->mk_acc_ref([qw( _ul_classes )]); =head1 NAME HTML::Widgets::NavMenu::Iterator::NavMenu - navmenu iterator. =head1 SYNOPSIS For internal use only. =head1 METHODS =cut sub _init { my $self = shift; my $args = shift; $self->SUPER::_init($args); # Make a fresh copy just to be on the safe side. $self->_ul_classes([ @{$args->{'ul_classes'}} ]); return 0; } sub _calc_li_id_attr { my $self = shift; my $li_id = $self->top()->_li_id; return (defined ($li_id) ? qq/ id="/ . escape_html($li_id) . qq/"/ : q// ); } =head2 $self->gen_ul_tag({depth => $depth}); Generate a UL tag of depth $depth. =cut # Depth is 1 for the uppermost depth. sub gen_ul_tag { my ($self, $args) = @_; my $depth = $args->{'depth'}; my $class = $self->_get_ul_class({'depth' => $depth}); return ""; } sub _get_ul_class { my ($self, $args) = @_; my $depth = $args->{'depth'}; return $self->_ul_classes->[$depth-1]; } =head2 get_currently_active_text ( $node ) Calculates the highlighted text for the node C<$node>. Normally surrounds it with C<<< ... >>> tags. =cut sub get_currently_active_text { my $self = shift; my $node = shift; return "" . $node->text() . ""; } =head2 $self->get_link_tag() Gets the tag for the link - an item in the menu. =cut sub get_link_tag { my $self = shift; my $node = $self->top->_node(); if ($node->CurrentlyActive()) { return $self->get_currently_active_text($node); } else { return $self->get_a_tag(); } } sub _start_root { my $self = shift; $self->_add_tags( $self->gen_ul_tag( { 'depth' => $self->stack->len() } ) ); } sub _start_sep { my $self = shift; $self->_add_tags(""); } sub _start_handle_role { my $self = shift; return $self->_start_handle_non_role(); } =head2 my @tags = $self->get_open_sub_menu_tags() Gets the tags to open a new sub menu. =cut sub get_open_sub_menu_tags { my $self = shift; return ("
    ", $self->gen_ul_tag( {'depth' => $self->stack->len()} ) ); } sub _start_handle_non_role { my $self = shift; my $top_item = $self->top; my @tags_to_add = (("_calc_li_id_attr() . ">"), $self->get_link_tag()); if ($top_item->_num_subs_to_go() && $self->_is_expanded()) { push @tags_to_add, ($self->get_open_sub_menu_tags()); } $self->_add_tags(@tags_to_add); } sub _start_regular { my $self = shift; my $top_item = $self->top; my $node = $self->top->_node(); if ($self->_is_hidden()) { # Do nothing } else { if ($self->_is_role_specified()) { $self->_start_handle_role(); } else { $self->_start_handle_non_role(); } } } sub _end_sep { my $self = shift; $self->_add_tags( $self->gen_ul_tag( { 'depth' => $self->stack->len()-1 } ) ); } sub _end_handle_role { my $self = shift; return $self->_end_handle_non_role(); } sub _end_handle_non_role { my $self = shift; return $self->SUPER::_end_regular(); } sub _end_regular { my $self = shift; if ($self->_is_hidden()) { # Do nothing } elsif ($self->_is_role_specified()) { $self->_end_handle_role(); } else { $self->_end_handle_non_role(); } } sub _is_hidden { my $self = shift; return $self->top->_node()->hide(); } sub _is_expanded { my $self = shift; my $node = $self->top->_node(); return ($node->expanded() || $self->top->_accum_state->{'show_always'}); } =head2 $self->get_role() Retrieves the current role. =cut sub get_role { my $self = shift; return $self->top->_node->role(); } sub _is_role_specified { my $self = shift; return defined($self->get_role()); } 1; SiteMap.pm000444000764000764 175012146726607 25675 0ustar00shlomifshlomif000000000000HTML-Widgets-NavMenu-1.0702/lib/HTML/Widgets/NavMenu/Iteratorpackage HTML::Widgets::NavMenu::Iterator::SiteMap; use strict; use warnings; use base qw(HTML::Widgets::NavMenu::Iterator::Html); =head1 NAME HTML::Widgets::NavMenu::Iterator::SiteMap - a site-map iterator. =head1 SYNOPSIS For internal use only. =head1 METHODS =cut sub _start_root { my $self = shift; $self->_add_tags("