commit e60c138ed920cf60be509d10acf1bcafbd13b231 Author: Karsten Loesing karsten.loesing@gmx.net Date: Wed Dec 21 14:11:21 2016 +0100
Apply new design to error pages. --- website/etc/web.xml | 19 ++++- .../org/torproject/metrics/web/ErrorServlet.java | 31 ++++++++ website/web/WEB-INF/error.jsp | 92 +++++++++++----------- website/web/WEB-INF/footer.jsp | 13 --- 4 files changed, 90 insertions(+), 65 deletions(-)
diff --git a/website/etc/web.xml b/website/etc/web.xml index 7436906..6df2aa0 100644 --- a/website/etc/web.xml +++ b/website/etc/web.xml @@ -260,21 +260,32 @@ <welcome-file>index.html</welcome-file> </welcome-file-list>
+ <servlet> + <servlet-name>ErrorServlet</servlet-name> + <servlet-class> + org.torproject.metrics.web.ErrorServlet + </servlet-class> + </servlet> + <servlet-mapping> + <servlet-name>ErrorServlet</servlet-name> + <url-pattern>/error.html</url-pattern> + </servlet-mapping> + <error-page> <error-code>400</error-code> - <location>/WEB-INF/error.jsp</location> + <location>/error.html</location> </error-page> <error-page> <error-code>404</error-code> - <location>/WEB-INF/error.jsp</location> + <location>/error.html</location> </error-page> <error-page> <error-code>500</error-code> - <location>/WEB-INF/error.jsp</location> + <location>/error.html</location> </error-page> <error-page> <exception-type>java.lang.Throwable</exception-type> - <location>/WEB-INF/error.jsp</location> + <location>/error.html</location> </error-page>
<context-param> diff --git a/website/src/org/torproject/metrics/web/ErrorServlet.java b/website/src/org/torproject/metrics/web/ErrorServlet.java new file mode 100644 index 0000000..1e682ec --- /dev/null +++ b/website/src/org/torproject/metrics/web/ErrorServlet.java @@ -0,0 +1,31 @@ +/* Copyright 2016 The Tor Project + * See LICENSE for licensing information */ + +package org.torproject.metrics.web; + +import java.io.IOException; + +import javax.servlet.ServletException; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +public class ErrorServlet extends AnyServlet { + + private static final long serialVersionUID = 6850919895248020945L; + + @Override + public void init() throws ServletException { + super.init(); + } + + @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/error.jsp").forward(request, + response); + } +} + diff --git a/website/web/WEB-INF/error.jsp b/website/web/WEB-INF/error.jsp index 0574606..6a55f8d 100644 --- a/website/web/WEB-INF/error.jsp +++ b/website/web/WEB-INF/error.jsp @@ -1,51 +1,47 @@ <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> -<%@ page isErrorPage="true" %> -<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> -<html> -<head> - <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> - <div class="center"> - <div class="main-column"> -<h2><a href="/"><img src="images/metrics-wordmark-small.png" width="138" height="18" alt="Metrics wordmark"></a> — Error</h2> -<br> -<p> -Oops! Something went wrong here! We encountered a -<b> -<c:choose> -<c:when test="${pageContext.errorData.statusCode eq 400}"> -400 Bad Request -</c:when> -<c:when test="${pageContext.errorData.statusCode eq 404}"> -404 Not Found -</c:when> -<c:when test="${pageContext.errorData.statusCode eq 500}"> -500 Internal Server Error -</c:when> -<c:when test="${not empty pageContext.errorData.throwable}"> -${pageContext.exception} -</c:when> -<c:otherwise> -Unknown Error -</c:otherwise> -</c:choose> -</b> -when processing your request!</p> - -<p>Maybe start over from the <a href="/">home page</a>.</p> - -<p>If this problem persists, please -<a href="https://www.torproject.org/about/contact">let us know</a>!</p> +<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %> +<jsp:include page="top.jsp"> + <jsp:param name="pageTitle" value="${pageContext.errorData.statusCode} – Tor Metrics"/> +</jsp:include>
+ <div class="container"> + <ul class="breadcrumb"> + <li><a href="index.html">Home</a></li> + <li class="active">${pageContext.errorData.statusCode}</li> + </ul> </div> - </div> - <div class="bottom" id="bottom"> - <%@ include file="footer.jsp"%> - </div> -</body> -</html> + + <div class="container"> + <h1>Error</h1> + + <p> + Oops! Something went wrong here! We encountered a + <b> + <c:choose> + <c:when test="${pageContext.errorData.statusCode eq 400}"> + 400 Bad Request + </c:when> + <c:when test="${pageContext.errorData.statusCode eq 404}"> + 404 Not Found + </c:when> + <c:when test="${pageContext.errorData.statusCode eq 500}"> + 500 Internal Server Error + </c:when> + <c:when test="${not empty pageContext.errorData.throwable}"> + ${pageContext.exception} + </c:when> + <c:otherwise> + Unknown Error + </c:otherwise> + </c:choose> + </b> + when processing your request!</p> + + <p>Maybe start over from the <a href="index.html">home page</a>.</p> + + <p>If this problem persists, please <a href="about.html#contact">let us know</a>!</p> + + </div> + +<jsp:include page="bottom.jsp"/> + diff --git a/website/web/WEB-INF/footer.jsp b/website/web/WEB-INF/footer.jsp deleted file mode 100644 index cab9e7f..0000000 --- a/website/web/WEB-INF/footer.jsp +++ /dev/null @@ -1,13 +0,0 @@ - <p>This material is supported in part by the National Science - Foundation under Grant No. CNS-0959138. Any opinions, - finding, and conclusions or recommendations expressed in this - material are those of the author(s) and do not necessarily reflect - the views of the National Science Foundation.</p> - <p>"Tor" and the "Onion Logo" are <a href="https://www.torproject.org/docs/trademark-faq.html.en">registered trademarks</a> of The Tor Project, Inc.</p> - <p>Data on this site is freely available under a - <a href="http://creativecommons.org/publicdomain/zero/1.0/">CC0 no - copyright declaration</a>: To the extent possible under law, the Tor - Project has waived all copyright and related or neighboring rights - in the data. Graphs are licensed under a - <a href="http://creativecommons.org/licenses/by/3.0/us/">Creative - Commons Attribution 3.0 United States License</a>.</p>
tor-commits@lists.torproject.org