50d71b7df381662063643df5cd4fc1b6deec5ea5
Andrew Lewman first cut of the new, shiny...

Andrew Lewman authored 13 years ago

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) 
Nima Fatemi some meta clean up. making...

Nima Fatemi authored 9 years ago

9) <!DOCTYPE html>
10)  <html>
11)  <head>
Andrew Lewman first cut of the new, shiny...

Andrew Lewman authored 13 years ago

12) 
Nima Fatemi some meta clean up. making...

Nima Fatemi authored 9 years ago

13)    <meta charset="utf-8">
14)    <meta http-equiv="X-UA-Compatible" content="IE=edge">
15)    <meta name="viewport" content="width=device-width, initial-scale=1">
16)    <meta name="author" content="The Tor Project, Inc.">
Arthur Edelstein Bug 20465: Call it 'Tor Bro...

Arthur Edelstein authored 7 years ago

17)    <meta name="description" content="Tor is a free software that prevents people from learning your location or browsing habits by letting you communicate anonymously on the Internet. It also helps you bypass censorship online. If you can't open the website, email gettor@torproject.org for instruction on how to get Tor Browser.">
Nima Fatemi some meta clean up. making...

Nima Fatemi authored 9 years ago

18)    <meta name="keywords" content="anonymity online, tor, tor project, censorship circumvention, traffic analysis, anonymous communications research">
Sebastian Hahn Add open graph meta tag

Sebastian Hahn authored 9 years ago

19)    <meta property="og:image" content="https://www.torproject.org/images/tor-logo.jpg">
20) 
Nima Fatemi some meta clean up. making...

Nima Fatemi authored 9 years ago

21)    <title>$(TITLE)</title>
Sebastian Hahn Add open graph meta tag

Sebastian Hahn authored 9 years ago

22) 
Nima Fatemi some meta clean up. making...

Nima Fatemi authored 9 years ago

23)    <link rel="icon" href="$(IMGROOT)/favicon.ico">
24)    <ifneq "$(REDIRECT)" "" "<meta http-equiv="refresh" content="0;url=$(DOCROOT)/$(REDIRECT)">">
25)    <ifneq "$(REDIRECT_GLOBAL)" "" "<meta http-equiv="refresh" content="0;url=$(REDIRECT_GLOBAL)">">
Sebastian Hahn Add open graph meta tag

Sebastian Hahn authored 9 years ago

26) 
hiromipaw Fix navigation active tab i...

hiromipaw authored 7 years ago

27)    # begin WML to generate css/js paths
Nima Fatemi some meta clean up. making...

Nima Fatemi authored 9 years ago

28)    <ifneq "$(STYLESHEET)" "" "<link href="$(DOCROOT)/$(STYLESHEET)" rel="stylesheet">">
29)    <ifeq "$(STYLESHEET)" "" "<link href="$(DOCROOT)/css/master.css" rel="stylesheet">">
Sebastian Hahn Add open graph meta tag

Sebastian Hahn authored 9 years ago

30) 
Nima Fatemi some meta clean up. making...

Nima Fatemi authored 9 years ago

31)    #<link href="css/master.css" rel="stylesheet">
32)    <!--[if lte IE 8]>
33)    <link href="$(DOCROOT)/css/ie8-and-down.css" rel="stylesheet">
34)    <![endif]-->
35)    <!--[if lte IE 7]>
36)    <link href="$(DOCROOT)/css/ie7-and-down.css" rel="stylesheet">
37)    <![endif]-->
38)    <!--[if IE 6]>
39)    <link href="$(DOCROOT)/css/ie6.css" rel="stylesheet">
40)    <![endif]-->
41)  #  <script language="javascript" type="text/javascript" src="$(DOCROOT)/global.js"></script>
hiromipaw Fix navigation active tab i...

hiromipaw authored 7 years ago

42)    # end WML to generate css/js paths
Andrew Lewman first cut of the new, shiny...

Andrew Lewman authored 13 years ago

43) </head>
44) <body>
45) <div id="wrap">
46)   <div id="header">
Andrew Lewman it's called index, not home

Andrew Lewman authored 13 years ago

47)     <h1 id="logo"><a href="<page index>">Tor</a></h1>
Andrew Lewman first cut of the new, shiny...

Andrew Lewman authored 13 years ago

48)       # navigation menu generation
49)       <div id="nav">
50)         <ul>
51)         <:{
52)             # create a hash and maintain order of keys
53)             my %navigation;
54)             my @keys;
55)             while (@navigation) {
56)               my $key = shift @navigation;
57)               my $val = shift @navigation;
58)               push @keys, $key;
59)               $navigation{$key} = $val;
60)             }
61) 
62)             my $page = $WML_SRC_BASENAME;
63)             my $lang = "$(LANG)";
64) 
65)             for my $key (@keys) {
hiromipaw Fix navigation active tab i...

hiromipaw authored 7 years ago

66)               my ($dir, $base) = $key =~ m,^(?:(.*)/)?(.*?)$,;
Andrew Lewman first cut of the new, shiny...

Andrew Lewman authored 13 years ago

67) 
hiromipaw Fix navigation active tab i...

hiromipaw authored 7 years ago

68)               # in directory of active link, set class active. This rule should be improved with proper structuring of the links.
Andrew Lewman first cut of the new, shiny...

Andrew Lewman authored 13 years ago

69)               my $class;
hiromipaw Fix navigation active tab i...

hiromipaw authored 7 years ago

70)               if ((index($page, 'contact') ne -1) and (index($base, 'overview') ne -1)) {
71)                 $class = '';
72)               } elsif ((defined $dir) and ($WML_SRC_DIRNAME =~/$dir/) and (index($key, 'contact') eq -1) or ($WML_SRC_BASENAME eq $base)) {
73)                 $class = 'class="active '.$base.' '.$page.'"';
Andrew Lewman first cut of the new, shiny...

Andrew Lewman authored 13 years ago

74)               } else {
75)                 $class = '';
76)               }
77) 
78) 	            $dir = '.' unless defined $dir;
hiromipaw Fix navigation active tab i...

hiromipaw authored 7 years ago

79) 
Andrew Lewman first cut of the new, shiny...

Andrew Lewman authored 13 years ago

80)               # translated version
Andrew Lewman revert the pathing for lang

Andrew Lewman authored 13 years ago

81)               if (-e "$(DOCROOT)/$dir/$lang/$base.wml") {
Andrew Lewman first cut of the new, shiny...

Andrew Lewman authored 13 years ago

82)                   printf '<li><a '.$class.' href="%s">%s</a></li>'."\n",
83)                          stripDotSlashs("$(DOCROOT)/$dir/$base.html.$(LANG)"),$navigation{$key};
hiromipaw Fix navigation active tab i...

hiromipaw authored 7 years ago

84)               }
Andrew Lewman first cut of the new, shiny...

Andrew Lewman authored 13 years ago

85)               # english version
86)               elsif (-e "$(DOCROOT)/$dir/en/$base.wml") {
87)               	printf '<li><a '.$class.' href="%s">%s</a></li>'."\n",
88)                   stripDotSlashs("$(DOCROOT)/$dir/$base.html"), $navigation{$key};
89)               }
90)               # full url
91)               elsif ($key =~/^http/) {
92)                 printf '<li><a href="%s">%s</a></li>'."\n", $key, $navigation{$key};
93)               } else {
Andrew Lewman switch to Goldstein's idea...

Andrew Lewman authored 13 years ago

94)                 warn "$WML_SRC_FILENAME has a [page $key] (parses to
Andrew Lewman revert the pathing for lang

Andrew Lewman authored 13 years ago

95) docdir: $(DOCROOT)/; dir: $dir; base: $base -> $(DOCROOT)/$dir/$lang/$base.wml), but that doesn't exist.";
Andrew Lewman first cut of the new, shiny...

Andrew Lewman authored 13 years ago

96)               }
97)             }
98)         }:>
99)         </ul>
100)       </div>
101)       <!-- END NAV -->
102)      # end navigation generation
103)       <div id="calltoaction">
104)         <ul>
105)           <:{
106)             my %calltoaction;
107)             my @keys;
108)             while (@calltoaction) {
109)               my $key = shift @calltoaction;
110)               my $val = shift @calltoaction;
111)               push @keys, $key;
112)               $calltoaction{$key} = $val;
hiromipaw Fix navigation active tab i...

hiromipaw authored 7 years ago

113)             }
Andrew Lewman first cut of the new, shiny...

Andrew Lewman authored 13 years ago

114) 
115)             my $page = $WML_SRC_BASENAME;
116)             my $lang = "$(LANG)";
117)             for my $key (@keys) {
hiromipaw Fix navigation active tab i...

hiromipaw authored 7 years ago

118)               my ($dir, $base) = $key =~ m,^(?:(.*)/)?(.*?)$,;
Andrew Lewman first cut of the new, shiny...

Andrew Lewman authored 13 years ago

119) 
hiromipaw Fix navigation active tab i...

hiromipaw authored 7 years ago

120)               # in directory, set active
Andrew Lewman first cut of the new, shiny...

Andrew Lewman authored 13 years ago

121)               my $class;
122)               if ((defined $dir) and ($WML_SRC_DIRNAME =~/$dir/) or ($WML_SRC_BASENAME eq $base)) {
123)               #if ($WML_SRC_BASENAME eq $base) {
124)                 $class = 'class="active"';
125)               } else {
126)                 $class = '';
127)               }
128) 
129) 	          $dir = '.' unless defined $dir;
130)               # try to use a translated version
Andrew Lewman revert the pathing for lang

Andrew Lewman authored 13 years ago

131)               if (-e "$(DOCROOT)/$dir/$lang/$base.wml") {
Andrew Lewman first cut of the new, shiny...

Andrew Lewman authored 13 years ago

132)                   printf '<li class="donate"><a '.$class.' href="%s">%s</a></li>'."\n",
133)                          stripDotSlashs("$(DOCROOT)/$dir/$base.html.$(LANG)"),$calltoaction{$key};
hiromipaw Fix navigation active tab i...

hiromipaw authored 7 years ago

134)               }
Andrew Lewman first cut of the new, shiny...

Andrew Lewman authored 13 years ago

135)               # default to english version
136)               elsif (-e "$(DOCROOT)/$dir/en/$base.wml") {
137)               	printf '<li class="donate"><a '.$class.' href="%s">%s</a></li>'."\n",
138)                   stripDotSlashs("$(DOCROOT)/$dir/$base.html"), $calltoaction{$key};
139)               } else {
Andrew Lewman revert the pathing for lang

Andrew Lewman authored 13 years ago

140)                 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.";
Andrew Lewman first cut of the new, shiny...

Andrew Lewman authored 13 years ago

141)               }
hiromipaw Fix navigation active tab i...

hiromipaw authored 7 years ago

142)             }