# HG changeset patch # User Mike Becker # Date 1747829947 -7200 # Node ID 34abadbdd0e3d7788fc5f6b3f67140650cc60b6c # Parent 4ea722f9cb66ccce115bb171a0caee84356c7274 fix "what's new" not shown after redirects + do not show it when accessed via RSS diff -r 4ea722f9cb66 -r 34abadbdd0e3 src/main/kotlin/de/uapcore/lightpit/AbstractServlet.kt --- a/src/main/kotlin/de/uapcore/lightpit/AbstractServlet.kt Sun May 18 13:24:55 2025 +0200 +++ b/src/main/kotlin/de/uapcore/lightpit/AbstractServlet.kt Wed May 21 14:19:07 2025 +0200 @@ -83,6 +83,13 @@ } } + private fun forwardIfRequested(req: HttpServletRequest, resp: HttpServletResponse) { + val site = req.getAttribute(Constants.REQ_ATTR_JSP) + if (site != null) { + req.getRequestDispatcher(Constants.JSP_PATH_PREFIX + site + ".jsp").forward(req, resp) + } + } + private fun invokeMapping( mapping: Pair, req: HttpServletRequest, @@ -92,9 +99,10 @@ val params = mapping.first.obtainPathParameters(sanitizedRequestPath(req)) val method = mapping.second val authenticatedUser = req.remoteUser?.let(dao::findUserByName) - showWhatsNewPopup(authenticatedUser, req, dao) logger.trace("invoke {0}", method) method(HttpRequest(authenticatedUser, req, resp, params), dao) + showWhatsNewPopup(authenticatedUser, req, resp, dao) + forwardIfRequested(req, resp) } private fun sanitizedRequestPath(req: HttpServletRequest) = req.pathInfo ?: "/" @@ -213,8 +221,17 @@ } } - private fun showWhatsNewPopup(user: User?, req: HttpServletRequest, dao: DataAccessObject) { + private fun showWhatsNewPopup(user: User?, req: HttpServletRequest, resp: HttpServletResponse, dao: DataAccessObject) { + // don't show to anonymous users if (user == null) return + + // don't show if we aren't going to forward to the site JSP + if (req.getAttribute(Constants.REQ_ATTR_JSP) != "site") return + + // don't show for different sources + if (listOf("rss").contains(req.getParameter("source").orEmpty())) return + + // show the popup and remember that we've shown it logger.trace("show user with ID {0} what's new", user.id) val userKnowsUpdatesUntil = dao.untilWhenUserKnowsUpdates(user) if (userKnowsUpdatesUntil == null || userKnowsUpdatesUntil.before(SqlDate.valueOf(Constants.VERSION_DATE))) { diff -r 4ea722f9cb66 -r 34abadbdd0e3 src/main/kotlin/de/uapcore/lightpit/Constants.kt --- a/src/main/kotlin/de/uapcore/lightpit/Constants.kt Sun May 18 13:24:55 2025 +0200 +++ b/src/main/kotlin/de/uapcore/lightpit/Constants.kt Wed May 21 14:19:07 2025 +0200 @@ -26,6 +26,9 @@ package de.uapcore.lightpit object Constants { + /** + * A data in yyyy-mm-dd format to identify the release. + */ const val VERSION_DATE = "2025-05-18" /** @@ -54,6 +57,11 @@ const val CTX_ATTR_DB_DIALECT = "db-dialect" /** + * The name of the main JSP file the request has been forwarded to. + */ + const val REQ_ATTR_JSP = "jspFile" + + /** * Key for the request attribute containing the optional navigation menu. */ const val REQ_ATTR_NAVIGATION = "navMenu" diff -r 4ea722f9cb66 -r 34abadbdd0e3 src/main/kotlin/de/uapcore/lightpit/RequestMapping.kt --- a/src/main/kotlin/de/uapcore/lightpit/RequestMapping.kt Sun May 18 13:24:55 2025 +0200 +++ b/src/main/kotlin/de/uapcore/lightpit/RequestMapping.kt Wed May 21 14:19:07 2025 +0200 @@ -68,7 +68,8 @@ var contentPage = "" set(value) { field = value - request.setAttribute(Constants.REQ_ATTR_CONTENT_PAGE, jspPath(value)) + request.setAttribute(Constants.REQ_ATTR_CONTENT_PAGE, + Constants.JSP_PATH_PREFIX + value + ".jsp") } /** @@ -91,7 +92,7 @@ set(value) { field = value request.setAttribute(Constants.REQ_ATTR_STYLESHEET, - value.map { it.withExt(".css") } + value.map { "$it.css" } ) } @@ -104,7 +105,7 @@ set(value) { field = value request.setAttribute(Constants.REQ_ATTR_JAVASCRIPT, - value.withExt(".js") + "$value.js" ) } @@ -157,9 +158,6 @@ request.setAttribute(Constants.REQ_ATTR_BASE_HREF, baseHref) } - 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") - fun paramIndexed(prefix: String): Map = buildMap { for (name in request.parameterNames) { if (name.startsWith(prefix)) { @@ -203,7 +201,7 @@ } private fun forward(jsp: String) { - request.getRequestDispatcher(jspPath(jsp)).forward(request, response) + request.setAttribute(Constants.REQ_ATTR_JSP, jsp) } fun renderFeed(page: String? = null) { diff -r 4ea722f9cb66 -r 34abadbdd0e3 src/main/webapp/WEB-INF/jsp/issues-feed.jsp --- a/src/main/webapp/WEB-INF/jsp/issues-feed.jsp Sun May 18 13:24:55 2025 +0200 +++ b/src/main/webapp/WEB-INF/jsp/issues-feed.jsp Wed May 21 14:19:07 2025 +0200 @@ -34,8 +34,8 @@ <fmt:message key="feed.issues.title"/> - ${baseHref}issues/ + ${issueHref} ${pageContext.response.locale.language} @@ -77,7 +77,7 @@ - ${link} + ${link}?source=rss ${link}