add these files as well
Runa A. Sandvik

Runa A. Sandvik commited on 2011-03-31 13:33:20
Zeige 2 geänderte Dateien mit 233 Einfügungen und 0 Löschungen.

... ...
@@ -0,0 +1,142 @@
1
+#! /usr/bin/wml
2
+<: use strict; :>
3
+<: use warnings; :>
4
+#use "perl-globals.wmi"
5
+#use "links.wmi"
6
+#use "versions.wmi"
7
+#use "navigation.wmi"
8
+
9
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
10
+<html>
11
+<head>
12
+  <title>$(TITLE)</title>
13
+  <link rel="shortcut icon" type="image/x-icon" href="$(IMGROOT)/favicon.ico">
14
+  <ifneq "$(REDIRECT)" "" "<meta http-equiv="refresh" content="0;url=$(DOCROOT)/$(REDIRECT)">">
15
+  <ifneq "$(REDIRECT_GLOBAL)" "" "<meta http-equiv="refresh" content="0;url=$(REDIRECT_GLOBAL)">">
16
+  <ifeq "$(ANNOUNCE_RSS)" "yes" "<link rel="alternate" title="Tor Project OR-announce" href="http://rss.gmane.org/gmane.network.onion-routing.announce"
17
+type="application/rss+xml">">
18
+
19
+  # begin WML to generate css/js paths 
20
+  <ifneq "$(STYLESHEET)" "" "<link rel="stylesheet" type="text/css" href="$(DOCROOT)/$(STYLESHEET)">">
21
+  <ifeq "$(STYLESHEET)" "" "<link rel="stylesheet" type="text/css" href="$(DOCROOT)/css/master.css">">
22
+
23
+  #<link href="css/master.css" rel="stylesheet" type="text/css">
24
+  <!--[if lte IE 7]>
25
+  <link rel="stylesheet" type="text/css" href="$(DOCROOT)/css/ie7-and-down.css">
26
+  <![endif]-->
27
+  <!--[if IE 6]>
28
+  <link rel="stylesheet" type="text/css" href="$(DOCROOT)/css/ie6.css">
29
+  <![endif]-->
30
+#  <script language="javascript" type="text/javascript" src="$(DOCROOT)/global.js"></script>
31
+  # end WML to generate css/js paths 
32
+
33
+  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
34
+  <meta name="author" content="The Tor Project, Inc.">
35
+  <meta name="keywords" content="anonymity online, tor, tor project, censorship circumvention, traffic analysis, anonymous communications research">
36
+</head>
37
+<body>
38
+<div id="wrap">
39
+  <div id="header">
40
+    <h1 id="logo"><a href="<page index>">Tor</a></h1>
41
+      # navigation menu generation
42
+      <div id="nav">
43
+        <ul>
44
+        <:{
45
+            # create a hash and maintain order of keys
46
+            my %navigation;
47
+            my @keys;
48
+            while (@navigation) {
49
+              my $key = shift @navigation;
50
+              my $val = shift @navigation;
51
+              push @keys, $key;
52
+              $navigation{$key} = $val;
53
+            }
54
+
55
+            my $page = $WML_SRC_BASENAME;
56
+            my $lang = "$(LANG)";
57
+
58
+            for my $key (@keys) {
59
+              my ($dir, $base) = $key =~ m,^(?:(.*)/)?(.*?)$,;  
60
+
61
+              # in directory of active link, set class active 
62
+              my $class;
63
+              if ((defined $dir) and ($WML_SRC_DIRNAME =~/$dir/) or ($WML_SRC_BASENAME eq $base)) {
64
+                $class = 'class="active"';
65
+              } else {
66
+                $class = '';
67
+              }
68
+
69
+	            $dir = '.' unless defined $dir;
70
+                
71
+              # translated version
72
+              if (-e "$(DOCROOT)/$dir/$lang/$base.wml") {
73
+                  printf '<li><a '.$class.' href="%s">%s</a></li>'."\n",
74
+                         stripDotSlashs("$(DOCROOT)/$dir/$base.html.$(LANG)"),$navigation{$key};
75
+              } 
76
+              # english version
77
+              elsif (-e "$(DOCROOT)/$dir/en/$base.wml") {
78
+              	printf '<li><a '.$class.' href="%s">%s</a></li>'."\n",
79
+                  stripDotSlashs("$(DOCROOT)/$dir/$base.html"), $navigation{$key};
80
+              }
81
+              # full url
82
+              elsif ($key =~/^http/) {
83
+                printf '<li><a href="%s">%s</a></li>'."\n", $key, $navigation{$key};
84
+              } else {
85
+                warn "$WML_SRC_FILENAME has a [page $key] (parses to
86
+docdir: $(DOCROOT)/; dir: $dir; base: $base -> $(DOCROOT)/$dir/$lang/$base.wml), but that doesn't exist.";
87
+              }
88
+            }
89
+        }:>
90
+        </ul>
91
+      </div>
92
+      <!-- END NAV -->
93
+     # end navigation generation
94
+      <div id="calltoaction">
95
+        <ul>
96
+          <:{
97
+            my %calltoaction;
98
+            my @keys;
99
+            while (@calltoaction) {
100
+              my $key = shift @calltoaction;
101
+              my $val = shift @calltoaction;
102
+              push @keys, $key;
103
+              $calltoaction{$key} = $val;
104
+            } 
105
+
106
+            my $page = $WML_SRC_BASENAME;
107
+            my $lang = "$(LANG)";
108
+            for my $key (@keys) {
109
+              my ($dir, $base) = $key =~ m,^(?:(.*)/)?(.*?)$,;  
110
+
111
+              # in directory, set active 
112
+              my $class;
113
+              if ((defined $dir) and ($WML_SRC_DIRNAME =~/$dir/) or ($WML_SRC_BASENAME eq $base)) {
114
+              #if ($WML_SRC_BASENAME eq $base) {
115
+                $class = 'class="active"';
116
+              } else {
117
+                $class = '';
118
+              }
119
+
120
+	          $dir = '.' unless defined $dir;
121
+              # try to use a translated version
122
+              if (-e "$(DOCROOT)/$dir/$lang/$base.wml") {
123
+                  printf '<li class="donate"><a '.$class.' href="%s">%s</a></li>'."\n",
124
+                         stripDotSlashs("$(DOCROOT)/$dir/$base.html.$(LANG)"),$calltoaction{$key};
125
+              } 
126
+              # default to english version
127
+              elsif (-e "$(DOCROOT)/$dir/en/$base.wml") {
128
+              	printf '<li class="donate"><a '.$class.' href="%s">%s</a></li>'."\n",
129
+                  stripDotSlashs("$(DOCROOT)/$dir/$base.html"), $calltoaction{$key};
130
+              } else {
131
+                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.";
132
+              }
133
+            }    
134
+          }:>
135
+        </ul>
136
+      </div>
137
+      <!-- END CALLTOACTION -->
138
+  </div>
139
+  <!-- END HEADER -->
140
+
141
+#<ifneq "$(REDIRECT)" "" "Redirecting to <a href="$(DOCROOT)/$(REDIRECT)">$(DOCROOT)/$(REDIRECT)</a>.">
142
+#<ifneq "$(REDIRECT_GLOBAL)" "" "Redirecting to <a href="$(REDIRECT_GLOBAL)">$(REDIRECT_GLOBAL)</a>.">
... ...
@@ -0,0 +1,91 @@
1
+#! /usr/bin/wml
2
+<: use strict; :>
3
+<: use warnings; :>
4
+#use "perl-globals.wmi"
5
+#use "links.wmi"
6
+#use "versions.wmi"
7
+#use "sidenav.wmi"
8
+<div class="img-shadow">
9
+  <div id="sidenav">
10
+    <:
11
+      # recursively search menu structure to see if it contains a given page
12
+      sub containsSub($$);
13
+      sub containsSub($$) {
14
+          my ($elements, $page) = @_;
15
+          for my $ele (@{$elements}) {
16
+              if (containsSub($ele->{'subelements'},$page)){
17
+                  return 1;
18
+              } elsif ($page eq $ele->{'url'}) {
19
+                  return 1;
20
+              }
21
+
22
+          }
23
+          return 0;
24
+      } 
25
+
26
+      # generate navigation menu
27
+      sub printNavMenu($$$);
28
+      sub printNavMenu($$$) {
29
+          my ($navmenu, $page, $lang) = @_;
30
+          print '<ul>'."\n";
31
+          for my $navmenu (@{$navmenu}) {
32
+              # this menu entry is the current (active) page
33
+              if ($navmenu->{'url'} eq $page) {
34
+      
35
+                  # the current page has nested menu elements
36
+                  if ($navmenu->{'subelements'}) { # menu has dropdown
37
+                      printf '<li class="dropdown active"><a class="active" href="%s">%s</a></li>'."\n",
38
+                             pageToURL($navmenu->{'url'}, $lang), $navmenu->{'txt'}; 
39
+      
40
+                      print '<li>'."\n";
41
+                      printNavMenu($navmenu->{'subelements'},$page,$lang); 
42
+                      print '</li>'."\n";
43
+
44
+                  # the current (active) page does not have sub elements
45
+                  } else {
46
+                      printf '<li class="active"><a class="active" href="%s">%s</a></li>'."\n",
47
+                             pageToURL($navmenu->{'url'}, $lang), $navmenu->{'txt'}; 
48
+                  }
49
+      
50
+              # a subelement of this menu item is the current (active) page
51
+              } elsif (containsSub($navmenu->{'subelements'}, $page)) {
52
+                  printf '<li class="dropdown"><a class="active" href="%s">%s</a></li>'."\n",
53
+                         pageToURL($navmenu->{'url'}, $lang), $navmenu->{'txt'};
54
+
55
+                  print '<li>'."\n"; #encapsulate subelements
56
+                  # recurse to generate the expanded menu
57
+                  printNavMenu($navmenu->{'subelements'},$page,$lang); 
58
+                  print '</li>'."\n"; #encapsulate subelements
59
+      
60
+              # the menu entry is not active and does not enclose the active page
61
+              } else {
62
+
63
+                  # if there are subelements, set collapsed style
64
+                  if ($navmenu->{'subelements'}) {
65
+                      printf '<li class="dropdown"><a href="%s">%s</a></li>'."\n",
66
+                             pageToURL($navmenu->{'url'}, $lang), $navmenu->{'txt'};
67
+                  # regular menu entry
68
+                  } else {
69
+                      printf '<li><a href="%s">%s</a></li>'."\n",
70
+                             pageToURL($navmenu->{'url'}, $lang), $navmenu->{'txt'};
71
+                  }
72
+              }
73
+          }
74
+          print '</ul>'."\n";
75
+      }
76
+
77
+      my $lang = "$(LANG)";
78
+
79
+      use Cwd;
80
+      use Cwd 'abs_path';
81
+      use File::Spec;
82
+      
83
+      # get document path from site root
84
+      my $path = File::Spec->abs2rel(getcwd(),abs_path("$(DOCROOT)"));
85
+      my $page = $WML_SRC_BASENAME; 
86
+      printNavMenu($sidenav, $path.'/'.$page, $lang);
87
+    :>
88
+  </div>
89
+  <!-- END SIDENAV -->
90
+</div>
91
+<!-- END IMG-SHADOW -->
0 92