diff --git a/examples/nginx-contextpath/README.md b/examples/nginx-contextpath/README.md index 2a9b279..e4a190a 100644 --- a/examples/nginx-contextpath/README.md +++ b/examples/nginx-contextpath/README.md @@ -69,8 +69,8 @@ services: image: plantuml/plantuml-server:jetty container_name: plantuml-server environment: - - TZ="Europe/Berlin" - - BASE_URL="plantuml" + - TZ=Europe/Berlin + - BASE_URL=plantuml nginx: image: nginx:alpine @@ -78,7 +78,7 @@ services: ports: - "80:80" environment: - - TZ="Europe/Berlin" + - TZ=Europe/Berlin volumes: - ./nginx.conf:/etc/nginx/nginx.conf:ro ``` diff --git a/examples/nginx-contextpath/docker-compose.yml b/examples/nginx-contextpath/docker-compose.yml index f38afa4..86caa70 100644 --- a/examples/nginx-contextpath/docker-compose.yml +++ b/examples/nginx-contextpath/docker-compose.yml @@ -5,7 +5,7 @@ services: image: plantuml/plantuml-server:jetty container_name: plantuml-server environment: - - TZ="Europe/Berlin" + - TZ=Europe/Berlin - BASE_URL=plantuml nginx: @@ -14,6 +14,6 @@ services: ports: - "80:80" environment: - - TZ="Europe/Berlin" + - TZ=Europe/Berlin volumes: - ./nginx.conf:/etc/nginx/nginx.conf:ro diff --git a/examples/nginx-simple/README.md b/examples/nginx-simple/README.md index 5957a09..68c2614 100644 --- a/examples/nginx-simple/README.md +++ b/examples/nginx-simple/README.md @@ -64,7 +64,7 @@ services: image: plantuml/plantuml-server:jetty container_name: plantuml-server environment: - - TZ="Europe/Berlin" + - TZ=Europe/Berlin nginx: image: nginx:alpine @@ -72,7 +72,7 @@ services: ports: - "80:80" environment: - - TZ="Europe/Berlin" + - TZ=Europe/Berlin volumes: - ./nginx.conf:/etc/nginx/nginx.conf:ro ``` diff --git a/examples/nginx-simple/docker-compose.yml b/examples/nginx-simple/docker-compose.yml index b3b8367..1b541d8 100644 --- a/examples/nginx-simple/docker-compose.yml +++ b/examples/nginx-simple/docker-compose.yml @@ -5,7 +5,7 @@ services: image: plantuml/plantuml-server:jetty container_name: plantuml-server environment: - - TZ="Europe/Berlin" + - TZ=Europe/Berlin nginx: image: nginx:alpine @@ -13,6 +13,6 @@ services: ports: - "80:80" environment: - - TZ="Europe/Berlin" + - TZ=Europe/Berlin volumes: - ./nginx.conf:/etc/nginx/nginx.conf:ro diff --git a/src/main/java/net/sourceforge/plantuml/servlet/PlantUmlServlet.java b/src/main/java/net/sourceforge/plantuml/servlet/PlantUmlServlet.java index 8804eab..cd83b63 100644 --- a/src/main/java/net/sourceforge/plantuml/servlet/PlantUmlServlet.java +++ b/src/main/java/net/sourceforge/plantuml/servlet/PlantUmlServlet.java @@ -255,16 +255,16 @@ public class PlantUmlServlet extends HttpServlet { request.setAttribute("showSocialButtons", Configuration.get("SHOW_SOCIAL_BUTTONS")); request.setAttribute("showGithubRibbon", Configuration.get("SHOW_GITHUB_RIBBON")); // URL base - final String hostpath = getHostpath(request); - request.setAttribute("hostpath", hostpath); + final String contextpath = request.getContextPath(); + request.setAttribute("contextpath", contextpath); // image URLs final boolean hasImg = !text.isEmpty(); request.setAttribute("hasImg", hasImg); - request.setAttribute("imgurl", hostpath + "/png/" + index + encoded); - request.setAttribute("svgurl", hostpath + "/svg/" + index + encoded); - request.setAttribute("pdfurl", hostpath + "/pdf/" + index + encoded); - request.setAttribute("txturl", hostpath + "/txt/" + index + encoded); - request.setAttribute("mapurl", hostpath + "/map/" + index + encoded); + request.setAttribute("imgurl", contextpath + "/png/" + index + encoded); + request.setAttribute("svgurl", contextpath + "/svg/" + index + encoded); + request.setAttribute("pdfurl", contextpath + "/pdf/" + index + encoded); + request.setAttribute("txturl", contextpath + "/txt/" + index + encoded); + request.setAttribute("mapurl", contextpath + "/map/" + index + encoded); // map for diagram source if necessary final boolean hasMap = PlantumlUtils.hasCMapData(text); request.setAttribute("hasMap", hasMap); @@ -279,33 +279,6 @@ public class PlantUmlServlet extends HttpServlet { request.setAttribute("map", map); } - /** - * Get hostpath (URL base) from request. - * - * @param request http request - * - * @return hostpath - */ - private String getHostpath(final HttpServletRequest request) { - // port - String port = ""; - if ( - (request.getScheme() == "http" && request.getServerPort() != 80) - || - (request.getScheme() == "https" && request.getServerPort() != 443) - ) { - port = ":" + request.getServerPort(); - } - // scheme - String scheme = request.getScheme(); - final String forwardedProto = request.getHeader("x-forwarded-proto"); - if (forwardedProto != null && !forwardedProto.isEmpty()) { - scheme = forwardedProto; - } - // hostpath - return scheme + "://" + request.getServerName() + port + request.getContextPath(); - } - /** * Send redirect response to encoded uml text. * diff --git a/src/main/webapp/error.jsp b/src/main/webapp/error.jsp index 247ebbd..8743344 100644 --- a/src/main/webapp/error.jsp +++ b/src/main/webapp/error.jsp @@ -1,20 +1,7 @@ <%@ page isErrorPage="true" contentType="text/html; charset=utf-8" pageEncoding="utf-8" session="false" %> <% - String contextroot = request.getContextPath(); - String port = ""; - if ( - (request.getScheme() == "http" && request.getServerPort() != 80) - || - (request.getScheme() == "https" && request.getServerPort() != 443) - ) { - port = ":" + request.getServerPort(); - } - String scheme = request.getScheme(); - if (request.getHeader("x-forwarded-proto") != null && request.getHeader("x-forwarded-proto") != "") { - scheme = request.getHeader("x-forwarded-proto"); - } - String hostpath = scheme + "://" + request.getServerName() + port + contextroot; + String contextpath = request.getContextPath(); %> @@ -24,9 +11,9 @@ - - - + + + PlantUMLServer Error diff --git a/src/main/webapp/index.jsp b/src/main/webapp/index.jsp index 4006451..ae2d4ad 100644 --- a/src/main/webapp/index.jsp +++ b/src/main/webapp/index.jsp @@ -7,7 +7,7 @@ boolean showSocialButtons = (boolean)request.getAttribute("showSocialButtons"); boolean showGithubRibbon = (boolean)request.getAttribute("showGithubRibbon"); // URL base - String hostpath = request.getAttribute("hostpath").toString(); + String contextpath = request.getAttribute("contextpath").toString(); // image URLs boolean hasImg = (boolean)request.getAttribute("hasImg"); String imgurl = request.getAttribute("imgurl").toString(); @@ -27,20 +27,26 @@ - - - - - + + + + + PlantUMLServer @@ -58,7 +64,7 @@
<%-- CONTENT --%> -
+

  @@ -67,7 +73,7 @@


You can enter here a previously generated URL:

-
+


@@ -88,8 +94,12 @@ <%@ include file="resource/socialbuttons2.jspf" %> <% } %>

- PlantUML diagram - <%= map %> + <% if (!hasMap) { %> + PlantUML diagram + <% } else { %> + PlantUML diagram + <%= map %> + <% } %>

<% } %>