Thu, 13 May 2021 11:28:50 +0200
#109 - add RSS feed
--- a/src/main/kotlin/de/uapcore/lightpit/RequestMapping.kt Thu May 13 10:23:37 2021 +0200 +++ b/src/main/kotlin/de/uapcore/lightpit/RequestMapping.kt Thu May 13 11:28:50 2021 +0200 @@ -108,9 +108,13 @@ fun param(name: String): String? = request.getParameter(name) fun paramArray(name: String): Array<String> = request.getParameterValues(name) ?: emptyArray() + fun forward(jsp: String) { + request.getRequestDispatcher(jspPath(jsp)).forward(request, response) + } + fun render(page: String? = null) { page?.let { contentPage = it } - request.getRequestDispatcher(jspPath("site")).forward(request, response) + forward("site") } fun renderCommit(location: String? = null) {
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/main/kotlin/de/uapcore/lightpit/servlet/FeedServlet.kt Thu May 13 11:28:50 2021 +0200 @@ -0,0 +1,51 @@ +/* + * Copyright 2021 Mike Becker. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +package de.uapcore.lightpit.servlet + +import de.uapcore.lightpit.AbstractServlet +import de.uapcore.lightpit.HttpRequest +import de.uapcore.lightpit.dao.DataAccessObject +import de.uapcore.lightpit.entities.Issue +import de.uapcore.lightpit.util.IssueFilter +import de.uapcore.lightpit.util.IssueSorter +import de.uapcore.lightpit.viewmodel.IssueFeed +import javax.servlet.annotation.WebServlet + +@WebServlet(urlPatterns = ["/feed/*"]) +class FeedServlet : AbstractServlet() { + + init { + get("/issues.rss", this::issues) + } + + private fun issues(http: HttpRequest, dao: DataAccessObject) { + + val issues = dao.listIssues(IssueFilter()).sortedWith(IssueSorter.DEFAULT_ISSUE_SORTER) + + http.view = IssueFeed(issues.groupBy(Issue::project)) + http.forward("issues-feed") + } +} \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/main/kotlin/de/uapcore/lightpit/viewmodel/Feeds.kt Thu May 13 11:28:50 2021 +0200 @@ -0,0 +1,33 @@ +/* + * Copyright 2021 Mike Becker. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +package de.uapcore.lightpit.viewmodel + +import de.uapcore.lightpit.entities.Issue +import de.uapcore.lightpit.entities.Project + +class IssueFeed( + val issues: Map<Project, List<Issue>> +) : View() \ No newline at end of file
--- a/src/main/resources/localization/strings.properties Thu May 13 10:23:37 2021 +0200 +++ b/src/main/resources/localization/strings.properties Thu May 13 11:28:50 2021 +0200 @@ -126,4 +126,6 @@ version.status.Released=Released version.status.Unreleased=Unreleased version.status=Status -version=Version \ No newline at end of file +version=Version +feed.issues.title=LightPIT - Issues +feed.issues.description=Feed about recently updated issues. \ No newline at end of file
--- a/src/main/resources/localization/strings_de.properties Thu May 13 10:23:37 2021 +0200 +++ b/src/main/resources/localization/strings_de.properties Thu May 13 11:28:50 2021 +0200 @@ -99,7 +99,7 @@ no-users=Bislang wurden keine Entwickler hinterlegt. node.tooltip=Name, der zur Konstruktion der URL genutzt werden soll. node=Pfadname -ordinal.tooltip=Use to override lexicographic ordering.=\u00dcbersteuert die lexikographische Sortierung. +ordinal.tooltip=Use to override lexicographic ordering. \u00dcbersteuert die lexikographische Sortierung. ordinal=Sequenznummer placeholder.auto-assignee.tooltip=Weist, wenn m\u00f6glich, den Vorgang dem Leiter der Komponente. placeholder.auto-assignee=Automatisch @@ -127,3 +127,5 @@ version.status.Unreleased=Unver\u00f6ffentlicht version.status=Status version=Version +feed.issues.title=LightPIT - Vorg\u00e4nge +feed.issues.description=Feed \u00fcber k\u00fcrzlich aktualisierte Vorg\u00e4nge.
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/main/webapp/WEB-INF/jsp/issues-feed.jsp Thu May 13 11:28:50 2021 +0200 @@ -0,0 +1,60 @@ +<%-- + ~ Copyright 2021 Mike Becker. All rights reserved. + ~ + ~ Redistribution and use in source and binary forms, with or without + ~ modification, are permitted provided that the following conditions are met: + ~ + ~ 1. Redistributions of source code must retain the above copyright + ~ notice, this list of conditions and the following disclaimer. + ~ + ~ 2. Redistributions in binary form must reproduce the above copyright + ~ notice, this list of conditions and the following disclaimer in the + ~ documentation and/or other materials provided with the distribution. + ~ + ~ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + ~ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + ~ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + ~ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + ~ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + ~ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + ~ SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + ~ CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + ~ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + ~ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + --%> +<%@ page contentType="application/rss+xml;charset=UTF-8" trimDirectiveWhitespaces="true" %> +<%@page import="de.uapcore.lightpit.Constants" %> +<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> +<%@taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %> +<jsp:useBean id="viewmodel" type="de.uapcore.lightpit.viewmodel.IssueFeed" scope="request"/> +<c:set scope="page" var="baseHref" value="${requestScope[Constants.REQ_ATTR_BASE_HREF]}"/> +<fmt:setLocale scope="request" value="${pageContext.response.locale}"/> +<fmt:setBundle scope="request" basename="localization.strings"/> +<?xml version="1.0" encoding="utf-8"?> +<rss version="2.0"> + <c:forEach items="${viewmodel.issues}" var="feed"> + <c:set var="project" value="${feed.key}"/> + <c:set var="issues" value="${feed.value}"/> + <channel> + <title> + <fmt:message key="feed.issues.title"/> - <c:out value="${project.name}"/> + </title> + <link>${baseHref}projects/${project.node}/</link> + <description><fmt:message key="feed.issues.description"/></description> + <language>${pageContext.response.locale.language}</language> + + <c:forEach items="${issues}" var="issue"> + <item> + <title><c:if test="${not empty issue.component}"><c:out value="${issue.component.name}"/> - </c:if><c:out value="${issue.subject}"/></title> + <description> + <c:out value="${issue.description}"/> + </description> + <category><fmt:message key="issue.category.${issue.category}"/></category> + <link>${baseHref}projects/${issue.project.node}/issues/-/${empty issue.component ? '-' : issue.component.node}/${issue.id}</link> + <guid isPermaLink="true">${baseHref}projects/${issue.project.node}/issues/-/-/${issue.id}</guid> + <pubDate><fmt:formatDate value="${issue.updated}" pattern="EEE, dd MMM yyyy HH:mm:ss zzz" /></pubDate> + </item> + </c:forEach> + </channel> + </c:forEach> +</rss> \ No newline at end of file
--- a/src/main/webapp/WEB-INF/jsp/site.jsp Thu May 13 10:23:37 2021 +0200 +++ b/src/main/webapp/WEB-INF/jsp/site.jsp Thu May 13 11:28:50 2021 +0200 @@ -48,12 +48,8 @@ <%-- Define an alias for the additional stylesheet --%> <c:set scope="page" var="extraCss" value="${requestScope[Constants.REQ_ATTR_STYLESHEET]}"/> -<%-- Apply the session locale (should always be present, but check nevertheless) --%> -<c:if test="${not empty sessionScope[Constants.SESSION_ATTR_LANGUAGE]}"> - <fmt:setLocale scope="request" value="${sessionScope[Constants.SESSION_ATTR_LANGUAGE]}"/> -</c:if> - <%-- Load resource bundle --%> +<fmt:setLocale scope="request" value="${pageContext.response.locale}"/> <fmt:setBundle scope="request" basename="localization.strings"/> <!DOCTYPE html> @@ -66,6 +62,8 @@ <meta http-equiv="refresh" content="0; URL=${redirectLocation}"> </c:if> <link rel="stylesheet" href="lightpit.css" type="text/css"> + <link rel="alternate" type="application/rss+xml" + title="RSS" href="${baseHref}feed/issues.rss" /> <c:if test="${not empty extraCss}"> <c:forEach items="${extraCss}" var="cssFile"> <link rel="stylesheet" href="${cssFile}" type="text/css">