# HG changeset patch # User Mike Becker # Date 1627836988 -7200 # Node ID 7725a79416f32d927c22d9e702789ecd56581e48 # Parent 54c612612c69db4a68bd52cc4346cec6a80f649c #115 adds custom page titles diff -r 54c612612c69 -r 7725a79416f3 src/main/kotlin/de/uapcore/lightpit/Constants.kt --- 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" diff -r 54c612612c69 -r 7725a79416f3 src/main/kotlin/de/uapcore/lightpit/RequestMapping.kt --- 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) } /** diff -r 54c612612c69 -r 7725a79416f3 src/main/kotlin/de/uapcore/lightpit/servlet/ProjectServlet.kt --- 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) diff -r 54c612612c69 -r 7725a79416f3 src/main/resources/localization/strings.properties --- 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 diff -r 54c612612c69 -r 7725a79416f3 src/main/webapp/WEB-INF/jsp/about.jsp --- 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" %> -

+

LightPIT

diff -r 54c612612c69 -r 7725a79416f3 src/main/webapp/WEB-INF/jsp/site.jsp --- 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 --%> +<%-- Define an alias for the custom page title --%> + + <%-- Define an alias for the content page name --%> @@ -59,7 +62,10 @@ - <fmt:message key="app.title"/> + + LightPIT + <c:if test="${not empty pageTitle}"> - <c:out value="${pageTitle}"/></c:if> +