Commits

Anonymous committed 3ef9886

Refactored the section menus into something much better and modular, written
mostly in .pm files.

Comments (0)

Files changed (7)

 t2/SFresume_detailed.html.wml : lib/SFresume_base.wml
 	touch $@
 
-PHILOSOPHY_DEPS = lib/sub-menus/essays.wml lib/MyEssaysNavData.pm
-LECTURES_DEPS = lib/sub-menus/lectures.wml lib/MyLecturesNavData.pm
+SECTION_MENU_DEPS = lib/Shlomif/Homepage/SectionMenu.pm
+PHILOSOPHY_DEPS = $(SECTION_MENU_DEPS) lib/Shlomif/Homepage/SectionMenu/Sects/Essays.pm 
+LECTURES_DEPS = $(SECTION_MENU_DEPS) lib/Shlomif/Homepage/SectionMenu/Sects/Lectures.pm
 
 t2/philosophy/Index/index.html.wml : lib/article-index/article-index.dtd lib/article-index/article-index.xml lib/article-index/article-index.xsl $(PHILOSOPHY_DEPS)
 	touch $@

lib/MyEssaysNavData.pm

-package MyEssaysNavData;
-
-my $essays_tree_contents =
-{
-    'host' => "t2",
-    'text' => "Shlomi Fish' Essays",
-    'title' => "Shlomi Fish' Essays",
-    'show_always' => 1,
-    'subs' =>
-    [
-        {
-            'text' => "Essays",
-            'url' => "philosophy/",
-            'title' => "Nav Menu for Shlomi Fish' Essays",
-        },
-        {
-            'text' => "Index to Essays",
-            'url' => "philosophy/Index/",
-            'title' => "Index to Essays and Articles I wrote.",
-        },
-        {
-            'text' => "Books Recommendations",
-            'url' => "philosophy/books-recommends/",
-            'title' => "Recommendations of Good Books I read and was Enlightened by.",
-        },
-        {
-            'text' => "Computing",
-            'url' => "philosophy/computers/",
-            'title' => "Computing-related Essays and Articles",
-            'subs' =>
-            [
-                {
-                    'text' => "What is Open Source?",
-                    'url' => "philosophy/foss-other-beasts/",
-                    'title' => "Free Software, Open Source and Other Beasts",
-                },
-                {
-                    'text' => "Perl & Newcomers",
-                    'url' => "philosophy/perl-newcomers/",
-                    'title' => ""Usability" of the Perl Online World for Newcomers",
-                },
-                {
-                    'text' => "When C is the Best?",
-                    'url' => "philosophy/computers/when-c-is-best/",
-                    'title' => "An Essay that Explains when the C Language should be used instead of Other Languages",
-                },
-                {
-                    'text' => "The Joy of Perl",
-                    'url' => "philosophy/computers/perl/joy-of-perl/",
-                    'title' => "An Essay about why I Like Perl so much.",
-                },
-                {
-                    'text' => "Perl 6 Critique",
-                    'url' => "philosophy/computers/perl/perl6-critique/",
-                    'title' => "Critique of where Perl 6 is Heading",
-                },
-                {
-                    'text' => "Which Wiki?",
-                    'url' => "philosophy/computers/web/which-wiki/",
-                    'title' => "Which Open Source Wiki Engine Works for you",
-                },
-            ],
-        },
-        {
-            'text' => "Political Essays",
-            'url' => "philosophy/politics/",
-            'title' => "Essays about Politics and Philosophical Politics",
-            'subs' =>
-            [
-                {
-                    'text' => "Objectivism and Open Source",
-                    'url' => "philosophy/obj-oss/",
-                    'title' => "Objectivism and Open Source",
-                },
-                {
-                    'text' => "Israeli-Palestinian Conflict",
-                    'url' => "philosophy/israel-pales/",
-                    'title' => "A Solution to the Israeli Palestinian Conflict",
-                },
-            ],
-        },
-        {
-            'text' => "The Eternal Jew",
-            'url' => "philosophy/the-eternal-jew/",
-            'title' => "The Eternal Jew - An Essay about the value of Self",
-        },
-    ],
-};
-
-sub get_params
-{
-    return 
-        (
-            'hosts' => MyNavData::get_hosts(),
-            'tree_contents' => $essays_tree_contents,
-        );
-}
-
-1;
-

lib/MyLecturesNavData.pm

-package MyLecturesNavData;
-
-my $essays_tree_contents =
-{
-    'host' => "vipe",
-    'text' => "Shlomi Fish' Presentations",
-    'title' => "Shlomi Fish' Presentations",
-    'show_always' => 1,
-    'subs' =>
-    [
-        {
-            'text' => "Presentations",
-            'url' => "lecture/",
-            'title' => "Nav Menu for Shlomi Fish' Presentations",
-        },
-        {
-            'text' => "Perl for Newbies",
-            'url' => "lecture/Perl/Newbies/",
-            'title' => "Perl for Perl Newbies - Introducing Perl for Beginners",
-        },
-        {
-            'text' => "Web Publishing with LAMP",
-            'url' => "lecture/LAMP/",
-            'title' => "Web Publishing using Linux/Apache/MySQL/Perl/PHP/Python",
-            'host' => "t2",
-        },
-        {
-            'text' => "Scheme & Lambda Calculus",
-            'url' => "lecture/Lambda-Calculus/",
-        },
-        {
-            'text' => "Haskell for Perlers",
-            'url' => "lecture/Perl/Haskell/",
-            'title' => "The Haskell Programming Language for Perl Programmers",
-        },
-        {
-            'text' => "Tools",
-            'url' => "lecture/cat/various-tools/",
-            'title' => "Various Tools",
-            'subs' =>
-            [
-                {
-                    'text' => "GIMP",
-                    'url' => "lecture/Gimp/",
-                    'title' => "The GNU Image Manipulation Program",
-                },
-                {
-                    'text' => "PostgreSQL",
-                    'url' => "lecture/PostgreSQL/",
-                    'title' => "The PostgreSQL Database Server",
-                },
-                {
-                    'text' => "Lex & Yacc",
-                    'url' => "lecture/Sys-Call-Track/Lex-Yacc/",
-                    'title' => "Lex and Yacc - for Tokenizing and Parsing",
-                },
-                {
-                    'text' => "Autotools",
-                    'url' =>"lecture/Autotools/",
-                    'title' => "GNU Autoconf/Automake/Libtool",
-                },
-                {
-                    'text' => "Web Meta Lecture",
-                    'url' => "lecture/WebMetaLecture/",
-                    'title' => "Presentation about Web Meta Language",
-                },
-            ],
-        },
-        {
-            'text' => "Welcome to Linux",
-            'url' => "lecture/W2L/",
-            'title' => "Presentations in the Series for Linux Beginners",
-            'subs' =>
-            [
-                {
-                    'text' => "Basic Use",
-                    'url' => "lecture/W2L/Basic_Use/",
-                    'title' => "Basic Linux Use",
-                },
-                {
-                    'text' => "Linux for the Technion Student",
-                    'url' => "lecture/W2L/Technion/",
-                    'title' => "Performing Common Programming Tasks in Linux",
-                },
-                {
-                    'text' => "Blitz",
-                    'url' => "lecture/W2L/Blitz/",
-                    'host' => "t2",
-                    'title' => "Getting up to speed with Linux (Hebrew)",
-                },
-            ],
-        },
-        {
-            'text' => "Projects",
-            'url' => "lecture/cat/projects/",
-            'title' => "Presentations about my Software Projects",
-            'subs' =>
-            [
-                {
-                    'text' => "Freecell Solver",
-                    'url' => "lecture/Freecell-Solver/",
-                    'title' => "Freecell Solver - Evolution of a C Program",
-                    'subs' =>
-                    [
-                        {
-                            'text' => "The Next Presentation",
-                            'url' => "lecture/Freecell-Solver/The-Next-Pres/",
-                            'title' => "Freecell Solver - The Next Presentation",
-                        },
-                        {
-                            'text' => "Project Intro",
-                            'url' => "lecture/Freecell-Solver/project-intro/",
-                            'title' => "Freecell Solver: Project Introduction",
-                        },
-                    ],
-                },
-                {
-                    'text' => "LM-Solve",
-                    'url' => "lecture/LM-Solve/",
-                    'title' => "LM-Solve - a Logic Mazes Solver",
-                },
-            ],
-        },
-        {
-            'text' => "CatB",
-            'url' => "lecture/CatB/",
-            'title' => "Presentation about the Cathedral and the Bazaar",
-        },
-        {
-            'text' => "Pres Tools",
-            'url' => "lecture/cat/pres-tools/",
-            'title' => "Tools for Preparing Slides for Presentations",
-            'subs' =>
-            [
-                {
-                    'text' => "Quad-Pres",
-                    'url' => "lecture/Quad-Pres/",
-                },
-                {
-                    'text' => "PerlPoint",
-                    'url' => "lecture/Pres-Tools/Perl-Point/",
-                },
-            ],
-        },
-        {
-            'text' => "Lightning Talks",
-            'url' => "lecture/cat/lightning-talks/",
-            'title' => "Short Presentations",
-            'subs' =>
-            [
-                {
-                    'text' => "Meta-Data Database Access",
-                    'url' => "lecture/mini/mdda/",
-                },
-                {
-                    'text' => "Graham Function",
-                    'url' => "lecture/Perl/Graham-Function/",
-                    'title' => "Presentation about Finding the Graham Function",
-
-                },
-                {
-                    'text' => "The Template Toolkit",
-                    'url' => "lecture/Perl/Template-Toolkit/",
-                    'title' => "A Powerful Templating System for Perl",
-                },
-            ],
-        },
-    ],
-};
-
-sub get_params
-{
-    return 
-        (
-            'hosts' => MyNavData::get_hosts(),
-            'tree_contents' => $essays_tree_contents,
-        );
-}
-
-1;
-

lib/MySectNavData.pm

+package MySectNavData;
+
+use strict;
+use warnings;
+
+use Shlomif::Homepage::SectionMenu;
+
+my @sections = 
+(
+    {
+        'id' => "essays",
+        'regex' => "^/philosophy/",
+        'class' => "Essays",
+    },
+    {
+        'id' => "lectures",
+        'regex' => "^/lecture/",
+        'class' => "Lectures",
+    },
+    
+);
+
+sub get_nav_menu
+{
+    return Shlomif::Homepage::SectionMenu->new(
+        'sections' => \@sections,
+        @_,
+    );
+}
+
+1;

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

+package Shlomif::Homepage::SectionMenu::Sects::Essays;
+
+use strict;
+use warnings;
+
+use MyNavData;
+
+my $essays_tree_contents =
+{
+    'host' => "t2",
+    'text' => "Shlomi Fish' Essays",
+    'title' => "Shlomi Fish' Essays",
+    'show_always' => 1,
+    'subs' =>
+    [
+        {
+            'text' => "Essays",
+            'url' => "philosophy/",
+            'title' => "Nav Menu for Shlomi Fish' Essays",
+        },
+        {
+            'text' => "Index to Essays",
+            'url' => "philosophy/Index/",
+            'title' => "Index to Essays and Articles I wrote.",
+        },
+        {
+            'text' => "Books Recommendations",
+            'url' => "philosophy/books-recommends/",
+            'title' => "Recommendations of Good Books I read and was Enlightened by.",
+        },
+        {
+            'text' => "Computing",
+            'url' => "philosophy/computers/",
+            'title' => "Computing-related Essays and Articles",
+            'subs' =>
+            [
+                {
+                    'text' => "What is Open Source?",
+                    'url' => "philosophy/foss-other-beasts/",
+                    'title' => "Free Software, Open Source and Other Beasts",
+                },
+                {
+                    'text' => "Perl & Newcomers",
+                    'url' => "philosophy/perl-newcomers/",
+                    'title' => ""Usability" of the Perl Online World for Newcomers",
+                },
+                {
+                    'text' => "When C is the Best?",
+                    'url' => "philosophy/computers/when-c-is-best/",
+                    'title' => "An Essay that Explains when the C Language should be used instead of Other Languages",
+                },
+                {
+                    'text' => "The Joy of Perl",
+                    'url' => "philosophy/computers/perl/joy-of-perl/",
+                    'title' => "An Essay about why I Like Perl so much.",
+                },
+                {
+                    'text' => "Perl 6 Critique",
+                    'url' => "philosophy/computers/perl/perl6-critique/",
+                    'title' => "Critique of where Perl 6 is Heading",
+                },
+                {
+                    'text' => "Which Wiki?",
+                    'url' => "philosophy/computers/web/which-wiki/",
+                    'title' => "Which Open Source Wiki Engine Works for you",
+                },
+            ],
+        },
+        {
+            'text' => "Political Essays",
+            'url' => "philosophy/politics/",
+            'title' => "Essays about Politics and Philosophical Politics",
+            'subs' =>
+            [
+                {
+                    'text' => "Objectivism and Open Source",
+                    'url' => "philosophy/obj-oss/",
+                    'title' => "Objectivism and Open Source",
+                },
+                {
+                    'text' => "Israeli-Palestinian Conflict",
+                    'url' => "philosophy/israel-pales/",
+                    'title' => "A Solution to the Israeli Palestinian Conflict",
+                },
+            ],
+        },
+        {
+            'text' => "The Eternal Jew",
+            'url' => "philosophy/the-eternal-jew/",
+            'title' => "The Eternal Jew - An Essay about the value of Self",
+        },
+    ],
+};
+
+sub get_params
+{
+    return 
+        (
+            'hosts' => MyNavData::get_hosts(),
+            'tree_contents' => $essays_tree_contents,
+        );
+}
+
+1;
+

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

+package Shlomif::Homepage::SectionMenu::Sects::Lectures;
+
+use strict;
+use warnings;
+
+use MyNavData;
+
+my $essays_tree_contents =
+{
+    'host' => "vipe",
+    'text' => "Shlomi Fish' Presentations",
+    'title' => "Shlomi Fish' Presentations",
+    'show_always' => 1,
+    'subs' =>
+    [
+        {
+            'text' => "Presentations",
+            'url' => "lecture/",
+            'title' => "Nav Menu for Shlomi Fish' Presentations",
+        },
+        {
+            'text' => "Perl for Newbies",
+            'url' => "lecture/Perl/Newbies/",
+            'title' => "Perl for Perl Newbies - Introducing Perl for Beginners",
+        },
+        {
+            'text' => "Web Publishing with LAMP",
+            'url' => "lecture/LAMP/",
+            'title' => "Web Publishing using Linux/Apache/MySQL/Perl/PHP/Python",
+            'host' => "t2",
+        },
+        {
+            'text' => "Scheme & Lambda Calculus",
+            'url' => "lecture/Lambda-Calculus/",
+        },
+        {
+            'text' => "Haskell for Perlers",
+            'url' => "lecture/Perl/Haskell/",
+            'title' => "The Haskell Programming Language for Perl Programmers",
+        },
+        {
+            'text' => "Tools",
+            'url' => "lecture/cat/various-tools/",
+            'title' => "Various Tools",
+            'subs' =>
+            [
+                {
+                    'text' => "GIMP",
+                    'url' => "lecture/Gimp/",
+                    'title' => "The GNU Image Manipulation Program",
+                },
+                {
+                    'text' => "PostgreSQL",
+                    'url' => "lecture/PostgreSQL/",
+                    'title' => "The PostgreSQL Database Server",
+                },
+                {
+                    'text' => "Lex & Yacc",
+                    'url' => "lecture/Sys-Call-Track/Lex-Yacc/",
+                    'title' => "Lex and Yacc - for Tokenizing and Parsing",
+                },
+                {
+                    'text' => "Autotools",
+                    'url' =>"lecture/Autotools/",
+                    'title' => "GNU Autoconf/Automake/Libtool",
+                },
+                {
+                    'text' => "Web Meta Lecture",
+                    'url' => "lecture/WebMetaLecture/",
+                    'title' => "Presentation about Web Meta Language",
+                },
+            ],
+        },
+        {
+            'text' => "Welcome to Linux",
+            'url' => "lecture/W2L/",
+            'title' => "Presentations in the Series for Linux Beginners",
+            'subs' =>
+            [
+                {
+                    'text' => "Basic Use",
+                    'url' => "lecture/W2L/Basic_Use/",
+                    'title' => "Basic Linux Use",
+                },
+                {
+                    'text' => "Linux for the Technion Student",
+                    'url' => "lecture/W2L/Technion/",
+                    'title' => "Performing Common Programming Tasks in Linux",
+                },
+                {
+                    'text' => "Blitz",
+                    'url' => "lecture/W2L/Blitz/",
+                    'host' => "t2",
+                    'title' => "Getting up to speed with Linux (Hebrew)",
+                },
+            ],
+        },
+        {
+            'text' => "Projects",
+            'url' => "lecture/cat/projects/",
+            'title' => "Presentations about my Software Projects",
+            'subs' =>
+            [
+                {
+                    'text' => "Freecell Solver",
+                    'url' => "lecture/Freecell-Solver/",
+                    'title' => "Freecell Solver - Evolution of a C Program",
+                    'subs' =>
+                    [
+                        {
+                            'text' => "The Next Presentation",
+                            'url' => "lecture/Freecell-Solver/The-Next-Pres/",
+                            'title' => "Freecell Solver - The Next Presentation",
+                        },
+                        {
+                            'text' => "Project Intro",
+                            'url' => "lecture/Freecell-Solver/project-intro/",
+                            'title' => "Freecell Solver: Project Introduction",
+                        },
+                    ],
+                },
+                {
+                    'text' => "LM-Solve",
+                    'url' => "lecture/LM-Solve/",
+                    'title' => "LM-Solve - a Logic Mazes Solver",
+                },
+            ],
+        },
+        {
+            'text' => "CatB",
+            'url' => "lecture/CatB/",
+            'title' => "Presentation about the Cathedral and the Bazaar",
+        },
+        {
+            'text' => "Pres Tools",
+            'url' => "lecture/cat/pres-tools/",
+            'title' => "Tools for Preparing Slides for Presentations",
+            'subs' =>
+            [
+                {
+                    'text' => "Quad-Pres",
+                    'url' => "lecture/Quad-Pres/",
+                },
+                {
+                    'text' => "PerlPoint",
+                    'url' => "lecture/Pres-Tools/Perl-Point/",
+                },
+            ],
+        },
+        {
+            'text' => "Lightning Talks",
+            'url' => "lecture/cat/lightning-talks/",
+            'title' => "Short Presentations",
+            'subs' =>
+            [
+                {
+                    'text' => "Meta-Data Database Access",
+                    'url' => "lecture/mini/mdda/",
+                },
+                {
+                    'text' => "Graham Function",
+                    'url' => "lecture/Perl/Graham-Function/",
+                    'title' => "Presentation about Finding the Graham Function",
+
+                },
+                {
+                    'text' => "The Template Toolkit",
+                    'url' => "lecture/Perl/Template-Toolkit/",
+                    'title' => "A Powerful Templating System for Perl",
+                },
+            ],
+        },
+    ],
+};
+
+sub get_params
+{
+    return 
+        (
+            'hosts' => MyNavData::get_hosts(),
+            'tree_contents' => $essays_tree_contents,
+        );
+}
+
+1;
+
     />
 </latemp_foot_image>
 
-#include "sub-menus/essays.wml"
-#include "sub-menus/lectures.wml"
+<latemp_after_main_title>
+<:{
+    use MySectNavData;
 
-<latemp_after_main_title>
-<if "<match "$(LATEMP_FILENAME)" "^philosophy/" action="report" />"
-    "<essays_sub_menu />"
-    "<if "<match "$(LATEMP_FILENAME)" "^lecture/" action="report" />"
-        "<lectures_sub_menu />"
-        "" />"
-    />
+    use vars (qw($section_nav_menu));
+    my $filename = "<latemp_default_val "<get-var latemp_filename />" "$(LATEMP_FILENAME)" />";
+    $filename =~ s{index\.html$}{};
+    $filename = "/$filename";
+
+    $section_nav_menu = MySectNavData::get_nav_menu(
+        'path_info' => $filename,
+        'current_host' => "<latemp_default_val "<get-var latemp_server />" "$(LATEMP_SERVER)" />",
+        );
+
+    print $section_nav_menu->get_html();
+}:>
 </latemp_after_main_title>