# HG changeset patch # User Mike Becker # Date 1621088369 -7200 # Node ID 59393c8cc5573a0ed32a1de3767edd76c8f18e37 # Parent 94f174d591ab94abe227dd835456193709bd3ff1 #109 adds RSS feed button to project header and changes feed output slightly diff -r 94f174d591ab -r 59393c8cc557 src/main/kotlin/de/uapcore/lightpit/RequestMapping.kt --- a/src/main/kotlin/de/uapcore/lightpit/RequestMapping.kt Thu May 13 19:31:09 2021 +0200 +++ b/src/main/kotlin/de/uapcore/lightpit/RequestMapping.kt Sat May 15 16:19:29 2021 +0200 @@ -80,16 +80,24 @@ request.setAttribute(Constants.REQ_ATTR_NAVIGATION, navigationMenu) } - var redirectLocation = "" + var redirectLocation: String? = null set(value) { field = value - request.setAttribute(Constants.REQ_ATTR_REDIRECT_LOCATION, baseHref + value) + if (value == null) { + request.removeAttribute(Constants.REQ_ATTR_REDIRECT_LOCATION) + } else { + request.setAttribute(Constants.REQ_ATTR_REDIRECT_LOCATION, baseHref + value) + } } - var feedPath = "" + var feedPath: String? = null set(value) { field = value - request.setAttribute(Constants.REQ_ATTR_FEED_HREF, baseHref + value) + if (value == null) { + request.removeAttribute(Constants.REQ_ATTR_FEED_HREF) + } else { + request.setAttribute(Constants.REQ_ATTR_FEED_HREF, baseHref + value) + } } /** @@ -116,10 +124,6 @@ */ val baseHref get() = "${request.scheme}://${request.serverName}$portInfo${request.contextPath}/" - init { - feedPath = "feed/projects.rss" - } - private fun String.withExt(ext: String) = if (endsWith(ext)) this else plus(ext) private fun jspPath(name: String) = Constants.JSP_PATH_PREFIX.plus(name).withExt(".jsp") diff -r 94f174d591ab -r 59393c8cc557 src/main/kotlin/de/uapcore/lightpit/servlet/FeedServlet.kt --- a/src/main/kotlin/de/uapcore/lightpit/servlet/FeedServlet.kt Thu May 13 19:31:09 2021 +0200 +++ b/src/main/kotlin/de/uapcore/lightpit/servlet/FeedServlet.kt Sat May 15 16:19:29 2021 +0200 @@ -32,25 +32,15 @@ import de.uapcore.lightpit.util.IssueSorter import de.uapcore.lightpit.util.SpecificFilter import de.uapcore.lightpit.viewmodel.IssueFeed -import de.uapcore.lightpit.viewmodel.ProjectFeed import javax.servlet.annotation.WebServlet @WebServlet(urlPatterns = ["/feed/*"]) class FeedServlet : AbstractServlet() { init { - get("/projects.rss", this::projects) get("/%project/issues.rss", this::issues) } - private fun projects(http: HttpRequest, dao: DataAccessObject) { - - val projects = dao.listProjects() - - http.view = ProjectFeed(projects) - http.renderFeed("project-feed") - } - private fun issues(http: HttpRequest, dao: DataAccessObject) { val project = http.pathParams["project"]?.let { dao.findProjectByNode(it) } if (project == null) { @@ -58,6 +48,7 @@ return } + // TODO: add a timestamp filter (e.g. last 30 days) val issues = dao.listIssues(IssueFilter(SpecificFilter(project))).sortedWith(IssueSorter.DEFAULT_ISSUE_SORTER) http.view = IssueFeed(project, issues) diff -r 94f174d591ab -r 59393c8cc557 src/main/kotlin/de/uapcore/lightpit/viewmodel/Feeds.kt --- a/src/main/kotlin/de/uapcore/lightpit/viewmodel/Feeds.kt Thu May 13 19:31:09 2021 +0200 +++ b/src/main/kotlin/de/uapcore/lightpit/viewmodel/Feeds.kt Sat May 15 16:19:29 2021 +0200 @@ -27,12 +27,12 @@ import de.uapcore.lightpit.entities.Issue import de.uapcore.lightpit.entities.Project - -class ProjectFeed( - val projects: List -) : View() +import java.sql.Timestamp +import java.time.Instant class IssueFeed( val project: Project, val issues: List -) : View() \ No newline at end of file +) : View() { + val lastModified = issues.map(Issue::updated).maxOrNull() ?: Timestamp.from(Instant.now()) +} \ No newline at end of file diff -r 94f174d591ab -r 59393c8cc557 src/main/resources/localization/strings.properties --- a/src/main/resources/localization/strings.properties Thu May 13 19:31:09 2021 +0200 +++ b/src/main/resources/localization/strings.properties Sat May 15 16:19:29 2021 +0200 @@ -54,11 +54,11 @@ error.message = Server Message error.returnLink = Return to error.timestamp = Timestamp +feed.issues.created=Issue has been created. feed.issues.description=Feed about recently updated issues. feed.issues.title=LightPIT Issues -feed.projects.description=Feed about tracked projects. -feed.projects.source=Issues -feed.projects.title=LightPIT Projects +feed.issues.updated=Issue has been updated. +feed=Feed issue.affected-versions=Affected Versions issue.assignee=Assignee issue.category.Bug=Bug diff -r 94f174d591ab -r 59393c8cc557 src/main/resources/localization/strings_de.properties --- a/src/main/resources/localization/strings_de.properties Thu May 13 19:31:09 2021 +0200 +++ b/src/main/resources/localization/strings_de.properties Sat May 15 16:19:29 2021 +0200 @@ -54,11 +54,11 @@ error.message = Server Nachricht error.returnLink = Kehre zurück zu error.timestamp = Zeitstempel +feed=Feed +feed.issues.created=Vorgang wurde erstellt. feed.issues.description=Feed \u00fcber k\u00fcrzlich aktualisierte Vorg\u00e4nge. feed.issues.title=LightPIT Vorg\u00e4nge -feed.projects.description=Feed \u00fcber verwaltete Projekte. -feed.projects.source=Vorg\u00e4nge -feed.projects.title=LightPIT Projekte +feed.issues.updated=Vorgang wurde aktualisiert. issue.affected-versions=Betroffene Versionen issue.assignee=Zugewiesen issue.category.Bug=Fehler @@ -130,5 +130,5 @@ version.status.LTS=Langzeitsupport version.status.Released=Ver\u00f6ffentlicht version.status.Unreleased=Unver\u00f6ffentlicht -version.status=Status +version.status=Status version=Version diff -r 94f174d591ab -r 59393c8cc557 src/main/webapp/WEB-INF/jsp/issues-feed.jsp --- a/src/main/webapp/WEB-INF/jsp/issues-feed.jsp Thu May 13 19:31:09 2021 +0200 +++ b/src/main/webapp/WEB-INF/jsp/issues-feed.jsp Sat May 15 16:19:29 2021 +0200 @@ -22,7 +22,7 @@ ~ 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" pageEncoding="UTF-8" %> +<%@page contentType="application/rss+xml;charset=UTF-8" pageEncoding="UTF-8" trimDirectiveWhitespaces="true" %> <%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> <%@taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %> @@ -31,11 +31,20 @@ ${baseHref}projects/${viewmodel.project.node} ${pageContext.response.locale.language} + + <c:if test="${not empty issue.component}"><c:out value="${issue.component.name}"/> - </c:if><c:out value="${issue.subject}"/> - + + + + + + + + ${baseHref}projects/${issue.project.node}/issues/-/${empty issue.component ? '-' : issue.component.node}/${issue.id} ${baseHref}projects/${issue.project.node}/issues/-/-/${issue.id} diff -r 94f174d591ab -r 59393c8cc557 src/main/webapp/WEB-INF/jsp/project-feed.jsp --- a/src/main/webapp/WEB-INF/jsp/project-feed.jsp Thu May 13 19:31:09 2021 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,43 +0,0 @@ -<%-- - ~ 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" pageEncoding="UTF-8" %> -<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> -<%@taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %> - - - <fmt:message key="feed.projects.title"/> - - ${baseHref}projects/ - ${pageContext.response.locale.language} - - - - <c:out value="${project.name}"/> - - ${baseHref}projects/${project.node} - - - - diff -r 94f174d591ab -r 59393c8cc557 src/main/webapp/WEB-INF/jsp/site.jsp --- a/src/main/webapp/WEB-INF/jsp/site.jsp Thu May 13 19:31:09 2021 +0200 +++ b/src/main/webapp/WEB-INF/jsp/site.jsp Sat May 15 16:19:29 2021 +0200 @@ -65,26 +65,31 @@ - + + + - +