From 9ce438f1c99c189c1c52622833a8d7e58a7fc0f2 Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Wed, 29 Nov 2017 21:16:34 +0100 Subject: [PATCH] Fix indentation --- .../sone/web/pages/EditProfileFieldPage.kt | 36 +++++++++++----------- .../net/pterodactylus/sone/web/pages/LikePage.kt | 14 ++++----- .../net/pterodactylus/sone/web/pages/TrustPage.kt | 8 ++--- .../sone/web/pages/UnfollowSonePage.kt | 6 ++-- .../pterodactylus/sone/web/pages/UntrustPage.kt | 8 ++--- 5 files changed, 36 insertions(+), 36 deletions(-) diff --git a/src/main/kotlin/net/pterodactylus/sone/web/pages/EditProfileFieldPage.kt b/src/main/kotlin/net/pterodactylus/sone/web/pages/EditProfileFieldPage.kt index b63301b..f3486d2 100644 --- a/src/main/kotlin/net/pterodactylus/sone/web/pages/EditProfileFieldPage.kt +++ b/src/main/kotlin/net/pterodactylus/sone/web/pages/EditProfileFieldPage.kt @@ -10,31 +10,31 @@ import net.pterodactylus.util.template.TemplateContext /** * Page that lets the user edit the name of a profile field. */ -class EditProfileFieldPage(template: Template, webInterface: WebInterface): +class EditProfileFieldPage(template: Template, webInterface: WebInterface) : LoggedInPage("editProfileField.html", template, "Page.EditProfileField.Title", webInterface) { override fun handleRequest(freenetRequest: FreenetRequest, currentSone: Sone, templateContext: TemplateContext) { - currentSone.profile.let { profile -> - if (freenetRequest.isPOST) { - if (freenetRequest.httpRequest.getPartAsStringFailsafe("cancel", 4) == "true") { - throw RedirectException("editProfile.html#profile-fields") - } - val field = profile.getFieldById(freenetRequest.httpRequest.getPartAsStringFailsafe("field", 36)) ?: throw RedirectException("invalid.html") - freenetRequest.httpRequest.getPartAsStringFailsafe("name", 256).let { name -> - try { - if (name != field.name) { - field.name = name - currentSone.profile = profile - } - throw RedirectException("editProfile.html#profile-fields") - } catch (e: IllegalArgumentException) { - templateContext["duplicateFieldName"] = true - return + currentSone.profile.let { profile -> + if (freenetRequest.isPOST) { + if (freenetRequest.httpRequest.getPartAsStringFailsafe("cancel", 4) == "true") { + throw RedirectException("editProfile.html#profile-fields") + } + val field = profile.getFieldById(freenetRequest.httpRequest.getPartAsStringFailsafe("field", 36)) ?: throw RedirectException("invalid.html") + freenetRequest.httpRequest.getPartAsStringFailsafe("name", 256).let { name -> + try { + if (name != field.name) { + field.name = name + currentSone.profile = profile } + throw RedirectException("editProfile.html#profile-fields") + } catch (e: IllegalArgumentException) { + templateContext["duplicateFieldName"] = true + return } } - templateContext["field"] = profile.getFieldById(freenetRequest.httpRequest.getParam("field")) ?: throw RedirectException("invalid.html") } + templateContext["field"] = profile.getFieldById(freenetRequest.httpRequest.getParam("field")) ?: throw RedirectException("invalid.html") + } } } diff --git a/src/main/kotlin/net/pterodactylus/sone/web/pages/LikePage.kt b/src/main/kotlin/net/pterodactylus/sone/web/pages/LikePage.kt index 7d6af18..ef622df 100644 --- a/src/main/kotlin/net/pterodactylus/sone/web/pages/LikePage.kt +++ b/src/main/kotlin/net/pterodactylus/sone/web/pages/LikePage.kt @@ -12,17 +12,17 @@ import net.pterodactylus.util.template.TemplateContext * Page that lets the user like [net.pterodactylus.sone.data.Post]s and [net.pterodactylus.sone.data.Reply]s. */ class LikePage(template: Template, webInterface: WebInterface) : - LoggedInPage("like.html", template, "Page.Like.Title", webInterface) { + LoggedInPage("like.html", template, "Page.Like.Title", webInterface) { override fun handleRequest(freenetRequest: FreenetRequest, currentSone: Sone, templateContext: TemplateContext) { if (freenetRequest.isPOST) { - freenetRequest.parameters["type", 16]?.also { type -> - when(type) { - "post" -> currentSone.addLikedPostId(freenetRequest.parameters["post", 36]!!) - "reply" -> currentSone.addLikedReplyId(freenetRequest.parameters["reply", 36]!!) - } + freenetRequest.parameters["type", 16]?.also { type -> + when (type) { + "post" -> currentSone.addLikedPostId(freenetRequest.parameters["post", 36]!!) + "reply" -> currentSone.addLikedReplyId(freenetRequest.parameters["reply", 36]!!) } - throw RedirectException(freenetRequest.parameters["returnPage", 256]!!) + } + throw RedirectException(freenetRequest.parameters["returnPage", 256]!!) } } diff --git a/src/main/kotlin/net/pterodactylus/sone/web/pages/TrustPage.kt b/src/main/kotlin/net/pterodactylus/sone/web/pages/TrustPage.kt index b6fb038..758ae07 100644 --- a/src/main/kotlin/net/pterodactylus/sone/web/pages/TrustPage.kt +++ b/src/main/kotlin/net/pterodactylus/sone/web/pages/TrustPage.kt @@ -12,14 +12,14 @@ import net.pterodactylus.util.template.TemplateContext * Page that lets the user trust another Sone. This will assign a configurable * amount of trust to an identity. */ -class TrustPage(template: Template, webInterface: WebInterface): +class TrustPage(template: Template, webInterface: WebInterface) : LoggedInPage("trust.html", template, "Page.Trust.Title", webInterface) { override fun handleRequest(freenetRequest: FreenetRequest, currentSone: Sone, templateContext: TemplateContext) { if (freenetRequest.isPOST) { - webInterface.core.getSone(freenetRequest.parameters["sone"]!!)?.let { sone -> - webInterface.core.trustSone(currentSone, sone) - } + webInterface.core.getSone(freenetRequest.parameters["sone"]!!)?.let { sone -> + webInterface.core.trustSone(currentSone, sone) + } throw RedirectException(freenetRequest.parameters["returnPage", 256]) } } diff --git a/src/main/kotlin/net/pterodactylus/sone/web/pages/UnfollowSonePage.kt b/src/main/kotlin/net/pterodactylus/sone/web/pages/UnfollowSonePage.kt index ef4eab9..2521ef0 100644 --- a/src/main/kotlin/net/pterodactylus/sone/web/pages/UnfollowSonePage.kt +++ b/src/main/kotlin/net/pterodactylus/sone/web/pages/UnfollowSonePage.kt @@ -11,13 +11,13 @@ import net.pterodactylus.util.template.TemplateContext /** * This page lets the user unfollow another Sone. */ -class UnfollowSonePage(template: Template, webInterface: WebInterface): +class UnfollowSonePage(template: Template, webInterface: WebInterface) : LoggedInPage("unfollowSone.html", template, "Page.UnfollowSone.Title", webInterface) { override fun handleRequest(freenetRequest: FreenetRequest, currentSone: Sone, templateContext: TemplateContext) { if (freenetRequest.isPOST) { - freenetRequest.parameters["sone"]!!.split(Regex("[ ,]+")) - .forEach { webInterface.core.unfollowSone(currentSone, it) } + freenetRequest.parameters["sone"]!!.split(Regex("[ ,]+")) + .forEach { webInterface.core.unfollowSone(currentSone, it) } throw RedirectException(freenetRequest.parameters["returnPage", 256]) } } diff --git a/src/main/kotlin/net/pterodactylus/sone/web/pages/UntrustPage.kt b/src/main/kotlin/net/pterodactylus/sone/web/pages/UntrustPage.kt index ad34432..f522c34 100644 --- a/src/main/kotlin/net/pterodactylus/sone/web/pages/UntrustPage.kt +++ b/src/main/kotlin/net/pterodactylus/sone/web/pages/UntrustPage.kt @@ -12,14 +12,14 @@ import net.pterodactylus.util.template.TemplateContext * Page that lets the user untrust another Sone. This will remove all trust * assignments for an identity. */ -class UntrustPage(template: Template, webInterface: WebInterface): +class UntrustPage(template: Template, webInterface: WebInterface) : LoggedInPage("untrust.html", template, "Page.Untrust.Title", webInterface) { override fun handleRequest(freenetRequest: FreenetRequest, currentSone: Sone, templateContext: TemplateContext) { if (freenetRequest.isPOST) { - freenetRequest.parameters["sone", 44]!! - .let(webInterface.core::getSone) - ?.also { webInterface.core.untrustSone(currentSone, it) } + freenetRequest.parameters["sone", 44]!! + .let(webInterface.core::getSone) + ?.also { webInterface.core.untrustSone(currentSone, it) } throw RedirectException(freenetRequest.parameters["returnPage", 256]) } } -- 2.7.4