[tor-commits] [check/master] Introduce some design changes.

arlo at torproject.org arlo at torproject.org
Thu Oct 10 19:32:13 UTC 2013


commit ec6b0a4fafc489ef930bd311db9b170447a20f21
Author: Arlo Breault <arlolra at gmail.com>
Date:   Thu Oct 3 11:58:47 2013 -0700

    Introduce some design changes.
    
    Mainly, adding the available languages to a header.
---
 handlers.go       |   20 +++-----------------
 public/base.html  |   35 +++++++++++++++++++++++++++++++----
 public/bulk.html  |    8 +++++---
 public/index.html |   36 ++++++++++++++++++++++++++----------
 utils.go          |   11 +++++++++++
 5 files changed, 76 insertions(+), 34 deletions(-)

diff --git a/handlers.go b/handlers.go
index 3a91087..57e82f8 100644
--- a/handlers.go
+++ b/handlers.go
@@ -19,12 +19,11 @@ var Locales = GetLocaleList()
 type Page struct {
 	IsTor       bool
 	UpToDate    bool
-	NotSmall    bool
+	Small       bool
 	Fingerprint string
 	OnOff       string
 	Lang        string
 	IP          string
-	Extra       string
 	Locales     map[string]string
 }
 
@@ -72,28 +71,15 @@ func RootHandler(Layout *template.Template, Exits *Exits, domain *gettext.Domain
 			onOff = "off"
 		}
 
-		small := Small(r)
-		upToDate := UpToDate(r)
-
-		// querystring params
-		extra := ""
-		if small {
-			extra += "&small=1"
-		}
-		if !upToDate {
-			extra += "&uptodate=0"
-		}
-
 		// instance of your page model
 		p := Page{
 			isTor,
-			isTor && !upToDate,
-			!small,
+			UpToDate(r),
+			Small(r),
 			fingerprint,
 			onOff,
 			Lang(r),
 			host,
-			extra,
 			Locales,
 		}
 
diff --git a/public/base.html b/public/base.html
index c3e3427..9b1c668 100644
--- a/public/base.html
+++ b/public/base.html
@@ -6,10 +6,12 @@
   <title>{{ template "title" . }}</title>
   <link rel="icon" type="image/x-icon" href="/torcheck/favicon.ico" />
   <style>
+    html { height: 100%; }
     body {
-    	text-align: center;
-    	font-family: Helvetica, sans-serif;
-    	margin: 2em 4em;
+      height: 100%;
+      text-align: center;
+      font-family: Helvetica, sans-serif;
+      margin: 0;
     }
     a { text-decoration: none; }
     a:hover { text-decoration: underline; }
@@ -42,9 +44,34 @@
       display: inline;
       margin-right: 0.4em;
     }
+    .content {
+      padding: 4em;
+    }
+    .foot {
+      padding: 2em 4em;
+    }
+    .head {
+      background-color: #85559f;
+      padding: 0.8em 0;
+      color: #fff;
+    }
+    .project {
+      margin: 0;
+      font-size: 0.8em;
+    }
+    .project a { color: #fff; }
   </style>
 </head>
 <body>
-  {{ template "body" . }}
+  <div class="head">
+    {{ template "head" . }}
+  </div>
+  <div class="content">
+    {{ template "body" . }}
+  </div>
+  <div class="foot">
+    {{ template "foot" . }}
+    <p class="project">The Tor Project is a US 501(c)(3) non-profit dedicated to the research, development, and education of online anonymity and privacy. <a href="https://www.torproject.org/about/overview.html.en">Learn More »</a></p>
+  </div>
 </body>
 </html>
\ No newline at end of file
diff --git a/public/bulk.html b/public/bulk.html
index d190d9e..4d3e793 100644
--- a/public/bulk.html
+++ b/public/bulk.html
@@ -1,9 +1,10 @@
 {{ template "base.html" . }}
 {{ define "lang" }}en{{ end }}
 {{ define "title" }}Bulk Tor Exit Exporter{{ end }}
+{{ define "head" }}{{ end }}
 {{ define "body" }}
-  <p><img src="/torcheck/img/tor-on.png" class="onion" /></p>
-  <p>Welcome to the Tor Bulk Exit List exporting tool.</p>
+  <img src="/torcheck/img/tor-on.png" class="onion" />
+  <h4>Welcome to the Tor Bulk Exit List exporting tool.</h4>
   <p>If you are a service provider and you wish to build a list of possible Tor nodes that might contact one of your servers, enter that single server address below. Giving you the whole list means you can query the list privately, rather than telling us your users' IP addresses. This list allows you to have a nearly real time authoritative source for Tor exits that allow contacting your server on port 80. We don't log the IP address that queries for a given list. If you'd like, you're free to run your own copy of this program. It's Free Software and can be downloaded from the <a href="https://gitweb.torproject.org/check.git">git repository</a>.</p>
 
   <form action="/cgi-bin/TorBulkExitList.py" name="ip">
@@ -20,4 +21,5 @@
     </div>
   </form>
 
-{{ end }}
\ No newline at end of file
+{{ end }}
+{{ define "foot" }}{{ end }}
\ No newline at end of file
diff --git a/public/index.html b/public/index.html
index 652f7ae..2c6adbe 100644
--- a/public/index.html
+++ b/public/index.html
@@ -1,9 +1,24 @@
 {{ template "base.html" . }}
 {{ define "lang" }}{{ .Lang }}{{ end }}
 {{ define "title" }}{{ GetText .Lang "Are you using Tor?" }}{{ end }}
+{{ define "head" }}
+<form action="/" method="get" id="lang">
+  {{ if .Small }}<input type="hidden" name="small" value="1" />{{ end }}
+  {{ if And .IsTor (Not .UpToDate) }}<input type="hidden" name="uptodate" value="0" />{{ end }}
+  <label for="lang" class="small">{{ GetText .Lang "This page is also available in the following languages:" }}</label>
+  <select name="lang" onchange="onChange()">
+    {{ $out := . }}
+      <option value="en_US">
+    {{ range $k, $i := .Locales }}
+      <option value="{{ $k }}" {{ if Equal $k $out.Lang }}selected="selected"{{ end }}>{{ $i | UnEscaped }}</option>
+    {{ end }}
+  </select>
+  <input type="submit" value="Go" />
+</form>
+{{ end }}
 {{ define "body" }}
-  {{ if .NotSmall }}
-    <p><img src="/torcheck/img/tor-{{ .OnOff }}.png" class="onion" /></p>
+  {{ if Not .Small }}
+    <img src="/torcheck/img/tor-{{ .OnOff }}.png" class="onion" />
   {{ end }}
   <h1 class="{{ .OnOff }}">
     {{ if .IsTor }}
@@ -13,7 +28,7 @@
     {{ end }}
   </h1>
   <p>{{ GetText .Lang "Your IP address appears to be: " }} <strong>{{ .IP }}</strong></p>
-  {{ if .UpToDate }}
+  {{ if And .IsTor (Not .UpToDate) }}
     <p class="security">
       {{ GetText .Lang "There is a security update available for the Tor Browser Bundle." }}<br />
       {{ GetText .Lang "<a href=\"https://www.torproject.org/download/download-easy.html\">Click here to go to the download page</a>" | UnEscaped }}
@@ -27,11 +42,12 @@
       {{ GetText .Lang "If you are attempting to use a Tor client, please refer to the <a href=\"https://www.torproject.org/\">Tor website</a> and specifically the <a href=\"https://www.torproject.org/docs/faq#DoesntWork\">instructions for configuring your Tor client</a>." | UnEscaped }}
     {{ end }}
   </p>
-  <p class="small">{{ GetText .Lang "This page is also available in the following languages:" }}</p>
-  <ul class="small">
-    {{ $out := . }}
-    {{ range $k, $i := .Locales }}
-      <li><a href="/?lang={{ $k }}{{ $out.Extra | UnEscapedURL }}">{{ $i | UnEscaped }}</a></li>
-    {{ end }}
-  </ul>
+{{ end }}
+{{ define "foot" }}
+<script>
+  function onChange() {
+    var form = document.getElementById("lang");
+    form.submit();
+  }
+</script>
 {{ end }}
\ No newline at end of file
diff --git a/utils.go b/utils.go
index 9d2667b..ef7be1d 100644
--- a/utils.go
+++ b/utils.go
@@ -59,6 +59,15 @@ func FuncMap(domain *gettext.Domain) template.FuncMap {
 		"GetText": func(lang string, text string) string {
 			return domain.GetText(lang, text)
 		},
+		"Equal": func(one string, two string) bool {
+			return one == two
+		},
+		"Not": func(b bool) bool {
+			return !b
+		},
+		"And": func(a bool, b bool) bool {
+			return a && b
+		},
 	}
 }
 
@@ -164,6 +173,8 @@ func GetInstalledLocales(webLocales map[string]locale, nameTranslations map[stri
 	}
 
 	locales := make(map[string]string, len(localFiles))
+	locales["en_US"] = "English"
+
 	for _, f := range localFiles {
 		// TODO: Ensure a language has 100% of the template file
 		// Currently this is what should be on the torcheck_completed



More information about the tor-commits mailing list