96 field = value |
102 field = value |
97 request.setAttribute(Constants.REQ_ATTR_VIEWMODEL, value) |
103 request.setAttribute(Constants.REQ_ATTR_VIEWMODEL, value) |
98 } |
104 } |
99 |
105 |
100 /** |
106 /** |
|
107 * Additional port info, if necessary. |
|
108 */ |
|
109 private val portInfo = |
|
110 if ((request.scheme == "http" && request.serverPort == 80) |
|
111 || (request.scheme == "https" && request.serverPort == 443) |
|
112 ) "" else ":${request.serverPort}" |
|
113 |
|
114 /** |
101 * The base path of this application. |
115 * The base path of this application. |
102 */ |
116 */ |
103 val baseHref get() = "${request.scheme}://${request.serverName}:${request.serverPort}${request.contextPath}/" |
117 val baseHref get() = "${request.scheme}://${request.serverName}$portInfo${request.contextPath}/" |
|
118 |
|
119 init { |
|
120 feedPath = "feed/projects.rss" |
|
121 } |
104 |
122 |
105 private fun String.withExt(ext: String) = if (endsWith(ext)) this else plus(ext) |
123 private fun String.withExt(ext: String) = if (endsWith(ext)) this else plus(ext) |
106 private fun jspPath(name: String) = Constants.JSP_PATH_PREFIX.plus(name).withExt(".jsp") |
124 private fun jspPath(name: String) = Constants.JSP_PATH_PREFIX.plus(name).withExt(".jsp") |
107 |
125 |
108 fun param(name: String): String? = request.getParameter(name) |
126 fun param(name: String): String? = request.getParameter(name) |
109 fun paramArray(name: String): Array<String> = request.getParameterValues(name) ?: emptyArray() |
127 fun paramArray(name: String): Array<String> = request.getParameterValues(name) ?: emptyArray() |
110 |
128 |
111 fun forward(jsp: String) { |
129 private fun forward(jsp: String) { |
112 request.getRequestDispatcher(jspPath(jsp)).forward(request, response) |
130 request.getRequestDispatcher(jspPath(jsp)).forward(request, response) |
|
131 } |
|
132 |
|
133 fun renderFeed(page: String? = null) { |
|
134 page?.let { contentPage = it } |
|
135 forward("feed") |
113 } |
136 } |
114 |
137 |
115 fun render(page: String? = null) { |
138 fun render(page: String? = null) { |
116 page?.let { contentPage = it } |
139 page?.let { contentPage = it } |
117 forward("site") |
140 forward("site") |