Sun, 01 Aug 2021 18:56:28 +0200
#115 adds custom page titles
--- a/src/main/kotlin/de/uapcore/lightpit/Constants.kt Sun Aug 01 18:14:36 2021 +0200 +++ b/src/main/kotlin/de/uapcore/lightpit/Constants.kt Sun Aug 01 18:56:28 2021 +0200 @@ -72,6 +72,11 @@ const val REQ_ATTR_PATH = "requestPath" /** + * Key for the optional custom page title. + */ + const val REQ_ATTR_PAGE_TITLE = "pageTitle" + + /** * Key for the name of the page which should be rendered. */ const val REQ_ATTR_CONTENT_PAGE = "contentPage"
--- a/src/main/kotlin/de/uapcore/lightpit/RequestMapping.kt Sun Aug 01 18:14:36 2021 +0200 +++ b/src/main/kotlin/de/uapcore/lightpit/RequestMapping.kt Sun Aug 01 18:56:28 2021 +0200 @@ -28,6 +28,7 @@ import de.uapcore.lightpit.dao.DataAccessObject import de.uapcore.lightpit.viewmodel.NavMenu import de.uapcore.lightpit.viewmodel.View +import java.util.* import javax.servlet.http.HttpServletRequest import javax.servlet.http.HttpServletResponse import javax.servlet.http.HttpSession @@ -57,6 +58,17 @@ } /** + * The name of the content page. + * + * @see Constants#REQ_ATTR_CONTENT_PAGE + */ + var pageTitle = "" + set(value) { + field = value + request.setAttribute(Constants.REQ_ATTR_PAGE_TITLE, value) + } + + /** * A list of additional style sheets. * * @see Constants#REQ_ATTR_STYLESHEET @@ -149,6 +161,8 @@ contentPage = Constants.JSP_COMMIT_SUCCESSFUL render() } + + fun i18n(key: String) = ResourceBundle.getBundle("localization/strings", response.locale).getString(key) } /**
--- a/src/main/kotlin/de/uapcore/lightpit/servlet/ProjectServlet.kt Sun Aug 01 18:14:36 2021 +0200 +++ b/src/main/kotlin/de/uapcore/lightpit/servlet/ProjectServlet.kt Sun Aug 01 18:56:28 2021 +0200 @@ -195,6 +195,7 @@ )).sortedWith(DEFAULT_ISSUE_SORTER) with(http) { + pageTitle = project.name view = ProjectDetails(projectInfo, issues, version, component) feedPath = feedPath(project) navigationMenu = activeProjectNavMenu( @@ -263,6 +264,7 @@ } with(http) { + pageTitle = "${projectInfo.project.name} - ${i18n("navmenu.versions")}" view = VersionsView( projectInfo, dao.listVersionSummaries(projectInfo.project) @@ -346,6 +348,7 @@ } with(http) { + pageTitle = "${projectInfo.project.name} - ${i18n("navmenu.components")}" view = ComponentsView( projectInfo, dao.listComponentSummaries(projectInfo.project) @@ -436,6 +439,7 @@ val comments = dao.listComments(issue) with(http) { + pageTitle = "${projectInfo.project.name}: #${issue.id} ${issue.subject}" view = IssueDetailView(issue, comments, project, version, component) // TODO: feed path for this particular issue feedPath = feedPath(projectInfo.project)
--- a/src/main/resources/localization/strings.properties Sun Aug 01 18:14:36 2021 +0200 +++ b/src/main/resources/localization/strings.properties Sun Aug 01 18:56:28 2021 +0200 @@ -24,7 +24,6 @@ app.changelog=Changelog app.license.title=License app.name=Lightweight Project and Issue Tracking -app.title=LightPIT button.cancel=Cancel button.comment=Comment button.component.create=New Component
--- a/src/main/webapp/WEB-INF/jsp/about.jsp Sun Aug 01 18:14:36 2021 +0200 +++ b/src/main/webapp/WEB-INF/jsp/about.jsp Sun Aug 01 18:56:28 2021 +0200 @@ -26,7 +26,7 @@ <%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> <%@taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %> -<h1><fmt:message key="app.title"/></h1> +<h1>LightPIT</h1> <fmt:message key="app.name"/>
--- a/src/main/webapp/WEB-INF/jsp/site.jsp Sun Aug 01 18:14:36 2021 +0200 +++ b/src/main/webapp/WEB-INF/jsp/site.jsp Sun Aug 01 18:56:28 2021 +0200 @@ -42,6 +42,9 @@ <%-- Define an alias for the navigation menu --%> <c:set scope="page" var="navMenu" value="${requestScope[Constants.REQ_ATTR_NAVIGATION]}"/> +<%-- Define an alias for the custom page title --%> +<c:set scope="page" var="pageTitle" value="${requestScope[Constants.REQ_ATTR_PAGE_TITLE]}"/> + <%-- Define an alias for the content page name --%> <c:set scope="page" var="contentPage" value="${requestScope[Constants.REQ_ATTR_CONTENT_PAGE]}"/> @@ -59,7 +62,10 @@ <html> <head> <base href="${baseHref}"> - <title><fmt:message key="app.title"/></title> + <title> + LightPIT + <c:if test="${not empty pageTitle}"> - <c:out value="${pageTitle}"/></c:if> + </title> <meta charset="UTF-8"> <c:if test="${not empty redirectLocation}"> <meta http-equiv="refresh" content="0; URL=${redirectLocation}">