[tor-commits] [metrics-web/master] Add another navigation bar to Metrics subpages.

karsten at torproject.org karsten at torproject.org
Mon Jan 9 17:03:42 UTC 2017


commit e09b16a25de6c574778ef3d1a1afdf5d2e3440f3
Author: Karsten Loesing <karsten.loesing at gmx.net>
Date:   Tue Dec 13 15:59:08 2016 +0100

    Add another navigation bar to Metrics subpages.
---
 website/etc/categories.json                         | 12 ++++++------
 .../org/torproject/metrics/web/GraphServlet.java    | 12 ++++++++++++
 .../org/torproject/metrics/web/IndexServlet.java    | 17 +++++++++++++++++
 website/web/WEB-INF/about.jsp                       |  1 +
 website/web/WEB-INF/bubbles.jsp                     |  1 +
 website/web/WEB-INF/data.jsp                        |  1 +
 website/web/WEB-INF/error.jsp                       |  1 +
 website/web/WEB-INF/graph.jsp                       |  7 ++++++-
 website/web/WEB-INF/index.jsp                       | 21 ++++++---------------
 website/web/WEB-INF/link.jsp                        |  1 +
 website/web/WEB-INF/research.jsp                    |  1 +
 website/web/WEB-INF/sources.jsp                     |  1 +
 website/web/WEB-INF/table.jsp                       |  3 ++-
 website/web/WEB-INF/tools.jsp                       |  1 +
 14 files changed, 57 insertions(+), 23 deletions(-)

diff --git a/website/etc/categories.json b/website/etc/categories.json
index 563b662..fe01905 100644
--- a/website/etc/categories.json
+++ b/website/etc/categories.json
@@ -2,7 +2,7 @@
   {
     "id": "clients",
     "header": "Users",
-    "description": "<p>Where are Tor users from? How do they connect to Tor?</p>",
+    "description": "Where are Tor users from? How do they connect to Tor?",
     "metrics": [
       "userstats-relay-country",
       "userstats-bridge-country",
@@ -17,7 +17,7 @@
   {
     "id": "servers",
     "header": "Relays and Bridges",
-    "description": "<p>How many relays and bridges are online? What do we know about them?</p>",
+    "description": "How many relays and bridges are online? What do we know about them?",
     "metrics": [
       "networksize",
       "relayflags",
@@ -28,7 +28,7 @@
   {
     "id": "traffic",
     "header": "Traffic",
-    "description": "<p>How much traffic can the Tor network handle? How much traffic is there?</p>",
+    "description": "How much traffic can the Tor network handle? How much traffic is there?",
     "metrics": [
       "bandwidth",
       "bandwidth-flags",
@@ -41,7 +41,7 @@
   {
     "id": "performance",
     "header": "Performance",
-    "description": "<p>How fast and reliable is the Tor network?</p>",
+    "description": "How fast and reliable is the Tor network?",
     "metrics": [
       "torperf",
       "torperf-failures",
@@ -51,7 +51,7 @@
   {
     "id": "onion-services",
     "header": "Onion Services",
-    "description": "<p>How many onion services are there? How much traffic do they pull?</p>",
+    "description": "How many onion services are there? How much traffic do they pull?",
     "metrics": [
       "hidserv-dir-onions-seen",
       "hidserv-rend-relayed-cells",
@@ -61,7 +61,7 @@
   {
     "id": "downloads",
     "header": "Downloads (coming soon)",
-    "description": "<p>How many downloads of Tor applications are there? How many updates?</p>",
+    "description": "How many downloads of Tor applications are there? How many updates?",
     "metrics": []
   }
 ]
diff --git a/website/src/org/torproject/metrics/web/GraphServlet.java b/website/src/org/torproject/metrics/web/GraphServlet.java
index 3a73fa5..5e90499 100644
--- a/website/src/org/torproject/metrics/web/GraphServlet.java
+++ b/website/src/org/torproject/metrics/web/GraphServlet.java
@@ -134,6 +134,18 @@ public class GraphServlet extends MetricServlet {
       response.sendError(HttpServletResponse.SC_BAD_REQUEST);
       return;
     }
+    List<String[]> categories = new ArrayList<String[]>();
+    for (Category category :
+        ContentProvider.getInstance().getCategoriesList()) {
+      if (category.getMetrics().isEmpty()
+          || this.categories.get(requestedId).equals(category)) {
+        categories.add(new String[] { "", category.getHeader() });
+      } else {
+        categories.add(new String[] { category.getMetrics().get(0),
+            category.getHeader() });
+      }
+    }
+    request.setAttribute("categories", categories);
     request.setAttribute("id", requestedId);
     request.setAttribute("title", this.titles.get(requestedId));
     if (this.categories.containsKey(requestedId)) {
diff --git a/website/src/org/torproject/metrics/web/IndexServlet.java b/website/src/org/torproject/metrics/web/IndexServlet.java
index f365cbb..be4134b 100644
--- a/website/src/org/torproject/metrics/web/IndexServlet.java
+++ b/website/src/org/torproject/metrics/web/IndexServlet.java
@@ -4,6 +4,8 @@
 package org.torproject.metrics.web;
 
 import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
 
 import javax.servlet.ServletException;
 import javax.servlet.http.HttpServlet;
@@ -14,11 +16,26 @@ public class IndexServlet extends HttpServlet {
 
   private static final long serialVersionUID = -5156539049907533057L;
 
+  protected List<String[]> categories;
+
+  @Override
+  public void init() throws ServletException {
+    List<String[]> categories = new ArrayList<String[]>();
+    for (Category category :
+        ContentProvider.getInstance().getCategoriesList()) {
+      categories.add(new String[] {
+          category.getMetrics().isEmpty() ? "" : category.getMetrics().get(0),
+          category.getHeader(), category.getDescription() });
+    }
+    this.categories = categories;
+  }
+
   @Override
   public void doGet(HttpServletRequest request,
       HttpServletResponse response) throws IOException, ServletException {
 
     /* Forward the request to the JSP that does all the hard work. */
+    request.setAttribute("categories", this.categories);
     request.getRequestDispatcher("WEB-INF/index.jsp").forward(request,
         response);
   }
diff --git a/website/web/WEB-INF/about.jsp b/website/web/WEB-INF/about.jsp
index a067674..c169969 100644
--- a/website/web/WEB-INF/about.jsp
+++ b/website/web/WEB-INF/about.jsp
@@ -4,6 +4,7 @@
   <title>Tor Metrics</title>
   <meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
   <link href="css/stylesheet-ltr.css" type="text/css" rel="stylesheet">
+  <link href="css/bootstrap.min.css" type="text/css" rel="stylesheet">
   <link href="images/favicon.ico" type="image/x-icon" rel="shortcut icon">
 </head>
 <body>
diff --git a/website/web/WEB-INF/bubbles.jsp b/website/web/WEB-INF/bubbles.jsp
index 1fedbeb..9edc575 100644
--- a/website/web/WEB-INF/bubbles.jsp
+++ b/website/web/WEB-INF/bubbles.jsp
@@ -5,6 +5,7 @@
   <title>Tor Metrics — Network bubble graphs</title>
   <meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
   <link href="css/stylesheet-ltr.css" type="text/css" rel="stylesheet">
+  <link href="css/bootstrap.min.css" type="text/css" rel="stylesheet">
   <link href="images/favicon.ico" type="image/x-icon" rel="shortcut icon">
   <script src="js/d3.min.js"></script>
   <script src="js/bubbles.js"></script>
diff --git a/website/web/WEB-INF/data.jsp b/website/web/WEB-INF/data.jsp
index d75f4d7..0c86fd7 100644
--- a/website/web/WEB-INF/data.jsp
+++ b/website/web/WEB-INF/data.jsp
@@ -6,6 +6,7 @@
   <title>Tor Metrics — ${title}</title>
   <meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
   <link href="css/stylesheet-ltr.css" type="text/css" rel="stylesheet">
+  <link href="css/bootstrap.min.css" type="text/css" rel="stylesheet">
   <link href="images/favicon.ico" type="image/x-icon" rel="shortcut icon">
 </head>
 <body>
diff --git a/website/web/WEB-INF/error.jsp b/website/web/WEB-INF/error.jsp
index 8081f49..0574606 100644
--- a/website/web/WEB-INF/error.jsp
+++ b/website/web/WEB-INF/error.jsp
@@ -6,6 +6,7 @@
   <title>Tor Metrics — Error</title>
   <meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
   <link href="css/stylesheet-ltr.css" type="text/css" rel="stylesheet">
+  <link href="css/bootstrap.min.css" type="text/css" rel="stylesheet">
   <link href="images/favicon.ico" type="image/x-icon" rel="shortcut icon">
 </head>
 <body>
diff --git a/website/web/WEB-INF/graph.jsp b/website/web/WEB-INF/graph.jsp
index 2ce9583..aab373a 100644
--- a/website/web/WEB-INF/graph.jsp
+++ b/website/web/WEB-INF/graph.jsp
@@ -6,6 +6,7 @@
   <title>Tor Metrics — ${title}</title>
   <meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
   <link href="css/stylesheet-ltr.css" type="text/css" rel="stylesheet">
+  <link href="css/bootstrap.min.css" type="text/css" rel="stylesheet">
   <link href="images/favicon.ico" type="image/x-icon" rel="shortcut icon">
 </head>
 <body>
@@ -30,9 +31,13 @@ of data, rather than just dogma or perspective."
         <br>
         <!-- Navigation end -->
 
+<c:forEach var="category" items="${categories}"><c:if test="${fn:length(category[0]) > 0}"><a href="${category[0]}.html"></c:if>${category[1]}<c:if test="${fn:length(category[0]) > 0}"></a></c:if> |
+</c:forEach>
+<br>
+
 <h2>${categoryHeader}</h2>
 
-${categoryDescription}
+<p>${categoryDescription}</p>
 
 <c:forEach var="tab" items="${categoryTabs}">
 <c:if test="${fn:length(tab[1]) > 0}"><a href="${tab[1]}.html"></c:if>${tab[0]}<c:if test="${fn:length(tab[1]) > 0}"></a></c:if> |
diff --git a/website/web/WEB-INF/index.jsp b/website/web/WEB-INF/index.jsp
index ad4b79f..2101f5f 100644
--- a/website/web/WEB-INF/index.jsp
+++ b/website/web/WEB-INF/index.jsp
@@ -6,6 +6,7 @@
   <title>Tor Metrics</title>
   <meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
   <link href="css/stylesheet-ltr.css" type="text/css" rel="stylesheet">
+  <link href="css/bootstrap.min.css" type="text/css" rel="stylesheet">
   <link href="images/favicon.ico" type="image/x-icon" rel="shortcut icon">
 </head>
 <body>
@@ -33,23 +34,13 @@ of data, rather than just dogma or perspective."
         <p>Welcome! What would you like to know about the Tor network?</p>
 
 <div>
-<a href="userstats-relay-country.html"><h3>Users</h3></a>
-<p>Where are Tor users from? How do they connect to Tor?</p>
 
-<a href="networksize.html"><h3>Relays and Bridges</h3></a>
-<p>How many relays and bridges are online? What do we know about them?</p>
+<c:forEach var="category" items="${categories}">
+<c:if test="${fn:length(category[0]) > 0}"><a href="${category[0]}.html"></c:if><h3>${category[1]}</h3><c:if test="${fn:length(category[0]) > 0}"></a></c:if>
+<p>${category[2]}</p>
+</c:forEach>
+<br>
 
-<a href="bandwidth.html"><h3>Traffic</h3></a>
-<p>How much traffic can the Tor network handle? How much traffic is there?</p>
-
-<a href="torperf.html"><h3>Performance</h3></a>
-<p>How fast and reliable is the Tor network?</p>
-
-<a href="hidserv-dir-onions-seen.html"><h3>Onion Services</h3></a>
-<p>How many onion services are there? How much traffic do they pull?</p>
-
-<h3>Downloads (coming soon)</h3>
-<p>How many downloads of Tor applications are there? How many updates?</p>
 </div>
 
 <p>Let us know if we're missing anything, or if we should measure something
diff --git a/website/web/WEB-INF/link.jsp b/website/web/WEB-INF/link.jsp
index 15a9234..08f7d7b 100644
--- a/website/web/WEB-INF/link.jsp
+++ b/website/web/WEB-INF/link.jsp
@@ -6,6 +6,7 @@
   <title>Tor Metrics — ${title}</title>
   <meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
   <link href="css/stylesheet-ltr.css" type="text/css" rel="stylesheet">
+  <link href="css/bootstrap.min.css" type="text/css" rel="stylesheet">
   <link href="images/favicon.ico" type="image/x-icon" rel="shortcut icon">
 </head>
 <body>
diff --git a/website/web/WEB-INF/research.jsp b/website/web/WEB-INF/research.jsp
index 648fdab..52fd50e 100644
--- a/website/web/WEB-INF/research.jsp
+++ b/website/web/WEB-INF/research.jsp
@@ -6,6 +6,7 @@
   <title>Tor Metrics</title>
   <meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
   <link href="css/stylesheet-ltr.css" type="text/css" rel="stylesheet">
+  <link href="css/bootstrap.min.css" type="text/css" rel="stylesheet">
   <link href="images/favicon.ico" type="image/x-icon" rel="shortcut icon">
 </head>
 <body>
diff --git a/website/web/WEB-INF/sources.jsp b/website/web/WEB-INF/sources.jsp
index 900bcb2..dc53c52 100644
--- a/website/web/WEB-INF/sources.jsp
+++ b/website/web/WEB-INF/sources.jsp
@@ -6,6 +6,7 @@
   <title>Tor Metrics</title>
   <meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
   <link href="css/stylesheet-ltr.css" type="text/css" rel="stylesheet">
+  <link href="css/bootstrap.min.css" type="text/css" rel="stylesheet">
   <link href="images/favicon.ico" type="image/x-icon" rel="shortcut icon">
 </head>
 <body>
diff --git a/website/web/WEB-INF/table.jsp b/website/web/WEB-INF/table.jsp
index ffabd75..eece114 100644
--- a/website/web/WEB-INF/table.jsp
+++ b/website/web/WEB-INF/table.jsp
@@ -6,6 +6,7 @@
   <title>Tor Metrics — ${title}</title>
   <meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
   <link href="css/stylesheet-ltr.css" type="text/css" rel="stylesheet">
+  <link href="css/bootstrap.min.css" type="text/css" rel="stylesheet">
   <link href="images/favicon.ico" type="image/x-icon" rel="shortcut icon">
 </head>
 <body>
@@ -32,7 +33,7 @@ of data, rather than just dogma or perspective."
 
 <h2>${categoryHeader}</h2>
 
-${categoryDescription}
+<p>${categoryDescription}</p>
 
 <c:forEach var="tab" items="${categoryTabs}">
 <c:if test="${fn:length(tab[1]) > 0}"><a href="${tab[1]}.html"></c:if>${tab[0]}<c:if test="${fn:length(tab[1]) > 0}"></a></c:if> |
diff --git a/website/web/WEB-INF/tools.jsp b/website/web/WEB-INF/tools.jsp
index f27ece2..d935989 100644
--- a/website/web/WEB-INF/tools.jsp
+++ b/website/web/WEB-INF/tools.jsp
@@ -6,6 +6,7 @@
   <title>Tor Metrics</title>
   <meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
   <link href="css/stylesheet-ltr.css" type="text/css" rel="stylesheet">
+  <link href="css/bootstrap.min.css" type="text/css" rel="stylesheet">
   <link href="images/favicon.ico" type="image/x-icon" rel="shortcut icon">
 </head>
 <body>





More information about the tor-commits mailing list