From 3cb0e2c78bb37f2d70ecde92ad4fcf642de788a3 Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Fri, 6 Oct 2017 22:59:07 +0200 Subject: [PATCH] Change a couple of method argument names --- .../net/pterodactylus/sone/web/pages/AboutPage.kt | 2 +- .../pterodactylus/sone/web/pages/BookmarksPage.kt | 2 +- .../sone/web/pages/CreateAlbumPage.kt | 14 +++---- .../pterodactylus/sone/web/pages/CreatePostPage.kt | 14 +++---- .../sone/web/pages/CreateReplyPage.kt | 14 +++---- .../pterodactylus/sone/web/pages/CreateSonePage.kt | 8 ++-- .../sone/web/pages/DeleteAlbumPage.kt | 10 ++--- .../sone/web/pages/DeleteImagePage.kt | 10 ++--- .../pterodactylus/sone/web/pages/DeletePostPage.kt | 16 ++++---- .../sone/web/pages/DeleteProfileFieldPage.kt | 12 +++--- .../sone/web/pages/DeleteReplyPage.kt | 16 ++++---- .../pterodactylus/sone/web/pages/DeleteSonePage.kt | 8 ++-- .../sone/web/pages/DismissNotificationPage.kt | 6 +-- .../pterodactylus/sone/web/pages/DistrustPage.kt | 10 ++--- .../pterodactylus/sone/web/pages/EditAlbumPage.kt | 14 +++---- .../pterodactylus/sone/web/pages/EditImagePage.kt | 16 ++++---- .../sone/web/pages/EditProfileFieldPage.kt | 14 +++---- .../sone/web/pages/EditProfilePage.kt | 42 ++++++++++----------- .../pterodactylus/sone/web/pages/FollowSonePage.kt | 10 ++--- .../sone/web/pages/ImageBrowserPage.kt | 18 ++++----- .../net/pterodactylus/sone/web/pages/IndexPage.kt | 6 +-- .../pterodactylus/sone/web/pages/KnownSonesPage.kt | 28 +++++++------- .../net/pterodactylus/sone/web/pages/LikePage.kt | 14 +++---- .../pterodactylus/sone/web/pages/LockSonePage.kt | 6 +-- .../net/pterodactylus/sone/web/pages/LoginPage.kt | 14 +++---- .../net/pterodactylus/sone/web/pages/LogoutPage.kt | 4 +- .../sone/web/pages/MarkAsKnownPage.kt | 8 ++-- .../net/pterodactylus/sone/web/pages/NewPage.kt | 6 +-- .../pterodactylus/sone/web/pages/OptionsPage.kt | 44 +++++++++++----------- .../net/pterodactylus/sone/web/pages/RescuePage.kt | 10 ++--- .../net/pterodactylus/sone/web/pages/SearchPage.kt | 8 ++-- .../sone/web/pages/SoneTemplatePage.kt | 14 +++---- .../net/pterodactylus/sone/web/pages/TrustPage.kt | 10 ++--- .../pterodactylus/sone/web/pages/UnbookmarkPage.kt | 10 ++--- .../sone/web/pages/UnfollowSonePage.kt | 10 ++--- .../net/pterodactylus/sone/web/pages/UnlikePage.kt | 12 +++--- .../pterodactylus/sone/web/pages/UnlockSonePage.kt | 8 ++-- .../pterodactylus/sone/web/pages/UntrustPage.kt | 10 ++--- .../sone/web/pages/UploadImagePage.kt | 16 ++++---- .../pterodactylus/sone/web/pages/ViewPostPage.kt | 12 +++--- .../pterodactylus/sone/web/pages/ViewSonePage.kt | 14 +++---- .../sone/web/pages/SoneTemplatePageTest.kt | 2 +- 42 files changed, 261 insertions(+), 261 deletions(-) diff --git a/src/main/kotlin/net/pterodactylus/sone/web/pages/AboutPage.kt b/src/main/kotlin/net/pterodactylus/sone/web/pages/AboutPage.kt index 3a93679..d3382b4 100644 --- a/src/main/kotlin/net/pterodactylus/sone/web/pages/AboutPage.kt +++ b/src/main/kotlin/net/pterodactylus/sone/web/pages/AboutPage.kt @@ -16,7 +16,7 @@ class AboutPage(template: Template, webInterface: WebInterface, private val pluginYear: PluginYear, private val pluginHomepage: PluginHomepage): SoneTemplatePage("about.html", template, "Page.About.Title", webInterface, false) { - override fun handleRequest(request: FreenetRequest, templateContext: TemplateContext) { + override fun handleRequest(freenetRequest: FreenetRequest, templateContext: TemplateContext) { templateContext["version"] = pluginVersion.version templateContext["year"] = pluginYear.year templateContext["homepage"] = pluginHomepage.homepage diff --git a/src/main/kotlin/net/pterodactylus/sone/web/pages/BookmarksPage.kt b/src/main/kotlin/net/pterodactylus/sone/web/pages/BookmarksPage.kt index e4b3d28..fbfc7d3 100644 --- a/src/main/kotlin/net/pterodactylus/sone/web/pages/BookmarksPage.kt +++ b/src/main/kotlin/net/pterodactylus/sone/web/pages/BookmarksPage.kt @@ -12,7 +12,7 @@ import net.pterodactylus.util.template.TemplateContext */ class BookmarksPage(template: Template, webInterface: WebInterface): SoneTemplatePage("bookmarks.html", template, "Page.Bookmarks.Title", webInterface) { - override fun handleRequest(request: FreenetRequest, templateContext: TemplateContext) { + override fun handleRequest(freenetRequest: FreenetRequest, templateContext: TemplateContext) { webInterface.core.bookmarkedPosts.let { posts -> val pagination = Pagination(posts.filter { it.isLoaded }.sortedByDescending { it.time }, webInterface.core.preferences.postsPerPage) templateContext["pagination"] = pagination diff --git a/src/main/kotlin/net/pterodactylus/sone/web/pages/CreateAlbumPage.kt b/src/main/kotlin/net/pterodactylus/sone/web/pages/CreateAlbumPage.kt index d14ba3a..ee3936e 100644 --- a/src/main/kotlin/net/pterodactylus/sone/web/pages/CreateAlbumPage.kt +++ b/src/main/kotlin/net/pterodactylus/sone/web/pages/CreateAlbumPage.kt @@ -14,22 +14,22 @@ import net.pterodactylus.util.template.TemplateContext class CreateAlbumPage(template: Template, webInterface: WebInterface): SoneTemplatePage("createAlbum.html", template, "Page.CreateAlbum.Title", webInterface, true) { - override fun handleRequest(request: FreenetRequest, templateContext: TemplateContext) { - if (request.isPOST) { - val name = request.httpRequest.getPartAsStringFailsafe("name", 64).trim() + override fun handleRequest(freenetRequest: FreenetRequest, templateContext: TemplateContext) { + if (freenetRequest.isPOST) { + val name = freenetRequest.httpRequest.getPartAsStringFailsafe("name", 64).trim() if (name.isEmpty()) { templateContext["nameMissing"] = true return } - val description = request.httpRequest.getPartAsStringFailsafe("description", 256).trim() - val currentSone = webInterface.getCurrentSoneCreatingSession(request.toadletContext) - val parentId = request.httpRequest.getPartAsStringFailsafe("parent", 36) + val description = freenetRequest.httpRequest.getPartAsStringFailsafe("description", 256).trim() + val currentSone = webInterface.getCurrentSoneCreatingSession(freenetRequest.toadletContext) + val parentId = freenetRequest.httpRequest.getPartAsStringFailsafe("parent", 36) val parent = if (parentId == "") currentSone.rootAlbum else webInterface.core.getAlbum(parentId) val album = webInterface.core.createAlbum(currentSone, parent) try { album.modify().apply { setTitle(name) - setDescription(TextFilter.filter(request.httpRequest.getHeader("Host"), description)) + setDescription(TextFilter.filter(freenetRequest.httpRequest.getHeader("Host"), description)) }.update() } catch (e: AlbumTitleMustNotBeEmpty) { throw RedirectException("emptyAlbumTitle.html") diff --git a/src/main/kotlin/net/pterodactylus/sone/web/pages/CreatePostPage.kt b/src/main/kotlin/net/pterodactylus/sone/web/pages/CreatePostPage.kt index fe7027c..30a1c31 100644 --- a/src/main/kotlin/net/pterodactylus/sone/web/pages/CreatePostPage.kt +++ b/src/main/kotlin/net/pterodactylus/sone/web/pages/CreatePostPage.kt @@ -13,18 +13,18 @@ import net.pterodactylus.util.template.TemplateContext class CreatePostPage(template: Template, webInterface: WebInterface): SoneTemplatePage("createPost.html", template, "Page.CreatePost.Title", webInterface, true) { - override fun handleRequest(request: FreenetRequest, templateContext: TemplateContext) { - val returnPage = request.httpRequest.getPartAsStringFailsafe("returnPage", 256) + override fun handleRequest(freenetRequest: FreenetRequest, templateContext: TemplateContext) { + val returnPage = freenetRequest.httpRequest.getPartAsStringFailsafe("returnPage", 256) templateContext["returnPage"] = returnPage - if (request.isPOST) { - val text = request.httpRequest.getPartAsStringFailsafe("text", 65536).trim() + if (freenetRequest.isPOST) { + val text = freenetRequest.httpRequest.getPartAsStringFailsafe("text", 65536).trim() if (text == "") { templateContext["errorTextEmpty"] = true return } - val sender = webInterface.core.getLocalSone(request.httpRequest.getPartAsStringFailsafe("sender", 43)) ?: getCurrentSone(request.toadletContext) - val recipient = webInterface.core.getSone(request.httpRequest.getPartAsStringFailsafe("recipient", 43)) - webInterface.core.createPost(sender, recipient, TextFilter.filter(request.httpRequest.getHeader("Host"), text)) + val sender = webInterface.core.getLocalSone(freenetRequest.httpRequest.getPartAsStringFailsafe("sender", 43)) ?: getCurrentSone(freenetRequest.toadletContext) + val recipient = webInterface.core.getSone(freenetRequest.httpRequest.getPartAsStringFailsafe("recipient", 43)) + webInterface.core.createPost(sender, recipient, TextFilter.filter(freenetRequest.httpRequest.getHeader("Host"), text)) throw RedirectException(returnPage) } } diff --git a/src/main/kotlin/net/pterodactylus/sone/web/pages/CreateReplyPage.kt b/src/main/kotlin/net/pterodactylus/sone/web/pages/CreateReplyPage.kt index a83128b..a6c58e4 100644 --- a/src/main/kotlin/net/pterodactylus/sone/web/pages/CreateReplyPage.kt +++ b/src/main/kotlin/net/pterodactylus/sone/web/pages/CreateReplyPage.kt @@ -13,18 +13,18 @@ import net.pterodactylus.util.template.TemplateContext class CreateReplyPage(template: Template, webInterface: WebInterface): SoneTemplatePage("createReply.html", template, "Page.CreateReply.Title", webInterface, true) { - override fun handleRequest(request: FreenetRequest, templateContext: TemplateContext) { - val postId = request.httpRequest.getPartAsStringFailsafe("post", 36).apply { templateContext["postId"] = this } - val text = request.httpRequest.getPartAsStringFailsafe("text", 65536).trim().apply { templateContext["text"] = this } - val returnPage = request.httpRequest.getPartAsStringFailsafe("returnPage", 256).apply { templateContext["returnPage"] = this } - if (request.isPOST) { + override fun handleRequest(freenetRequest: FreenetRequest, templateContext: TemplateContext) { + val postId = freenetRequest.httpRequest.getPartAsStringFailsafe("post", 36).apply { templateContext["postId"] = this } + val text = freenetRequest.httpRequest.getPartAsStringFailsafe("text", 65536).trim().apply { templateContext["text"] = this } + val returnPage = freenetRequest.httpRequest.getPartAsStringFailsafe("returnPage", 256).apply { templateContext["returnPage"] = this } + if (freenetRequest.isPOST) { if (text == "") { templateContext["errorTextEmpty"] = true return } val post = webInterface.core.getPost(postId).orNull() ?: throw RedirectException("noPermission.html") - val sender = webInterface.core.getLocalSone(request.httpRequest.getPartAsStringFailsafe("sender", 43)) ?: getCurrentSone(request.toadletContext) - webInterface.core.createReply(sender, post, TextFilter.filter(request.httpRequest.getHeader("Host"), text)) + val sender = webInterface.core.getLocalSone(freenetRequest.httpRequest.getPartAsStringFailsafe("sender", 43)) ?: getCurrentSone(freenetRequest.toadletContext) + webInterface.core.createReply(sender, post, TextFilter.filter(freenetRequest.httpRequest.getHeader("Host"), text)) throw RedirectException(returnPage) } } diff --git a/src/main/kotlin/net/pterodactylus/sone/web/pages/CreateSonePage.kt b/src/main/kotlin/net/pterodactylus/sone/web/pages/CreateSonePage.kt index 6007346..efa6f1d 100644 --- a/src/main/kotlin/net/pterodactylus/sone/web/pages/CreateSonePage.kt +++ b/src/main/kotlin/net/pterodactylus/sone/web/pages/CreateSonePage.kt @@ -18,17 +18,17 @@ class CreateSonePage(template: Template, webInterface: WebInterface): private val logger = Logger.getLogger(CreateSonePage::class.java.name) - override fun handleRequest(request: FreenetRequest, templateContext: TemplateContext) { + override fun handleRequest(freenetRequest: FreenetRequest, templateContext: TemplateContext) { templateContext["sones"] = webInterface.core.localSones.sortedWith(Sone.NICE_NAME_COMPARATOR) templateContext["identitiesWithoutSone"] = webInterface.core.identityManager.allOwnIdentities.filterNot { "Sone" in it.contexts }.sortedBy { "${it.nickname}@${it.id}".toLowerCase() } - if (request.isPOST) { - val identity = request.httpRequest.getPartAsStringFailsafe("identity", 43) + if (freenetRequest.isPOST) { + val identity = freenetRequest.httpRequest.getPartAsStringFailsafe("identity", 43) webInterface.core.identityManager.allOwnIdentities.firstOrNull { it.id == identity }?.let { ownIdentity -> val sone = webInterface.core.createSone(ownIdentity) if (sone == null) { logger.log(Level.SEVERE, "Could not create Sone for OwnIdentity: $ownIdentity") } - setCurrentSone(request.toadletContext, sone) + setCurrentSone(freenetRequest.toadletContext, sone) throw RedirectException("index.html") } templateContext["errorNoIdentity"] = true diff --git a/src/main/kotlin/net/pterodactylus/sone/web/pages/DeleteAlbumPage.kt b/src/main/kotlin/net/pterodactylus/sone/web/pages/DeleteAlbumPage.kt index 66f989a..98eea86 100644 --- a/src/main/kotlin/net/pterodactylus/sone/web/pages/DeleteAlbumPage.kt +++ b/src/main/kotlin/net/pterodactylus/sone/web/pages/DeleteAlbumPage.kt @@ -12,19 +12,19 @@ import net.pterodactylus.util.template.TemplateContext class DeleteAlbumPage(template: Template, webInterface: WebInterface): SoneTemplatePage("deleteAlbum.html", template, "Page.DeleteAlbum.Title", webInterface, true) { - override fun handleRequest(request: FreenetRequest, templateContext: TemplateContext) { - if (request.isPOST) { - val album = webInterface.core.getAlbum(request.httpRequest.getPartAsStringFailsafe("album", 36)) ?: throw RedirectException("invalid.html") + override fun handleRequest(freenetRequest: FreenetRequest, templateContext: TemplateContext) { + if (freenetRequest.isPOST) { + val album = webInterface.core.getAlbum(freenetRequest.httpRequest.getPartAsStringFailsafe("album", 36)) ?: throw RedirectException("invalid.html") if (!album.sone.isLocal) { throw RedirectException("noPermission.html") } - if (request.httpRequest.getPartAsStringFailsafe("abortDelete", 4) == "true") { + if (freenetRequest.httpRequest.getPartAsStringFailsafe("abortDelete", 4) == "true") { throw RedirectException("imageBrowser.html?album=${album.id}") } webInterface.core.deleteAlbum(album) throw RedirectException(if (album.parent.isRoot) "imageBrowser.html?sone=${album.sone.id}" else "imageBrowser.html?album=${album.parent.id}") } - val album = webInterface.core.getAlbum(request.httpRequest.getParam("album")) + val album = webInterface.core.getAlbum(freenetRequest.httpRequest.getParam("album")) templateContext["album"] = album ?: throw RedirectException("invalid.html") } diff --git a/src/main/kotlin/net/pterodactylus/sone/web/pages/DeleteImagePage.kt b/src/main/kotlin/net/pterodactylus/sone/web/pages/DeleteImagePage.kt index de118be..61db304 100644 --- a/src/main/kotlin/net/pterodactylus/sone/web/pages/DeleteImagePage.kt +++ b/src/main/kotlin/net/pterodactylus/sone/web/pages/DeleteImagePage.kt @@ -12,19 +12,19 @@ import net.pterodactylus.util.template.TemplateContext class DeleteImagePage(template: Template, webInterface: WebInterface): SoneTemplatePage("deleteImage.html", template, "Page.DeleteImage.Title", webInterface, true) { - override fun handleRequest(request: FreenetRequest, templateContext: TemplateContext) { - if (request.isPOST) { - val image = webInterface.core.getImage(request.httpRequest.getPartAsStringFailsafe("image", 36)) ?: throw RedirectException("invalid.html") + override fun handleRequest(freenetRequest: FreenetRequest, templateContext: TemplateContext) { + if (freenetRequest.isPOST) { + val image = webInterface.core.getImage(freenetRequest.httpRequest.getPartAsStringFailsafe("image", 36)) ?: throw RedirectException("invalid.html") if (!image.sone.isLocal) { throw RedirectException("noPermission.html") } - if (request.httpRequest.isPartSet("abortDelete")) { + if (freenetRequest.httpRequest.isPartSet("abortDelete")) { throw RedirectException("imageBrowser.html?image=${image.id}") } webInterface.core.deleteImage(image) throw RedirectException("imageBrowser.html?album=${image.album.id}") } - val image = webInterface.core.getImage(request.httpRequest.getParam("image")) ?: throw RedirectException("invalid.html") + val image = webInterface.core.getImage(freenetRequest.httpRequest.getParam("image")) ?: throw RedirectException("invalid.html") if (!image.sone.isLocal) { throw RedirectException("noPermission.html") } diff --git a/src/main/kotlin/net/pterodactylus/sone/web/pages/DeletePostPage.kt b/src/main/kotlin/net/pterodactylus/sone/web/pages/DeletePostPage.kt index eab54a7..21465d7 100644 --- a/src/main/kotlin/net/pterodactylus/sone/web/pages/DeletePostPage.kt +++ b/src/main/kotlin/net/pterodactylus/sone/web/pages/DeletePostPage.kt @@ -12,25 +12,25 @@ import net.pterodactylus.util.template.TemplateContext class DeletePostPage(template: Template, webInterface: WebInterface): SoneTemplatePage("deletePost.html", template, "Page.DeletePost.Title", webInterface, true) { - override fun handleRequest(request: FreenetRequest, templateContext: TemplateContext) { - if (request.isPOST) { - val post = webInterface.core.getPost(request.httpRequest.getPartAsStringFailsafe("post", 36)).orNull() ?: throw RedirectException("noPermission.html") - val returnPage = request.httpRequest.getPartAsStringFailsafe("returnPage", 256) + override fun handleRequest(freenetRequest: FreenetRequest, templateContext: TemplateContext) { + if (freenetRequest.isPOST) { + val post = webInterface.core.getPost(freenetRequest.httpRequest.getPartAsStringFailsafe("post", 36)).orNull() ?: throw RedirectException("noPermission.html") + val returnPage = freenetRequest.httpRequest.getPartAsStringFailsafe("returnPage", 256) if (!post.sone.isLocal) { throw RedirectException("noPermission.html") } - if (request.httpRequest.isPartSet("confirmDelete")) { + if (freenetRequest.httpRequest.isPartSet("confirmDelete")) { webInterface.core.deletePost(post) throw RedirectException(returnPage) - } else if (request.httpRequest.isPartSet("abortDelete")) { + } else if (freenetRequest.httpRequest.isPartSet("abortDelete")) { throw RedirectException(returnPage) } templateContext["post"] = post templateContext["returnPage"] = returnPage return } - templateContext["post"] = webInterface.core.getPost(request.httpRequest.getParam("post")).orNull() ?: throw RedirectException("noPermission.html") - templateContext["returnPage"] = request.httpRequest.getParam("returnPage") + templateContext["post"] = webInterface.core.getPost(freenetRequest.httpRequest.getParam("post")).orNull() ?: throw RedirectException("noPermission.html") + templateContext["returnPage"] = freenetRequest.httpRequest.getParam("returnPage") } } diff --git a/src/main/kotlin/net/pterodactylus/sone/web/pages/DeleteProfileFieldPage.kt b/src/main/kotlin/net/pterodactylus/sone/web/pages/DeleteProfileFieldPage.kt index 63cf17f..cf5ac6e 100644 --- a/src/main/kotlin/net/pterodactylus/sone/web/pages/DeleteProfileFieldPage.kt +++ b/src/main/kotlin/net/pterodactylus/sone/web/pages/DeleteProfileFieldPage.kt @@ -12,16 +12,16 @@ import net.pterodactylus.util.template.TemplateContext class DeleteProfileFieldPage(template: Template, webInterface: WebInterface): SoneTemplatePage("deleteProfileField.html", template, "Page.DeleteProfileField.Title", webInterface, true) { - override fun handleRequest(request: FreenetRequest, templateContext: TemplateContext) { - val currentSone = getCurrentSone(request.toadletContext)!! - if (request.isPOST) { - val field = currentSone.profile.getFieldById(request.httpRequest.getPartAsStringFailsafe("field", 36)) ?: throw RedirectException("invalid.html") - if (request.httpRequest.getPartAsStringFailsafe("confirm", 4) == "true") { + override fun handleRequest(freenetRequest: FreenetRequest, templateContext: TemplateContext) { + val currentSone = getCurrentSone(freenetRequest.toadletContext)!! + if (freenetRequest.isPOST) { + val field = currentSone.profile.getFieldById(freenetRequest.httpRequest.getPartAsStringFailsafe("field", 36)) ?: throw RedirectException("invalid.html") + if (freenetRequest.httpRequest.getPartAsStringFailsafe("confirm", 4) == "true") { currentSone.profile = currentSone.profile.apply { removeField(field) } } throw RedirectException("editProfile.html#profile-fields") } - val field = currentSone.profile.getFieldById(request.httpRequest.getParam("field")) ?: throw RedirectException("invalid.html") + val field = currentSone.profile.getFieldById(freenetRequest.httpRequest.getParam("field")) ?: throw RedirectException("invalid.html") templateContext["field"] = field } diff --git a/src/main/kotlin/net/pterodactylus/sone/web/pages/DeleteReplyPage.kt b/src/main/kotlin/net/pterodactylus/sone/web/pages/DeleteReplyPage.kt index e9d536b..c67d620 100644 --- a/src/main/kotlin/net/pterodactylus/sone/web/pages/DeleteReplyPage.kt +++ b/src/main/kotlin/net/pterodactylus/sone/web/pages/DeleteReplyPage.kt @@ -12,27 +12,27 @@ import net.pterodactylus.util.template.TemplateContext class DeleteReplyPage(template: Template, webInterface: WebInterface): SoneTemplatePage("deleteReply.html", template, "Page.DeleteReply.Title", webInterface, true) { - override fun handleRequest(request: FreenetRequest, templateContext: TemplateContext) { - if (request.isPOST) { - val replyId = request.httpRequest.getPartAsStringFailsafe("reply", 36) + override fun handleRequest(freenetRequest: FreenetRequest, templateContext: TemplateContext) { + if (freenetRequest.isPOST) { + val replyId = freenetRequest.httpRequest.getPartAsStringFailsafe("reply", 36) val reply = webInterface.core.getPostReply(replyId).orNull() ?: throw RedirectException("noPermission.html") if (!reply.sone.isLocal) { throw RedirectException("noPermission.html") } - val returnPage = request.httpRequest.getPartAsStringFailsafe("returnPage", 256) - if (request.httpRequest.isPartSet("confirmDelete")) { + val returnPage = freenetRequest.httpRequest.getPartAsStringFailsafe("returnPage", 256) + if (freenetRequest.httpRequest.isPartSet("confirmDelete")) { webInterface.core.deleteReply(reply) throw RedirectException(returnPage) } - if (request.httpRequest.isPartSet("abortDelete")) { + if (freenetRequest.httpRequest.isPartSet("abortDelete")) { throw RedirectException(returnPage) } templateContext["reply"] = replyId templateContext["returnPage"] = returnPage return } - templateContext["reply"] = request.httpRequest.getParam("reply") - templateContext["returnPage"] = request.httpRequest.getParam("returnPage") + templateContext["reply"] = freenetRequest.httpRequest.getParam("reply") + templateContext["returnPage"] = freenetRequest.httpRequest.getParam("returnPage") } } diff --git a/src/main/kotlin/net/pterodactylus/sone/web/pages/DeleteSonePage.kt b/src/main/kotlin/net/pterodactylus/sone/web/pages/DeleteSonePage.kt index 7868484..0cce5ba 100644 --- a/src/main/kotlin/net/pterodactylus/sone/web/pages/DeleteSonePage.kt +++ b/src/main/kotlin/net/pterodactylus/sone/web/pages/DeleteSonePage.kt @@ -14,10 +14,10 @@ import net.pterodactylus.util.template.TemplateContext class DeleteSonePage(template: Template, webInterface: WebInterface): SoneTemplatePage("deleteSone.html", template, "Page.DeleteSone.Title", webInterface, true) { - override fun handleRequest(request: FreenetRequest, templateContext: TemplateContext) { - if (request.isPOST) { - if (request.httpRequest.isPartSet("deleteSone")) { - webInterface.core.deleteSone(getCurrentSone(request.toadletContext)) + override fun handleRequest(freenetRequest: FreenetRequest, templateContext: TemplateContext) { + if (freenetRequest.isPOST) { + if (freenetRequest.httpRequest.isPartSet("deleteSone")) { + webInterface.core.deleteSone(getCurrentSone(freenetRequest.toadletContext)) } throw RedirectException("index.html") } diff --git a/src/main/kotlin/net/pterodactylus/sone/web/pages/DismissNotificationPage.kt b/src/main/kotlin/net/pterodactylus/sone/web/pages/DismissNotificationPage.kt index 4c2472a..78cdb83 100644 --- a/src/main/kotlin/net/pterodactylus/sone/web/pages/DismissNotificationPage.kt +++ b/src/main/kotlin/net/pterodactylus/sone/web/pages/DismissNotificationPage.kt @@ -11,9 +11,9 @@ import net.pterodactylus.util.template.TemplateContext class DismissNotificationPage(template: Template, webInterface: WebInterface): SoneTemplatePage("dismissNotification.html", template, "Page.DismissNotification.Title", webInterface) { - override fun handleRequest(request: FreenetRequest, templateContext: TemplateContext) { - val returnPage = request.httpRequest.getPartAsStringFailsafe("returnPage", 256) - val notificationId = request.httpRequest.getPartAsStringFailsafe("notification", 36) + override fun handleRequest(freenetRequest: FreenetRequest, templateContext: TemplateContext) { + val returnPage = freenetRequest.httpRequest.getPartAsStringFailsafe("returnPage", 256) + val notificationId = freenetRequest.httpRequest.getPartAsStringFailsafe("notification", 36) webInterface.getNotification(notificationId).orNull()?.takeIf { it.isDismissable }?.dismiss() throw RedirectException(returnPage) } diff --git a/src/main/kotlin/net/pterodactylus/sone/web/pages/DistrustPage.kt b/src/main/kotlin/net/pterodactylus/sone/web/pages/DistrustPage.kt index d23d0e7..ce5aaec 100644 --- a/src/main/kotlin/net/pterodactylus/sone/web/pages/DistrustPage.kt +++ b/src/main/kotlin/net/pterodactylus/sone/web/pages/DistrustPage.kt @@ -15,11 +15,11 @@ import net.pterodactylus.util.template.TemplateContext class DistrustPage(template: Template, webInterface: WebInterface): SoneTemplatePage("distrust.html", template, "Page.Distrust.Title", webInterface, true) { - override fun handleRequest(request: FreenetRequest, templateContext: TemplateContext) { - if (request.isPOST) { - val sone = webInterface.core.getSone(request.httpRequest.getPartAsStringFailsafe("sone", 44)).orNull() - sone?.run { webInterface.core.distrustSone(getCurrentSone(request.toadletContext), this) } - throw RedirectException(request.httpRequest.getPartAsStringFailsafe("returnPage", 256)) + override fun handleRequest(freenetRequest: FreenetRequest, templateContext: TemplateContext) { + if (freenetRequest.isPOST) { + val sone = webInterface.core.getSone(freenetRequest.httpRequest.getPartAsStringFailsafe("sone", 44)).orNull() + sone?.run { webInterface.core.distrustSone(getCurrentSone(freenetRequest.toadletContext), this) } + throw RedirectException(freenetRequest.httpRequest.getPartAsStringFailsafe("returnPage", 256)) } } diff --git a/src/main/kotlin/net/pterodactylus/sone/web/pages/EditAlbumPage.kt b/src/main/kotlin/net/pterodactylus/sone/web/pages/EditAlbumPage.kt index 119d271..bd612c3 100644 --- a/src/main/kotlin/net/pterodactylus/sone/web/pages/EditAlbumPage.kt +++ b/src/main/kotlin/net/pterodactylus/sone/web/pages/EditAlbumPage.kt @@ -13,23 +13,23 @@ import net.pterodactylus.util.template.TemplateContext class EditAlbumPage(template: Template, webInterface: WebInterface): SoneTemplatePage("editAlbum.html", template, "Page.EditAlbum.Title", webInterface, true) { - override fun handleRequest(request: FreenetRequest, templateContext: TemplateContext) { - if (request.isPOST) { - val album = webInterface.core.getAlbum(request.httpRequest.getPartAsStringFailsafe("album", 36)) ?: throw RedirectException("invalid.html") + override fun handleRequest(freenetRequest: FreenetRequest, templateContext: TemplateContext) { + if (freenetRequest.isPOST) { + val album = webInterface.core.getAlbum(freenetRequest.httpRequest.getPartAsStringFailsafe("album", 36)) ?: throw RedirectException("invalid.html") album.takeUnless { it.sone.isLocal }?.run { throw RedirectException("noPermission.html") } - if (request.httpRequest.getPartAsStringFailsafe("moveLeft", 4) == "true") { + if (freenetRequest.httpRequest.getPartAsStringFailsafe("moveLeft", 4) == "true") { album.parent?.moveAlbumUp(album) webInterface.core.touchConfiguration() throw RedirectException("imageBrowser.html?album=${album.parent?.id}") - } else if (request.httpRequest.getPartAsStringFailsafe("moveRight", 4) == "true") { + } else if (freenetRequest.httpRequest.getPartAsStringFailsafe("moveRight", 4) == "true") { album.parent?.moveAlbumDown(album) webInterface.core.touchConfiguration() throw RedirectException("imageBrowser.html?album=${album.parent?.id}") } else { try { album.modify() - .setTitle(request.httpRequest.getPartAsStringFailsafe("title", 100)) - .setDescription(request.httpRequest.getPartAsStringFailsafe("description", 1000)) + .setTitle(freenetRequest.httpRequest.getPartAsStringFailsafe("title", 100)) + .setDescription(freenetRequest.httpRequest.getPartAsStringFailsafe("description", 1000)) .update() } catch (e: AlbumTitleMustNotBeEmpty) { throw RedirectException("emptyAlbumTitle.html") diff --git a/src/main/kotlin/net/pterodactylus/sone/web/pages/EditImagePage.kt b/src/main/kotlin/net/pterodactylus/sone/web/pages/EditImagePage.kt index 5ce1702..b674cb9 100644 --- a/src/main/kotlin/net/pterodactylus/sone/web/pages/EditImagePage.kt +++ b/src/main/kotlin/net/pterodactylus/sone/web/pages/EditImagePage.kt @@ -14,24 +14,24 @@ import net.pterodactylus.util.template.TemplateContext class EditImagePage(template: Template, webInterface: WebInterface): SoneTemplatePage("editImage.html", template, "Page.EditImage.Title", webInterface, true) { - override fun handleRequest(request: FreenetRequest, templateContext: TemplateContext) { - if (request.isPOST) { - val image = webInterface.core.getImage(request.httpRequest.getPartAsStringFailsafe("image", 36)) ?: throw RedirectException("invalid.html") + override fun handleRequest(freenetRequest: FreenetRequest, templateContext: TemplateContext) { + if (freenetRequest.isPOST) { + val image = webInterface.core.getImage(freenetRequest.httpRequest.getPartAsStringFailsafe("image", 36)) ?: throw RedirectException("invalid.html") if (!image.sone.isLocal) { throw RedirectException("noPermission.html") } - request.httpRequest.getPartAsStringFailsafe("returnPage", 256).let { returnPage -> - if (request.httpRequest.getPartAsStringFailsafe("moveLeft", 4) == "true") { + freenetRequest.httpRequest.getPartAsStringFailsafe("returnPage", 256).let { returnPage -> + if (freenetRequest.httpRequest.getPartAsStringFailsafe("moveLeft", 4) == "true") { image.album.moveImageUp(image) webInterface.core.touchConfiguration() - } else if (request.httpRequest.getPartAsStringFailsafe("moveRight", 4) == "true") { + } else if (freenetRequest.httpRequest.getPartAsStringFailsafe("moveRight", 4) == "true") { image.album.moveImageDown(image) webInterface.core.touchConfiguration() } else { try { image.modify() - .setTitle(request.httpRequest.getPartAsStringFailsafe("title", 100)) - .setDescription(TextFilter.filter(request.httpRequest.getHeader("Host"), request.httpRequest.getPartAsStringFailsafe("description", 1024))) + .setTitle(freenetRequest.httpRequest.getPartAsStringFailsafe("title", 100)) + .setDescription(TextFilter.filter(freenetRequest.httpRequest.getHeader("Host"), freenetRequest.httpRequest.getPartAsStringFailsafe("description", 1024))) .update() webInterface.core.touchConfiguration() } catch (e: ImageTitleMustNotBeEmpty) { 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 be681e3..5e3d3c6 100644 --- a/src/main/kotlin/net/pterodactylus/sone/web/pages/EditProfileFieldPage.kt +++ b/src/main/kotlin/net/pterodactylus/sone/web/pages/EditProfileFieldPage.kt @@ -12,15 +12,15 @@ import net.pterodactylus.util.template.TemplateContext class EditProfileFieldPage(template: Template, webInterface: WebInterface): SoneTemplatePage("editProfileField.html", template, "Page.EditProfileField.Title", webInterface, true) { - override fun handleRequest(request: FreenetRequest, templateContext: TemplateContext) { - sessionProvider.getCurrentSone(request.toadletContext)!!.let { currentSone -> + override fun handleRequest(freenetRequest: FreenetRequest, templateContext: TemplateContext) { + sessionProvider.getCurrentSone(freenetRequest.toadletContext)!!.let { currentSone -> currentSone.profile.let { profile -> - if (request.isPOST) { - if (request.httpRequest.getPartAsStringFailsafe("cancel", 4) == "true") { + if (freenetRequest.isPOST) { + if (freenetRequest.httpRequest.getPartAsStringFailsafe("cancel", 4) == "true") { throw RedirectException("editProfile.html#profile-fields") } - val field = profile.getFieldById(request.httpRequest.getPartAsStringFailsafe("field", 36)) ?: throw RedirectException("invalid.html") - request.httpRequest.getPartAsStringFailsafe("name", 256).let { name -> + 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 @@ -33,7 +33,7 @@ class EditProfileFieldPage(template: Template, webInterface: WebInterface): } } } - templateContext["field"] = profile.getFieldById(request.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/EditProfilePage.kt b/src/main/kotlin/net/pterodactylus/sone/web/pages/EditProfilePage.kt index df47d9a..5ed0c2f 100644 --- a/src/main/kotlin/net/pterodactylus/sone/web/pages/EditProfilePage.kt +++ b/src/main/kotlin/net/pterodactylus/sone/web/pages/EditProfilePage.kt @@ -14,8 +14,8 @@ import net.pterodactylus.util.template.TemplateContext class EditProfilePage(template: Template, webInterface: WebInterface): SoneTemplatePage("editProfile.html", template, "Page.EditProfile.Title", webInterface, true) { - override fun handleRequest(request: FreenetRequest, templateContext: TemplateContext) { - request.currentSone!!.profile.let { profile -> + override fun handleRequest(freenetRequest: FreenetRequest, templateContext: TemplateContext) { + freenetRequest.currentSone!!.profile.let { profile -> templateContext["firstName"] = profile.firstName templateContext["middleName"] = profile.middleName templateContext["lastName"] = profile.lastName @@ -24,25 +24,25 @@ class EditProfilePage(template: Template, webInterface: WebInterface): templateContext["birthYear"] = profile.birthYear templateContext["avatarId"] = profile.avatar templateContext["fields"] = profile.fields - if (request.isPOST) { - if (request.httpRequest.getPartAsStringFailsafe("save-profile", 4) == "true") { - profile.firstName = request.httpRequest.getPartAsStringFailsafe("first-name", 256).trim() - profile.middleName = request.httpRequest.getPartAsStringFailsafe("middle-name", 256).trim() - profile.lastName = request.httpRequest.getPartAsStringFailsafe("last-name", 256).trim() - profile.birthDay = request.httpRequest.getPartAsStringFailsafe("birth-day", 256).trim().toIntOrNull() - profile.birthMonth = request.httpRequest.getPartAsStringFailsafe("birth-month", 256).trim().toIntOrNull() - profile.birthYear = request.httpRequest.getPartAsStringFailsafe("birth-year", 256).trim().toIntOrNull() - profile.setAvatar(webInterface.core.getImage(request.httpRequest.getPartAsStringFailsafe("avatarId", 256).trim(), false)) + if (freenetRequest.isPOST) { + if (freenetRequest.httpRequest.getPartAsStringFailsafe("save-profile", 4) == "true") { + profile.firstName = freenetRequest.httpRequest.getPartAsStringFailsafe("first-name", 256).trim() + profile.middleName = freenetRequest.httpRequest.getPartAsStringFailsafe("middle-name", 256).trim() + profile.lastName = freenetRequest.httpRequest.getPartAsStringFailsafe("last-name", 256).trim() + profile.birthDay = freenetRequest.httpRequest.getPartAsStringFailsafe("birth-day", 256).trim().toIntOrNull() + profile.birthMonth = freenetRequest.httpRequest.getPartAsStringFailsafe("birth-month", 256).trim().toIntOrNull() + profile.birthYear = freenetRequest.httpRequest.getPartAsStringFailsafe("birth-year", 256).trim().toIntOrNull() + profile.setAvatar(webInterface.core.getImage(freenetRequest.httpRequest.getPartAsStringFailsafe("avatarId", 256).trim(), false)) profile.fields.forEach { field -> - field.value = TextFilter.filter(request.httpRequest.getHeader("Host"), request.httpRequest.getPartAsStringFailsafe("field-${field.id}", 400).trim()) + field.value = TextFilter.filter(freenetRequest.httpRequest.getHeader("Host"), freenetRequest.httpRequest.getPartAsStringFailsafe("field-${field.id}", 400).trim()) } webInterface.core.touchConfiguration() throw RedirectException("editProfile.html") - } else if (request.httpRequest.getPartAsStringFailsafe("add-field", 4) == "true") { - val fieldName = request.httpRequest.getPartAsStringFailsafe("field-name", 100) + } else if (freenetRequest.httpRequest.getPartAsStringFailsafe("add-field", 4) == "true") { + val fieldName = freenetRequest.httpRequest.getPartAsStringFailsafe("field-name", 100) try { profile.addField(fieldName) - request.currentSone!!.profile = profile + freenetRequest.currentSone!!.profile = profile webInterface.core.touchConfiguration() throw RedirectException("editProfile.html#profile-fields") } catch (e: DuplicateField) { @@ -50,17 +50,17 @@ class EditProfilePage(template: Template, webInterface: WebInterface): templateContext["duplicateFieldName"] = true } } else profile.fields.forEach { field -> - if (request.httpRequest.getPartAsStringFailsafe("delete-field-${field.id}", 4) == "true") { + if (freenetRequest.httpRequest.getPartAsStringFailsafe("delete-field-${field.id}", 4) == "true") { throw RedirectException("deleteProfileField.html?field=${field.id}") - } else if (request.httpRequest.getPartAsStringFailsafe("edit-field-${field.id}", 4) == "true") { + } else if (freenetRequest.httpRequest.getPartAsStringFailsafe("edit-field-${field.id}", 4) == "true") { throw RedirectException("editProfileField.html?field=${field.id}") - } else if (request.httpRequest.getPartAsStringFailsafe("move-down-field-${field.id}", 4) == "true") { + } else if (freenetRequest.httpRequest.getPartAsStringFailsafe("move-down-field-${field.id}", 4) == "true") { profile.moveFieldDown(field) - request.currentSone!!.profile = profile + freenetRequest.currentSone!!.profile = profile throw RedirectException("editProfile.html#profile-fields") - } else if (request.httpRequest.getPartAsStringFailsafe("move-up-field-${field.id}", 4) == "true") { + } else if (freenetRequest.httpRequest.getPartAsStringFailsafe("move-up-field-${field.id}", 4) == "true") { profile.moveFieldUp(field) - request.currentSone!!.profile = profile + freenetRequest.currentSone!!.profile = profile throw RedirectException("editProfile.html#profile-fields") } } diff --git a/src/main/kotlin/net/pterodactylus/sone/web/pages/FollowSonePage.kt b/src/main/kotlin/net/pterodactylus/sone/web/pages/FollowSonePage.kt index 75ce7f8..781e07f 100644 --- a/src/main/kotlin/net/pterodactylus/sone/web/pages/FollowSonePage.kt +++ b/src/main/kotlin/net/pterodactylus/sone/web/pages/FollowSonePage.kt @@ -12,17 +12,17 @@ import net.pterodactylus.util.template.TemplateContext class FollowSonePage(template: Template, webInterface: WebInterface): SoneTemplatePage("followSone.html", template, "Page.FollowSone.Title", webInterface, true) { - override fun handleRequest(request: FreenetRequest, templateContext: TemplateContext) { - if (request.isPOST) { - request.httpRequest.getPartAsStringFailsafe("sone", 1200).split(Regex("[ ,]+")) + override fun handleRequest(freenetRequest: FreenetRequest, templateContext: TemplateContext) { + if (freenetRequest.isPOST) { + freenetRequest.httpRequest.getPartAsStringFailsafe("sone", 1200).split(Regex("[ ,]+")) .map { it to webInterface.core.getSone(it) } .filter { it.second.isPresent } .map { it.first to it.second.get() } .forEach { sone -> - webInterface.core.followSone(request.currentSone, sone.first) + webInterface.core.followSone(freenetRequest.currentSone, sone.first) webInterface.core.markSoneKnown(sone.second) } - throw RedirectException(request.httpRequest.getPartAsStringFailsafe("returnPage", 256)) + throw RedirectException(freenetRequest.httpRequest.getPartAsStringFailsafe("returnPage", 256)) } } diff --git a/src/main/kotlin/net/pterodactylus/sone/web/pages/ImageBrowserPage.kt b/src/main/kotlin/net/pterodactylus/sone/web/pages/ImageBrowserPage.kt index 5e8701b..3181355 100644 --- a/src/main/kotlin/net/pterodactylus/sone/web/pages/ImageBrowserPage.kt +++ b/src/main/kotlin/net/pterodactylus/sone/web/pages/ImageBrowserPage.kt @@ -16,15 +16,15 @@ import java.net.URI class ImageBrowserPage(template: Template, webInterface: WebInterface): SoneTemplatePage("imageBrowser.html", template, "Page.ImageBrowser.Title", webInterface, true) { - override fun handleRequest(request: FreenetRequest, templateContext: TemplateContext) { - if ("album" in request.parameters) { + override fun handleRequest(freenetRequest: FreenetRequest, templateContext: TemplateContext) { + if ("album" in freenetRequest.parameters) { templateContext["albumRequested"] = true - templateContext["album"] = webInterface.core.getAlbum(request.parameters["album"]!!) - templateContext["page"] = request.parameters["page"] - } else if ("image" in request.parameters) { + templateContext["album"] = webInterface.core.getAlbum(freenetRequest.parameters["album"]!!) + templateContext["page"] = freenetRequest.parameters["page"] + } else if ("image" in freenetRequest.parameters) { templateContext["imageRequested"] = true - templateContext["image"] = webInterface.core.getImage(request.parameters["image"]) - } else if (request.parameters["mode"] == "gallery") { + templateContext["image"] = webInterface.core.getImage(freenetRequest.parameters["image"]) + } else if (freenetRequest.parameters["mode"] == "gallery") { templateContext["galleryRequested"] = true webInterface.core.sones .map(Sone::getRootAlbum) @@ -33,14 +33,14 @@ class ImageBrowserPage(template: Template, webInterface: WebInterface): .filterNot(Album::isEmpty) .sortedBy(Album::getTitle) .also { albums -> - Pagination(albums, webInterface.core.preferences.imagesPerPage).apply { page = request.parameters["page"]?.toIntOrNull() ?: 0 }.also { pagination -> + Pagination(albums, webInterface.core.preferences.imagesPerPage).apply { page = freenetRequest.parameters["page"]?.toIntOrNull() ?: 0 }.also { pagination -> templateContext["albumPagination"] = pagination templateContext["albums"] = pagination.items } } } else { templateContext["soneRequested"] = true - templateContext["sone"] = webInterface.core.getSone(request.httpRequest.getParam("sone")).orNull() ?: getCurrentSone(request.toadletContext) + templateContext["sone"] = webInterface.core.getSone(freenetRequest.httpRequest.getParam("sone")).orNull() ?: getCurrentSone(freenetRequest.toadletContext) } } diff --git a/src/main/kotlin/net/pterodactylus/sone/web/pages/IndexPage.kt b/src/main/kotlin/net/pterodactylus/sone/web/pages/IndexPage.kt index 35f0f75..bf6e0c4 100644 --- a/src/main/kotlin/net/pterodactylus/sone/web/pages/IndexPage.kt +++ b/src/main/kotlin/net/pterodactylus/sone/web/pages/IndexPage.kt @@ -15,8 +15,8 @@ import net.pterodactylus.util.template.TemplateContext class IndexPage(template: Template, webInterface: WebInterface, private val postVisibilityFilter: PostVisibilityFilter): SoneTemplatePage("index.html", template, "Page.Index.Title", webInterface, true) { - override fun handleRequest(request: FreenetRequest, templateContext: TemplateContext) { - getCurrentSone(request.toadletContext)!!.let { currentSone -> + override fun handleRequest(freenetRequest: FreenetRequest, templateContext: TemplateContext) { + getCurrentSone(freenetRequest.toadletContext)!!.let { currentSone -> (currentSone.posts + currentSone.friends .map { webInterface.core.getSone(it) } @@ -29,7 +29,7 @@ class IndexPage(template: Template, webInterface: WebInterface, private val post .sortedByDescending { it.time } .let { posts -> Pagination(posts, webInterface.core.preferences.postsPerPage).apply { - page = request.parameters["page"]?.toIntOrNull() ?: 0 + page = freenetRequest.parameters["page"]?.toIntOrNull() ?: 0 }.let { pagination -> templateContext["pagination"] = pagination templateContext["posts"] = pagination.items diff --git a/src/main/kotlin/net/pterodactylus/sone/web/pages/KnownSonesPage.kt b/src/main/kotlin/net/pterodactylus/sone/web/pages/KnownSonesPage.kt index 53941fc..9d6930d 100644 --- a/src/main/kotlin/net/pterodactylus/sone/web/pages/KnownSonesPage.kt +++ b/src/main/kotlin/net/pterodactylus/sone/web/pages/KnownSonesPage.kt @@ -14,35 +14,35 @@ import net.pterodactylus.util.template.TemplateContext class KnownSonesPage(template: Template, webInterface: WebInterface): SoneTemplatePage("knownSones.html", template, "Page.KnownSones.Title", webInterface, false) { - override fun handleRequest(request: FreenetRequest, templateContext: TemplateContext) { - getCurrentSone(request.toadletContext).let { currentSone -> + override fun handleRequest(freenetRequest: FreenetRequest, templateContext: TemplateContext) { + getCurrentSone(freenetRequest.toadletContext).let { currentSone -> Pagination(webInterface.core.sones - .filterNot { request.parameters["filter"] == "followed" && currentSone != null && !currentSone.hasFriend(it.id) } - .filterNot { request.parameters["filter"] == "not-followed" && currentSone != null && currentSone.hasFriend(it.id) } - .filterNot { request.parameters["filter"] == "new" && it.isKnown } - .filterNot { request.parameters["filter"] == "not-new" && !it.isKnown } - .filterNot { request.parameters["filter"] == "own" && !it.isLocal } - .filterNot { request.parameters["filter"] == "not-own" && it.isLocal } + .filterNot { freenetRequest.parameters["filter"] == "followed" && currentSone != null && !currentSone.hasFriend(it.id) } + .filterNot { freenetRequest.parameters["filter"] == "not-followed" && currentSone != null && currentSone.hasFriend(it.id) } + .filterNot { freenetRequest.parameters["filter"] == "new" && it.isKnown } + .filterNot { freenetRequest.parameters["filter"] == "not-new" && !it.isKnown } + .filterNot { freenetRequest.parameters["filter"] == "own" && !it.isLocal } + .filterNot { freenetRequest.parameters["filter"] == "not-own" && it.isLocal } .sortedWith( - when (request.parameters["sort"]) { + when (freenetRequest.parameters["sort"]) { "images" -> Sone.IMAGE_COUNT_COMPARATOR "name" -> Sone.NICE_NAME_COMPARATOR.reversed() "posts" -> Sone.POST_COUNT_COMPARATOR else -> Sone.LAST_ACTIVITY_COMPARATOR }.let { comparator -> - when (request.parameters["order"]) { + when (freenetRequest.parameters["order"]) { "asc" -> comparator.reversed() else -> comparator } } - ), 25).apply { page = request.parameters["page"]?.toIntOrNull() ?: 0 } + ), 25).apply { page = freenetRequest.parameters["page"]?.toIntOrNull() ?: 0 } .let { pagination -> templateContext["pagination"] = pagination templateContext["knownSones"] = pagination.items } - templateContext["sort"] = request.parameters["sort"].let { sort -> if (sort in listOf("images", "name", "posts")) sort else "activity" } - templateContext["order"] = request.parameters["order"].let { order -> if (order == "asc") "asc" else "desc" } - templateContext["filter"] = request.parameters["filter"] + templateContext["sort"] = freenetRequest.parameters["sort"].let { sort -> if (sort in listOf("images", "name", "posts")) sort else "activity" } + templateContext["order"] = freenetRequest.parameters["order"].let { order -> if (order == "asc") "asc" else "desc" } + templateContext["filter"] = freenetRequest.parameters["filter"] } } 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 9f6191e..43753a3 100644 --- a/src/main/kotlin/net/pterodactylus/sone/web/pages/LikePage.kt +++ b/src/main/kotlin/net/pterodactylus/sone/web/pages/LikePage.kt @@ -13,16 +13,16 @@ import net.pterodactylus.util.template.TemplateContext class LikePage(template: Template, webInterface: WebInterface) : SoneTemplatePage("like.html", template, "Page.Like.Title", webInterface, true) { - override fun handleRequest(request: FreenetRequest, templateContext: TemplateContext) { - if (request.isPOST) { - getCurrentSone(request.toadletContext)!!.let { currentSone -> - request.parameters["type", 16]?.also { type -> + override fun handleRequest(freenetRequest: FreenetRequest, templateContext: TemplateContext) { + if (freenetRequest.isPOST) { + getCurrentSone(freenetRequest.toadletContext)!!.let { currentSone -> + freenetRequest.parameters["type", 16]?.also { type -> when(type) { - "post" -> currentSone.addLikedPostId(request.parameters["post", 36]!!) - "reply" -> currentSone.addLikedReplyId(request.parameters["reply", 36]!!) + "post" -> currentSone.addLikedPostId(freenetRequest.parameters["post", 36]!!) + "reply" -> currentSone.addLikedReplyId(freenetRequest.parameters["reply", 36]!!) } } - throw RedirectException(request.parameters["returnPage", 256]!!) + throw RedirectException(freenetRequest.parameters["returnPage", 256]!!) } } } diff --git a/src/main/kotlin/net/pterodactylus/sone/web/pages/LockSonePage.kt b/src/main/kotlin/net/pterodactylus/sone/web/pages/LockSonePage.kt index ca70301..835fe23 100644 --- a/src/main/kotlin/net/pterodactylus/sone/web/pages/LockSonePage.kt +++ b/src/main/kotlin/net/pterodactylus/sone/web/pages/LockSonePage.kt @@ -12,9 +12,9 @@ import net.pterodactylus.util.template.TemplateContext class LockSonePage(template: Template, webInterface: WebInterface): SoneTemplatePage("lockSone.html", template, "Page.LockSone.Title", webInterface, false) { - override fun handleRequest(request: FreenetRequest, templateContext: TemplateContext) { - request.parameters["returnPage", 256]!!.let { returnPage -> - request.parameters["sone", 44]!! + override fun handleRequest(freenetRequest: FreenetRequest, templateContext: TemplateContext) { + freenetRequest.parameters["returnPage", 256]!!.let { returnPage -> + freenetRequest.parameters["sone", 44]!! .let { webInterface.core.getLocalSone(it) } ?.let { webInterface.core.lockSone(it) } throw RedirectException(returnPage) 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 442aa7b..0e0fee5 100644 --- a/src/main/kotlin/net/pterodactylus/sone/web/pages/LoginPage.kt +++ b/src/main/kotlin/net/pterodactylus/sone/web/pages/LoginPage.kt @@ -15,12 +15,12 @@ import net.pterodactylus.util.template.TemplateContext class LoginPage(template: Template, webInterface: WebInterface): SoneTemplatePage("login.html", template, "Page.Login.Title", webInterface) { - override fun handleRequest(request: FreenetRequest, templateContext: TemplateContext) { - if (request.isPOST) { - val soneId = request.httpRequest.getPartAsStringFailsafe("sone-id", 43) + override fun handleRequest(freenetRequest: FreenetRequest, templateContext: TemplateContext) { + if (freenetRequest.isPOST) { + val soneId = freenetRequest.httpRequest.getPartAsStringFailsafe("sone-id", 43) webInterface.core.getLocalSone(soneId)?.let { sone -> - setCurrentSone(request.toadletContext, sone) - val target = request.httpRequest.getParam("target").emptyToNull ?: "index.html" + setCurrentSone(freenetRequest.toadletContext, sone) + val target = freenetRequest.httpRequest.getParam("target").emptyToNull ?: "index.html" throw RedirectException(target) } } @@ -28,8 +28,8 @@ class LoginPage(template: Template, webInterface: WebInterface): templateContext["identitiesWithoutSone"] = webInterface.core.identityManager.allOwnIdentities.filterNot { "Sone" in it.contexts }.sortedBy { "${it.nickname}@${it.id}" } } - override public fun getRedirectTarget(request: FreenetRequest) = - getCurrentSone(request.toadletContext)?.let { "index.html" } + override public fun getRedirectTarget(freenetRequest: FreenetRequest) = + getCurrentSone(freenetRequest.toadletContext)?.let { "index.html" } override fun isEnabled(toadletContext: ToadletContext) = when { webInterface.core.preferences.isRequireFullAccess && !toadletContext.isAllowedFullAccess -> false diff --git a/src/main/kotlin/net/pterodactylus/sone/web/pages/LogoutPage.kt b/src/main/kotlin/net/pterodactylus/sone/web/pages/LogoutPage.kt index 12cf8b4..3a2a023 100644 --- a/src/main/kotlin/net/pterodactylus/sone/web/pages/LogoutPage.kt +++ b/src/main/kotlin/net/pterodactylus/sone/web/pages/LogoutPage.kt @@ -12,8 +12,8 @@ import net.pterodactylus.util.template.TemplateContext class LogoutPage(template: Template, webInterface: WebInterface): SoneTemplatePage("logout.html", template, "Page.Logout.Title", webInterface, true) { - override fun handleRequest(request: FreenetRequest, templateContext: TemplateContext) { - setCurrentSone(request.toadletContext, null) + override fun handleRequest(freenetRequest: FreenetRequest, templateContext: TemplateContext) { + setCurrentSone(freenetRequest.toadletContext, null) throw RedirectException("index.html") } diff --git a/src/main/kotlin/net/pterodactylus/sone/web/pages/MarkAsKnownPage.kt b/src/main/kotlin/net/pterodactylus/sone/web/pages/MarkAsKnownPage.kt index f88fab3..570e570 100644 --- a/src/main/kotlin/net/pterodactylus/sone/web/pages/MarkAsKnownPage.kt +++ b/src/main/kotlin/net/pterodactylus/sone/web/pages/MarkAsKnownPage.kt @@ -15,15 +15,15 @@ import net.pterodactylus.util.template.TemplateContext class MarkAsKnownPage(template: Template, webInterface: WebInterface): SoneTemplatePage("markAsKnown.html", template, "Page.MarkAsKnown.Title", webInterface, false) { - override fun handleRequest(request: FreenetRequest, templateContext: TemplateContext) { - val ids = request.parameters["id", 65536]!!.split(" ") - when (request.parameters["type", 5]) { + override fun handleRequest(freenetRequest: FreenetRequest, templateContext: TemplateContext) { + val ids = freenetRequest.parameters["id", 65536]!!.split(" ") + when (freenetRequest.parameters["type", 5]) { "sone" -> ids.mapPresent(webInterface.core::getSone).forEach(webInterface.core::markSoneKnown) "post" -> ids.mapPresent(webInterface.core::getPost).forEach(webInterface.core::markPostKnown) "reply" -> ids.mapPresent(webInterface.core::getPostReply).forEach(webInterface.core::markReplyKnown) else -> throw RedirectException("invalid.html") } - throw RedirectException(request.parameters["returnPage", 256]!!) + throw RedirectException(freenetRequest.parameters["returnPage", 256]!!) } } diff --git a/src/main/kotlin/net/pterodactylus/sone/web/pages/NewPage.kt b/src/main/kotlin/net/pterodactylus/sone/web/pages/NewPage.kt index d1841d4..55df67a 100644 --- a/src/main/kotlin/net/pterodactylus/sone/web/pages/NewPage.kt +++ b/src/main/kotlin/net/pterodactylus/sone/web/pages/NewPage.kt @@ -15,14 +15,14 @@ import net.pterodactylus.util.template.TemplateContext class NewPage(template: Template, webInterface: WebInterface): SoneTemplatePage("new.html", template, "Page.New.Title", webInterface, false) { - override fun handleRequest(request: FreenetRequest, templateContext: TemplateContext) = - getCurrentSone(request.toadletContext).let { currentSone -> + override fun handleRequest(freenetRequest: FreenetRequest, templateContext: TemplateContext) = + getCurrentSone(freenetRequest.toadletContext).let { currentSone -> (webInterface.getNewPosts(currentSone) + webInterface.getNewReplies(currentSone).mapPresent { it.post }) .distinct() .sortedByDescending { it.time } .let { posts -> Pagination(posts, webInterface.core.preferences.postsPerPage).apply { - page = request.parameters["page"]?.toIntOrNull() ?: 0 + page = freenetRequest.parameters["page"]?.toIntOrNull() ?: 0 }.let { pagination -> templateContext["pagination"] = pagination templateContext["posts"] = pagination.items diff --git a/src/main/kotlin/net/pterodactylus/sone/web/pages/OptionsPage.kt b/src/main/kotlin/net/pterodactylus/sone/web/pages/OptionsPage.kt index c8295ac..7cf1bb3 100644 --- a/src/main/kotlin/net/pterodactylus/sone/web/pages/OptionsPage.kt +++ b/src/main/kotlin/net/pterodactylus/sone/web/pages/OptionsPage.kt @@ -17,17 +17,17 @@ import net.pterodactylus.util.template.TemplateContext class OptionsPage(template: Template, webInterface: WebInterface): SoneTemplatePage("options.html", template, "Page.Options.Title", webInterface, false) { - override fun handleRequest(request: FreenetRequest, templateContext: TemplateContext) { - if (request.isPOST) { + override fun handleRequest(freenetRequest: FreenetRequest, templateContext: TemplateContext) { + if (freenetRequest.isPOST) { val fieldsWithErrors = mutableListOf() - getCurrentSone(request.toadletContext)?.options?.let { options -> - val autoFollow = "auto-follow" in request.parameters - val loadLinkedImages = request.parameters["load-linked-images"].emptyToNull - val showCustomAvatars = request.parameters["show-custom-avatars"].emptyToNull - val enableSoneInsertNotification = "enable-sone-insert-notifications" in request.parameters - val showNewSoneNotification = "show-notification-new-sones" in request.parameters - val showNewPostNotification = "show-notification-new-posts" in request.parameters - val showNewReplyNotification = "show-notification-new-replies" in request.parameters + getCurrentSone(freenetRequest.toadletContext)?.options?.let { options -> + val autoFollow = "auto-follow" in freenetRequest.parameters + val loadLinkedImages = freenetRequest.parameters["load-linked-images"].emptyToNull + val showCustomAvatars = freenetRequest.parameters["show-custom-avatars"].emptyToNull + val enableSoneInsertNotification = "enable-sone-insert-notifications" in freenetRequest.parameters + val showNewSoneNotification = "show-notification-new-sones" in freenetRequest.parameters + val showNewPostNotification = "show-notification-new-posts" in freenetRequest.parameters + val showNewReplyNotification = "show-notification-new-replies" in freenetRequest.parameters options.isAutoFollow = autoFollow options.isSoneInsertNotificationEnabled = enableSoneInsertNotification @@ -37,21 +37,21 @@ class OptionsPage(template: Template, webInterface: WebInterface): loadLinkedImages?.also { if (cantSetOption { options.loadLinkedImages = LoadExternalContent.valueOf(loadLinkedImages) }) fieldsWithErrors += "load-linked-images" } showCustomAvatars?.also { if (cantSetOption { options.showCustomAvatars = LoadExternalContent.valueOf(showCustomAvatars) }) fieldsWithErrors += "show-custom-avatars" } } - val fullAccessRequired = "require-full-access" in request.parameters - val fcpInterfaceActive = "fcp-interface-active" in request.parameters + val fullAccessRequired = "require-full-access" in freenetRequest.parameters + val fcpInterfaceActive = "fcp-interface-active" in freenetRequest.parameters webInterface.core.preferences.isRequireFullAccess = fullAccessRequired webInterface.core.preferences.isFcpInterfaceActive = fcpInterfaceActive - val postsPerPage = request.parameters["posts-per-page"]?.toIntOrNull() - val charactersPerPost = request.parameters["characters-per-post"]?.toIntOrNull() - val postCutOffLength = request.parameters["post-cut-off-length"]?.toIntOrNull() - val imagesPerPage = request.parameters["images-per-page"]?.toIntOrNull() - val insertionDelay = request.parameters["insertion-delay"]?.toIntOrNull() - val fcpFullAccessRequired = request.parameters["fcp-full-access-required"]?.toIntOrNull() - val negativeTrust = request.parameters["negative-trust"]?.toIntOrNull() - val positiveTrust = request.parameters["positive-trust"]?.toIntOrNull() - val trustComment = request.parameters["trust-comment"]?.emptyToNull + val postsPerPage = freenetRequest.parameters["posts-per-page"]?.toIntOrNull() + val charactersPerPost = freenetRequest.parameters["characters-per-post"]?.toIntOrNull() + val postCutOffLength = freenetRequest.parameters["post-cut-off-length"]?.toIntOrNull() + val imagesPerPage = freenetRequest.parameters["images-per-page"]?.toIntOrNull() + val insertionDelay = freenetRequest.parameters["insertion-delay"]?.toIntOrNull() + val fcpFullAccessRequired = freenetRequest.parameters["fcp-full-access-required"]?.toIntOrNull() + val negativeTrust = freenetRequest.parameters["negative-trust"]?.toIntOrNull() + val positiveTrust = freenetRequest.parameters["positive-trust"]?.toIntOrNull() + val trustComment = freenetRequest.parameters["trust-comment"]?.emptyToNull if (cantSetOption { it.setPostsPerPage(postsPerPage) }) fieldsWithErrors += "posts-per-page" if (cantSetOption { it.setCharactersPerPost(charactersPerPost) }) fieldsWithErrors += "characters-per-post" @@ -69,7 +69,7 @@ class OptionsPage(template: Template, webInterface: WebInterface): } templateContext["fieldErrors"] = fieldsWithErrors } - getCurrentSone(request.toadletContext)?.options?.let { options -> + getCurrentSone(freenetRequest.toadletContext)?.options?.let { options -> templateContext["auto-follow"] = options.isAutoFollow templateContext["show-notification-new-sones"] = options.isShowNewSoneNotifications templateContext["show-notification-new-posts"] = options.isShowNewPostNotifications diff --git a/src/main/kotlin/net/pterodactylus/sone/web/pages/RescuePage.kt b/src/main/kotlin/net/pterodactylus/sone/web/pages/RescuePage.kt index b882ee6..dbcf59f 100644 --- a/src/main/kotlin/net/pterodactylus/sone/web/pages/RescuePage.kt +++ b/src/main/kotlin/net/pterodactylus/sone/web/pages/RescuePage.kt @@ -13,16 +13,16 @@ import net.pterodactylus.util.template.TemplateContext class RescuePage(template: Template, webInterface: WebInterface): SoneTemplatePage("rescue.html", template, "Page.Rescue.Title", webInterface, true) { - override fun handleRequest(request: FreenetRequest, templateContext: TemplateContext) { - val soneRescuer = webInterface.core.getSoneRescuer(getCurrentSone(request.toadletContext)!!) + override fun handleRequest(freenetRequest: FreenetRequest, templateContext: TemplateContext) { + val soneRescuer = webInterface.core.getSoneRescuer(getCurrentSone(freenetRequest.toadletContext)!!) templateContext["soneRescuer"] = soneRescuer - if (request.isPOST) { - request.parameters["edition", 9]?.toIntOrNull()?.also { + if (freenetRequest.isPOST) { + freenetRequest.parameters["edition", 9]?.toIntOrNull()?.also { if (it > -1) { soneRescuer.setEdition(it.toLong()) } } - if (request.parameters["fetch", 8] == "true") { + if (freenetRequest.parameters["fetch", 8] == "true") { soneRescuer.startNextFetch() } throw RedirectException("rescue.html") diff --git a/src/main/kotlin/net/pterodactylus/sone/web/pages/SearchPage.kt b/src/main/kotlin/net/pterodactylus/sone/web/pages/SearchPage.kt index 321146a..aff6aaf 100644 --- a/src/main/kotlin/net/pterodactylus/sone/web/pages/SearchPage.kt +++ b/src/main/kotlin/net/pterodactylus/sone/web/pages/SearchPage.kt @@ -30,9 +30,9 @@ class SearchPage @JvmOverloads constructor(template: Template, webInterface: Web private val cache: Cache, Pagination> = CacheBuilder.newBuilder().ticker(ticker).expireAfterAccess(5, MINUTES).build() - override fun handleRequest(request: FreenetRequest, templateContext: TemplateContext) { + override fun handleRequest(freenetRequest: FreenetRequest, templateContext: TemplateContext) { val phrases = try { - request.parameters["query"].emptyToNull?.parse() + freenetRequest.parameters["query"].emptyToNull?.parse() } catch (te: TextException) { redirect("index.html") } @@ -53,13 +53,13 @@ class SearchPage @JvmOverloads constructor(template: Template, webInterface: Web val sonePagination = webInterface.core.sones .scoreAndPaginate(phrases) { it.allText() } - .apply { page = request.parameters["sonePage"].emptyToNull?.toIntOrNull() ?: 0 } + .apply { page = freenetRequest.parameters["sonePage"].emptyToNull?.toIntOrNull() ?: 0 } val postPagination = cache.get(phrases) { webInterface.core.sones .flatMap(Sone::getPosts) .filter { Post.FUTURE_POSTS_FILTER.apply(it) } .scoreAndPaginate(phrases) { it.allText() } - }.apply { page = request.parameters["postPage"].emptyToNull?.toIntOrNull() ?: 0 } + }.apply { page = freenetRequest.parameters["postPage"].emptyToNull?.toIntOrNull() ?: 0 } templateContext["sonePagination"] = sonePagination templateContext["soneHits"] = sonePagination.items 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 6f5de15..3f04236 100644 --- a/src/main/kotlin/net/pterodactylus/sone/web/pages/SoneTemplatePage.kt +++ b/src/main/kotlin/net/pterodactylus/sone/web/pages/SoneTemplatePage.kt @@ -42,7 +42,7 @@ open class SoneTemplatePage( fun requiresLogin() = requiresLogin - override public fun getPageTitle(request: FreenetRequest) = + override public fun getPageTitle(freenetRequest: FreenetRequest) = pageTitleKey?.let(webInterface.l10n::getString) ?: "" override public fun getStyleSheets() = @@ -76,16 +76,16 @@ open class SoneTemplatePage( handleRequest(freenetRequest, templateContext) } - internal open fun handleRequest(request: FreenetRequest, templateContext: TemplateContext) { + internal open fun handleRequest(freenetRequest: FreenetRequest, templateContext: TemplateContext) { } - 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 } } + 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 } } .joinToString("&") { "${it.first.urlEncode}=${it.second.urlEncode}" } .emptyToNull - return "login.html?target=${request.httpRequest.path}${parameters?.let { ("?" + it).urlEncode } ?: ""}" + return "login.html?target=${freenetRequest.httpRequest.path}${parameters?.let { ("?" + it).urlEncode } ?: ""}" } return null } 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 a93dc2e..bdc8952 100644 --- a/src/main/kotlin/net/pterodactylus/sone/web/pages/TrustPage.kt +++ b/src/main/kotlin/net/pterodactylus/sone/web/pages/TrustPage.kt @@ -15,14 +15,14 @@ import net.pterodactylus.util.template.TemplateContext class TrustPage(template: Template, webInterface: WebInterface): SoneTemplatePage("trust.html", template, "Page.Trust.Title", webInterface, true) { - override fun handleRequest(request: FreenetRequest, templateContext: TemplateContext) { - if (request.isPOST) { - getCurrentSone(request.toadletContext)?.also { currentSone -> - webInterface.core.getSone(request.parameters["sone"]).let { sone -> + override fun handleRequest(freenetRequest: FreenetRequest, templateContext: TemplateContext) { + if (freenetRequest.isPOST) { + getCurrentSone(freenetRequest.toadletContext)?.also { currentSone -> + webInterface.core.getSone(freenetRequest.parameters["sone"]).let { sone -> webInterface.core.trustSone(currentSone, sone) } } - throw RedirectException(request.parameters["returnPage", 256]) + throw RedirectException(freenetRequest.parameters["returnPage", 256]) } } diff --git a/src/main/kotlin/net/pterodactylus/sone/web/pages/UnbookmarkPage.kt b/src/main/kotlin/net/pterodactylus/sone/web/pages/UnbookmarkPage.kt index 6af1bcf..01a0fde 100644 --- a/src/main/kotlin/net/pterodactylus/sone/web/pages/UnbookmarkPage.kt +++ b/src/main/kotlin/net/pterodactylus/sone/web/pages/UnbookmarkPage.kt @@ -16,19 +16,19 @@ import net.pterodactylus.util.template.TemplateContext class UnbookmarkPage(template: Template, webInterface: WebInterface): SoneTemplatePage("unbookmark.html", template, "Page.Unbookmark.Title", webInterface, false) { - override fun handleRequest(request: FreenetRequest, templateContext: TemplateContext) { + override fun handleRequest(freenetRequest: FreenetRequest, templateContext: TemplateContext) { when { - request.isGET && (request.parameters["post"] == "allNotLoaded") -> { + freenetRequest.isGET && (freenetRequest.parameters["post"] == "allNotLoaded") -> { webInterface.core.bookmarkedPosts .filterNot(Post::isLoaded) .forEach(webInterface.core::unbookmarkPost) throw RedirectException("bookmarks.html") } - request.isPOST -> { - request.parameters["post", 36] + freenetRequest.isPOST -> { + freenetRequest.parameters["post", 36] .let(webInterface.core::getPost) .also(webInterface.core::unbookmarkPost) - throw RedirectException(request.parameters["returnPage", 256]) + 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 3b299d2..db79d16 100644 --- a/src/main/kotlin/net/pterodactylus/sone/web/pages/UnfollowSonePage.kt +++ b/src/main/kotlin/net/pterodactylus/sone/web/pages/UnfollowSonePage.kt @@ -14,13 +14,13 @@ import java.util.regex.Pattern class UnfollowSonePage(template: Template, webInterface: WebInterface): SoneTemplatePage("unfollowSone.html", template, "Page.UnfollowSone.Title", webInterface, true) { - override fun handleRequest(request: FreenetRequest, templateContext: TemplateContext) { - if (request.isPOST) { - getCurrentSone(request.toadletContext)!!.also { currentSone -> - request.parameters["sone"]!!.split(Regex("[ ,]+")) + override fun handleRequest(freenetRequest: FreenetRequest, templateContext: TemplateContext) { + if (freenetRequest.isPOST) { + getCurrentSone(freenetRequest.toadletContext)!!.also { currentSone -> + freenetRequest.parameters["sone"]!!.split(Regex("[ ,]+")) .forEach { webInterface.core.unfollowSone(currentSone, it) } } - throw RedirectException(request.parameters["returnPage", 256]) + throw RedirectException(freenetRequest.parameters["returnPage", 256]) } } diff --git a/src/main/kotlin/net/pterodactylus/sone/web/pages/UnlikePage.kt b/src/main/kotlin/net/pterodactylus/sone/web/pages/UnlikePage.kt index 280ccbb..42e552e 100644 --- a/src/main/kotlin/net/pterodactylus/sone/web/pages/UnlikePage.kt +++ b/src/main/kotlin/net/pterodactylus/sone/web/pages/UnlikePage.kt @@ -13,13 +13,13 @@ import net.pterodactylus.util.template.TemplateContext class UnlikePage(template: Template, webInterface: WebInterface): SoneTemplatePage("unlike.html", template, "Page.Unlike.Title", webInterface, true) { - override fun handleRequest(request: FreenetRequest, templateContext: TemplateContext) { - if (request.isPOST) { - when (request.parameters["type"]) { - "post" -> getCurrentSone(request.toadletContext)!!.removeLikedPostId(request.parameters["post"]!!) - "reply" -> getCurrentSone(request.toadletContext)!!.removeLikedReplyId(request.parameters["reply"]!!) + override fun handleRequest(freenetRequest: FreenetRequest, templateContext: TemplateContext) { + if (freenetRequest.isPOST) { + when (freenetRequest.parameters["type"]) { + "post" -> getCurrentSone(freenetRequest.toadletContext)!!.removeLikedPostId(freenetRequest.parameters["post"]!!) + "reply" -> getCurrentSone(freenetRequest.toadletContext)!!.removeLikedReplyId(freenetRequest.parameters["reply"]!!) } - throw RedirectException(request.parameters["returnPage", 256]) + throw RedirectException(freenetRequest.parameters["returnPage", 256]) } } diff --git a/src/main/kotlin/net/pterodactylus/sone/web/pages/UnlockSonePage.kt b/src/main/kotlin/net/pterodactylus/sone/web/pages/UnlockSonePage.kt index 7ed2418..e792318 100644 --- a/src/main/kotlin/net/pterodactylus/sone/web/pages/UnlockSonePage.kt +++ b/src/main/kotlin/net/pterodactylus/sone/web/pages/UnlockSonePage.kt @@ -13,12 +13,12 @@ import net.pterodactylus.util.template.TemplateContext class UnlockSonePage(template: Template, webInterface: WebInterface): SoneTemplatePage("unlockSone.html", template, "Page.UnlockSone.Title", webInterface, false) { - override fun handleRequest(request: FreenetRequest, templateContext: TemplateContext) { - if (request.isPOST) { - request.parameters["sone", 44] + override fun handleRequest(freenetRequest: FreenetRequest, templateContext: TemplateContext) { + if (freenetRequest.isPOST) { + freenetRequest.parameters["sone", 44] .let(webInterface.core::getLocalSone) ?.also(webInterface.core::unlockSone) - throw RedirectException(request.parameters["returnPage", 256]) + 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 fb3f281..a46b272 100644 --- a/src/main/kotlin/net/pterodactylus/sone/web/pages/UntrustPage.kt +++ b/src/main/kotlin/net/pterodactylus/sone/web/pages/UntrustPage.kt @@ -15,14 +15,14 @@ import net.pterodactylus.util.template.TemplateContext class UntrustPage(template: Template, webInterface: WebInterface): SoneTemplatePage("untrust.html", template, "Page.Untrust.Title", webInterface, true) { - override fun handleRequest(request: FreenetRequest, templateContext: TemplateContext) { - if (request.isPOST) { - getCurrentSone(request.toadletContext)!!.also { currentSone -> - request.parameters["sone", 44] + override fun handleRequest(freenetRequest: FreenetRequest, templateContext: TemplateContext) { + if (freenetRequest.isPOST) { + getCurrentSone(freenetRequest.toadletContext)!!.also { currentSone -> + freenetRequest.parameters["sone", 44] .let(webInterface.core::getSone) .also { webInterface.core.untrustSone(currentSone, it) } } - throw RedirectException(request.parameters["returnPage", 256]) + throw RedirectException(freenetRequest.parameters["returnPage", 256]) } } diff --git a/src/main/kotlin/net/pterodactylus/sone/web/pages/UploadImagePage.kt b/src/main/kotlin/net/pterodactylus/sone/web/pages/UploadImagePage.kt index 774a179..577d52c 100644 --- a/src/main/kotlin/net/pterodactylus/sone/web/pages/UploadImagePage.kt +++ b/src/main/kotlin/net/pterodactylus/sone/web/pages/UploadImagePage.kt @@ -23,15 +23,15 @@ import javax.imageio.ImageIO class UploadImagePage(template: Template, webInterface: WebInterface): SoneTemplatePage("uploadImage.html", template, "Page.UploadImage.Title", webInterface, true) { - override fun handleRequest(request: FreenetRequest, templateContext: TemplateContext) { - if (request.isPOST) { - val parentAlbum = request.parameters["parent"]!!.let(webInterface.core::getAlbum) ?: throw RedirectException("noPermission.html") - if (parentAlbum.sone != getCurrentSone(request.toadletContext)) { + override fun handleRequest(freenetRequest: FreenetRequest, templateContext: TemplateContext) { + if (freenetRequest.isPOST) { + val parentAlbum = freenetRequest.parameters["parent"]!!.let(webInterface.core::getAlbum) ?: throw RedirectException("noPermission.html") + if (parentAlbum.sone != getCurrentSone(freenetRequest.toadletContext)) { throw RedirectException("noPermission.html") } - val title = request.parameters["title", 200].emptyToNull ?: throw RedirectException("emptyImageTitle.html") + val title = freenetRequest.parameters["title", 200].emptyToNull ?: throw RedirectException("emptyImageTitle.html") - val uploadedFile = request.httpRequest.getUploadedFile("image") + val uploadedFile = freenetRequest.httpRequest.getUploadedFile("image") val bytes = uploadedFile.data.use { it.toByteArray() } val bufferedImage = bytes.toImage() if (bufferedImage == null) { @@ -40,11 +40,11 @@ class UploadImagePage(template: Template, webInterface: WebInterface): } val temporaryImage = webInterface.core.createTemporaryImage(bytes.mimeType, bytes) - webInterface.core.createImage(getCurrentSone(request.toadletContext), parentAlbum, temporaryImage).modify().apply { + webInterface.core.createImage(getCurrentSone(freenetRequest.toadletContext), parentAlbum, temporaryImage).modify().apply { setWidth(bufferedImage.width) setHeight(bufferedImage.height) setTitle(title) - setDescription(TextFilter.filter(request.headers["Host"], request.parameters["description", 4000])) + setDescription(TextFilter.filter(freenetRequest.headers["Host"], freenetRequest.parameters["description", 4000])) }.update() throw RedirectException("imageBrowser.html?album=${parentAlbum.id}") } diff --git a/src/main/kotlin/net/pterodactylus/sone/web/pages/ViewPostPage.kt b/src/main/kotlin/net/pterodactylus/sone/web/pages/ViewPostPage.kt index d2e163d..457e13f 100644 --- a/src/main/kotlin/net/pterodactylus/sone/web/pages/ViewPostPage.kt +++ b/src/main/kotlin/net/pterodactylus/sone/web/pages/ViewPostPage.kt @@ -15,20 +15,20 @@ import java.net.URI class ViewPostPage(template: Template, webInterface: WebInterface): SoneTemplatePage("viewPost.html", template, "Page.ViewPost.Title", webInterface, false) { - override fun handleRequest(request: FreenetRequest, templateContext: TemplateContext) { - templateContext["post"] = request.parameters["post"].let(webInterface.core::getPost).orNull() - templateContext["raw"] = request.parameters["raw"] == "true" + override fun handleRequest(freenetRequest: FreenetRequest, templateContext: TemplateContext) { + templateContext["post"] = freenetRequest.parameters["post"].let(webInterface.core::getPost).orNull() + templateContext["raw"] = freenetRequest.parameters["raw"] == "true" } override fun isLinkExcepted(link: URI?) = true - public override fun getPageTitle(request: FreenetRequest) = - (request.parameters["post"].let(webInterface.core::getPost).let { + public override fun getPageTitle(freenetRequest: FreenetRequest) = + (freenetRequest.parameters["post"].let(webInterface.core::getPost).let { if (it.text.length > 20) { it.text.substring(0..19) + "…" } else { it.text } + " - ${SoneAccessor.getNiceName(it.sone)} - " - } ?: "") + super.getPageTitle(request) + } ?: "") + super.getPageTitle(freenetRequest) } diff --git a/src/main/kotlin/net/pterodactylus/sone/web/pages/ViewSonePage.kt b/src/main/kotlin/net/pterodactylus/sone/web/pages/ViewSonePage.kt index 6903920..90bc147 100644 --- a/src/main/kotlin/net/pterodactylus/sone/web/pages/ViewSonePage.kt +++ b/src/main/kotlin/net/pterodactylus/sone/web/pages/ViewSonePage.kt @@ -19,16 +19,16 @@ import java.net.URI class ViewSonePage(template: Template, webInterface: WebInterface): SoneTemplatePage("viewSone.html", template, webInterface, false) { - override fun handleRequest(request: FreenetRequest, templateContext: TemplateContext) { - templateContext["soneId"] = request.parameters["sone"] - request.parameters["sone"].let(webInterface.core::getSone).let { sone -> + override fun handleRequest(freenetRequest: FreenetRequest, templateContext: TemplateContext) { + templateContext["soneId"] = freenetRequest.parameters["sone"] + freenetRequest.parameters["sone"].let(webInterface.core::getSone).let { sone -> templateContext["sone"] = sone val sonePosts = sone.posts val directedPosts = webInterface.core.getDirectedPosts(sone.id) (sonePosts + directedPosts) .sortedByDescending(Post::getTime) .paginate(webInterface.core.preferences.postsPerPage) - .apply { page = request.parameters["postPage"]?.toIntOrNull() ?: 0 } + .apply { page = freenetRequest.parameters["postPage"]?.toIntOrNull() ?: 0 } .also { templateContext["postPagination"] = it templateContext["posts"] = it.items @@ -40,7 +40,7 @@ class ViewSonePage(template: Template, webInterface: WebInterface): .minus(directedPosts) .sortedByDescending { webInterface.core.getReplies(it.id).first().time } .paginate(webInterface.core.preferences.postsPerPage) - .apply { page = request.parameters["repliedPostPage"]?.toIntOrNull() ?: 0 } + .apply { page = freenetRequest.parameters["repliedPostPage"]?.toIntOrNull() ?: 0 } .also { templateContext["repliedPostPagination"] = it templateContext["repliedPosts"] = it.items @@ -50,8 +50,8 @@ class ViewSonePage(template: Template, webInterface: WebInterface): override fun isLinkExcepted(link: URI?) = true - public override fun getPageTitle(request: FreenetRequest): String = - request.parameters["sone"].let(webInterface.core::getSone).let { sone -> + public override fun getPageTitle(freenetRequest: FreenetRequest): String = + freenetRequest.parameters["sone"].let(webInterface.core::getSone).let { sone -> "${SoneAccessor.getNiceName(sone)} - ${webInterface.l10n.getString("Page.ViewSone.Title")}" } ?: webInterface.l10n.getString("Page.ViewSone.Page.TitleWithoutSone") diff --git a/src/test/kotlin/net/pterodactylus/sone/web/pages/SoneTemplatePageTest.kt b/src/test/kotlin/net/pterodactylus/sone/web/pages/SoneTemplatePageTest.kt index 6e7613c..3cb08e6 100644 --- a/src/test/kotlin/net/pterodactylus/sone/web/pages/SoneTemplatePageTest.kt +++ b/src/test/kotlin/net/pterodactylus/sone/web/pages/SoneTemplatePageTest.kt @@ -145,7 +145,7 @@ class SoneTemplatePageTest : WebPageTest({ template, webInterface -> object : So fun `handleRequest method is called`() { var called = false val page = object : SoneTemplatePage("path.html", template, webInterface, true) { - override fun handleRequest(request: FreenetRequest, templateContext: TemplateContext) { + override fun handleRequest(freenetRequest: FreenetRequest, templateContext: TemplateContext) { called = true } } -- 2.7.4