[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[tor-commits] [metrics-web/master] Add directory listing for /csv.
commit 4f6c4bc456fd2f35588722df161549f903eeafca
Author: Karsten Loesing <karsten.loesing@xxxxxxx>
Date: Tue Sep 13 17:29:58 2011 +0200
Add directory listing for /csv.
See https://metrics.torproject.org/csv/ .
---
src/org/torproject/ernie/web/CsvServlet.java | 16 +++++++++++++---
web/WEB-INF/dir.jsp | 25 +++++++++++++++++++++++++
2 files changed, 38 insertions(+), 3 deletions(-)
diff --git a/src/org/torproject/ernie/web/CsvServlet.java b/src/org/torproject/ernie/web/CsvServlet.java
index 99dc63c..01cdb28 100644
--- a/src/org/torproject/ernie/web/CsvServlet.java
+++ b/src/org/torproject/ernie/web/CsvServlet.java
@@ -18,7 +18,7 @@ public class CsvServlet extends HttpServlet {
private RObjectGenerator rObjectGenerator;
/* Available CSV files. */
- private Set<String> availableCsvFiles;
+ private SortedSet<String> availableCsvFiles;
private Logger logger;
@@ -28,7 +28,7 @@ public class CsvServlet extends HttpServlet {
this.logger = Logger.getLogger(CsvServlet.class.toString());
/* Initialize map of available CSV files. */
- this.availableCsvFiles = new HashSet<String>();
+ this.availableCsvFiles = new TreeSet<String>();
this.availableCsvFiles.add("bandwidth");
this.availableCsvFiles.add("bridge-users");
this.availableCsvFiles.add("bwhist-flags");
@@ -60,9 +60,19 @@ public class CsvServlet extends HttpServlet {
HttpServletResponse response) throws IOException,
ServletException {
+ /* Check if the directory listing was requested. */
+ String requestURI = request.getRequestURI();
+ if (requestURI.equals("/ernie/csv/")) {
+ request.setAttribute("directory", "/csv");
+ request.setAttribute("extension", ".csv");
+ request.setAttribute("files", this.availableCsvFiles);
+ request.getRequestDispatcher("/WEB-INF/dir.jsp").forward(request,
+ response);
+ return;
+ }
+
/* Find out which CSV file was requested and make sure we know this
* CSV file type. */
- String requestURI = request.getRequestURI();
String requestedCsvFile = requestURI;
if (requestedCsvFile.endsWith(".csv")) {
requestedCsvFile = requestedCsvFile.substring(0,
diff --git a/web/WEB-INF/dir.jsp b/web/WEB-INF/dir.jsp
new file mode 100644
index 0000000..1ac1819
--- /dev/null
+++ b/web/WEB-INF/dir.jsp
@@ -0,0 +1,25 @@
+<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+<html>
+<head>
+ <title>Tor Metrics Portal: Index of ${directory}</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="/images/favicon.ico" type="image/x-icon" rel="shortcut icon">
+</head>
+<body>
+ <div class="center">
+ <%@ include file="banner.jsp"%>
+ <div class="main-column">
+ <h2>Tor Metrics Portal: Index of ${directory}</h2>
+ <br>
+ <c:forEach var="file" items="${files}" >
+ <a href="${directory}/${file}${extension}">${file}${extension}</a><br>
+ </c:forEach>
+ </div>
+ </div>
+ <div class="bottom" id="bottom">
+ <%@ include file="footer.jsp"%>
+ </div>
+</body>
+</html>
_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits