Shlomi Fish avatar Shlomi Fish committed f615f7b

Integrate the section menus inside MyNavData.

TODO : perhaps speed up page loading by using a command <script src="..."
or AJAX or whatever (with a fallback to users with JS
disabled/blocked/blacklisted/etc. naturally).

Comments (0)

Files changed (3)

 
 use utf8;
 
+use Shlomif::Homepage::SectionMenu;
+
 my $hosts =
 {
     t2 =>
                 },
             ],
         },
+        Shlomif::Homepage::SectionMenu->get_modified_sub_tree('Humour'),
+        Shlomif::Homepage::SectionMenu->get_modified_sub_tree('Puzzles'),
+        {
+            text => "Computer Art",
+            url => "art/",
+            expand => { re => "^art/", },
+            title => "Computer art I created while explaining how.",
+            subs =>
+            [
+                {
+                    text => "Back to my Homepage",
+                    url => "art/bk2hp/",
+                    title => "A Back to my Homepage logo not unlike the one from the movie “Back to the Future”",
+                },
+                {
+                    text => "Linux Banner",
+                    url => "art/linux_banner/",
+                    title => "Linux - Because Software Problems should not Cost Money",
+                },
+                {
+                    text => "Made with Latemp",
+                    url => "art/made-with-latemp/",
+                    title => "“Made with Latemp” Button",
+                },
+                {
+                    text => "HHFG Background",
+                    url => "art/hhfg-background/",
+                    title => "Background Image for the “Human Hacking Field Guide” Story",
+                },
+                {
+                    text => "Better SCM Logo",
+                    url => "art/better-scm/",
+                    title => "Logo for the “Better SCM” Site",
+                },
+                {
+                    text => "Slogans’ Designs",
+                    url => "art/slogans/",
+                    title => "The design of my aphorism - useful for T-shirts and other merchandise",
+                },
+            ],
+        },
+        Shlomif::Homepage::SectionMenu->get_modified_sub_tree('Software'),
+        Shlomif::Homepage::SectionMenu->get_modified_sub_tree('Lectures'),
+        Shlomif::Homepage::SectionMenu->get_modified_sub_tree('Essays'),
+        {
+            text => "Work",
+            url => "work/",
+            expand => { re => "", capt => 0,},
+            title => "Work-Related Pages",
+            subs =>
+            [
+                {
+                    text => "Hire Me!",
+                    url => "work/hire-me/",
+                    title => "I’m a Geek for Hire",
+                    expand => { re => "work/", },
+                    subs =>
+                    [
+                        {
+                            text => "Private Lessons",
+                            url => "work/private-lessons/",
+                            title => "I’m Giving Private Lessons for High School Subjects and Computing.",
+                        },
+                    ],
+                },
+            ],
+        },
+        {
+            separator => 1,
+            skip => 1,
+        },
+        {
+            text => "Cool Links",
+            url => "links.html",
+            title => "An incomplete list of links I find cool and/or useful.",
+        },
+        {
+            text => "Recommendations",
+            url => "recommendations/",
+            title => "Recommendations of Books, Compact Discs, Movies, etc.",
+        },
+        {
+            separator => 1,
+            skip => 1,
+        },
+        {
+            url => "site-map/",
+            text => "Site Map",
+            title => "A site map showing all of the main pages.",
+        },
+        {
+            separator => 1,
+            skip => 1,
+        },
+        Shlomif::Homepage::SectionMenu->get_modified_sub_tree('Meta'),
+    ],
+};
+
+sub get_params
+{
+    return
+        (
+            hosts => $hosts,
+            tree_contents => $tree_contents,
+        );
+}
+
+1;
+
+=begin removed
+
         {
             text => "Humour",
             url => "humour/",
             ],
         },
         {
-            text => "Computer Art",
-            url => "art/",
-            expand => { re => "^art/", },
-            title => "Computer art I created while explaining how.",
-            subs =>
-            [
-                {
-                    text => "Back to my Homepage",
-                    url => "art/bk2hp/",
-                    title => "A Back to my Homepage logo not unlike the one from the movie “Back to the Future”",
-                },
-                {
-                    text => "Linux Banner",
-                    url => "art/linux_banner/",
-                    title => "Linux - Because Software Problems should not Cost Money",
-                },
-                {
-                    text => "Made with Latemp",
-                    url => "art/made-with-latemp/",
-                    title => "“Made with Latemp” Button",
-                },
-                {
-                    text => "HHFG Background",
-                    url => "art/hhfg-background/",
-                    title => "Background Image for the “Human Hacking Field Guide” Story",
-                },
-                {
-                    text => "Better SCM Logo",
-                    url => "art/better-scm/",
-                    title => "Logo for the “Better SCM” Site",
-                },
-                {
-                    text => "Slogans’ Designs",
-                    url => "art/slogans/",
-                    title => "The design of my aphorism - useful for T-shirts and other merchandise",
-                },
-            ],
-        },
-        {
             text => "Software",
             url => "open-source/",
             expand => { re => "^open-source/", },
             ],
         },
         {
-            text => "Work",
-            url => "work/",
-            expand => { re => "", capt => 0,},
-            title => "Work-Related Pages",
-            subs =>
-            [
-                {
-                    text => "Hire Me!",
-                    url => "work/hire-me/",
-                    title => "I’m a Geek for Hire",
-                    expand => { re => "work/", },
-                    subs =>
-                    [
-                        {
-                            text => "Private Lessons",
-                            url => "work/private-lessons/",
-                            title => "I’m Giving Private Lessons for High School Subjects and Computing.",
-                        },
-                    ],
-                },
-            ],
-        },
-        {
-            separator => 1,
-            skip => 1,
-        },
-        {
-            text => "Cool Links",
-            url => "links.html",
-            title => "An incomplete list of links I find cool and/or useful.",
-        },
-        {
-            text => "Recommendations",
-            url => "recommendations/",
-            title => "Recommendations of Books, Compact Discs, Movies, etc.",
-        },
-        {
-            separator => 1,
-            skip => 1,
-        },
-        {
-            url => "site-map/",
-            text => "Site Map",
-            title => "A site map showing all of the main pages.",
-        },
-        {
-            separator => 1,
-            skip => 1,
-        },
-        {
             expand_re => "^meta/",
             url => "meta/",
             text => "Meta Info",
                 },
             ],
         },
-    ],
-};
+=end removed
 
-sub get_params
-{
-    return
-        (
-            hosts => $hosts,
-            tree_contents => $tree_contents,
-        );
-}
-
-1;
+=cut

lib/Shlomif/Homepage/SectionMenu.pm

     title
 ));
 
+sub get_section_nav_menu_params
+{
+    my $self = shift;
+    my $class_id = shift;
+    my $class = "Shlomif::Homepage::SectionMenu::Sects::$class_id";
+    eval "require $class";
+
+    return eval "${class}::get_params()";
+}
+
+sub get_modified_sub_tree
+{
+    my ($self, $class) = @_;
+
+    my %params = $self->get_section_nav_menu_params($class);
+
+    my $tree = $params{tree_contents};
+
+    my $subs = $tree->{subs};
+    return
+        {
+            %{ $subs->[0] },
+            subs => [ @{ $subs }[1 .. $#$subs ] ],
+        };
+}
+
 sub _init
 {
     my $self = shift;
     else
     {
         my $class_id= $current_sect->{'class'};
-        my $class = "Shlomif::Homepage::SectionMenu::Sects::$class_id";
-        eval "require $class";
         my $nav_menu = HTML::Widgets::NavMenu->new(
             'path_info' => $self->path_info(),
             current_host => $self->current_host(),
-            (eval "${class}::get_params()"),
+            $self->get_section_nav_menu_params($class_id),
             'ul_classes' =>
                 [ "nm_main", "nm_nested", "nm_subnested", "nm_subsubnested", ],
             'no_leading_dot' => 1,

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

     subs =>
     [
         {
-            text => "Stories and Aphorisms",
+            text => "Humour",
             url => "humour/",
         },
         {
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.