Sun, 01 Aug 2021 18:56:28 +0200
#115 adds custom page titles
1.1 --- a/src/main/kotlin/de/uapcore/lightpit/Constants.kt Sun Aug 01 18:14:36 2021 +0200 1.2 +++ b/src/main/kotlin/de/uapcore/lightpit/Constants.kt Sun Aug 01 18:56:28 2021 +0200 1.3 @@ -72,6 +72,11 @@ 1.4 const val REQ_ATTR_PATH = "requestPath" 1.5 1.6 /** 1.7 + * Key for the optional custom page title. 1.8 + */ 1.9 + const val REQ_ATTR_PAGE_TITLE = "pageTitle" 1.10 + 1.11 + /** 1.12 * Key for the name of the page which should be rendered. 1.13 */ 1.14 const val REQ_ATTR_CONTENT_PAGE = "contentPage"
2.1 --- a/src/main/kotlin/de/uapcore/lightpit/RequestMapping.kt Sun Aug 01 18:14:36 2021 +0200 2.2 +++ b/src/main/kotlin/de/uapcore/lightpit/RequestMapping.kt Sun Aug 01 18:56:28 2021 +0200 2.3 @@ -28,6 +28,7 @@ 2.4 import de.uapcore.lightpit.dao.DataAccessObject 2.5 import de.uapcore.lightpit.viewmodel.NavMenu 2.6 import de.uapcore.lightpit.viewmodel.View 2.7 +import java.util.* 2.8 import javax.servlet.http.HttpServletRequest 2.9 import javax.servlet.http.HttpServletResponse 2.10 import javax.servlet.http.HttpSession 2.11 @@ -57,6 +58,17 @@ 2.12 } 2.13 2.14 /** 2.15 + * The name of the content page. 2.16 + * 2.17 + * @see Constants#REQ_ATTR_CONTENT_PAGE 2.18 + */ 2.19 + var pageTitle = "" 2.20 + set(value) { 2.21 + field = value 2.22 + request.setAttribute(Constants.REQ_ATTR_PAGE_TITLE, value) 2.23 + } 2.24 + 2.25 + /** 2.26 * A list of additional style sheets. 2.27 * 2.28 * @see Constants#REQ_ATTR_STYLESHEET 2.29 @@ -149,6 +161,8 @@ 2.30 contentPage = Constants.JSP_COMMIT_SUCCESSFUL 2.31 render() 2.32 } 2.33 + 2.34 + fun i18n(key: String) = ResourceBundle.getBundle("localization/strings", response.locale).getString(key) 2.35 } 2.36 2.37 /**
3.1 --- a/src/main/kotlin/de/uapcore/lightpit/servlet/ProjectServlet.kt Sun Aug 01 18:14:36 2021 +0200 3.2 +++ b/src/main/kotlin/de/uapcore/lightpit/servlet/ProjectServlet.kt Sun Aug 01 18:56:28 2021 +0200 3.3 @@ -195,6 +195,7 @@ 3.4 )).sortedWith(DEFAULT_ISSUE_SORTER) 3.5 3.6 with(http) { 3.7 + pageTitle = project.name 3.8 view = ProjectDetails(projectInfo, issues, version, component) 3.9 feedPath = feedPath(project) 3.10 navigationMenu = activeProjectNavMenu( 3.11 @@ -263,6 +264,7 @@ 3.12 } 3.13 3.14 with(http) { 3.15 + pageTitle = "${projectInfo.project.name} - ${i18n("navmenu.versions")}" 3.16 view = VersionsView( 3.17 projectInfo, 3.18 dao.listVersionSummaries(projectInfo.project) 3.19 @@ -346,6 +348,7 @@ 3.20 } 3.21 3.22 with(http) { 3.23 + pageTitle = "${projectInfo.project.name} - ${i18n("navmenu.components")}" 3.24 view = ComponentsView( 3.25 projectInfo, 3.26 dao.listComponentSummaries(projectInfo.project) 3.27 @@ -436,6 +439,7 @@ 3.28 val comments = dao.listComments(issue) 3.29 3.30 with(http) { 3.31 + pageTitle = "${projectInfo.project.name}: #${issue.id} ${issue.subject}" 3.32 view = IssueDetailView(issue, comments, project, version, component) 3.33 // TODO: feed path for this particular issue 3.34 feedPath = feedPath(projectInfo.project)
4.1 --- a/src/main/resources/localization/strings.properties Sun Aug 01 18:14:36 2021 +0200 4.2 +++ b/src/main/resources/localization/strings.properties Sun Aug 01 18:56:28 2021 +0200 4.3 @@ -24,7 +24,6 @@ 4.4 app.changelog=Changelog 4.5 app.license.title=License 4.6 app.name=Lightweight Project and Issue Tracking 4.7 -app.title=LightPIT 4.8 button.cancel=Cancel 4.9 button.comment=Comment 4.10 button.component.create=New Component
5.1 --- a/src/main/webapp/WEB-INF/jsp/about.jsp Sun Aug 01 18:14:36 2021 +0200 5.2 +++ b/src/main/webapp/WEB-INF/jsp/about.jsp Sun Aug 01 18:56:28 2021 +0200 5.3 @@ -26,7 +26,7 @@ 5.4 <%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> 5.5 <%@taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %> 5.6 5.7 -<h1><fmt:message key="app.title"/></h1> 5.8 +<h1>LightPIT</h1> 5.9 5.10 <fmt:message key="app.name"/> 5.11
6.1 --- a/src/main/webapp/WEB-INF/jsp/site.jsp Sun Aug 01 18:14:36 2021 +0200 6.2 +++ b/src/main/webapp/WEB-INF/jsp/site.jsp Sun Aug 01 18:56:28 2021 +0200 6.3 @@ -42,6 +42,9 @@ 6.4 <%-- Define an alias for the navigation menu --%> 6.5 <c:set scope="page" var="navMenu" value="${requestScope[Constants.REQ_ATTR_NAVIGATION]}"/> 6.6 6.7 +<%-- Define an alias for the custom page title --%> 6.8 +<c:set scope="page" var="pageTitle" value="${requestScope[Constants.REQ_ATTR_PAGE_TITLE]}"/> 6.9 + 6.10 <%-- Define an alias for the content page name --%> 6.11 <c:set scope="page" var="contentPage" value="${requestScope[Constants.REQ_ATTR_CONTENT_PAGE]}"/> 6.12 6.13 @@ -59,7 +62,10 @@ 6.14 <html> 6.15 <head> 6.16 <base href="${baseHref}"> 6.17 - <title><fmt:message key="app.title"/></title> 6.18 + <title> 6.19 + LightPIT 6.20 + <c:if test="${not empty pageTitle}"> - <c:out value="${pageTitle}"/></c:if> 6.21 + </title> 6.22 <meta charset="UTF-8"> 6.23 <c:if test="${not empty redirectLocation}"> 6.24 <meta http-equiv="refresh" content="0; URL=${redirectLocation}">