removes (now) unnecessary possibility to customize the main menu

Fri, 23 Oct 2020 12:38:20 +0200

author
Mike Becker <universe@uap-core.de>
date
Fri, 23 Oct 2020 12:38:20 +0200
changeset 145
6d2d69fd1c12
parent 144
7e06b75cf1b9
child 146
b0e83cab0bde

removes (now) unnecessary possibility to customize the main menu

src/main/java/de/uapcore/lightpit/AbstractLightPITServlet.java file | annotate | diff | comparison | revisions
src/main/java/de/uapcore/lightpit/Constants.java file | annotate | diff | comparison | revisions
src/main/java/de/uapcore/lightpit/MenuEntry.java file | annotate | diff | comparison | revisions
src/main/webapp/WEB-INF/jsp/site.jsp file | annotate | diff | comparison | revisions
src/main/webapp/WEB-INF/jspf/menu-entry.jspf file | annotate | diff | comparison | revisions
     1.1 --- a/src/main/java/de/uapcore/lightpit/AbstractLightPITServlet.java	Fri Oct 23 12:26:08 2020 +0200
     1.2 +++ b/src/main/java/de/uapcore/lightpit/AbstractLightPITServlet.java	Fri Oct 23 12:38:20 2020 +0200
     1.3 @@ -376,24 +376,6 @@
     1.4          }
     1.5      }
     1.6  
     1.7 -    private void forwardToFullView(HttpServletRequest req, HttpServletResponse resp)
     1.8 -            throws IOException, ServletException {
     1.9 -
    1.10 -        final String lightpitBundle = "localization.lightpit";
    1.11 -        final var mainMenu = List.of(
    1.12 -                new MenuEntry(new ResourceKey(lightpitBundle, "menu.projects"), "projects/"),
    1.13 -                new MenuEntry(new ResourceKey(lightpitBundle, "menu.users"), "teams/"),
    1.14 -                new MenuEntry(new ResourceKey(lightpitBundle, "menu.languages"), "language/")
    1.15 -        );
    1.16 -        for (var entry : mainMenu) {
    1.17 -            if (Functions.fullPath(req).startsWith("/" + entry.getPathName())) {
    1.18 -                entry.setActive(true);
    1.19 -            }
    1.20 -        }
    1.21 -        req.setAttribute(Constants.REQ_ATTR_MENU, mainMenu);
    1.22 -        req.getRequestDispatcher(SITE_JSP).forward(req, resp);
    1.23 -    }
    1.24 -
    1.25      private String sanitizeRequestPath(HttpServletRequest req) {
    1.26          return Optional.ofNullable(req.getPathInfo()).orElse("/");
    1.27      }
    1.28 @@ -412,7 +394,7 @@
    1.29              case NONE:
    1.30                  return;
    1.31              case HTML:
    1.32 -                forwardToFullView(req, resp);
    1.33 +                req.getRequestDispatcher(SITE_JSP).forward(req, resp);
    1.34                  return;
    1.35              // TODO: implement remaining response types
    1.36              default:
     2.1 --- a/src/main/java/de/uapcore/lightpit/Constants.java	Fri Oct 23 12:26:08 2020 +0200
     2.2 +++ b/src/main/java/de/uapcore/lightpit/Constants.java	Fri Oct 23 12:38:20 2020 +0200
     2.3 @@ -67,11 +67,6 @@
     2.4      public static final String REQ_ATTR_RESOURCE_BUNDLE = fqn(AbstractLightPITServlet.class, "bundleName");
     2.5  
     2.6      /**
     2.7 -     * Key for the request attribute containing the menu list.
     2.8 -     */
     2.9 -    public static final String REQ_ATTR_MENU = fqn(AbstractLightPITServlet.class, "mainMenu");
    2.10 -
    2.11 -    /**
    2.12       * Key for the request attribute containing the optional navigation menu jsp.
    2.13       */
    2.14      public static final String REQ_ATTR_NAVIGATION = fqn(AbstractLightPITServlet.class, "navMenu");
     3.1 --- a/src/main/java/de/uapcore/lightpit/MenuEntry.java	Fri Oct 23 12:26:08 2020 +0200
     3.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.3 @@ -1,78 +0,0 @@
     3.4 -/*
     3.5 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
     3.6 - *
     3.7 - * Copyright 2018 Mike Becker. All rights reserved.
     3.8 - *
     3.9 - * Redistribution and use in source and binary forms, with or without
    3.10 - * modification, are permitted provided that the following conditions are met:
    3.11 - *
    3.12 - *   1. Redistributions of source code must retain the above copyright
    3.13 - *      notice, this list of conditions and the following disclaimer.
    3.14 - *
    3.15 - *   2. Redistributions in binary form must reproduce the above copyright
    3.16 - *      notice, this list of conditions and the following disclaimer in the
    3.17 - *      documentation and/or other materials provided with the distribution.
    3.18 - *
    3.19 - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
    3.20 - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
    3.21 - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
    3.22 - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
    3.23 - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
    3.24 - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
    3.25 - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
    3.26 - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
    3.27 - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
    3.28 - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
    3.29 - * POSSIBILITY OF SUCH DAMAGE.
    3.30 - *
    3.31 - */
    3.32 -package de.uapcore.lightpit;
    3.33 -
    3.34 -public class MenuEntry {
    3.35 -
    3.36 -    /**
    3.37 -     * Resource key for the menu label.
    3.38 -     */
    3.39 -    private final ResourceKey resourceKey;
    3.40 -
    3.41 -    /**
    3.42 -     * Custom menu text.
    3.43 -     */
    3.44 -    private final String text;
    3.45 -
    3.46 -    /**
    3.47 -     * Path name of the module, linked by this menu entry.
    3.48 -     */
    3.49 -    private final String pathName;
    3.50 -
    3.51 -    /**
    3.52 -     * True if this menu entry is active.
    3.53 -     */
    3.54 -    private boolean active = false;
    3.55 -
    3.56 -    public MenuEntry(ResourceKey resourceKey, String pathName) {
    3.57 -        this.text = null;
    3.58 -        this.resourceKey = resourceKey;
    3.59 -        this.pathName = pathName;
    3.60 -    }
    3.61 -
    3.62 -    public ResourceKey getResourceKey() {
    3.63 -        return resourceKey;
    3.64 -    }
    3.65 -
    3.66 -    public String getText() {
    3.67 -        return text;
    3.68 -    }
    3.69 -
    3.70 -    public String getPathName() {
    3.71 -        return pathName;
    3.72 -    }
    3.73 -
    3.74 -    public boolean isActive() {
    3.75 -        return this.active;
    3.76 -    }
    3.77 -
    3.78 -    public void setActive(boolean active) {
    3.79 -        this.active = active;
    3.80 -    }
    3.81 -}
     4.1 --- a/src/main/webapp/WEB-INF/jsp/site.jsp	Fri Oct 23 12:26:08 2020 +0200
     4.2 +++ b/src/main/webapp/WEB-INF/jsp/site.jsp	Fri Oct 23 12:38:20 2020 +0200
     4.3 @@ -36,9 +36,6 @@
     4.4  <%-- Define an alias for the request path --%>
     4.5  <c:set scope="page" var="requestPath" value="${requestScope[Constants.REQ_ATTR_PATH]}"/>
     4.6  
     4.7 -<%-- Define an alias for the main menu --%>
     4.8 -<c:set scope="page" var="mainMenu" value="${requestScope[Constants.REQ_ATTR_MENU]}"/>
     4.9 -
    4.10  <%-- Define an alias for the navigation menu --%>
    4.11  <c:set scope="page" var="navMenu" value="${requestScope[Constants.REQ_ATTR_NAVIGATION]}"/>
    4.12  
    4.13 @@ -79,9 +76,21 @@
    4.14  </head>
    4.15  <body>
    4.16  <div id="mainMenu">
    4.17 -    <c:forEach var="menu" items="${mainMenu}">
    4.18 -        <%@include file="../jspf/menu-entry.jspf" %>
    4.19 -    </c:forEach>
    4.20 +    <div class="menuEntry" <c:if test="${fn:startsWith(requestPath, '/projects/')}">data-active</c:if> >
    4.21 +        <a href="projects/">
    4.22 +            <fmt:message bundle="${lightpit_bundle}" key="menu.projects"/>
    4.23 +        </a>
    4.24 +    </div>
    4.25 +    <div class="menuEntry" <c:if test="${fn:startsWith(requestPath, '/teams/')}">data-active</c:if> >
    4.26 +        <a href="teams/">
    4.27 +            <fmt:message bundle="${lightpit_bundle}" key="menu.users"/>
    4.28 +        </a>
    4.29 +    </div>
    4.30 +    <div class="menuEntry" <c:if test="${fn:startsWith(requestPath, '/language/')}">data-active</c:if> >
    4.31 +        <a href="language/">
    4.32 +            <fmt:message bundle="${lightpit_bundle}" key="menu.languages"/>
    4.33 +        </a>
    4.34 +    </div>
    4.35  </div>
    4.36  <div>
    4.37      <c:if test="${not empty navMenu}">
     5.1 --- a/src/main/webapp/WEB-INF/jspf/menu-entry.jspf	Fri Oct 23 12:26:08 2020 +0200
     5.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     5.3 @@ -1,13 +0,0 @@
     5.4 -<div class="menuEntry"
     5.5 -     <c:if test="${menu.active}">data-active</c:if> >
     5.6 -    <a href="${menu.pathName}">
     5.7 -        <c:if test="${empty menu.resourceKey}">
     5.8 -            <c:out value="${menu.text}"/>
     5.9 -        </c:if>
    5.10 -        <c:if test="${not empty menu.resourceKey}">
    5.11 -            <fmt:bundle basename="${menu.resourceKey.bundle}">
    5.12 -                <fmt:message key="${menu.resourceKey.key}"/>
    5.13 -            </fmt:bundle>
    5.14 -        </c:if>
    5.15 -    </a>
    5.16 -</div>
    5.17 \ No newline at end of file

mercurial