adds possibility to specify multiple additional CSS files

Fri, 18 Dec 2020 15:54:39 +0100

author
Mike Becker <universe@uap-core.de>
date
Fri, 18 Dec 2020 15:54:39 +0100
changeset 163
a5b9632729b6
parent 162
2adc8623dd89
child 164
003b08bb3f25

adds possibility to specify multiple additional CSS files

src/main/java/de/uapcore/lightpit/AbstractLightPITServlet.java file | annotate | diff | comparison | revisions
src/main/webapp/WEB-INF/jsp/site.jsp file | annotate | diff | comparison | revisions
     1.1 --- a/src/main/java/de/uapcore/lightpit/AbstractLightPITServlet.java	Sat Dec 05 13:05:00 2020 +0100
     1.2 +++ b/src/main/java/de/uapcore/lightpit/AbstractLightPITServlet.java	Fri Dec 18 15:54:39 2020 +0100
     1.3 @@ -44,6 +44,7 @@
     1.4  import java.sql.SQLException;
     1.5  import java.util.*;
     1.6  import java.util.function.Function;
     1.7 +import java.util.stream.Collectors;
     1.8  
     1.9  /**
    1.10   * A special implementation of a HTTPServlet which is focused on implementing
    1.11 @@ -265,19 +266,19 @@
    1.12      }
    1.13  
    1.14      /**
    1.15 -     * Specifies the name of an additional stylesheet used by the module.
    1.16 -     * <p>
    1.17 -     * Setting an additional stylesheet is optional, but quite common for HTML
    1.18 -     * output.
    1.19 +     * Specifies the names of additional stylesheets used by this Servlet.
    1.20       * <p>
    1.21       * It is sufficient to specify the name without any extension. The extension
    1.22       * is added automatically if not specified.
    1.23       *
    1.24 -     * @param req        the servlet request object
    1.25 -     * @param stylesheet the name of the stylesheet
    1.26 +     * @param req         the servlet request object
    1.27 +     * @param stylesheets the names of the stylesheets
    1.28       */
    1.29 -    public void setStylesheet(HttpServletRequest req, String stylesheet) {
    1.30 -        req.setAttribute(Constants.REQ_ATTR_STYLESHEET, enforceExt(stylesheet, ".css"));
    1.31 +    public void setStylesheet(HttpServletRequest req, String ... stylesheets) {
    1.32 +        req.setAttribute(Constants.REQ_ATTR_STYLESHEET, Arrays
    1.33 +                .stream(stylesheets)
    1.34 +                .map(s -> enforceExt(s, ".css"))
    1.35 +                .collect(Collectors.toUnmodifiableList()));
    1.36      }
    1.37  
    1.38      /**
     2.1 --- a/src/main/webapp/WEB-INF/jsp/site.jsp	Sat Dec 05 13:05:00 2020 +0100
     2.2 +++ b/src/main/webapp/WEB-INF/jsp/site.jsp	Fri Dec 18 15:54:39 2020 +0100
     2.3 @@ -71,7 +71,9 @@
     2.4      </c:if>
     2.5      <link rel="stylesheet" href="lightpit.css" type="text/css">
     2.6      <c:if test="${not empty extraCss}">
     2.7 -        <link rel="stylesheet" href="${extraCss}" type="text/css">
     2.8 +        <c:forEach items="${extraCss}" var="cssFile">
     2.9 +        <link rel="stylesheet" href="${cssFile}" type="text/css">
    2.10 +        </c:forEach>
    2.11      </c:if>
    2.12  </head>
    2.13  <body>

mercurial