Commits

Shlomi Fish  committed e042332

Extract code to lib/NavSectMenuRender.pm .

  • Participants
  • Parent commits f604cf4

Comments (0)

Files changed (2)

File lib/NavSectMenuRender.pm

+package NavSectMenuRender;
+
+use strict;
+use warnings;
+
+use utf8;
+
+use MyNavData;
+use HTML::Widgets::NavMenu::JQueryTreeView;
+
+use CGI qw();
+use MyNavLinks;
+
+use Shlomif::WrapAsUtf8 (qw(_wrap_as_utf8));
+
+use MySectNavData;
+
+use vars (qw($section_nav_menu));
+
+sub init_section_nav_menu
+{
+    my ($class, $args) = @_;
+
+    my $filename = $args->{filename};
+    my $host = $args->{host};
+    my $ROOT = $args->{ROOT};
+
+    # Adding to disable the google ads since they're not
+    # operational.
+    my $ads_side = '';
+
+    my $section_nav_menu = MySectNavData::get_nav_menu(
+        'path_info' => $filename,
+        'current_host' => $host,
+        'root' => "$ROOT",
+        'bottom_code' => $ads_side,
+    );
+
+    return
+    +{
+        section_nav_menu => $section_nav_menu,
+    };
+}
+
+1;

File lib/rest-of-template.wml

 </latemp_before_main_title>
 
 <section_nav_menu_elements>
+<set-var host="<latemp_default_val "<get-var latemp_server />" "$(LATEMP_SERVER)" />" />
 <:{
-    use MySectNavData;
+    use strict;
+    use warnings;
 
-    BEGIN
-    {
-        # binmode STDOUT, ":encoding(utf-8)";
-    }
+    use NavSectMenuRender;
 
     sub get_page_path
     {
 
     sub init_section_nav_menu
     {
-        my $ads_side = <<"EOF_ADS_CODE";
-<shlomif_web_ads_code_side />
-EOF_ADS_CODE
+        if (! defined( $section_nav_menu))
+        {
+            my $results = NavSectMenuRender->init_section_nav_menu(
+                {
+                    filename => ('/' . get_page_path()),
+                    host => "<get-var host />",
+                    'ROOT' => "$(ROOT)",
+                }
+            );
 
-        # Adding to disable the google ads since they're not
-        # operational.
-        $ads_side = "";
-
-        if (defined($section_nav_menu))
-        {
-            return;
+            $section_nav_menu = $results->{section_nav_menu};
         }
-    $filename = "/" . get_page_path();
-
-    $section_nav_menu = MySectNavData::get_nav_menu(
-        'path_info' => $filename,
-        'current_host' => "<latemp_default_val "<get-var latemp_server />" "$(LATEMP_SERVER)" />",
-        'root' => "$(ROOT)",
-        'bottom_code' => $ads_side,
-        );
-
-return;
     }
 
     init_section_nav_menu();
+
     {
         _wrap_as_utf8 (sub {
             print $section_nav_menu->get_html();