From 76f3cee76957a00d6cb8f1ebcef9a2af3be7b603 Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Sat, 18 May 2019 00:13:36 +0200 Subject: [PATCH] =?utf8?q?=F0=9F=90=9B=20Fix=20parameter=20name?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../net/pterodactylus/sone/web/pages/LoginPage.kt | 4 ++-- .../sone/web/pages/SoneTemplatePage.kt | 24 +++++++++++----------- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/src/main/kotlin/net/pterodactylus/sone/web/pages/LoginPage.kt b/src/main/kotlin/net/pterodactylus/sone/web/pages/LoginPage.kt index 637ea9f..6647cd4 100644 --- a/src/main/kotlin/net/pterodactylus/sone/web/pages/LoginPage.kt +++ b/src/main/kotlin/net/pterodactylus/sone/web/pages/LoginPage.kt @@ -29,8 +29,8 @@ class LoginPage @Inject constructor(webInterface: WebInterface, loaders: Loaders templateContext["identitiesWithoutSone"] = soneRequest.core.identityManager.allOwnIdentities.filterNot { "Sone" in it.contexts }.sortedBy { "${it.nickname}@${it.id}" } } - override fun getRedirectTarget(freenetRequest: FreenetRequest) = - getCurrentSone(freenetRequest.toadletContext)?.let { "index.html" } + override fun getRedirectTarget(request: FreenetRequest) = + getCurrentSone(request.toadletContext)?.let { "index.html" } override fun isEnabled(soneRequest: SoneRequest) = when { soneRequest.core.preferences.requireFullAccess && !soneRequest.toadletContext.isAllowedFullAccess -> false diff --git a/src/main/kotlin/net/pterodactylus/sone/web/pages/SoneTemplatePage.kt b/src/main/kotlin/net/pterodactylus/sone/web/pages/SoneTemplatePage.kt index 3122c64..d031a00 100644 --- a/src/main/kotlin/net/pterodactylus/sone/web/pages/SoneTemplatePage.kt +++ b/src/main/kotlin/net/pterodactylus/sone/web/pages/SoneTemplatePage.kt @@ -35,7 +35,7 @@ open class SoneTemplatePage @JvmOverloads constructor( fun requiresLogin() = requiresLogin - override public fun getPageTitle(freenetRequest: FreenetRequest) = getPageTitle(freenetRequest.toSoneRequest(core, webInterface)) + override public fun getPageTitle(request: FreenetRequest) = getPageTitle(request.toSoneRequest(core, webInterface)) open fun getPageTitle(soneRequest: SoneRequest) = pageTitle(soneRequest) @@ -51,22 +51,22 @@ open class SoneTemplatePage @JvmOverloads constructor( "href" to "http://${request.httpRequest.getHeader("host")}/Sone/OpenSearch.xml" )) - final override public fun processTemplate(freenetRequest: FreenetRequest, templateContext: TemplateContext) { - super.processTemplate(freenetRequest, templateContext) + final override public fun processTemplate(request: FreenetRequest, templateContext: TemplateContext) { + super.processTemplate(request, templateContext) templateContext["preferences"] = core.preferences - templateContext["currentSone"] = getCurrentSone(freenetRequest.toadletContext) + templateContext["currentSone"] = getCurrentSone(request.toadletContext) templateContext["localSones"] = core.localSones - templateContext["request"] = freenetRequest + templateContext["request"] = request templateContext["currentVersion"] = SonePlugin.getPluginVersion() templateContext["hasLatestVersion"] = core.updateChecker.hasLatestVersion() templateContext["latestEdition"] = core.updateChecker.latestEdition templateContext["latestVersion"] = core.updateChecker.latestVersion templateContext["latestVersionTime"] = core.updateChecker.latestVersionDate - webInterface.getNotifications(getCurrentSone(freenetRequest.toadletContext)).sortedBy(Notification::getCreatedTime).run { + webInterface.getNotifications(getCurrentSone(request.toadletContext)).sortedBy(Notification::getCreatedTime).run { templateContext["notifications"] = this templateContext["notificationHash"] = this.hashCode() } - handleRequest(freenetRequest, templateContext) + handleRequest(request, templateContext) } open fun handleRequest(freenetRequest: FreenetRequest, templateContext: TemplateContext) { @@ -76,13 +76,13 @@ open class SoneTemplatePage @JvmOverloads constructor( open fun handleRequest(soneRequest: SoneRequest, templateContext: TemplateContext) { } - override public fun getRedirectTarget(freenetRequest: FreenetRequest): String? { - if (requiresLogin && getCurrentSone(freenetRequest.toadletContext) == null) { - val parameters = freenetRequest.httpRequest.parameterNames - .flatMap { name -> freenetRequest.httpRequest.getMultipleParam(name).map { name to it } } + override public fun getRedirectTarget(request: FreenetRequest): String? { + if (requiresLogin && getCurrentSone(request.toadletContext) == null) { + val parameters = request.httpRequest.parameterNames + .flatMap { name -> request.httpRequest.getMultipleParam(name).map { name to it } } .joinToString("&") { "${it.first.urlEncode}=${it.second.urlEncode}" } .emptyToNull - return "login.html?target=${freenetRequest.httpRequest.path}${parameters?.let { ("?" + it).urlEncode } ?: ""}" + return "login.html?target=${request.httpRequest.path}${parameters?.let { ("?" + it).urlEncode } ?: ""}" } return null } -- 2.7.4