[tor-commits] [webwml/master] Fix navigation active tab issue

hiro at torproject.org hiro at torproject.org
Thu Jan 12 15:08:35 UTC 2017


commit 50d71b7df381662063643df5cd4fc1b6deec5ea5
Author: hiromipaw <hiro at torproject.org>
Date:   Thu Jan 12 12:53:37 2017 +0100

    Fix navigation active tab issue
---
 .gitignore                 |  2 ++
 docs/en/tor-manual-dev.wml |  4 ++--
 include/head.wmi           | 28 +++++++++++++++-------------
 3 files changed, 19 insertions(+), 15 deletions(-)

diff --git a/.gitignore b/.gitignore
index fa0eba6..71fe665 100644
--- a/.gitignore
+++ b/.gitignore
@@ -8,9 +8,11 @@ about/corepeople.html.en
 about/financials.html.en
 about/gsoc.html.en
 about/jobs-browserhacker.html.en
+about/jobs-comm-director.html.en
 about/jobs-controller.html.en
 about/jobs-coredev.html.en
 about/jobs-dircomms.html.en
+about/jobs-execadmin.html.en
 about/jobs-extdev.html.en
 about/jobs-lead-automation.html.en
 about/jobs-pluggabletransport.html.en
diff --git a/docs/en/tor-manual-dev.wml b/docs/en/tor-manual-dev.wml
index 14e3cfe..e39510d 100644
--- a/docs/en/tor-manual-dev.wml
+++ b/docs/en/tor-manual-dev.wml
@@ -11,7 +11,7 @@
     <a href="<page docs/documentation>">Documentation » </a>
     <a href="<page docs/tor-doc-osx>">Tor Dev Manual</a>
   </div>
-  <div id="maincol">  
+  <div id="maincol">
     <:
     	die "Missing git clone at $(TORGIT)" unless -d "$(TORGIT)";
     	my $man = `GIT_DIR=$(TORGIT) git show $(DEVTAG):doc/tor.1.txt | asciidoc -d manpage -s -o - -`;
@@ -27,4 +27,4 @@
   <!-- END SIDECOL -->
 </div>
 <!-- END CONTENT -->
-#include <foot.wmi>  
+#include <foot.wmi>
diff --git a/include/head.wmi b/include/head.wmi
index faf8dd1..091fda8 100644
--- a/include/head.wmi
+++ b/include/head.wmi
@@ -24,7 +24,7 @@
    <ifneq "$(REDIRECT)" "" "<meta http-equiv="refresh" content="0;url=$(DOCROOT)/$(REDIRECT)">">
    <ifneq "$(REDIRECT_GLOBAL)" "" "<meta http-equiv="refresh" content="0;url=$(REDIRECT_GLOBAL)">">
 
-   # begin WML to generate css/js paths 
+   # begin WML to generate css/js paths
    <ifneq "$(STYLESHEET)" "" "<link href="$(DOCROOT)/$(STYLESHEET)" rel="stylesheet">">
    <ifeq "$(STYLESHEET)" "" "<link href="$(DOCROOT)/css/master.css" rel="stylesheet">">
 
@@ -39,7 +39,7 @@
    <link href="$(DOCROOT)/css/ie6.css" rel="stylesheet">
    <![endif]-->
  #  <script language="javascript" type="text/javascript" src="$(DOCROOT)/global.js"></script>
-   # end WML to generate css/js paths 
+   # end WML to generate css/js paths
 </head>
 <body>
 <div id="wrap">
@@ -63,23 +63,25 @@
             my $lang = "$(LANG)";
 
             for my $key (@keys) {
-              my ($dir, $base) = $key =~ m,^(?:(.*)/)?(.*?)$,;  
+              my ($dir, $base) = $key =~ m,^(?:(.*)/)?(.*?)$,;
 
-              # in directory of active link, set class active 
+              # in directory of active link, set class active. This rule should be improved with proper structuring of the links.
               my $class;
-              if ((defined $dir) and ($WML_SRC_DIRNAME =~/$dir/) or ($WML_SRC_BASENAME eq $base)) {
-                $class = 'class="active"';
+              if ((index($page, 'contact') ne -1) and (index($base, 'overview') ne -1)) {
+                $class = '';
+              } elsif ((defined $dir) and ($WML_SRC_DIRNAME =~/$dir/) and (index($key, 'contact') eq -1) or ($WML_SRC_BASENAME eq $base)) {
+                $class = 'class="active '.$base.' '.$page.'"';
               } else {
                 $class = '';
               }
 
 	            $dir = '.' unless defined $dir;
-                
+
               # translated version
               if (-e "$(DOCROOT)/$dir/$lang/$base.wml") {
                   printf '<li><a '.$class.' href="%s">%s</a></li>'."\n",
                          stripDotSlashs("$(DOCROOT)/$dir/$base.html.$(LANG)"),$navigation{$key};
-              } 
+              }
               # english version
               elsif (-e "$(DOCROOT)/$dir/en/$base.wml") {
               	printf '<li><a '.$class.' href="%s">%s</a></li>'."\n",
@@ -108,14 +110,14 @@ docdir: $(DOCROOT)/; dir: $dir; base: $base -> $(DOCROOT)/$dir/$lang/$base.wml),
               my $val = shift @calltoaction;
               push @keys, $key;
               $calltoaction{$key} = $val;
-            } 
+            }
 
             my $page = $WML_SRC_BASENAME;
             my $lang = "$(LANG)";
             for my $key (@keys) {
-              my ($dir, $base) = $key =~ m,^(?:(.*)/)?(.*?)$,;  
+              my ($dir, $base) = $key =~ m,^(?:(.*)/)?(.*?)$,;
 
-              # in directory, set active 
+              # in directory, set active
               my $class;
               if ((defined $dir) and ($WML_SRC_DIRNAME =~/$dir/) or ($WML_SRC_BASENAME eq $base)) {
               #if ($WML_SRC_BASENAME eq $base) {
@@ -129,7 +131,7 @@ docdir: $(DOCROOT)/; dir: $dir; base: $base -> $(DOCROOT)/$dir/$lang/$base.wml),
               if (-e "$(DOCROOT)/$dir/$lang/$base.wml") {
                   printf '<li class="donate"><a '.$class.' href="%s">%s</a></li>'."\n",
                          stripDotSlashs("$(DOCROOT)/$dir/$base.html.$(LANG)"),$calltoaction{$key};
-              } 
+              }
               # default to english version
               elsif (-e "$(DOCROOT)/$dir/en/$base.wml") {
               	printf '<li class="donate"><a '.$class.' href="%s">%s</a></li>'."\n",
@@ -137,7 +139,7 @@ docdir: $(DOCROOT)/; dir: $dir; base: $base -> $(DOCROOT)/$dir/$lang/$base.wml),
               } else {
                 warn "$WML_SRC_FILENAME has a [page $key] (parses to docdir: $(DOCROOT)/; dir: $dir; base: $base -> $(DOCROOT)/$dir/$lang/$base.wml), but that doesn't exist.";
               }
-            }    
+            }
           }:>
         </ul>
       </div>





More information about the tor-commits mailing list