Commits

Anonymous committed 5e4a4c0

r1605@telaviv1: shlomi | 2007-05-10 22:52:33 +0300
Made sure that we consult the section nav-menus regarding the breadcrumbs'
trail to make sure the breadcrumbs' trail will be longer and more definitive.

  • Participants
  • Parent commits 622f16e

Comments (0)

Files changed (9)

File bin/Test/render-breadcrumbs-trail.pl

+#!/usr/bin/perl 
+
+use strict;
+use warnings;
+use MyNavData;
+use HTML::Widgets::NavMenu;
+use CGI qw();
+use MyNavLinks;
+
+{
+my $filename = "philosophy/Index/index.html";
+$filename =~ s!index\.html$!!;
+$filename = "/$filename";
+
+use vars qw($nav_bar);
+
+$nav_bar = HTML::Widgets::NavMenu->new(
+    'path_info' => $filename,
+    'current_host' => "t2",
+    MyNavData::get_params(),
+    'ul_classes' => [ "navbarmain", ("navbarnested") x 10 ],
+    );
+
+my $rendered_results = $nav_bar->render();
+
+use vars qw($nav_links);
+
+$nav_links = $rendered_results->{nav_links};
+
+use vars qw($nav_links_obj);
+
+$nav_links_obj = $rendered_results->{nav_links_obj};
+
+use vars qw($nav_html);
+
+$nav_html = $rendered_results->{html};
+
+use vars qw($leading_path);
+$leading_path = $rendered_results->{leading_path};
+
+my $render_leading_path_component = sub {
+    my $component = shift;
+    my $title = $component->title();
+    my $title_attr = defined($title) ? " title=\"$title\"" : "";
+    return "<a href=\"" . CGI::escapeHTML($component->direct_url()) .
+        "\"$title_attr>" .
+        $component->label() . "</a>";
+};
+
+use vars qw($leading_path_string);
+
+$leading_path_string =
+    join(" &rarr; ",
+        (map
+        { $render_leading_path_component->($_) }
+        @$leading_path
+        ));
+
+use vars qw($nav_links_renderer);
+
+$nav_links_renderer = MyNavLinks->new(
+        'nav_links' => $nav_links,
+        'nav_links_obj' => $nav_links_obj,
+        'root' => "../..",
+        );
+    }
+
+    use MySectNavData;
+
+    use vars (qw($section_nav_menu));
+
+    sub init_section_nav_menu
+    {
+        if (defined($section_nav_menu))
+        {
+            return;
+        }
+    my $filename = "philosophy/Index/index.html";
+    $filename =~ s{index\.html$}{};
+    $filename = "/$filename";
+
+    $section_nav_menu = MySectNavData::get_nav_menu(
+        'path_info' => $filename,
+        'current_host' => "t2",
+        'root' => "../..",
+        );
+
+return;
+    }
+
+    init_section_nav_menu();
+    my $total_leading_path = $section_nav_menu->total_leading_path(
+        {
+            main_leading_path => $leading_path,
+        }
+    );
+
+    my $render_leading_path_component = sub {
+        my $component = shift;
+        my $title = $component->title();
+        my $title_attr = defined($title) ? " title=\"$title\"" : "";
+        return "<a href=\"" . CGI::escapeHTML($component->direct_url()) .
+            "\"$title_attr>" .
+            $component->label() . "</a>";
+    };
+
+    print join(" &rarr; ",
+        (map
+        { $render_leading_path_component->($_) }
+        @$total_leading_path
+        ));

File lib/Shlomif/Homepage/SectionMenu.pm

         root => $self->root(),
     )->get_total_html();
 }
+
 sub get_html
 {
     my $self = shift;
     }
 }
 
+sub total_leading_path
+{
+    my $self = shift;
+    my $args = shift;
+
+    my @main_leading_path = @{$args->{main_leading_path}};
+
+    if ($self->empty)
+    {
+        return [ @main_leading_path ];
+    }
+    else
+    {
+        my @local_path = @{$self->results()->{'leading_path'}};
+
+        use Data::Dumper;
+
+        # warn Dumper([\@main_leading_path, \@local_path, ]);
+        while ( @local_path && 
+                (
+                    $local_path[0]->direct_url() ne 
+                    $main_leading_path[-1]->direct_url()
+                )
+            )
+        {
+            shift(@local_path);
+        }
+        shift(@local_path);
+        # warn "Foo foo" . Dumper([\@main_leading_path, \@local_path, ]);
+        return [ @main_leading_path, @local_path];
+    }
+}
+
 1;
 
 

File lib/Shlomif/Homepage/SectionMenu/Sects/Essays.pm

     'host' => "t2",
     'text' => "Shlomi Fish' Essays",
     'title' => "Shlomi Fish' Essays",
+    'url' => "philosophy/",
     'show_always' => 1,
     'subs' =>
     [

File lib/Shlomif/Homepage/SectionMenu/Sects/Humour.pm

     'text' => "Shlomi Fish' Stories and Aphorisms",
     'title' => "Shlomi Fish' Stories and Aphorisms",
     'show_always' => 1,
+    'url' => "humour/",
     'subs' =>
     [
         {

File lib/Shlomif/Homepage/SectionMenu/Sects/Lectures.pm

     'text' => "Shlomi Fish' Presentations",
     'title' => "Shlomi Fish' Presentations",
     'show_always' => 1,
+    'url' => "lecture/",
     'subs' =>
     [
         {

File lib/Shlomif/Homepage/SectionMenu/Sects/Puzzles.pm

     'text' => "Shlomi Fish' Essays",
     'title' => "Shlomi Fish' Essays",
     'show_always' => 1,
+    'url' => "puzzles/",
     'subs' =>
     [
         {

File lib/Shlomif/Homepage/SectionMenu/Sects/Software.pm

     'text' => "Shlomi Fish' Software",
     'title' => "Shlomi Fish' Software",
     'show_always' => 1,
+    'url' => "open-source/",
     'subs' =>
     [
         {

File lib/local-defs.wml

 <set-var latemp_with_head_meta_tags="<latemp_mynot "$(PRINTABLE)" />" />
 <set-var latemp_with_html_head_nav_links="<latemp_mynot "$(PRINTABLE)" />" />
 <set-var latemp_with_html_head_stylesheets="<latemp_mynot "$(PRINTABLE)" />" />
+<define-tag latemp_get_breadcrumbs_trail_unconditionally>
+<:{
+    init_section_nav_menu();
+    my $total_leading_path = $section_nav_menu->total_leading_path(
+        {
+            main_leading_path => $leading_path,
+        }
+    );
 
+    my $render_leading_path_component = sub {
+        my $component = shift;
+        my $title = $component->title();
+        my $title_attr = defined($title) ? " title=\"$title\"" : "";
+        return "<a href=\"" . CGI::escapeHTML($component->direct_url()) .
+            "\"$title_attr>" .
+            $component->label() . "</a>";
+    };
+
+    print join(" &rarr; ",
+        (map
+        { $render_leading_path_component->($_) }
+        @$total_leading_path
+        ));
+}:>
+</define-tag>
+

File lib/rest-of-template.wml

     use MySectNavData;
 
     use vars (qw($section_nav_menu));
+
+    sub init_section_nav_menu
+    {
+        if (defined($section_nav_menu))
+        {
+            return;
+        }
     my $filename = "<latemp_default_val "<get-var latemp_filename />" "$(LATEMP_FILENAME)" />";
     $filename =~ s{index\.html$}{};
     $filename = "/$filename";
         'root' => "$(ROOT)",
         );
 
+return;
+    }
+
+    init_section_nav_menu();
     print $section_nav_menu->get_html();
 }:>
 </latemp_before_main_title>
     />
 </latemp_extra_head_elements>
 
+