1.1 --- a/src/main/kotlin/de/uapcore/lightpit/RequestMapping.kt Thu May 13 18:01:56 2021 +0200 1.2 +++ b/src/main/kotlin/de/uapcore/lightpit/RequestMapping.kt Thu May 13 19:31:09 2021 +0200 1.3 @@ -86,6 +86,12 @@ 1.4 request.setAttribute(Constants.REQ_ATTR_REDIRECT_LOCATION, baseHref + value) 1.5 } 1.6 1.7 + var feedPath = "" 1.8 + set(value) { 1.9 + field = value 1.10 + request.setAttribute(Constants.REQ_ATTR_FEED_HREF, baseHref + value) 1.11 + } 1.12 + 1.13 /** 1.14 * The view object. 1.15 * 1.16 @@ -98,9 +104,21 @@ 1.17 } 1.18 1.19 /** 1.20 + * Additional port info, if necessary. 1.21 + */ 1.22 + private val portInfo = 1.23 + if ((request.scheme == "http" && request.serverPort == 80) 1.24 + || (request.scheme == "https" && request.serverPort == 443) 1.25 + ) "" else ":${request.serverPort}" 1.26 + 1.27 + /** 1.28 * The base path of this application. 1.29 */ 1.30 - val baseHref get() = "${request.scheme}://${request.serverName}:${request.serverPort}${request.contextPath}/" 1.31 + val baseHref get() = "${request.scheme}://${request.serverName}$portInfo${request.contextPath}/" 1.32 + 1.33 + init { 1.34 + feedPath = "feed/projects.rss" 1.35 + } 1.36 1.37 private fun String.withExt(ext: String) = if (endsWith(ext)) this else plus(ext) 1.38 private fun jspPath(name: String) = Constants.JSP_PATH_PREFIX.plus(name).withExt(".jsp") 1.39 @@ -108,10 +126,15 @@ 1.40 fun param(name: String): String? = request.getParameter(name) 1.41 fun paramArray(name: String): Array<String> = request.getParameterValues(name) ?: emptyArray() 1.42 1.43 - fun forward(jsp: String) { 1.44 + private fun forward(jsp: String) { 1.45 request.getRequestDispatcher(jspPath(jsp)).forward(request, response) 1.46 } 1.47 1.48 + fun renderFeed(page: String? = null) { 1.49 + page?.let { contentPage = it } 1.50 + forward("feed") 1.51 + } 1.52 + 1.53 fun render(page: String? = null) { 1.54 page?.let { contentPage = it } 1.55 forward("site")