♻️ Use SoneRequest instead of FreenetRequest
authorDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Tue, 7 May 2019 19:59:09 +0000 (21:59 +0200)
committerDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Tue, 7 May 2019 19:59:09 +0000 (21:59 +0200)
72 files changed:
src/main/kotlin/net/pterodactylus/sone/web/pages/BookmarkPage.kt
src/main/kotlin/net/pterodactylus/sone/web/pages/BookmarksPage.kt
src/main/kotlin/net/pterodactylus/sone/web/pages/CreateAlbumPage.kt
src/main/kotlin/net/pterodactylus/sone/web/pages/CreatePostPage.kt
src/main/kotlin/net/pterodactylus/sone/web/pages/CreateReplyPage.kt
src/main/kotlin/net/pterodactylus/sone/web/pages/CreateSonePage.kt
src/main/kotlin/net/pterodactylus/sone/web/pages/DeleteAlbumPage.kt
src/main/kotlin/net/pterodactylus/sone/web/pages/DeleteImagePage.kt
src/main/kotlin/net/pterodactylus/sone/web/pages/DeletePostPage.kt
src/main/kotlin/net/pterodactylus/sone/web/pages/DeleteProfileFieldPage.kt
src/main/kotlin/net/pterodactylus/sone/web/pages/DeleteReplyPage.kt
src/main/kotlin/net/pterodactylus/sone/web/pages/DeleteSonePage.kt
src/main/kotlin/net/pterodactylus/sone/web/pages/DismissNotificationPage.kt
src/main/kotlin/net/pterodactylus/sone/web/pages/DistrustPage.kt
src/main/kotlin/net/pterodactylus/sone/web/pages/EditAlbumPage.kt
src/main/kotlin/net/pterodactylus/sone/web/pages/EditImagePage.kt
src/main/kotlin/net/pterodactylus/sone/web/pages/EditProfileFieldPage.kt
src/main/kotlin/net/pterodactylus/sone/web/pages/EditProfilePage.kt
src/main/kotlin/net/pterodactylus/sone/web/pages/FollowSonePage.kt
src/main/kotlin/net/pterodactylus/sone/web/pages/ImageBrowserPage.kt
src/main/kotlin/net/pterodactylus/sone/web/pages/IndexPage.kt
src/main/kotlin/net/pterodactylus/sone/web/pages/KnownSonesPage.kt
src/main/kotlin/net/pterodactylus/sone/web/pages/LikePage.kt
src/main/kotlin/net/pterodactylus/sone/web/pages/LockSonePage.kt
src/main/kotlin/net/pterodactylus/sone/web/pages/LoggedInPage.kt
src/main/kotlin/net/pterodactylus/sone/web/pages/LoginPage.kt
src/main/kotlin/net/pterodactylus/sone/web/pages/LogoutPage.kt
src/main/kotlin/net/pterodactylus/sone/web/pages/MarkAsKnownPage.kt
src/main/kotlin/net/pterodactylus/sone/web/pages/NewPage.kt
src/main/kotlin/net/pterodactylus/sone/web/pages/OptionsPage.kt
src/main/kotlin/net/pterodactylus/sone/web/pages/RescuePage.kt
src/main/kotlin/net/pterodactylus/sone/web/pages/SearchPage.kt
src/main/kotlin/net/pterodactylus/sone/web/pages/SoneTemplatePage.kt
src/main/kotlin/net/pterodactylus/sone/web/pages/TrustPage.kt
src/main/kotlin/net/pterodactylus/sone/web/pages/UnbookmarkPage.kt
src/main/kotlin/net/pterodactylus/sone/web/pages/UnfollowSonePage.kt
src/main/kotlin/net/pterodactylus/sone/web/pages/UnlikePage.kt
src/main/kotlin/net/pterodactylus/sone/web/pages/UnlockSonePage.kt
src/main/kotlin/net/pterodactylus/sone/web/pages/UntrustPage.kt
src/main/kotlin/net/pterodactylus/sone/web/pages/UploadImagePage.kt
src/main/kotlin/net/pterodactylus/sone/web/pages/ViewPostPage.kt
src/main/kotlin/net/pterodactylus/sone/web/pages/ViewSonePage.kt
src/test/kotlin/net/pterodactylus/sone/web/pages/DeleteSonePageTest.kt
src/test/kotlin/net/pterodactylus/sone/web/pages/DismissNotificationPageTest.kt
src/test/kotlin/net/pterodactylus/sone/web/pages/DistrustPageTest.kt
src/test/kotlin/net/pterodactylus/sone/web/pages/EditAlbumPageTest.kt
src/test/kotlin/net/pterodactylus/sone/web/pages/EditImagePageTest.kt
src/test/kotlin/net/pterodactylus/sone/web/pages/EditProfileFieldPageTest.kt
src/test/kotlin/net/pterodactylus/sone/web/pages/EditProfilePageTest.kt
src/test/kotlin/net/pterodactylus/sone/web/pages/FollowSonePageTest.kt
src/test/kotlin/net/pterodactylus/sone/web/pages/ImageBrowserPageTest.kt
src/test/kotlin/net/pterodactylus/sone/web/pages/IndexPageTest.kt
src/test/kotlin/net/pterodactylus/sone/web/pages/KnownSonesPageTest.kt
src/test/kotlin/net/pterodactylus/sone/web/pages/LikePageTest.kt
src/test/kotlin/net/pterodactylus/sone/web/pages/LockSonePageTest.kt
src/test/kotlin/net/pterodactylus/sone/web/pages/LogoutPageTest.kt
src/test/kotlin/net/pterodactylus/sone/web/pages/MarkAsKnownPageTest.kt
src/test/kotlin/net/pterodactylus/sone/web/pages/NewPageTest.kt
src/test/kotlin/net/pterodactylus/sone/web/pages/OptionsPageTest.kt
src/test/kotlin/net/pterodactylus/sone/web/pages/RescuePageTest.kt
src/test/kotlin/net/pterodactylus/sone/web/pages/SearchPageTest.kt
src/test/kotlin/net/pterodactylus/sone/web/pages/SoneTemplatePageTest.kt
src/test/kotlin/net/pterodactylus/sone/web/pages/TrustPageTest.kt
src/test/kotlin/net/pterodactylus/sone/web/pages/UnbookmarkPageTest.kt
src/test/kotlin/net/pterodactylus/sone/web/pages/UnfollowSonePageTest.kt
src/test/kotlin/net/pterodactylus/sone/web/pages/UnlikePageTest.kt
src/test/kotlin/net/pterodactylus/sone/web/pages/UnlockSonePageTest.kt
src/test/kotlin/net/pterodactylus/sone/web/pages/UntrustPageTest.kt
src/test/kotlin/net/pterodactylus/sone/web/pages/UploadImagePageTest.kt
src/test/kotlin/net/pterodactylus/sone/web/pages/ViewPostPageTest.kt
src/test/kotlin/net/pterodactylus/sone/web/pages/ViewSonePageTest.kt
src/test/kotlin/net/pterodactylus/sone/web/pages/WebPageTest.kt

index bcff177..81cd332 100644 (file)
@@ -2,7 +2,7 @@ package net.pterodactylus.sone.web.pages
 
 import net.pterodactylus.sone.utils.isPOST
 import net.pterodactylus.sone.web.WebInterface
-import net.pterodactylus.sone.web.page.FreenetRequest
+import net.pterodactylus.sone.web.page.*
 import net.pterodactylus.util.template.Template
 import net.pterodactylus.util.template.TemplateContext
 import javax.inject.Inject
@@ -13,12 +13,12 @@ import javax.inject.Inject
 class BookmarkPage @Inject constructor(template: Template, webInterface: WebInterface)
        : SoneTemplatePage("bookmark.html", webInterface, template, "Page.Bookmark.Title") {
 
-       override fun handleRequest(freenetRequest: FreenetRequest, templateContext: TemplateContext) {
-               if (freenetRequest.isPOST) {
-                       val returnPage = freenetRequest.httpRequest.getPartAsStringFailsafe("returnPage", 256)
-                       val postId = freenetRequest.httpRequest.getPartAsStringFailsafe("post", 36)
-                       webInterface.core.getPost(postId)?.let {
-                               webInterface.core.bookmarkPost(it)
+       override fun handleRequest(soneRequest: SoneRequest, templateContext: TemplateContext) {
+               if (soneRequest.isPOST) {
+                       val returnPage = soneRequest.httpRequest.getPartAsStringFailsafe("returnPage", 256)
+                       val postId = soneRequest.httpRequest.getPartAsStringFailsafe("post", 36)
+                       soneRequest.core.getPost(postId)?.let {
+                               soneRequest.core.bookmarkPost(it)
                        }
                        throw RedirectException(returnPage)
                }
index 3411164..f6cdd0b 100644 (file)
@@ -3,7 +3,7 @@ package net.pterodactylus.sone.web.pages
 import net.pterodactylus.sone.data.Post
 import net.pterodactylus.sone.utils.paginate
 import net.pterodactylus.sone.web.WebInterface
-import net.pterodactylus.sone.web.page.FreenetRequest
+import net.pterodactylus.sone.web.page.*
 import net.pterodactylus.util.template.Template
 import net.pterodactylus.util.template.TemplateContext
 import javax.inject.Inject
@@ -14,9 +14,9 @@ import javax.inject.Inject
 class BookmarksPage @Inject constructor(template: Template, webInterface: WebInterface) :
                SoneTemplatePage("bookmarks.html", webInterface, template, "Page.Bookmarks.Title") {
 
-       override fun handleRequest(freenetRequest: FreenetRequest, templateContext: TemplateContext) {
-               webInterface.core.bookmarkedPosts.let { posts ->
-                       val pagination = posts.filter(Post::isLoaded).sortedByDescending { it.time }.paginate(webInterface.core.preferences.postsPerPage)
+       override fun handleRequest(soneRequest: SoneRequest, templateContext: TemplateContext) {
+               soneRequest.core.bookmarkedPosts.let { posts ->
+                       val pagination = posts.filter(Post::isLoaded).sortedByDescending { it.time }.paginate(soneRequest.core.preferences.postsPerPage)
                        templateContext["pagination"] = pagination
                        templateContext["posts"] = pagination.items
                        templateContext["postsNotLoaded"] = posts.any { !it.isLoaded }
index 2db3148..609c6cb 100644 (file)
@@ -5,7 +5,7 @@ import net.pterodactylus.sone.data.Sone
 import net.pterodactylus.sone.text.TextFilter
 import net.pterodactylus.sone.utils.isPOST
 import net.pterodactylus.sone.web.WebInterface
-import net.pterodactylus.sone.web.page.FreenetRequest
+import net.pterodactylus.sone.web.page.*
 import net.pterodactylus.util.template.Template
 import net.pterodactylus.util.template.TemplateContext
 import javax.inject.Inject
@@ -16,26 +16,26 @@ import javax.inject.Inject
 class CreateAlbumPage @Inject constructor(template: Template, webInterface: WebInterface):
                LoggedInPage("createAlbum.html", template, "Page.CreateAlbum.Title", webInterface) {
 
-       override fun handleRequest(freenetRequest: FreenetRequest, currentSone: Sone, templateContext: TemplateContext) {
-               if (freenetRequest.isPOST) {
-                       val name = freenetRequest.httpRequest.getPartAsStringFailsafe("name", 64).trim()
+       override fun handleRequest(soneRequest: SoneRequest, currentSone: Sone, templateContext: TemplateContext) {
+               if (soneRequest.isPOST) {
+                       val name = soneRequest.httpRequest.getPartAsStringFailsafe("name", 64).trim()
                        if (name.isEmpty()) {
                                templateContext["nameMissing"] = true
                                return
                        }
-                       val description = freenetRequest.httpRequest.getPartAsStringFailsafe("description", 256).trim()
-                       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)
+                       val description = soneRequest.httpRequest.getPartAsStringFailsafe("description", 256).trim()
+                       val parentId = soneRequest.httpRequest.getPartAsStringFailsafe("parent", 36)
+                       val parent = if (parentId == "") currentSone.rootAlbum else soneRequest.core.getAlbum(parentId)
+                       val album = soneRequest.core.createAlbum(currentSone, parent)
                        try {
                                album.modify().apply {
                                        setTitle(name)
-                                       setDescription(TextFilter.filter(freenetRequest.httpRequest.getHeader("Host"), description))
+                                       setDescription(TextFilter.filter(soneRequest.httpRequest.getHeader("Host"), description))
                                }.update()
                        } catch (e: AlbumTitleMustNotBeEmpty) {
                                throw RedirectException("emptyAlbumTitle.html")
                        }
-                       webInterface.core.touchConfiguration()
+                       soneRequest.core.touchConfiguration()
                        throw RedirectException("imageBrowser.html?album=${album.id}")
                }
        }
index 8a1268e..aa5b94c 100644 (file)
@@ -5,7 +5,7 @@ import net.pterodactylus.sone.text.TextFilter
 import net.pterodactylus.sone.utils.asOptional
 import net.pterodactylus.sone.utils.isPOST
 import net.pterodactylus.sone.web.WebInterface
-import net.pterodactylus.sone.web.page.FreenetRequest
+import net.pterodactylus.sone.web.page.*
 import net.pterodactylus.util.template.Template
 import net.pterodactylus.util.template.TemplateContext
 import javax.inject.Inject
@@ -16,18 +16,18 @@ import javax.inject.Inject
 class CreatePostPage @Inject constructor(template: Template, webInterface: WebInterface):
                LoggedInPage("createPost.html", template, "Page.CreatePost.Title", webInterface) {
 
-       override fun handleRequest(freenetRequest: FreenetRequest, currentSone: Sone, templateContext: TemplateContext) {
-               val returnPage = freenetRequest.httpRequest.getPartAsStringFailsafe("returnPage", 256)
+       override fun handleRequest(soneRequest: SoneRequest, currentSone: Sone, templateContext: TemplateContext) {
+               val returnPage = soneRequest.httpRequest.getPartAsStringFailsafe("returnPage", 256)
                templateContext["returnPage"] = returnPage
-               if (freenetRequest.isPOST) {
-                       val text = freenetRequest.httpRequest.getPartAsStringFailsafe("text", 65536).trim()
+               if (soneRequest.isPOST) {
+                       val text = soneRequest.httpRequest.getPartAsStringFailsafe("text", 65536).trim()
                        if (text == "") {
                                templateContext["errorTextEmpty"] = true
                                return
                        }
-                       val sender = webInterface.core.getLocalSone(freenetRequest.httpRequest.getPartAsStringFailsafe("sender", 43)) ?: currentSone
-                       val recipient = webInterface.core.getSone(freenetRequest.httpRequest.getPartAsStringFailsafe("recipient", 43))
-                       webInterface.core.createPost(sender, recipient.asOptional(), TextFilter.filter(freenetRequest.httpRequest.getHeader("Host"), text))
+                       val sender = soneRequest.core.getLocalSone(soneRequest.httpRequest.getPartAsStringFailsafe("sender", 43)) ?: currentSone
+                       val recipient = soneRequest.core.getSone(soneRequest.httpRequest.getPartAsStringFailsafe("recipient", 43))
+                       soneRequest.core.createPost(sender, recipient.asOptional(), TextFilter.filter(soneRequest.httpRequest.getHeader("Host"), text))
                        throw RedirectException(returnPage)
                }
        }
index 4ff949d..813412a 100644 (file)
@@ -4,7 +4,7 @@ import net.pterodactylus.sone.data.Sone
 import net.pterodactylus.sone.text.TextFilter
 import net.pterodactylus.sone.utils.isPOST
 import net.pterodactylus.sone.web.WebInterface
-import net.pterodactylus.sone.web.page.FreenetRequest
+import net.pterodactylus.sone.web.page.*
 import net.pterodactylus.util.template.Template
 import net.pterodactylus.util.template.TemplateContext
 import javax.inject.Inject
@@ -15,18 +15,18 @@ import javax.inject.Inject
 class CreateReplyPage @Inject constructor(template: Template, webInterface: WebInterface):
                LoggedInPage("createReply.html", template, "Page.CreateReply.Title", webInterface) {
 
-       override fun handleRequest(freenetRequest: FreenetRequest, currentSone: Sone, 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) {
+       override fun handleRequest(soneRequest: SoneRequest, currentSone: Sone, templateContext: TemplateContext) {
+               val postId = soneRequest.httpRequest.getPartAsStringFailsafe("post", 36).apply { templateContext["postId"] = this }
+               val text = soneRequest.httpRequest.getPartAsStringFailsafe("text", 65536).trim().apply { templateContext["text"] = this }
+               val returnPage = soneRequest.httpRequest.getPartAsStringFailsafe("returnPage", 256).apply { templateContext["returnPage"] = this }
+               if (soneRequest.isPOST) {
                        if (text == "") {
                                templateContext["errorTextEmpty"] = true
                                return
                        }
-                       val post = webInterface.core.getPost(postId) ?: throw RedirectException("noPermission.html")
-                       val sender = webInterface.core.getLocalSone(freenetRequest.httpRequest.getPartAsStringFailsafe("sender", 43)) ?: currentSone
-                       webInterface.core.createReply(sender, post, TextFilter.filter(freenetRequest.httpRequest.getHeader("Host"), text))
+                       val post = soneRequest.core.getPost(postId) ?: throw RedirectException("noPermission.html")
+                       val sender = soneRequest.core.getLocalSone(soneRequest.httpRequest.getPartAsStringFailsafe("sender", 43)) ?: currentSone
+                       soneRequest.core.createReply(sender, post, TextFilter.filter(soneRequest.httpRequest.getHeader("Host"), text))
                        throw RedirectException(returnPage)
                }
        }
index a0fe7cb..78f981c 100644 (file)
@@ -4,7 +4,7 @@ import freenet.clients.http.ToadletContext
 import net.pterodactylus.sone.data.Sone
 import net.pterodactylus.sone.utils.isPOST
 import net.pterodactylus.sone.web.WebInterface
-import net.pterodactylus.sone.web.page.FreenetRequest
+import net.pterodactylus.sone.web.page.*
 import net.pterodactylus.util.template.Template
 import net.pterodactylus.util.template.TemplateContext
 import java.util.logging.Level
@@ -19,28 +19,28 @@ class CreateSonePage @Inject constructor(template: Template, webInterface: WebIn
 
        private val logger = Logger.getLogger(CreateSonePage::class.java.name)
 
-       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 (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)
+       override fun handleRequest(soneRequest: SoneRequest, templateContext: TemplateContext) {
+               templateContext["sones"] = soneRequest.core.localSones.sortedWith(Sone.NICE_NAME_COMPARATOR)
+               templateContext["identitiesWithoutSone"] = soneRequest.core.identityManager.allOwnIdentities.filterNot { "Sone" in it.contexts }.sortedBy { "${it.nickname}@${it.id}".toLowerCase() }
+               if (soneRequest.isPOST) {
+                       val identity = soneRequest.httpRequest.getPartAsStringFailsafe("identity", 43)
+                       soneRequest.core.identityManager.allOwnIdentities.firstOrNull { it.id == identity }?.let { ownIdentity ->
+                               val sone = soneRequest.core.createSone(ownIdentity)
                                if (sone == null) {
                                        logger.log(Level.SEVERE, "Could not create Sone for OwnIdentity: $ownIdentity")
                                }
-                               setCurrentSone(freenetRequest.toadletContext, sone)
+                               setCurrentSone(soneRequest.toadletContext, sone)
                                throw RedirectException("index.html")
                        }
                        templateContext["errorNoIdentity"] = true
                }
        }
 
-       override fun isEnabled(toadletContext: ToadletContext) =
-                       if (webInterface.core.preferences.requireFullAccess && !toadletContext.isAllowedFullAccess) {
+       override fun isEnabled(soneRequest: SoneRequest) =
+                       if (soneRequest.core.preferences.requireFullAccess && !soneRequest.toadletContext.isAllowedFullAccess) {
                                false
                        } else {
-                               (getCurrentSone(toadletContext) == null) || (webInterface.core.localSones.size == 1)
+                               (getCurrentSone(soneRequest.toadletContext) == null) || (soneRequest.core.localSones.size == 1)
                        }
 
 }
index 02a0f65..deeadfb 100644 (file)
@@ -3,7 +3,7 @@ package net.pterodactylus.sone.web.pages
 import net.pterodactylus.sone.data.Sone
 import net.pterodactylus.sone.utils.isPOST
 import net.pterodactylus.sone.web.WebInterface
-import net.pterodactylus.sone.web.page.FreenetRequest
+import net.pterodactylus.sone.web.page.*
 import net.pterodactylus.util.template.Template
 import net.pterodactylus.util.template.TemplateContext
 import javax.inject.Inject
@@ -14,19 +14,19 @@ import javax.inject.Inject
 class DeleteAlbumPage @Inject constructor(template: Template, webInterface: WebInterface):
                LoggedInPage("deleteAlbum.html", template, "Page.DeleteAlbum.Title", webInterface) {
 
-       override fun handleRequest(freenetRequest: FreenetRequest, currentSone: Sone, templateContext: TemplateContext) {
-               if (freenetRequest.isPOST) {
-                       val album = webInterface.core.getAlbum(freenetRequest.httpRequest.getPartAsStringFailsafe("album", 36)) ?: throw RedirectException("invalid.html")
+       override fun handleRequest(soneRequest: SoneRequest, currentSone: Sone, templateContext: TemplateContext) {
+               if (soneRequest.isPOST) {
+                       val album = soneRequest.core.getAlbum(soneRequest.httpRequest.getPartAsStringFailsafe("album", 36)) ?: throw RedirectException("invalid.html")
                        if (!album.sone.isLocal) {
                                throw RedirectException("noPermission.html")
                        }
-                       if (freenetRequest.httpRequest.getPartAsStringFailsafe("abortDelete", 4) == "true") {
+                       if (soneRequest.httpRequest.getPartAsStringFailsafe("abortDelete", 4) == "true") {
                                throw RedirectException("imageBrowser.html?album=${album.id}")
                        }
-                       webInterface.core.deleteAlbum(album)
+                       soneRequest.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(freenetRequest.httpRequest.getParam("album"))
+               val album = soneRequest.core.getAlbum(soneRequest.httpRequest.getParam("album"))
                templateContext["album"] = album ?: throw RedirectException("invalid.html")
        }
 
index 192cdfa..70440f2 100644 (file)
@@ -3,7 +3,7 @@ package net.pterodactylus.sone.web.pages
 import net.pterodactylus.sone.data.Sone
 import net.pterodactylus.sone.utils.isPOST
 import net.pterodactylus.sone.web.WebInterface
-import net.pterodactylus.sone.web.page.FreenetRequest
+import net.pterodactylus.sone.web.page.*
 import net.pterodactylus.util.template.Template
 import net.pterodactylus.util.template.TemplateContext
 import javax.inject.Inject
@@ -14,19 +14,19 @@ import javax.inject.Inject
 class DeleteImagePage @Inject constructor(template: Template, webInterface: WebInterface):
                LoggedInPage("deleteImage.html", template, "Page.DeleteImage.Title", webInterface) {
 
-       override fun handleRequest(freenetRequest: FreenetRequest, currentSone: Sone, templateContext: TemplateContext) {
-               if (freenetRequest.isPOST) {
-                       val image = webInterface.core.getImage(freenetRequest.httpRequest.getPartAsStringFailsafe("image", 36)) ?: throw RedirectException("invalid.html")
+       override fun handleRequest(soneRequest: SoneRequest, currentSone: Sone, templateContext: TemplateContext) {
+               if (soneRequest.isPOST) {
+                       val image = soneRequest.core.getImage(soneRequest.httpRequest.getPartAsStringFailsafe("image", 36)) ?: throw RedirectException("invalid.html")
                        if (!image.sone.isLocal) {
                                throw RedirectException("noPermission.html")
                        }
-                       if (freenetRequest.httpRequest.isPartSet("abortDelete")) {
+                       if (soneRequest.httpRequest.isPartSet("abortDelete")) {
                                throw RedirectException("imageBrowser.html?image=${image.id}")
                        }
-                       webInterface.core.deleteImage(image)
+                       soneRequest.core.deleteImage(image)
                        throw RedirectException("imageBrowser.html?album=${image.album.id}")
                }
-               val image = webInterface.core.getImage(freenetRequest.httpRequest.getParam("image")) ?: throw RedirectException("invalid.html")
+               val image = soneRequest.core.getImage(soneRequest.httpRequest.getParam("image")) ?: throw RedirectException("invalid.html")
                if (!image.sone.isLocal) {
                        throw RedirectException("noPermission.html")
                }
index b2014f0..d880fc5 100644 (file)
@@ -3,7 +3,7 @@ package net.pterodactylus.sone.web.pages
 import net.pterodactylus.sone.data.Sone
 import net.pterodactylus.sone.utils.isPOST
 import net.pterodactylus.sone.web.WebInterface
-import net.pterodactylus.sone.web.page.FreenetRequest
+import net.pterodactylus.sone.web.page.*
 import net.pterodactylus.util.template.Template
 import net.pterodactylus.util.template.TemplateContext
 import javax.inject.Inject
@@ -14,25 +14,25 @@ import javax.inject.Inject
 class DeletePostPage @Inject constructor(template: Template, webInterface: WebInterface):
                LoggedInPage("deletePost.html", template, "Page.DeletePost.Title", webInterface) {
 
-       override fun handleRequest(freenetRequest: FreenetRequest, currentSone: Sone, templateContext: TemplateContext) {
-               if (freenetRequest.isPOST) {
-                       val post = webInterface.core.getPost(freenetRequest.httpRequest.getPartAsStringFailsafe("post", 36)) ?: throw RedirectException("noPermission.html")
-                       val returnPage = freenetRequest.httpRequest.getPartAsStringFailsafe("returnPage", 256)
+       override fun handleRequest(soneRequest: SoneRequest, currentSone: Sone, templateContext: TemplateContext) {
+               if (soneRequest.isPOST) {
+                       val post = soneRequest.core.getPost(soneRequest.httpRequest.getPartAsStringFailsafe("post", 36)) ?: throw RedirectException("noPermission.html")
+                       val returnPage = soneRequest.httpRequest.getPartAsStringFailsafe("returnPage", 256)
                        if (!post.sone.isLocal) {
                                throw RedirectException("noPermission.html")
                        }
-                       if (freenetRequest.httpRequest.isPartSet("confirmDelete")) {
-                               webInterface.core.deletePost(post)
+                       if (soneRequest.httpRequest.isPartSet("confirmDelete")) {
+                               soneRequest.core.deletePost(post)
                                throw RedirectException(returnPage)
-                       } else if (freenetRequest.httpRequest.isPartSet("abortDelete")) {
+                       } else if (soneRequest.httpRequest.isPartSet("abortDelete")) {
                                throw RedirectException(returnPage)
                        }
                        templateContext["post"] = post
                        templateContext["returnPage"] = returnPage
                        return
                }
-               templateContext["post"] = webInterface.core.getPost(freenetRequest.httpRequest.getParam("post")) ?: throw RedirectException("noPermission.html")
-               templateContext["returnPage"] = freenetRequest.httpRequest.getParam("returnPage")
+               templateContext["post"] = soneRequest.core.getPost(soneRequest.httpRequest.getParam("post")) ?: throw RedirectException("noPermission.html")
+               templateContext["returnPage"] = soneRequest.httpRequest.getParam("returnPage")
        }
 
 }
index 845ec7f..9655815 100644 (file)
@@ -3,7 +3,7 @@ package net.pterodactylus.sone.web.pages
 import net.pterodactylus.sone.data.Sone
 import net.pterodactylus.sone.utils.isPOST
 import net.pterodactylus.sone.web.WebInterface
-import net.pterodactylus.sone.web.page.FreenetRequest
+import net.pterodactylus.sone.web.page.*
 import net.pterodactylus.util.template.Template
 import net.pterodactylus.util.template.TemplateContext
 import javax.inject.Inject
@@ -14,15 +14,15 @@ import javax.inject.Inject
 class DeleteProfileFieldPage @Inject constructor(template: Template, webInterface: WebInterface):
                LoggedInPage("deleteProfileField.html", template, "Page.DeleteProfileField.Title", webInterface) {
 
-       override fun handleRequest(freenetRequest: FreenetRequest, currentSone: Sone, templateContext: TemplateContext) {
-               if (freenetRequest.isPOST) {
-                       val field = currentSone.profile.getFieldById(freenetRequest.httpRequest.getPartAsStringFailsafe("field", 36)) ?: throw RedirectException("invalid.html")
-                       if (freenetRequest.httpRequest.getPartAsStringFailsafe("confirm", 4) == "true") {
+       override fun handleRequest(soneRequest: SoneRequest, currentSone: Sone, templateContext: TemplateContext) {
+               if (soneRequest.isPOST) {
+                       val field = currentSone.profile.getFieldById(soneRequest.httpRequest.getPartAsStringFailsafe("field", 36)) ?: throw RedirectException("invalid.html")
+                       if (soneRequest.httpRequest.getPartAsStringFailsafe("confirm", 4) == "true") {
                                currentSone.profile = currentSone.profile.apply { removeField(field) }
                        }
                        throw RedirectException("editProfile.html#profile-fields")
                }
-               val field = currentSone.profile.getFieldById(freenetRequest.httpRequest.getParam("field")) ?: throw RedirectException("invalid.html")
+               val field = currentSone.profile.getFieldById(soneRequest.httpRequest.getParam("field")) ?: throw RedirectException("invalid.html")
                templateContext["field"] = field
        }
 
index d524c0e..b20c4bb 100644 (file)
@@ -3,7 +3,7 @@ package net.pterodactylus.sone.web.pages
 import net.pterodactylus.sone.data.Sone
 import net.pterodactylus.sone.utils.isPOST
 import net.pterodactylus.sone.web.WebInterface
-import net.pterodactylus.sone.web.page.FreenetRequest
+import net.pterodactylus.sone.web.page.*
 import net.pterodactylus.util.template.Template
 import net.pterodactylus.util.template.TemplateContext
 import javax.inject.Inject
@@ -14,27 +14,27 @@ import javax.inject.Inject
 class DeleteReplyPage @Inject constructor(template: Template, webInterface: WebInterface):
                LoggedInPage("deleteReply.html", template, "Page.DeleteReply.Title", webInterface) {
 
-       override fun handleRequest(freenetRequest: FreenetRequest, currentSone: Sone, templateContext: TemplateContext) {
-               if (freenetRequest.isPOST) {
-                       val replyId = freenetRequest.httpRequest.getPartAsStringFailsafe("reply", 36)
-                       val reply = webInterface.core.getPostReply(replyId) ?: throw RedirectException("noPermission.html")
+       override fun handleRequest(soneRequest: SoneRequest, currentSone: Sone, templateContext: TemplateContext) {
+               if (soneRequest.isPOST) {
+                       val replyId = soneRequest.httpRequest.getPartAsStringFailsafe("reply", 36)
+                       val reply = soneRequest.core.getPostReply(replyId) ?: throw RedirectException("noPermission.html")
                        if (!reply.sone.isLocal) {
                                throw RedirectException("noPermission.html")
                        }
-                       val returnPage = freenetRequest.httpRequest.getPartAsStringFailsafe("returnPage", 256)
-                       if (freenetRequest.httpRequest.isPartSet("confirmDelete")) {
-                               webInterface.core.deleteReply(reply)
+                       val returnPage = soneRequest.httpRequest.getPartAsStringFailsafe("returnPage", 256)
+                       if (soneRequest.httpRequest.isPartSet("confirmDelete")) {
+                               soneRequest.core.deleteReply(reply)
                                throw RedirectException(returnPage)
                        }
-                       if (freenetRequest.httpRequest.isPartSet("abortDelete")) {
+                       if (soneRequest.httpRequest.isPartSet("abortDelete")) {
                                throw RedirectException(returnPage)
                        }
                        templateContext["reply"] = replyId
                        templateContext["returnPage"] = returnPage
                        return
                }
-               templateContext["reply"] = freenetRequest.httpRequest.getParam("reply")
-               templateContext["returnPage"] = freenetRequest.httpRequest.getParam("returnPage")
+               templateContext["reply"] = soneRequest.httpRequest.getParam("reply")
+               templateContext["returnPage"] = soneRequest.httpRequest.getParam("returnPage")
        }
 
 }
index 0b0df7d..1d39011 100644 (file)
@@ -3,7 +3,7 @@ package net.pterodactylus.sone.web.pages
 import net.pterodactylus.sone.data.Sone
 import net.pterodactylus.sone.utils.isPOST
 import net.pterodactylus.sone.web.WebInterface
-import net.pterodactylus.sone.web.page.FreenetRequest
+import net.pterodactylus.sone.web.page.*
 import net.pterodactylus.util.template.Template
 import net.pterodactylus.util.template.TemplateContext
 import javax.inject.Inject
@@ -16,10 +16,10 @@ import javax.inject.Inject
 class DeleteSonePage @Inject constructor(template: Template, webInterface: WebInterface):
                LoggedInPage("deleteSone.html", template, "Page.DeleteSone.Title", webInterface) {
 
-       override fun handleRequest(freenetRequest: FreenetRequest, currentSone: Sone, templateContext: TemplateContext) {
-               if (freenetRequest.isPOST) {
-                       if (freenetRequest.httpRequest.isPartSet("deleteSone")) {
-                               webInterface.core.deleteSone(currentSone)
+       override fun handleRequest(soneRequest: SoneRequest, currentSone: Sone, templateContext: TemplateContext) {
+               if (soneRequest.isPOST) {
+                       if (soneRequest.httpRequest.isPartSet("deleteSone")) {
+                               soneRequest.core.deleteSone(currentSone)
                        }
                        throw RedirectException("index.html")
                }
index 3cb3c43..ae0cfe0 100644 (file)
@@ -1,7 +1,7 @@
 package net.pterodactylus.sone.web.pages
 
 import net.pterodactylus.sone.web.WebInterface
-import net.pterodactylus.sone.web.page.FreenetRequest
+import net.pterodactylus.sone.web.page.*
 import net.pterodactylus.util.template.Template
 import net.pterodactylus.util.template.TemplateContext
 import javax.inject.Inject
@@ -12,10 +12,10 @@ import javax.inject.Inject
 class DismissNotificationPage @Inject constructor(template: Template, webInterface: WebInterface):
                SoneTemplatePage("dismissNotification.html", webInterface, template, "Page.DismissNotification.Title") {
 
-       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()
+       override fun handleRequest(soneRequest: SoneRequest, templateContext: TemplateContext) {
+               val returnPage = soneRequest.httpRequest.getPartAsStringFailsafe("returnPage", 256)
+               val notificationId = soneRequest.httpRequest.getPartAsStringFailsafe("notification", 36)
+               soneRequest.webInterface.getNotification(notificationId).orNull()?.takeIf { it.isDismissable }?.dismiss()
                throw RedirectException(returnPage)
        }
 
index c312a70..c29e974 100644 (file)
@@ -3,7 +3,7 @@ package net.pterodactylus.sone.web.pages
 import net.pterodactylus.sone.data.Sone
 import net.pterodactylus.sone.utils.isPOST
 import net.pterodactylus.sone.web.WebInterface
-import net.pterodactylus.sone.web.page.FreenetRequest
+import net.pterodactylus.sone.web.page.*
 import net.pterodactylus.util.template.Template
 import net.pterodactylus.util.template.TemplateContext
 import javax.inject.Inject
@@ -17,11 +17,11 @@ import javax.inject.Inject
 class DistrustPage @Inject constructor(template: Template, webInterface: WebInterface):
                LoggedInPage("distrust.html", template, "Page.Distrust.Title", webInterface) {
 
-       override fun handleRequest(freenetRequest: FreenetRequest, currentSone: Sone, templateContext: TemplateContext) {
-               if (freenetRequest.isPOST) {
-                       webInterface.core.getSone(freenetRequest.httpRequest.getPartAsStringFailsafe("sone", 44))
-                                       ?.run { webInterface.core.distrustSone(currentSone, this) }
-                       throw RedirectException(freenetRequest.httpRequest.getPartAsStringFailsafe("returnPage", 256))
+       override fun handleRequest(soneRequest: SoneRequest, currentSone: Sone, templateContext: TemplateContext) {
+               if (soneRequest.isPOST) {
+                       soneRequest.core.getSone(soneRequest.httpRequest.getPartAsStringFailsafe("sone", 44))
+                                       ?.run { soneRequest.core.distrustSone(currentSone, this) }
+                       throw RedirectException(soneRequest.httpRequest.getPartAsStringFailsafe("returnPage", 256))
                }
        }
 
index ff8e728..4e0cf5f 100644 (file)
@@ -4,7 +4,7 @@ import net.pterodactylus.sone.data.Album.Modifier.AlbumTitleMustNotBeEmpty
 import net.pterodactylus.sone.data.Sone
 import net.pterodactylus.sone.utils.isPOST
 import net.pterodactylus.sone.web.WebInterface
-import net.pterodactylus.sone.web.page.FreenetRequest
+import net.pterodactylus.sone.web.page.*
 import net.pterodactylus.util.template.Template
 import net.pterodactylus.util.template.TemplateContext
 import javax.inject.Inject
@@ -15,28 +15,28 @@ import javax.inject.Inject
 class EditAlbumPage @Inject constructor(template: Template, webInterface: WebInterface):
                LoggedInPage("editAlbum.html", template, "Page.EditAlbum.Title", webInterface) {
 
-       override fun handleRequest(freenetRequest: FreenetRequest, currentSone: Sone, templateContext: TemplateContext) {
-               if (freenetRequest.isPOST) {
-                       val album = webInterface.core.getAlbum(freenetRequest.httpRequest.getPartAsStringFailsafe("album", 36)) ?: throw RedirectException("invalid.html")
+       override fun handleRequest(soneRequest: SoneRequest, currentSone: Sone, templateContext: TemplateContext) {
+               if (soneRequest.isPOST) {
+                       val album = soneRequest.core.getAlbum(soneRequest.httpRequest.getPartAsStringFailsafe("album", 36)) ?: throw RedirectException("invalid.html")
                        album.takeUnless { it.sone.isLocal }?.run { throw RedirectException("noPermission.html") }
-                       if (freenetRequest.httpRequest.getPartAsStringFailsafe("moveLeft", 4) == "true") {
+                       if (soneRequest.httpRequest.getPartAsStringFailsafe("moveLeft", 4) == "true") {
                                album.parent?.moveAlbumUp(album)
-                               webInterface.core.touchConfiguration()
+                               soneRequest.core.touchConfiguration()
                                throw RedirectException("imageBrowser.html?album=${album.parent?.id}")
-                       } else if (freenetRequest.httpRequest.getPartAsStringFailsafe("moveRight", 4) == "true") {
+                       } else if (soneRequest.httpRequest.getPartAsStringFailsafe("moveRight", 4) == "true") {
                                album.parent?.moveAlbumDown(album)
-                               webInterface.core.touchConfiguration()
+                               soneRequest.core.touchConfiguration()
                                throw RedirectException("imageBrowser.html?album=${album.parent?.id}")
                        } else {
                                try {
                                        album.modify()
-                                                       .setTitle(freenetRequest.httpRequest.getPartAsStringFailsafe("title", 100))
-                                                       .setDescription(freenetRequest.httpRequest.getPartAsStringFailsafe("description", 1000))
+                                                       .setTitle(soneRequest.httpRequest.getPartAsStringFailsafe("title", 100))
+                                                       .setDescription(soneRequest.httpRequest.getPartAsStringFailsafe("description", 1000))
                                                        .update()
                                } catch (e: AlbumTitleMustNotBeEmpty) {
                                        throw RedirectException("emptyAlbumTitle.html")
                                }
-                               webInterface.core.touchConfiguration()
+                               soneRequest.core.touchConfiguration()
                                throw RedirectException("imageBrowser.html?album=${album.id}")
                        }
                }
index 50578a3..1870c02 100644 (file)
@@ -5,7 +5,7 @@ import net.pterodactylus.sone.data.Sone
 import net.pterodactylus.sone.text.TextFilter
 import net.pterodactylus.sone.utils.isPOST
 import net.pterodactylus.sone.web.WebInterface
-import net.pterodactylus.sone.web.page.FreenetRequest
+import net.pterodactylus.sone.web.page.*
 import net.pterodactylus.util.template.Template
 import net.pterodactylus.util.template.TemplateContext
 import javax.inject.Inject
@@ -16,26 +16,26 @@ import javax.inject.Inject
 class EditImagePage @Inject constructor(template: Template, webInterface: WebInterface):
                LoggedInPage("editImage.html", template, "Page.EditImage.Title", webInterface) {
 
-       override fun handleRequest(freenetRequest: FreenetRequest, currentSone: Sone, templateContext: TemplateContext) {
-               if (freenetRequest.isPOST) {
-                       val image = webInterface.core.getImage(freenetRequest.httpRequest.getPartAsStringFailsafe("image", 36)) ?: throw RedirectException("invalid.html")
+       override fun handleRequest(soneRequest: SoneRequest, currentSone: Sone, templateContext: TemplateContext) {
+               if (soneRequest.isPOST) {
+                       val image = soneRequest.core.getImage(soneRequest.httpRequest.getPartAsStringFailsafe("image", 36)) ?: throw RedirectException("invalid.html")
                        if (!image.sone.isLocal) {
                                throw RedirectException("noPermission.html")
                        }
-                       freenetRequest.httpRequest.getPartAsStringFailsafe("returnPage", 256).let { returnPage ->
-                               if (freenetRequest.httpRequest.getPartAsStringFailsafe("moveLeft", 4) == "true") {
+                       soneRequest.httpRequest.getPartAsStringFailsafe("returnPage", 256).let { returnPage ->
+                               if (soneRequest.httpRequest.getPartAsStringFailsafe("moveLeft", 4) == "true") {
                                        image.album.moveImageUp(image)
-                                       webInterface.core.touchConfiguration()
-                               } else if (freenetRequest.httpRequest.getPartAsStringFailsafe("moveRight", 4) == "true") {
+                                       soneRequest.core.touchConfiguration()
+                               } else if (soneRequest.httpRequest.getPartAsStringFailsafe("moveRight", 4) == "true") {
                                        image.album.moveImageDown(image)
-                                       webInterface.core.touchConfiguration()
+                                       soneRequest.core.touchConfiguration()
                                } else {
                                        try {
                                                image.modify()
-                                                               .setTitle(freenetRequest.httpRequest.getPartAsStringFailsafe("title", 100))
-                                                               .setDescription(TextFilter.filter(freenetRequest.httpRequest.getHeader("Host"), freenetRequest.httpRequest.getPartAsStringFailsafe("description", 1024)))
+                                                               .setTitle(soneRequest.httpRequest.getPartAsStringFailsafe("title", 100))
+                                                               .setDescription(TextFilter.filter(soneRequest.httpRequest.getHeader("Host"), soneRequest.httpRequest.getPartAsStringFailsafe("description", 1024)))
                                                                .update()
-                                               webInterface.core.touchConfiguration()
+                                               soneRequest.core.touchConfiguration()
                                        } catch (e: ImageTitleMustNotBeEmpty) {
                                                throw RedirectException("emptyImageTitle.html")
                                        }
index c9b7955..318bcf7 100644 (file)
@@ -3,7 +3,7 @@ package net.pterodactylus.sone.web.pages
 import net.pterodactylus.sone.data.Sone
 import net.pterodactylus.sone.utils.isPOST
 import net.pterodactylus.sone.web.WebInterface
-import net.pterodactylus.sone.web.page.FreenetRequest
+import net.pterodactylus.sone.web.page.*
 import net.pterodactylus.util.template.Template
 import net.pterodactylus.util.template.TemplateContext
 import javax.inject.Inject
@@ -14,14 +14,14 @@ import javax.inject.Inject
 class EditProfileFieldPage @Inject constructor(template: Template, webInterface: WebInterface) :
                LoggedInPage("editProfileField.html", template, "Page.EditProfileField.Title", webInterface) {
 
-       override fun handleRequest(freenetRequest: FreenetRequest, currentSone: Sone, templateContext: TemplateContext) {
+       override fun handleRequest(soneRequest: SoneRequest, currentSone: Sone, templateContext: TemplateContext) {
                currentSone.profile.let { profile ->
-                       if (freenetRequest.isPOST) {
-                               if (freenetRequest.httpRequest.getPartAsStringFailsafe("cancel", 4) == "true") {
+                       if (soneRequest.isPOST) {
+                               if (soneRequest.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 ->
+                               val field = profile.getFieldById(soneRequest.httpRequest.getPartAsStringFailsafe("field", 36)) ?: throw RedirectException("invalid.html")
+                               soneRequest.httpRequest.getPartAsStringFailsafe("name", 256).let { name ->
                                        try {
                                                if (name != field.name) {
                                                        field.name = name
@@ -34,7 +34,7 @@ class EditProfileFieldPage @Inject constructor(template: Template, webInterface:
                                        }
                                }
                        }
-                       templateContext["field"] = profile.getFieldById(freenetRequest.httpRequest.getParam("field")) ?: throw RedirectException("invalid.html")
+                       templateContext["field"] = profile.getFieldById(soneRequest.httpRequest.getParam("field")) ?: throw RedirectException("invalid.html")
                }
        }
 
index f1805cf..7999c8f 100644 (file)
@@ -5,7 +5,7 @@ import net.pterodactylus.sone.data.Sone
 import net.pterodactylus.sone.text.TextFilter
 import net.pterodactylus.sone.utils.isPOST
 import net.pterodactylus.sone.web.WebInterface
-import net.pterodactylus.sone.web.page.FreenetRequest
+import net.pterodactylus.sone.web.page.*
 import net.pterodactylus.util.template.Template
 import net.pterodactylus.util.template.TemplateContext
 import javax.inject.Inject
@@ -16,7 +16,7 @@ import javax.inject.Inject
 class EditProfilePage @Inject constructor(template: Template, webInterface: WebInterface) :
                LoggedInPage("editProfile.html", template, "Page.EditProfile.Title", webInterface) {
 
-       override fun handleRequest(freenetRequest: FreenetRequest, currentSone: Sone, templateContext: TemplateContext) {
+       override fun handleRequest(soneRequest: SoneRequest, currentSone: Sone, templateContext: TemplateContext) {
                currentSone.profile.let { profile ->
                        templateContext["firstName"] = profile.firstName
                        templateContext["middleName"] = profile.middleName
@@ -26,42 +26,42 @@ class EditProfilePage @Inject constructor(template: Template, webInterface: WebI
                        templateContext["birthYear"] = profile.birthYear
                        templateContext["avatarId"] = profile.avatar
                        templateContext["fields"] = profile.fields
-                       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))
+                       if (soneRequest.isPOST) {
+                               if (soneRequest.httpRequest.getPartAsStringFailsafe("save-profile", 4) == "true") {
+                                       profile.firstName = soneRequest.httpRequest.getPartAsStringFailsafe("first-name", 256).trim()
+                                       profile.middleName = soneRequest.httpRequest.getPartAsStringFailsafe("middle-name", 256).trim()
+                                       profile.lastName = soneRequest.httpRequest.getPartAsStringFailsafe("last-name", 256).trim()
+                                       profile.birthDay = soneRequest.httpRequest.getPartAsStringFailsafe("birth-day", 256).trim().toIntOrNull()
+                                       profile.birthMonth = soneRequest.httpRequest.getPartAsStringFailsafe("birth-month", 256).trim().toIntOrNull()
+                                       profile.birthYear = soneRequest.httpRequest.getPartAsStringFailsafe("birth-year", 256).trim().toIntOrNull()
+                                       profile.setAvatar(soneRequest.core.getImage(soneRequest.httpRequest.getPartAsStringFailsafe("avatarId", 256).trim(), false))
                                        profile.fields.forEach { field ->
-                                               field.value = TextFilter.filter(freenetRequest.httpRequest.getHeader("Host"), freenetRequest.httpRequest.getPartAsStringFailsafe("field-${field.id}", 400).trim())
+                                               field.value = TextFilter.filter(soneRequest.httpRequest.getHeader("Host"), soneRequest.httpRequest.getPartAsStringFailsafe("field-${field.id}", 400).trim())
                                        }
                                        currentSone.profile = profile
-                                       webInterface.core.touchConfiguration()
+                                       soneRequest.core.touchConfiguration()
                                        throw RedirectException("editProfile.html")
-                               } else if (freenetRequest.httpRequest.getPartAsStringFailsafe("add-field", 4) == "true") {
-                                       val fieldName = freenetRequest.httpRequest.getPartAsStringFailsafe("field-name", 100)
+                               } else if (soneRequest.httpRequest.getPartAsStringFailsafe("add-field", 4) == "true") {
+                                       val fieldName = soneRequest.httpRequest.getPartAsStringFailsafe("field-name", 100)
                                        try {
                                                profile.addField(fieldName)
                                                currentSone.profile = profile
-                                               webInterface.core.touchConfiguration()
+                                               soneRequest.core.touchConfiguration()
                                                throw RedirectException("editProfile.html#profile-fields")
                                        } catch (e: DuplicateField) {
                                                templateContext["fieldName"] = fieldName
                                                templateContext["duplicateFieldName"] = true
                                        }
                                } else profile.fields.forEach { field ->
-                                       if (freenetRequest.httpRequest.getPartAsStringFailsafe("delete-field-${field.id}", 4) == "true") {
+                                       if (soneRequest.httpRequest.getPartAsStringFailsafe("delete-field-${field.id}", 4) == "true") {
                                                throw RedirectException("deleteProfileField.html?field=${field.id}")
-                                       } else if (freenetRequest.httpRequest.getPartAsStringFailsafe("edit-field-${field.id}", 4) == "true") {
+                                       } else if (soneRequest.httpRequest.getPartAsStringFailsafe("edit-field-${field.id}", 4) == "true") {
                                                throw RedirectException("editProfileField.html?field=${field.id}")
-                                       } else if (freenetRequest.httpRequest.getPartAsStringFailsafe("move-down-field-${field.id}", 4) == "true") {
+                                       } else if (soneRequest.httpRequest.getPartAsStringFailsafe("move-down-field-${field.id}", 4) == "true") {
                                                profile.moveFieldDown(field)
                                                currentSone.profile = profile
                                                throw RedirectException("editProfile.html#profile-fields")
-                                       } else if (freenetRequest.httpRequest.getPartAsStringFailsafe("move-up-field-${field.id}", 4) == "true") {
+                                       } else if (soneRequest.httpRequest.getPartAsStringFailsafe("move-up-field-${field.id}", 4) == "true") {
                                                profile.moveFieldUp(field)
                                                currentSone.profile = profile
                                                throw RedirectException("editProfile.html#profile-fields")
index 187bb0d..e961430 100644 (file)
@@ -3,7 +3,7 @@ package net.pterodactylus.sone.web.pages
 import net.pterodactylus.sone.data.Sone
 import net.pterodactylus.sone.utils.isPOST
 import net.pterodactylus.sone.web.WebInterface
-import net.pterodactylus.sone.web.page.FreenetRequest
+import net.pterodactylus.sone.web.page.*
 import net.pterodactylus.util.template.Template
 import net.pterodactylus.util.template.TemplateContext
 import javax.inject.Inject
@@ -14,16 +14,16 @@ import javax.inject.Inject
 class FollowSonePage @Inject constructor(template: Template, webInterface: WebInterface):
                LoggedInPage("followSone.html", template, "Page.FollowSone.Title", webInterface) {
 
-       override fun handleRequest(freenetRequest: FreenetRequest, currentSone: Sone, templateContext: TemplateContext) {
-               if (freenetRequest.isPOST) {
-                       freenetRequest.httpRequest.getPartAsStringFailsafe("sone", 1200).split(Regex("[ ,]+"))
-                                       .map { it to webInterface.core.getSone(it) }
+       override fun handleRequest(soneRequest: SoneRequest, currentSone: Sone, templateContext: TemplateContext) {
+               if (soneRequest.isPOST) {
+                       soneRequest.httpRequest.getPartAsStringFailsafe("sone", 1200).split(Regex("[ ,]+"))
+                                       .map { it to soneRequest.core.getSone(it) }
                                        .filterNot { it.second == null }
                                        .forEach { sone ->
-                                               webInterface.core.followSone(currentSone, sone.first)
-                                               webInterface.core.markSoneKnown(sone.second)
+                                               soneRequest.core.followSone(currentSone, sone.first)
+                                               soneRequest.core.markSoneKnown(sone.second)
                                        }
-                       throw RedirectException(freenetRequest.httpRequest.getPartAsStringFailsafe("returnPage", 256))
+                       throw RedirectException(soneRequest.httpRequest.getPartAsStringFailsafe("returnPage", 256))
                }
        }
 
index 84634fc..d7714cd 100644 (file)
@@ -5,7 +5,7 @@ import net.pterodactylus.sone.data.Sone
 import net.pterodactylus.sone.utils.paginate
 import net.pterodactylus.sone.utils.parameters
 import net.pterodactylus.sone.web.WebInterface
-import net.pterodactylus.sone.web.page.FreenetRequest
+import net.pterodactylus.sone.web.page.*
 import net.pterodactylus.util.template.Template
 import net.pterodactylus.util.template.TemplateContext
 import java.net.URI
@@ -17,25 +17,25 @@ import javax.inject.Inject
 class ImageBrowserPage @Inject constructor(template: Template, webInterface: WebInterface):
                LoggedInPage("imageBrowser.html", template, "Page.ImageBrowser.Title", webInterface) {
 
-       override fun handleRequest(freenetRequest: FreenetRequest, currentSone: Sone, templateContext: TemplateContext) {
-               if ("album" in freenetRequest.parameters) {
+       override fun handleRequest(soneRequest: SoneRequest, currentSone: Sone, templateContext: TemplateContext) {
+               if ("album" in soneRequest.parameters) {
                        templateContext["albumRequested"] = true
-                       templateContext["album"] = webInterface.core.getAlbum(freenetRequest.parameters["album"]!!)
-                       templateContext["page"] = freenetRequest.parameters["page"]
-               } else if ("image" in freenetRequest.parameters) {
+                       templateContext["album"] = soneRequest.core.getAlbum(soneRequest.parameters["album"]!!)
+                       templateContext["page"] = soneRequest.parameters["page"]
+               } else if ("image" in soneRequest.parameters) {
                        templateContext["imageRequested"] = true
-                       templateContext["image"] = webInterface.core.getImage(freenetRequest.parameters["image"])
-               } else if (freenetRequest.parameters["mode"] == "gallery") {
+                       templateContext["image"] = soneRequest.core.getImage(soneRequest.parameters["image"])
+               } else if (soneRequest.parameters["mode"] == "gallery") {
                        templateContext["galleryRequested"] = true
-                       webInterface.core.sones
+                       soneRequest.core.sones
                                        .map(Sone::getRootAlbum)
                                        .flatMap(Album::getAlbums)
                                        .flatMap { Album.FLATTENER.apply(it)!! }
                                        .filterNot(Album::isEmpty)
                                        .sortedBy(Album::getTitle)
                                        .also { albums ->
-                                               albums.paginate(webInterface.core.preferences.imagesPerPage)
-                                                               .turnTo(freenetRequest.parameters["page"]?.toIntOrNull() ?: 0)
+                                               albums.paginate(soneRequest.core.preferences.imagesPerPage)
+                                                               .turnTo(soneRequest.parameters["page"]?.toIntOrNull() ?: 0)
                                                                .also { pagination ->
                                                        templateContext["albumPagination"] = pagination
                                                        templateContext["albums"] = pagination.items
@@ -43,7 +43,7 @@ class ImageBrowserPage @Inject constructor(template: Template, webInterface: Web
                                        }
                } else {
                        templateContext["soneRequested"] = true
-                       templateContext["sone"] = webInterface.core.getSone(freenetRequest.httpRequest.getParam("sone")) ?: currentSone
+                       templateContext["sone"] = soneRequest.core.getSone(soneRequest.httpRequest.getParam("sone")) ?: currentSone
                }
        }
 
index e330947..f44b145 100644 (file)
@@ -5,7 +5,7 @@ import net.pterodactylus.sone.notify.PostVisibilityFilter
 import net.pterodactylus.sone.utils.paginate
 import net.pterodactylus.sone.utils.parameters
 import net.pterodactylus.sone.web.WebInterface
-import net.pterodactylus.sone.web.page.FreenetRequest
+import net.pterodactylus.sone.web.page.*
 import net.pterodactylus.util.template.Template
 import net.pterodactylus.util.template.TemplateContext
 import javax.inject.Inject
@@ -17,18 +17,18 @@ import javax.inject.Inject
 class IndexPage @Inject constructor(template: Template, webInterface: WebInterface, private val postVisibilityFilter: PostVisibilityFilter) :
                LoggedInPage("index.html", template, "Page.Index.Title", webInterface) {
 
-       override fun handleRequest(freenetRequest: FreenetRequest, currentSone: Sone, templateContext: TemplateContext) {
+       override fun handleRequest(soneRequest: SoneRequest, currentSone: Sone, templateContext: TemplateContext) {
                (currentSone.posts +
                                currentSone.friends
-                                               .mapNotNull(webInterface.core::getSone)
+                                               .mapNotNull(soneRequest.core::getSone)
                                                .flatMap { it.posts } +
-                               webInterface.core.getDirectedPosts(currentSone.id)
+                               soneRequest.core.getDirectedPosts(currentSone.id)
                                ).distinct()
                                .filter { postVisibilityFilter.isVisible(currentSone).apply(it) }
                                .sortedByDescending { it.time }
                                .let { posts ->
-                                       posts.paginate(webInterface.core.preferences.postsPerPage)
-                                                       .turnTo(freenetRequest.parameters["page"]?.toIntOrNull() ?: 0)
+                                       posts.paginate(soneRequest.core.preferences.postsPerPage)
+                                                       .turnTo(soneRequest.parameters["page"]?.toIntOrNull() ?: 0)
                                                        .let { pagination ->
                                                                templateContext["pagination"] = pagination
                                                                templateContext["posts"] = pagination.items
index 92a856a..59b79e7 100644 (file)
@@ -4,7 +4,7 @@ import net.pterodactylus.sone.data.Sone
 import net.pterodactylus.sone.utils.paginate
 import net.pterodactylus.sone.utils.parameters
 import net.pterodactylus.sone.web.WebInterface
-import net.pterodactylus.sone.web.page.FreenetRequest
+import net.pterodactylus.sone.web.page.*
 import net.pterodactylus.util.template.Template
 import net.pterodactylus.util.template.TemplateContext
 import javax.inject.Inject
@@ -15,36 +15,36 @@ import javax.inject.Inject
 class KnownSonesPage @Inject constructor(template: Template, webInterface: WebInterface):
                SoneTemplatePage("knownSones.html", webInterface, template, "Page.KnownSones.Title") {
 
-       override fun handleRequest(freenetRequest: FreenetRequest, templateContext: TemplateContext) {
-               getCurrentSone(freenetRequest.toadletContext).let { currentSone ->
-                       webInterface.core.sones.asSequence()
-                                       .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 }
+       override fun handleRequest(soneRequest: SoneRequest, templateContext: TemplateContext) {
+               getCurrentSone(soneRequest.toadletContext).let { currentSone ->
+                       soneRequest.core.sones.asSequence()
+                                       .filterNot { soneRequest.parameters["filter"] == "followed" && currentSone != null && !currentSone.hasFriend(it.id) }
+                                       .filterNot { soneRequest.parameters["filter"] == "not-followed" && currentSone != null && currentSone.hasFriend(it.id) }
+                                       .filterNot { soneRequest.parameters["filter"] == "new" && it.isKnown }
+                                       .filterNot { soneRequest.parameters["filter"] == "not-new" && !it.isKnown }
+                                       .filterNot { soneRequest.parameters["filter"] == "own" && !it.isLocal }
+                                       .filterNot { soneRequest.parameters["filter"] == "not-own" && it.isLocal }
                                        .sortedWith(
-                                                       when (freenetRequest.parameters["sort"]) {
+                                                       when (soneRequest.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 (freenetRequest.parameters["order"]) {
+                                                               when (soneRequest.parameters["order"]) {
                                                                        "asc" -> comparator.reversed()
                                                                        else -> comparator
                                                                }
                                                        }
                                        ).paginate(25)
-                                       .turnTo(freenetRequest.parameters["page"]?.toIntOrNull() ?: 0)
+                                       .turnTo(soneRequest.parameters["page"]?.toIntOrNull() ?: 0)
                                        .let { pagination ->
                                                templateContext["pagination"] = pagination
                                                templateContext["knownSones"] = pagination.items
                                        }
-                       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"]
+                       templateContext["sort"] = soneRequest.parameters["sort"].let { sort -> if (sort in listOf("images", "name", "posts")) sort else "activity" }
+                       templateContext["order"] = soneRequest.parameters["order"].let { order -> if (order == "asc") "asc" else "desc" }
+                       templateContext["filter"] = soneRequest.parameters["filter"]
                }
        }
 
index a92eb44..02f5043 100644 (file)
@@ -4,7 +4,7 @@ import net.pterodactylus.sone.data.Sone
 import net.pterodactylus.sone.utils.isPOST
 import net.pterodactylus.sone.utils.parameters
 import net.pterodactylus.sone.web.WebInterface
-import net.pterodactylus.sone.web.page.FreenetRequest
+import net.pterodactylus.sone.web.page.*
 import net.pterodactylus.util.template.Template
 import net.pterodactylus.util.template.TemplateContext
 import javax.inject.Inject
@@ -15,15 +15,15 @@ import javax.inject.Inject
 class LikePage @Inject constructor(template: Template, webInterface: 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 ->
+       override fun handleRequest(soneRequest: SoneRequest, currentSone: Sone, templateContext: TemplateContext) {
+               if (soneRequest.isPOST) {
+                       soneRequest.parameters["type", 16]?.also { type ->
                                when (type) {
-                                       "post" -> currentSone.addLikedPostId(freenetRequest.parameters["post", 36]!!)
-                                       "reply" -> currentSone.addLikedReplyId(freenetRequest.parameters["reply", 36]!!)
+                                       "post" -> currentSone.addLikedPostId(soneRequest.parameters["post", 36]!!)
+                                       "reply" -> currentSone.addLikedReplyId(soneRequest.parameters["reply", 36]!!)
                                }
                        }
-                       throw RedirectException(freenetRequest.parameters["returnPage", 256]!!)
+                       throw RedirectException(soneRequest.parameters["returnPage", 256]!!)
                }
        }
 
index be70548..49ead37 100644 (file)
@@ -2,7 +2,7 @@ package net.pterodactylus.sone.web.pages
 
 import net.pterodactylus.sone.utils.parameters
 import net.pterodactylus.sone.web.WebInterface
-import net.pterodactylus.sone.web.page.FreenetRequest
+import net.pterodactylus.sone.web.page.*
 import net.pterodactylus.util.template.Template
 import net.pterodactylus.util.template.TemplateContext
 import javax.inject.Inject
@@ -13,11 +13,11 @@ import javax.inject.Inject
 class LockSonePage @Inject constructor(template: Template, webInterface: WebInterface):
                SoneTemplatePage("lockSone.html", webInterface, template, "Page.LockSone.Title") {
 
-       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) }
+       override fun handleRequest(soneRequest: SoneRequest, templateContext: TemplateContext) {
+               soneRequest.parameters["returnPage", 256]!!.let { returnPage ->
+                       soneRequest.parameters["sone", 44]!!
+                                       .let { soneRequest.core.getLocalSone(it) }
+                                       ?.let { soneRequest.core.lockSone(it) }
                        throw RedirectException(returnPage)
                }
        }
index ffe65d1..94f94d0 100644 (file)
@@ -2,7 +2,7 @@ package net.pterodactylus.sone.web.pages
 
 import net.pterodactylus.sone.data.Sone
 import net.pterodactylus.sone.web.WebInterface
-import net.pterodactylus.sone.web.page.FreenetRequest
+import net.pterodactylus.sone.web.page.*
 import net.pterodactylus.util.template.Template
 import net.pterodactylus.util.template.TemplateContext
 
@@ -12,10 +12,10 @@ import net.pterodactylus.util.template.TemplateContext
 abstract class LoggedInPage(path: String, template: Template, pageTitleKey: String, webInterface: WebInterface) :
                SoneTemplatePage(path, webInterface, template, pageTitleKey, true) {
 
-       final override fun handleRequest(freenetRequest: FreenetRequest, templateContext: TemplateContext) {
-               handleRequest(freenetRequest, getCurrentSone(freenetRequest.toadletContext, false)!!, templateContext)
+       final override fun handleRequest(soneRequest: SoneRequest, templateContext: TemplateContext) {
+               handleRequest(soneRequest, getCurrentSone(soneRequest.toadletContext, false)!!, templateContext)
        }
 
-       protected abstract fun handleRequest(freenetRequest: FreenetRequest, currentSone: Sone, templateContext: TemplateContext)
+       protected abstract fun handleRequest(soneRequest: SoneRequest, currentSone: Sone, templateContext: TemplateContext)
 
 }
index 4313a59..20251c0 100644 (file)
@@ -5,7 +5,7 @@ import net.pterodactylus.sone.data.Sone
 import net.pterodactylus.sone.utils.emptyToNull
 import net.pterodactylus.sone.utils.isPOST
 import net.pterodactylus.sone.web.WebInterface
-import net.pterodactylus.sone.web.page.FreenetRequest
+import net.pterodactylus.sone.web.page.*
 import net.pterodactylus.util.template.Template
 import net.pterodactylus.util.template.TemplateContext
 import javax.inject.Inject
@@ -16,25 +16,25 @@ import javax.inject.Inject
 class LoginPage @Inject constructor(template: Template, webInterface: WebInterface):
                SoneTemplatePage("login.html", webInterface, template, "Page.Login.Title") {
 
-       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(freenetRequest.toadletContext, sone)
-                               val target = freenetRequest.httpRequest.getParam("target").emptyToNull ?: "index.html"
+       override fun handleRequest(soneRequest: SoneRequest, templateContext: TemplateContext) {
+               if (soneRequest.isPOST) {
+                       val soneId = soneRequest.httpRequest.getPartAsStringFailsafe("sone-id", 43)
+                       soneRequest.core.getLocalSone(soneId)?.let { sone ->
+                               setCurrentSone(soneRequest.toadletContext, sone)
+                               val target = soneRequest.httpRequest.getParam("target").emptyToNull ?: "index.html"
                                throw RedirectException(target)
                        }
                }
-               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}" }
+               templateContext["sones"] = soneRequest.core.localSones.sortedWith(Sone.NICE_NAME_COMPARATOR)
+               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 isEnabled(toadletContext: ToadletContext) = when {
-               webInterface.core.preferences.requireFullAccess && !toadletContext.isAllowedFullAccess -> false
-               else -> getCurrentSone(toadletContext, false) == null
+       override fun isEnabled(soneRequest: SoneRequest) = when {
+               soneRequest.core.preferences.requireFullAccess && !soneRequest.toadletContext.isAllowedFullAccess -> false
+               else -> getCurrentSone(soneRequest.toadletContext, false) == null
        }
 
 }
index 4659d03..563f03b 100644 (file)
@@ -3,7 +3,7 @@ package net.pterodactylus.sone.web.pages
 import freenet.clients.http.ToadletContext
 import net.pterodactylus.sone.data.Sone
 import net.pterodactylus.sone.web.WebInterface
-import net.pterodactylus.sone.web.page.FreenetRequest
+import net.pterodactylus.sone.web.page.*
 import net.pterodactylus.util.template.Template
 import net.pterodactylus.util.template.TemplateContext
 import javax.inject.Inject
@@ -14,15 +14,15 @@ import javax.inject.Inject
 class LogoutPage @Inject constructor(template: Template, webInterface: WebInterface):
                LoggedInPage("logout.html", template, "Page.Logout.Title", webInterface) {
 
-       override fun handleRequest(freenetRequest: FreenetRequest, currentSone: Sone, templateContext: TemplateContext) {
-               setCurrentSone(freenetRequest.toadletContext, null)
+       override fun handleRequest(soneRequest: SoneRequest, currentSone: Sone, templateContext: TemplateContext) {
+               setCurrentSone(soneRequest.toadletContext, null)
                throw RedirectException("index.html")
        }
 
-       override fun isEnabled(toadletContext: ToadletContext): Boolean =
-                       if (webInterface.core.preferences.requireFullAccess && !toadletContext.isAllowedFullAccess) {
+       override fun isEnabled(soneRequest: SoneRequest): Boolean =
+                       if (soneRequest.core.preferences.requireFullAccess && !soneRequest.toadletContext.isAllowedFullAccess) {
                                false
                        } else
-                               getCurrentSone(toadletContext) != null && webInterface.core.localSones.size != 1
+                               getCurrentSone(soneRequest.toadletContext) != null && soneRequest.core.localSones.size != 1
 
 }
index f071bcd..5c1a720 100644 (file)
@@ -14,15 +14,15 @@ import javax.inject.*
 class MarkAsKnownPage @Inject constructor(template: Template, webInterface: WebInterface):
                SoneTemplatePage("markAsKnown.html", webInterface, template, "Page.MarkAsKnown.Title") {
 
-       override fun handleRequest(freenetRequest: FreenetRequest, templateContext: TemplateContext) {
-               val ids = freenetRequest.parameters["id", 65536]!!.split(" ")
-               when (freenetRequest.parameters["type", 5]) {
-                       "sone" -> ids.mapNotNull(webInterface.core::getSone).forEach(webInterface.core::markSoneKnown)
-                       "post" -> ids.mapNotNull(webInterface.core::getPost).forEach(webInterface.core::markPostKnown)
-                       "reply" -> ids.mapNotNull(webInterface.core::getPostReply).forEach(webInterface.core::markReplyKnown)
+       override fun handleRequest(soneRequest: SoneRequest, templateContext: TemplateContext) {
+               val ids = soneRequest.parameters["id", 65536]!!.split(" ")
+               when (soneRequest.parameters["type", 5]) {
+                       "sone" -> ids.mapNotNull(soneRequest.core::getSone).forEach(soneRequest.core::markSoneKnown)
+                       "post" -> ids.mapNotNull(soneRequest.core::getPost).forEach(soneRequest.core::markPostKnown)
+                       "reply" -> ids.mapNotNull(soneRequest.core::getPostReply).forEach(soneRequest.core::markReplyKnown)
                        else -> throw RedirectException("invalid.html")
                }
-               throw RedirectException(freenetRequest.parameters["returnPage", 256]!!)
+               throw RedirectException(soneRequest.parameters["returnPage", 256]!!)
        }
 
 }
index 2f9f1bb..8b4218d 100644 (file)
@@ -4,7 +4,7 @@ import net.pterodactylus.sone.utils.mapPresent
 import net.pterodactylus.sone.utils.paginate
 import net.pterodactylus.sone.utils.parameters
 import net.pterodactylus.sone.web.WebInterface
-import net.pterodactylus.sone.web.page.FreenetRequest
+import net.pterodactylus.sone.web.page.*
 import net.pterodactylus.util.template.Template
 import net.pterodactylus.util.template.TemplateContext
 import javax.inject.Inject
@@ -16,14 +16,14 @@ import javax.inject.Inject
 class NewPage @Inject constructor(  template: Template, webInterface: WebInterface):
                SoneTemplatePage("new.html", webInterface, template, "Page.New.Title") {
 
-       override fun handleRequest(freenetRequest: FreenetRequest, templateContext: TemplateContext) =
-                       getCurrentSone(freenetRequest.toadletContext).let { currentSone ->
-                               (webInterface.getNewPosts(currentSone) + webInterface.getNewReplies(currentSone).mapPresent { it.post })
+       override fun handleRequest(soneRequest: SoneRequest, templateContext: TemplateContext) =
+                       getCurrentSone(soneRequest.toadletContext).let { currentSone ->
+                               (soneRequest.webInterface.getNewPosts(currentSone) + soneRequest.webInterface.getNewReplies(currentSone).mapPresent { it.post })
                                                .distinct()
                                                .sortedByDescending { it.time }
                                                .let { posts ->
-                                                       posts.paginate(webInterface.core.preferences.postsPerPage)
-                                                                       .turnTo(freenetRequest.parameters["page"]?.toIntOrNull() ?: 0)
+                                                       posts.paginate(soneRequest.core.preferences.postsPerPage)
+                                                                       .turnTo(soneRequest.parameters["page"]?.toIntOrNull() ?: 0)
                                                                        .let { pagination ->
                                                                                templateContext["pagination"] = pagination
                                                                                templateContext["posts"] = pagination.items
index 27d85c2..dabe9f2 100644 (file)
@@ -7,7 +7,7 @@ import net.pterodactylus.sone.utils.emptyToNull
 import net.pterodactylus.sone.utils.isPOST
 import net.pterodactylus.sone.utils.parameters
 import net.pterodactylus.sone.web.WebInterface
-import net.pterodactylus.sone.web.page.FreenetRequest
+import net.pterodactylus.sone.web.page.*
 import net.pterodactylus.util.template.Template
 import net.pterodactylus.util.template.TemplateContext
 import javax.inject.Inject
@@ -18,17 +18,17 @@ import javax.inject.Inject
 class OptionsPage @Inject constructor(template: Template, webInterface: WebInterface):
                SoneTemplatePage("options.html", webInterface, template, "Page.Options.Title") {
 
-       override fun handleRequest(freenetRequest: FreenetRequest, templateContext: TemplateContext) {
-               if (freenetRequest.isPOST) {
+       override fun handleRequest(soneRequest: SoneRequest, templateContext: TemplateContext) {
+               if (soneRequest.isPOST) {
                        val fieldsWithErrors = mutableListOf<String>()
-                       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
+                       getCurrentSone(soneRequest.toadletContext)?.options?.let { options ->
+                               val autoFollow = "auto-follow" in soneRequest.parameters
+                               val loadLinkedImages = soneRequest.parameters["load-linked-images"].emptyToNull
+                               val showCustomAvatars = soneRequest.parameters["show-custom-avatars"].emptyToNull
+                               val enableSoneInsertNotification = "enable-sone-insert-notifications" in soneRequest.parameters
+                               val showNewSoneNotification = "show-notification-new-sones" in soneRequest.parameters
+                               val showNewPostNotification = "show-notification-new-posts" in soneRequest.parameters
+                               val showNewReplyNotification = "show-notification-new-replies" in soneRequest.parameters
 
                                options.isAutoFollow = autoFollow
                                options.isSoneInsertNotificationEnabled = enableSoneInsertNotification
@@ -38,39 +38,39 @@ class OptionsPage @Inject constructor(template: Template, webInterface: WebInter
                                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 freenetRequest.parameters
-                       val fcpInterfaceActive = "fcp-interface-active" in freenetRequest.parameters
+                       val fullAccessRequired = "require-full-access" in soneRequest.parameters
+                       val fcpInterfaceActive = "fcp-interface-active" in soneRequest.parameters
 
-                       webInterface.core.preferences.newRequireFullAccess = fullAccessRequired
-                       webInterface.core.preferences.newFcpInterfaceActive = fcpInterfaceActive
+                       soneRequest.core.preferences.newRequireFullAccess = fullAccessRequired
+                       soneRequest.core.preferences.newFcpInterfaceActive = fcpInterfaceActive
 
-                       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
+                       val postsPerPage = soneRequest.parameters["posts-per-page"]?.toIntOrNull()
+                       val charactersPerPost = soneRequest.parameters["characters-per-post"]?.toIntOrNull()
+                       val postCutOffLength = soneRequest.parameters["post-cut-off-length"]?.toIntOrNull()
+                       val imagesPerPage = soneRequest.parameters["images-per-page"]?.toIntOrNull()
+                       val insertionDelay = soneRequest.parameters["insertion-delay"]?.toIntOrNull()
+                       val fcpFullAccessRequired = soneRequest.parameters["fcp-full-access-required"]?.toIntOrNull()
+                       val negativeTrust = soneRequest.parameters["negative-trust"]?.toIntOrNull()
+                       val positiveTrust = soneRequest.parameters["positive-trust"]?.toIntOrNull()
+                       val trustComment = soneRequest.parameters["trust-comment"]?.emptyToNull
 
-                       if (cantSetOption { it.newPostsPerPage = postsPerPage }) fieldsWithErrors += "posts-per-page"
-                       if (cantSetOption { it.newCharactersPerPost = charactersPerPost }) fieldsWithErrors += "characters-per-post"
-                       if (cantSetOption { it.newPostCutOffLength = postCutOffLength }) fieldsWithErrors += "post-cut-off-length"
-                       if (cantSetOption { it.newImagesPerPage = imagesPerPage }) fieldsWithErrors += "images-per-page"
-                       if (cantSetOption { it.newInsertionDelay = insertionDelay }) fieldsWithErrors += "insertion-delay"
-                       fcpFullAccessRequired?.also { if (cantSetOption { it.newFcpFullAccessRequired = FullAccessRequired.values()[fcpFullAccessRequired] }) fieldsWithErrors += "fcp-full-access-required" }
-                       if (cantSetOption { it.newNegativeTrust = negativeTrust }) fieldsWithErrors += "negative-trust"
-                       if (cantSetOption { it.newPositiveTrust = positiveTrust }) fieldsWithErrors += "positive-trust"
-                       if (cantSetOption { it.newTrustComment = trustComment }) fieldsWithErrors += "trust-comment"
+                       if (cantSetOption { soneRequest.core.preferences.newPostsPerPage = postsPerPage }) fieldsWithErrors += "posts-per-page"
+                       if (cantSetOption { soneRequest.core.preferences.newCharactersPerPost = charactersPerPost }) fieldsWithErrors += "characters-per-post"
+                       if (cantSetOption { soneRequest.core.preferences.newPostCutOffLength = postCutOffLength }) fieldsWithErrors += "post-cut-off-length"
+                       if (cantSetOption { soneRequest.core.preferences.newImagesPerPage = imagesPerPage }) fieldsWithErrors += "images-per-page"
+                       if (cantSetOption { soneRequest.core.preferences.newInsertionDelay = insertionDelay }) fieldsWithErrors += "insertion-delay"
+                       fcpFullAccessRequired?.also { if (cantSetOption { soneRequest.core.preferences.newFcpFullAccessRequired = FullAccessRequired.values()[fcpFullAccessRequired] }) fieldsWithErrors += "fcp-full-access-required" }
+                       if (cantSetOption { soneRequest.core.preferences.newNegativeTrust = negativeTrust }) fieldsWithErrors += "negative-trust"
+                       if (cantSetOption { soneRequest.core.preferences.newPositiveTrust = positiveTrust }) fieldsWithErrors += "positive-trust"
+                       if (cantSetOption { soneRequest.core.preferences.newTrustComment = trustComment }) fieldsWithErrors += "trust-comment"
 
                        if (fieldsWithErrors.isEmpty()) {
-                               webInterface.core.touchConfiguration()
+                               soneRequest.core.touchConfiguration()
                                throw RedirectException("options.html")
                        }
                        templateContext["fieldErrors"] = fieldsWithErrors
                }
-               getCurrentSone(freenetRequest.toadletContext)?.options?.let { options ->
+               getCurrentSone(soneRequest.toadletContext)?.options?.let { options ->
                        templateContext["auto-follow"] = options.isAutoFollow
                        templateContext["show-notification-new-sones"] = options.isShowNewSoneNotifications
                        templateContext["show-notification-new-posts"] = options.isShowNewPostNotifications
@@ -79,7 +79,7 @@ class OptionsPage @Inject constructor(template: Template, webInterface: WebInter
                        templateContext["load-linked-images"] = options.loadLinkedImages.toString()
                        templateContext["show-custom-avatars"] = options.showCustomAvatars.toString()
                }
-               webInterface.core.preferences.let { preferences ->
+               soneRequest.core.preferences.let { preferences ->
                        templateContext["insertion-delay"] = preferences.insertionDelay
                        templateContext["characters-per-post"] = preferences.charactersPerPost
                        templateContext["fcp-full-access-required"] = preferences.fcpFullAccessRequired.ordinal
@@ -94,9 +94,9 @@ class OptionsPage @Inject constructor(template: Template, webInterface: WebInter
                }
        }
 
-       private fun cantSetOption(setter: (Preferences) -> Unit) =
+       private fun cantSetOption(setter: () -> Unit) =
                        try {
-                               setter(webInterface.core.preferences)
+                               setter()
                                false
                        } catch (iae: IllegalArgumentException) {
                                true
index 1061a10..367d6fb 100644 (file)
@@ -4,7 +4,7 @@ import net.pterodactylus.sone.data.Sone
 import net.pterodactylus.sone.utils.isPOST
 import net.pterodactylus.sone.utils.parameters
 import net.pterodactylus.sone.web.WebInterface
-import net.pterodactylus.sone.web.page.FreenetRequest
+import net.pterodactylus.sone.web.page.*
 import net.pterodactylus.util.template.Template
 import net.pterodactylus.util.template.TemplateContext
 import javax.inject.Inject
@@ -15,16 +15,16 @@ import javax.inject.Inject
 class RescuePage @Inject constructor(template: Template, webInterface: WebInterface):
                LoggedInPage("rescue.html", template, "Page.Rescue.Title", webInterface) {
 
-       override fun handleRequest(freenetRequest: FreenetRequest, currentSone: Sone, templateContext: TemplateContext) {
-               val soneRescuer = webInterface.core.getSoneRescuer(currentSone)
+       override fun handleRequest(soneRequest: SoneRequest, currentSone: Sone, templateContext: TemplateContext) {
+               val soneRescuer = soneRequest.core.getSoneRescuer(currentSone)
                templateContext["soneRescuer"] = soneRescuer
-               if (freenetRequest.isPOST) {
-                       freenetRequest.parameters["edition", 9]?.toIntOrNull()?.also {
+               if (soneRequest.isPOST) {
+                       soneRequest.parameters["edition", 9]?.toIntOrNull()?.also {
                                if (it > -1) {
                                        soneRescuer.setEdition(it.toLong())
                                }
                        }
-                       if (freenetRequest.parameters["fetch", 8] == "true") {
+                       if (soneRequest.parameters["fetch", 8] == "true") {
                                soneRescuer.startNextFetch()
                        }
                        throw RedirectException("rescue.html")
index 76c2341..11c85dd 100644 (file)
@@ -13,7 +13,7 @@ import net.pterodactylus.sone.utils.memoize
 import net.pterodactylus.sone.utils.paginate
 import net.pterodactylus.sone.utils.parameters
 import net.pterodactylus.sone.web.WebInterface
-import net.pterodactylus.sone.web.page.FreenetRequest
+import net.pterodactylus.sone.web.page.*
 import net.pterodactylus.sone.web.pages.SearchPage.Optionality.FORBIDDEN
 import net.pterodactylus.sone.web.pages.SearchPage.Optionality.OPTIONAL
 import net.pterodactylus.sone.web.pages.SearchPage.Optionality.REQUIRED
@@ -36,10 +36,10 @@ class SearchPage(template: Template, webInterface: WebInterface, ticker: Ticker
 
        private val cache: Cache<Iterable<Phrase>, Pagination<Post>> = CacheBuilder.newBuilder().ticker(ticker).expireAfterAccess(5, MINUTES).build()
 
-       override fun handleRequest(freenetRequest: FreenetRequest, templateContext: TemplateContext) {
+       override fun handleRequest(soneRequest: SoneRequest, templateContext: TemplateContext) {
                val startTime = System.currentTimeMillis()
                val phrases = try {
-                       freenetRequest.parameters["query"].emptyToNull?.parse()
+                       soneRequest.parameters["query"].emptyToNull?.parse()
                } catch (te: TextException) {
                        redirect("index.html")
                }
@@ -49,39 +49,39 @@ class SearchPage(template: Template, webInterface: WebInterface, ticker: Ticker
                        0 -> redirect("index.html")
                        1 -> phrases.first().phrase.also { word ->
                                when {
-                                       word.removePrefix("sone://").let(webInterface.core::getSone) != null -> redirect("viewSone.html?sone=${word.removePrefix("sone://")}")
-                                       word.removePrefix("post://").let(webInterface.core::getPost) != null -> redirect("viewPost.html?post=${word.removePrefix("post://")}")
-                                       word.removePrefix("reply://").let(webInterface.core::getPostReply) != null -> redirect("viewPost.html?post=${word.removePrefix("reply://").let(webInterface.core::getPostReply)?.postId}")
-                                       word.removePrefix("album://").let(webInterface.core::getAlbum) != null -> redirect("imageBrowser.html?album=${word.removePrefix("album://")}")
-                                       word.removePrefix("image://").let { webInterface.core.getImage(it, false) } != null -> redirect("imageBrowser.html?image=${word.removePrefix("image://")}")
+                                       word.removePrefix("sone://").let(soneRequest.core::getSone) != null -> redirect("viewSone.html?sone=${word.removePrefix("sone://")}")
+                                       word.removePrefix("post://").let(soneRequest.core::getPost) != null -> redirect("viewPost.html?post=${word.removePrefix("post://")}")
+                                       word.removePrefix("reply://").let(soneRequest.core::getPostReply) != null -> redirect("viewPost.html?post=${word.removePrefix("reply://").let(soneRequest.core::getPostReply)?.postId}")
+                                       word.removePrefix("album://").let(soneRequest.core::getAlbum) != null -> redirect("imageBrowser.html?album=${word.removePrefix("album://")}")
+                                       word.removePrefix("image://").let { soneRequest.core.getImage(it, false) } != null -> redirect("imageBrowser.html?image=${word.removePrefix("image://")}")
                                }
                        }
                }
 
                val soneNameCache = { sone: Sone -> sone.names() }.memoize()
-               val sonePagination = webInterface.core.sones
-                               .scoreAndPaginate(phrases) { it.allText(soneNameCache) }
-                               .apply { page = freenetRequest.parameters["sonePage"].emptyToNull?.toIntOrNull() ?: 0 }
+               val sonePagination = soneRequest.core.sones
+                               .scoreAndPaginate(phrases, soneRequest.core.preferences.postsPerPage) { it.allText(soneNameCache) }
+                               .apply { page = soneRequest.parameters["sonePage"].emptyToNull?.toIntOrNull() ?: 0 }
                val postPagination = cache.get(phrases) {
-                       webInterface.core.sones
+                       soneRequest.core.sones
                                        .flatMap(Sone::getPosts)
                                        .filter { Post.FUTURE_POSTS_FILTER.apply(it) }
-                                       .scoreAndPaginate(phrases) { it.allText(soneNameCache) }
-               }.apply { page = freenetRequest.parameters["postPage"].emptyToNull?.toIntOrNull() ?: 0 }
+                                       .scoreAndPaginate(phrases, soneRequest.core.preferences.postsPerPage) { it.allText(soneNameCache, soneRequest.core::getReplies) }
+               }.apply { page = soneRequest.parameters["postPage"].emptyToNull?.toIntOrNull() ?: 0 }
 
-               Logger.normal(SearchPage::class.java, "Finished search for “${freenetRequest.parameters["query"]}” in ${System.currentTimeMillis() - startTime}ms.")
+               Logger.normal(SearchPage::class.java, "Finished search for “${soneRequest.parameters["query"]}” in ${System.currentTimeMillis() - startTime}ms.")
                templateContext["sonePagination"] = sonePagination
                templateContext["soneHits"] = sonePagination.items
                templateContext["postPagination"] = postPagination
                templateContext["postHits"] = postPagination.items
        }
 
-       private fun <T> Iterable<T>.scoreAndPaginate(phrases: Iterable<Phrase>, texter: (T) -> String) =
+       private fun <T> Iterable<T>.scoreAndPaginate(phrases: Iterable<Phrase>, postsPerPage: Int, texter: (T) -> String) =
                        map { it to score(texter(it), phrases) }
                                        .filter { it.second > 0 }
                                        .sortedByDescending { it.second }
                                        .map { it.first }
-                                       .paginate(webInterface.core.preferences.postsPerPage)
+                                       .paginate(postsPerPage)
 
        private fun Sone.names() =
                        with(profile) {
@@ -93,8 +93,8 @@ class SearchPage(template: Template, webInterface: WebInterface, ticker: Ticker
        private fun Sone.allText(soneNameCache: (Sone) -> String) =
                        (soneNameCache(this) + profile.fields.map { "${it.name} ${it.value}" }.joinToString(" ", " ")).toLowerCase()
 
-       private fun Post.allText(soneNameCache: (Sone) -> String) =
-                       (text + recipient.orNull()?.let { " ${soneNameCache(it)}" } + webInterface.core.getReplies(id)
+       private fun Post.allText(soneNameCache: (Sone) -> String, getReplies: (String) -> Collection<PostReply>) =
+                       (text + recipient.orNull()?.let { " ${soneNameCache(it)}" } + getReplies(id)
                                        .filter { PostReply.FUTURE_REPLY_FILTER.apply(it) }
                                        .map { "${soneNameCache(it.sone)} ${it.text}" }.joinToString(" ", " ")).toLowerCase()
 
index 1ff35a8..abc58f5 100644 (file)
@@ -18,7 +18,7 @@ import java.net.URLEncoder
  */
 open class SoneTemplatePage @JvmOverloads constructor(
                path: String,
-               protected val webInterface: WebInterface,
+               private val webInterface: WebInterface,
                template: Template,
                private val pageTitleKey: String? = null,
                private val requiresLogin: Boolean = false,
@@ -71,7 +71,7 @@ open class SoneTemplatePage @JvmOverloads constructor(
                handleRequest(freenetRequest, templateContext)
        }
 
-       internal open fun handleRequest(freenetRequest: FreenetRequest, templateContext: TemplateContext) {
+       open fun handleRequest(freenetRequest: FreenetRequest, templateContext: TemplateContext) {
                handleRequest(freenetRequest.toSoneRequest(core, webInterface), templateContext)
        }
 
index f8cb6dd..7afe79c 100644 (file)
@@ -4,7 +4,7 @@ import net.pterodactylus.sone.data.Sone
 import net.pterodactylus.sone.utils.isPOST
 import net.pterodactylus.sone.utils.parameters
 import net.pterodactylus.sone.web.WebInterface
-import net.pterodactylus.sone.web.page.FreenetRequest
+import net.pterodactylus.sone.web.page.*
 import net.pterodactylus.util.template.Template
 import net.pterodactylus.util.template.TemplateContext
 import javax.inject.Inject
@@ -16,12 +16,12 @@ import javax.inject.Inject
 class TrustPage @Inject constructor(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)
+       override fun handleRequest(soneRequest: SoneRequest, currentSone: Sone, templateContext: TemplateContext) {
+               if (soneRequest.isPOST) {
+                       soneRequest.core.getSone(soneRequest.parameters["sone"]!!)?.let { sone ->
+                               soneRequest.core.trustSone(currentSone, sone)
                        }
-                       throw RedirectException(freenetRequest.parameters["returnPage", 256])
+                       throw RedirectException(soneRequest.parameters["returnPage", 256])
                }
        }
 
index dccaf46..ab8e42f 100644 (file)
@@ -13,19 +13,19 @@ import javax.inject.*
 class UnbookmarkPage @Inject constructor(template: Template, webInterface: WebInterface):
                SoneTemplatePage("unbookmark.html", webInterface, template, "Page.Unbookmark.Title") {
 
-       override fun handleRequest(freenetRequest: FreenetRequest, templateContext: TemplateContext) {
+       override fun handleRequest(soneRequest: SoneRequest, templateContext: TemplateContext) {
                when {
-                       freenetRequest.isGET && (freenetRequest.parameters["post"] == "allNotLoaded") -> {
-                               webInterface.core.bookmarkedPosts
+                       soneRequest.isGET && (soneRequest.parameters["post"] == "allNotLoaded") -> {
+                               soneRequest.core.bookmarkedPosts
                                                .filterNot(Post::isLoaded)
-                                               .forEach(webInterface.core::unbookmarkPost)
+                                               .forEach(soneRequest.core::unbookmarkPost)
                                throw RedirectException("bookmarks.html")
                        }
-                       freenetRequest.isPOST -> {
-                               freenetRequest.parameters["post", 36]
-                                               ?.let(webInterface.core::getPost)
-                                               ?.also(webInterface.core::unbookmarkPost)
-                               throw RedirectException(freenetRequest.parameters["returnPage", 256])
+                       soneRequest.isPOST -> {
+                               soneRequest.parameters["post", 36]
+                                               ?.let(soneRequest.core::getPost)
+                                               ?.also(soneRequest.core::unbookmarkPost)
+                               throw RedirectException(soneRequest.parameters["returnPage", 256])
                        }
                }
        }
index 29a8968..11d456c 100644 (file)
@@ -4,7 +4,7 @@ import net.pterodactylus.sone.data.Sone
 import net.pterodactylus.sone.utils.isPOST
 import net.pterodactylus.sone.utils.parameters
 import net.pterodactylus.sone.web.WebInterface
-import net.pterodactylus.sone.web.page.FreenetRequest
+import net.pterodactylus.sone.web.page.*
 import net.pterodactylus.util.template.Template
 import net.pterodactylus.util.template.TemplateContext
 import javax.inject.Inject
@@ -15,11 +15,11 @@ import javax.inject.Inject
 class UnfollowSonePage @Inject constructor(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) }
-                       throw RedirectException(freenetRequest.parameters["returnPage", 256])
+       override fun handleRequest(soneRequest: SoneRequest, currentSone: Sone, templateContext: TemplateContext) {
+               if (soneRequest.isPOST) {
+                       soneRequest.parameters["sone"]!!.split(Regex("[ ,]+"))
+                                       .forEach { soneRequest.core.unfollowSone(currentSone, it) }
+                       throw RedirectException(soneRequest.parameters["returnPage", 256])
                }
        }
 
index 4e03b76..ab93fed 100644 (file)
@@ -4,7 +4,7 @@ import net.pterodactylus.sone.data.Sone
 import net.pterodactylus.sone.utils.isPOST
 import net.pterodactylus.sone.utils.parameters
 import net.pterodactylus.sone.web.WebInterface
-import net.pterodactylus.sone.web.page.FreenetRequest
+import net.pterodactylus.sone.web.page.*
 import net.pterodactylus.util.template.Template
 import net.pterodactylus.util.template.TemplateContext
 import javax.inject.Inject
@@ -15,13 +15,13 @@ import javax.inject.Inject
 class UnlikePage @Inject constructor(template: Template, webInterface: WebInterface):
                LoggedInPage("unlike.html", template, "Page.Unlike.Title", webInterface) {
 
-       override fun handleRequest(freenetRequest: FreenetRequest, currentSone: Sone, templateContext: TemplateContext) {
-               if (freenetRequest.isPOST) {
-                       when (freenetRequest.parameters["type"]) {
-                               "post" -> currentSone.removeLikedPostId(freenetRequest.parameters["post"]!!)
-                               "reply" -> currentSone.removeLikedReplyId(freenetRequest.parameters["reply"]!!)
+       override fun handleRequest(soneRequest: SoneRequest, currentSone: Sone, templateContext: TemplateContext) {
+               if (soneRequest.isPOST) {
+                       when (soneRequest.parameters["type"]) {
+                               "post" -> currentSone.removeLikedPostId(soneRequest.parameters["post"]!!)
+                               "reply" -> currentSone.removeLikedReplyId(soneRequest.parameters["reply"]!!)
                        }
-                       throw RedirectException(freenetRequest.parameters["returnPage", 256])
+                       throw RedirectException(soneRequest.parameters["returnPage", 256])
                }
        }
 
index e3d0352..f8cedb4 100644 (file)
@@ -3,7 +3,7 @@ package net.pterodactylus.sone.web.pages
 import net.pterodactylus.sone.utils.isPOST
 import net.pterodactylus.sone.utils.parameters
 import net.pterodactylus.sone.web.WebInterface
-import net.pterodactylus.sone.web.page.FreenetRequest
+import net.pterodactylus.sone.web.page.*
 import net.pterodactylus.util.template.Template
 import net.pterodactylus.util.template.TemplateContext
 import javax.inject.Inject
@@ -14,12 +14,12 @@ import javax.inject.Inject
 class UnlockSonePage @Inject constructor(template: Template, webInterface: WebInterface):
                SoneTemplatePage("unlockSone.html", webInterface, template, "Page.UnlockSone.Title") {
 
-       override fun handleRequest(freenetRequest: FreenetRequest, templateContext: TemplateContext) {
-               if (freenetRequest.isPOST) {
-                       freenetRequest.parameters["sone", 44]
-                                       .let(webInterface.core::getLocalSone)
-                                       ?.also(webInterface.core::unlockSone)
-                       throw RedirectException(freenetRequest.parameters["returnPage", 256])
+       override fun handleRequest(soneRequest: SoneRequest, templateContext: TemplateContext) {
+               if (soneRequest.isPOST) {
+                       soneRequest.parameters["sone", 44]
+                                       .let(soneRequest.core::getLocalSone)
+                                       ?.also(soneRequest.core::unlockSone)
+                       throw RedirectException(soneRequest.parameters["returnPage", 256])
                }
        }
 
index 74a34b8..2d0cc50 100644 (file)
@@ -4,7 +4,7 @@ import net.pterodactylus.sone.data.Sone
 import net.pterodactylus.sone.utils.isPOST
 import net.pterodactylus.sone.utils.parameters
 import net.pterodactylus.sone.web.WebInterface
-import net.pterodactylus.sone.web.page.FreenetRequest
+import net.pterodactylus.sone.web.page.*
 import net.pterodactylus.util.template.Template
 import net.pterodactylus.util.template.TemplateContext
 import javax.inject.Inject
@@ -16,12 +16,12 @@ import javax.inject.Inject
 class UntrustPage @Inject constructor(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) }
-                       throw RedirectException(freenetRequest.parameters["returnPage", 256])
+       override fun handleRequest(soneRequest: SoneRequest, currentSone: Sone, templateContext: TemplateContext) {
+               if (soneRequest.isPOST) {
+                       soneRequest.parameters["sone", 44]!!
+                                       .let(soneRequest.core::getSone)
+                                       ?.also { soneRequest.core.untrustSone(currentSone, it) }
+                       throw RedirectException(soneRequest.parameters["returnPage", 256])
                }
        }
 
index 8cacb6a..4310c6b 100644 (file)
@@ -9,7 +9,7 @@ import net.pterodactylus.sone.utils.isPOST
 import net.pterodactylus.sone.utils.parameters
 import net.pterodactylus.sone.utils.use
 import net.pterodactylus.sone.web.WebInterface
-import net.pterodactylus.sone.web.page.FreenetRequest
+import net.pterodactylus.sone.web.page.*
 import net.pterodactylus.util.template.Template
 import net.pterodactylus.util.template.TemplateContext
 import java.awt.image.BufferedImage
@@ -24,28 +24,28 @@ import javax.inject.Inject
 class UploadImagePage @Inject constructor(template: Template, webInterface: WebInterface):
                LoggedInPage("uploadImage.html", template, "Page.UploadImage.Title", webInterface) {
 
-       override fun handleRequest(freenetRequest: FreenetRequest, currentSone: Sone, templateContext: TemplateContext) {
-               if (freenetRequest.isPOST) {
-                       val parentAlbum = freenetRequest.parameters["parent"]!!.let(webInterface.core::getAlbum) ?: throw RedirectException("noPermission.html")
+       override fun handleRequest(soneRequest: SoneRequest, currentSone: Sone, templateContext: TemplateContext) {
+               if (soneRequest.isPOST) {
+                       val parentAlbum = soneRequest.parameters["parent"]!!.let(soneRequest.core::getAlbum) ?: throw RedirectException("noPermission.html")
                        if (parentAlbum.sone != currentSone) {
                                throw RedirectException("noPermission.html")
                        }
-                       val title = freenetRequest.parameters["title", 200].emptyToNull ?: throw RedirectException("emptyImageTitle.html")
+                       val title = soneRequest.parameters["title", 200].emptyToNull ?: throw RedirectException("emptyImageTitle.html")
 
-                       val uploadedFile = freenetRequest.httpRequest.getUploadedFile("image")
+                       val uploadedFile = soneRequest.httpRequest.getUploadedFile("image")
                        val bytes = uploadedFile.data.use { it.toByteArray() }
                        val bufferedImage = bytes.toImage()
                        if (bufferedImage == null) {
-                               templateContext["messages"] = webInterface.l10n.getString("Page.UploadImage.Error.InvalidImage")
+                               templateContext["messages"] = soneRequest.l10n.getString("Page.UploadImage.Error.InvalidImage")
                                return
                        }
 
-                       val temporaryImage = webInterface.core.createTemporaryImage(bytes.mimeType, bytes)
-                       webInterface.core.createImage(currentSone, parentAlbum, temporaryImage).modify().apply {
+                       val temporaryImage = soneRequest.core.createTemporaryImage(bytes.mimeType, bytes)
+                       soneRequest.core.createImage(currentSone, parentAlbum, temporaryImage).modify().apply {
                                setWidth(bufferedImage.width)
                                setHeight(bufferedImage.height)
                                setTitle(title)
-                               setDescription(TextFilter.filter(freenetRequest.headers["Host"], freenetRequest.parameters["description", 4000]))
+                               setDescription(TextFilter.filter(soneRequest.headers["Host"], soneRequest.parameters["description", 4000]))
                        }.update()
                        throw RedirectException("imageBrowser.html?album=${parentAlbum.id}")
                }
index c6b0952..2152f19 100644 (file)
@@ -14,20 +14,20 @@ import javax.inject.*
 class ViewPostPage @Inject constructor(template: Template, webInterface: WebInterface):
                SoneTemplatePage("viewPost.html", webInterface, template, "Page.ViewPost.Title") {
 
-       override fun handleRequest(freenetRequest: FreenetRequest, templateContext: TemplateContext) {
-               templateContext["post"] = freenetRequest.parameters["post"]?.let(webInterface.core::getPost)
-               templateContext["raw"] = freenetRequest.parameters["raw"] == "true"
+       override fun handleRequest(soneRequest: SoneRequest, templateContext: TemplateContext) {
+               templateContext["post"] = soneRequest.parameters["post"]?.let(soneRequest.core::getPost)
+               templateContext["raw"] = soneRequest.parameters["raw"] == "true"
        }
 
        override fun isLinkExcepted(link: URI) = true
 
-       override fun getPageTitle(freenetRequest: FreenetRequest) =
-                       (freenetRequest.parameters["post"]?.let(webInterface.core::getPost)?.let {
+       override fun getPageTitle(soneRequest: SoneRequest) =
+                       (soneRequest.parameters["post"]?.let(soneRequest.core::getPost)?.let {
                                if (it.text.length > 20) {
                                        it.text.substring(0..19) + "…"
                                } else {
                                        it.text
                                } + " - ${SoneAccessor.getNiceName(it.sone)} - "
-                       } ?: "") + super.getPageTitle(freenetRequest)
+                       } ?: "") + super.getPageTitle(soneRequest)
 
 }
index 027373f..fd911ee 100644 (file)
@@ -7,7 +7,7 @@ import net.pterodactylus.sone.utils.mapPresent
 import net.pterodactylus.sone.utils.paginate
 import net.pterodactylus.sone.utils.parameters
 import net.pterodactylus.sone.web.WebInterface
-import net.pterodactylus.sone.web.page.FreenetRequest
+import net.pterodactylus.sone.web.page.*
 import net.pterodactylus.util.template.Template
 import net.pterodactylus.util.template.TemplateContext
 import java.net.URI
@@ -19,16 +19,16 @@ import javax.inject.Inject
 class ViewSonePage @Inject constructor(template: Template, webInterface: WebInterface):
                SoneTemplatePage("viewSone.html", webInterface, template) {
 
-       override fun handleRequest(freenetRequest: FreenetRequest, templateContext: TemplateContext) {
-               templateContext["soneId"] = freenetRequest.parameters["sone"]
-               freenetRequest.parameters["sone"]!!.let(webInterface.core::getSone)?.let { sone ->
+       override fun handleRequest(soneRequest: SoneRequest, templateContext: TemplateContext) {
+               templateContext["soneId"] = soneRequest.parameters["sone"]
+               soneRequest.parameters["sone"]!!.let(soneRequest.core::getSone)?.let { sone ->
                        templateContext["sone"] = sone
                        val sonePosts = sone.posts
-                       val directedPosts = webInterface.core.getDirectedPosts(sone.id)
+                       val directedPosts = soneRequest.core.getDirectedPosts(sone.id)
                        (sonePosts + directedPosts)
                                        .sortedByDescending(Post::getTime)
-                                       .paginate(webInterface.core.preferences.postsPerPage)
-                                       .apply { page = freenetRequest.parameters["postPage"]?.toIntOrNull() ?: 0 }
+                                       .paginate(soneRequest.core.preferences.postsPerPage)
+                                       .apply { page = soneRequest.parameters["postPage"]?.toIntOrNull() ?: 0 }
                                        .also {
                                                templateContext["postPagination"] = it
                                                templateContext["posts"] = it.items
@@ -38,9 +38,9 @@ class ViewSonePage @Inject constructor(template: Template, webInterface: WebInte
                                        .distinct()
                                        .minus(sonePosts)
                                        .minus(directedPosts)
-                                       .sortedByDescending { webInterface.core.getReplies(it.id).first().time }
-                                       .paginate(webInterface.core.preferences.postsPerPage)
-                                       .apply { page = freenetRequest.parameters["repliedPostPage"]?.toIntOrNull() ?: 0 }
+                                       .sortedByDescending { soneRequest.core.getReplies(it.id).first().time }
+                                       .paginate(soneRequest.core.preferences.postsPerPage)
+                                       .apply { page = soneRequest.parameters["repliedPostPage"]?.toIntOrNull() ?: 0 }
                                        .also {
                                                templateContext["repliedPostPagination"] = it
                                                templateContext["repliedPosts"] = it.items
@@ -50,9 +50,9 @@ class ViewSonePage @Inject constructor(template: Template, webInterface: WebInte
 
        override fun isLinkExcepted(link: URI) = true
 
-       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")
+       override fun getPageTitle(soneRequest: SoneRequest): String =
+                       soneRequest.parameters["sone"]!!.let(soneRequest.core::getSone)?.let { sone ->
+                               "${SoneAccessor.getNiceName(sone)} - ${soneRequest.l10n.getString("Page.ViewSone.Title")}"
+                       } ?: soneRequest.l10n.getString("Page.ViewSone.Page.TitleWithoutSone")
 
 }
index 7e237d6..b4031b1 100644 (file)
@@ -30,7 +30,7 @@ class DeleteSonePageTest: WebPageTest(::DeleteSonePage) {
        @Test
        fun `page returns correct title`() {
            whenever(l10n.getString("Page.DeleteSone.Title")).thenReturn("delete sone page")
-               assertThat(page.getPageTitle(freenetRequest), equalTo("delete sone page"))
+               assertThat(page.getPageTitle(soneRequest), equalTo("delete sone page"))
        }
 
        @Test
index c6aab00..933a90a 100644 (file)
@@ -33,7 +33,7 @@ class DismissNotificationPageTest: WebPageTest(::DismissNotificationPage) {
        @Test
        fun `page returns correct title`() {
                whenever(l10n.getString("Page.DismissNotification.Title")).thenReturn("dismiss notification page")
-               assertThat(page.getPageTitle(freenetRequest), equalTo("dismiss notification page"))
+               assertThat(page.getPageTitle(soneRequest), equalTo("dismiss notification page"))
        }
 
        @Test
index 0424476..28fdc24 100644 (file)
@@ -30,7 +30,7 @@ class DistrustPageTest: WebPageTest(::DistrustPage) {
        @Test
        fun `page returns correct title`() {
                whenever(l10n.getString("Page.Distrust.Title")).thenReturn("distrust page title")
-               assertThat(page.getPageTitle(freenetRequest), equalTo("distrust page title"))
+               assertThat(page.getPageTitle(soneRequest), equalTo("distrust page title"))
        }
 
        @Test
index b085fb4..b671caa 100644 (file)
@@ -52,7 +52,7 @@ class EditAlbumPageTest: WebPageTest(::EditAlbumPage) {
        @Test
        fun `page returns correct title`() {
                whenever(l10n.getString("Page.EditAlbum.Title")).thenReturn("edit album page")
-               assertThat(page.getPageTitle(freenetRequest), equalTo("edit album page"))
+               assertThat(page.getPageTitle(soneRequest), equalTo("edit album page"))
        }
 
        @Test
index ea104e0..57d1453 100644 (file)
@@ -53,7 +53,7 @@ class EditImagePageTest: WebPageTest(::EditImagePage) {
        @Test
        fun `page returns correct title`() {
                whenever(l10n.getString("Page.EditImage.Title")).thenReturn("edit image page title")
-           assertThat(page.getPageTitle(freenetRequest), equalTo("edit image page title"))
+           assertThat(page.getPageTitle(soneRequest), equalTo("edit image page title"))
        }
 
        @Test
index 81d10c0..cff74ac 100644 (file)
@@ -39,7 +39,7 @@ class EditProfileFieldPageTest: WebPageTest(::EditProfileFieldPage) {
        @Test
        fun `page returns correct title`() {
                whenever(l10n.getString("Page.EditProfileField.Title")).thenReturn("edit profile field title")
-           assertThat(page.getPageTitle(freenetRequest), equalTo("edit profile field title"))
+           assertThat(page.getPageTitle(soneRequest), equalTo("edit profile field title"))
        }
 
        @Test
index 999a720..98b1f6c 100644 (file)
@@ -53,7 +53,7 @@ class EditProfilePageTest: WebPageTest(::EditProfilePage) {
        @Test
        fun `page returns correct title`() {
            whenever(l10n.getString("Page.EditProfile.Title")).thenReturn("edit profile page title")
-               assertThat(page.getPageTitle(freenetRequest), equalTo("edit profile page title"))
+               assertThat(page.getPageTitle(soneRequest), equalTo("edit profile page title"))
        }
 
        @Test
index 906ebea..199c6fd 100644 (file)
@@ -34,7 +34,7 @@ class FollowSonePageTest: WebPageTest(::FollowSonePage) {
        @Test
        fun `page returns correct title`() {
            whenever(l10n.getString("Page.FollowSone.Title")).thenReturn("follow sone page title")
-               assertThat(page.getPageTitle(freenetRequest), equalTo("follow sone page title"))
+               assertThat(page.getPageTitle(soneRequest), equalTo("follow sone page title"))
        }
 
        @Test
index c21adee..c2bedfe 100644 (file)
@@ -32,7 +32,7 @@ class ImageBrowserPageTest: WebPageTest(::ImageBrowserPage) {
        @Test
        fun `page returns correct title`() {
                whenever(l10n.getString("Page.ImageBrowser.Title")).thenReturn("image browser page title")
-           assertThat(page.getPageTitle(freenetRequest), equalTo("image browser page title"))
+           assertThat(page.getPageTitle(soneRequest), equalTo("image browser page title"))
        }
 
        @Test
index 1e200c1..39be2d6 100644 (file)
@@ -41,7 +41,7 @@ class IndexPageTest: WebPageTest({ template, webInterface -> IndexPage(template,
        @Test
        fun `page returns correct title`() {
                whenever(l10n.getString("Page.Index.Title")).thenReturn("index page title")
-           assertThat(page.getPageTitle(freenetRequest), equalTo("index page title"))
+           assertThat(page.getPageTitle(soneRequest), equalTo("index page title"))
        }
 
        @Before
index a9763e0..ef837be 100644 (file)
@@ -84,7 +84,7 @@ class KnownSonesPageTest: WebPageTest(::KnownSonesPage) {
        @Test
        fun `page returns correct title`() {
                whenever(l10n.getString("Page.KnownSones.Title")).thenReturn("known sones page title")
-               assertThat(page.getPageTitle(freenetRequest), equalTo("known sones page title"))
+               assertThat(page.getPageTitle(soneRequest), equalTo("known sones page title"))
        }
 
        @Test
index 4727b7a..49adf50 100644 (file)
@@ -28,7 +28,7 @@ class LikePageTest: WebPageTest(::LikePage) {
        @Test
        fun `page returns correct title`() {
            addTranslation("Page.Like.Title", "like page title")
-               assertThat(page.getPageTitle(freenetRequest), equalTo("like page title"))
+               assertThat(page.getPageTitle(soneRequest), equalTo("like page title"))
        }
 
        @Test
index f8ad87a..5b96324 100644 (file)
@@ -31,7 +31,7 @@ class LockSonePageTest: WebPageTest(::LockSonePage) {
        @Test
        fun `page returns correct title`() {
            addTranslation("Page.LockSone.Title", "lock Sone page title")
-               assertThat(page.getPageTitle(freenetRequest), equalTo("lock Sone page title"))
+               assertThat(page.getPageTitle(soneRequest), equalTo("lock Sone page title"))
        }
 
        @Test
index 2efae9e..f3bed3c 100644 (file)
@@ -27,7 +27,7 @@ class LogoutPageTest: WebPageTest(::LogoutPage) {
        @Test
        fun `page returns correct title`() {
                addTranslation("Page.Logout.Title", "logout page title")
-               assertThat(page.getPageTitle(freenetRequest), equalTo("logout page title"))
+               assertThat(page.getPageTitle(soneRequest), equalTo("logout page title"))
        }
 
        @Test
index 2c6dbae..e87c492 100644 (file)
@@ -31,7 +31,7 @@ class MarkAsKnownPageTest: WebPageTest(::MarkAsKnownPage) {
        @Test
        fun `page returns correct title`() {
                addTranslation("Page.MarkAsKnown.Title", "mark as known page title")
-               assertThat(page.getPageTitle(freenetRequest), equalTo("mark as known page title"))
+               assertThat(page.getPageTitle(soneRequest), equalTo("mark as known page title"))
        }
 
        @Test
index fd654c1..0565c0f 100644 (file)
@@ -40,7 +40,7 @@ class NewPageTest: WebPageTest(::NewPage) {
        @Test
        fun `page returns correct title`() {
                addTranslation("Page.New.Title", "new page title")
-               assertThat(page.getPageTitle(freenetRequest), equalTo("new page title"))
+               assertThat(page.getPageTitle(soneRequest), equalTo("new page title"))
        }
 
        @Test
index a9dba9e..8875549 100644 (file)
@@ -64,7 +64,7 @@ class OptionsPageTest: WebPageTest(::OptionsPage) {
        @Test
        fun `page returns correct title`() {
                addTranslation("Page.Options.Title", "options page title")
-               assertThat(page.getPageTitle(freenetRequest), equalTo("options page title"))
+               assertThat(page.getPageTitle(soneRequest), equalTo("options page title"))
        }
 
        @Test
index 19bc02e..8bda29a 100644 (file)
@@ -40,7 +40,7 @@ class RescuePageTest: WebPageTest(::RescuePage) {
        @Test
        fun `page returns correct title`() {
                addTranslation("Page.Rescue.Title", "rescue page title")
-               assertThat(page.getPageTitle(freenetRequest), equalTo("rescue page title"))
+               assertThat(page.getPageTitle(soneRequest), equalTo("rescue page title"))
        }
 
        @Test
index 00fa5cf..8aaf736 100644 (file)
@@ -44,7 +44,7 @@ class SearchPageTest: WebPageTest({ template, webInterface -> SearchPage(templat
        @Test
        fun `page returns correct title`() {
                addTranslation("Page.Search.Title", "search page title")
-               assertThat(page.getPageTitle(freenetRequest), equalTo("search page title"))
+               assertThat(page.getPageTitle(soneRequest), equalTo("search page title"))
        }
 
        @Test
index d227a84..3eba7cf 100644 (file)
@@ -29,7 +29,7 @@ class SoneTemplatePageTest : WebPageTest({ template, webInterface -> object : So
        @Test
        fun `page title is empty string if no page title key was given`() {
                SoneTemplatePage("path.html", webInterface, template, requiresLogin = false).let { page ->
-                       assertThat(page.getPageTitle(freenetRequest), equalTo(""))
+                       assertThat(page.getPageTitle(soneRequest), equalTo(""))
                }
        }
 
@@ -37,7 +37,7 @@ class SoneTemplatePageTest : WebPageTest({ template, webInterface -> object : So
        fun `page title is retrieved from l10n if page title key is given`() {
                SoneTemplatePage("path.html", webInterface, template, "page.title", false).let { page ->
                        whenever(l10n.getString("page.title")).thenReturn("Page Title")
-                       assertThat(page.getPageTitle(freenetRequest), equalTo("Page Title"))
+                       assertThat(page.getPageTitle(soneRequest), equalTo("Page Title"))
                }
        }
 
index 17c24f1..3e155c5 100644 (file)
@@ -32,7 +32,7 @@ class TrustPageTest: WebPageTest(::TrustPage) {
        @Test
        fun `page returns correct title`() {
            addTranslation("Page.Trust.Title", "title trust page")
-               assertThat(page.getPageTitle(freenetRequest), equalTo("title trust page"))
+               assertThat(page.getPageTitle(soneRequest), equalTo("title trust page"))
        }
 
        @Test
index 92593d0..ebd06f4 100644 (file)
@@ -35,7 +35,7 @@ class UnbookmarkPageTest: WebPageTest(::UnbookmarkPage) {
        @Test
        fun `page returns correct title`() {
                addTranslation("Page.Unbookmark.Title", "unbookmark page title")
-               assertThat(page.getPageTitle(freenetRequest), equalTo("unbookmark page title"))
+               assertThat(page.getPageTitle(soneRequest), equalTo("unbookmark page title"))
        }
 
        @Test
index c3ddd6c..bd5e70e 100644 (file)
@@ -27,7 +27,7 @@ class UnfollowSonePageTest: WebPageTest(::UnfollowSonePage) {
        @Test
        fun `page returns correct page title`() {
            addTranslation("Page.UnfollowSone.Title", "unfollow page title")
-               assertThat(page.getPageTitle(freenetRequest), equalTo("unfollow page title"))
+               assertThat(page.getPageTitle(soneRequest), equalTo("unfollow page title"))
        }
 
        @Test
index 0fb4d1a..fd37fc8 100644 (file)
@@ -29,7 +29,7 @@ class UnlikePageTest: WebPageTest(::UnlikePage) {
        @Test
        fun `page returns correct title`() {
                addTranslation("Page.Unlike.Title", "unlike page title")
-           assertThat(page.getPageTitle(freenetRequest), equalTo("unlike page title"))
+           assertThat(page.getPageTitle(soneRequest), equalTo("unlike page title"))
        }
 
        @Test
index 0fff35c..a0fec9b 100644 (file)
@@ -32,7 +32,7 @@ class UnlockSonePageTest: WebPageTest(::UnlockSonePage) {
        @Test
        fun `page returns correct title`() {
                addTranslation("Page.UnlockSone.Title", "unlock page title")
-           assertThat(page.getPageTitle(freenetRequest), equalTo("unlock page title"))
+           assertThat(page.getPageTitle(soneRequest), equalTo("unlock page title"))
        }
 
        @Test
index 946fd34..d9d47e7 100644 (file)
@@ -32,7 +32,7 @@ class UntrustPageTest: WebPageTest(::UntrustPage) {
        @Test
        fun `page returns correct title`() {
                addTranslation("Page.Untrust.Title", "untrust page title")
-           assertThat(page.getPageTitle(freenetRequest), equalTo("untrust page title"))
+           assertThat(page.getPageTitle(soneRequest), equalTo("untrust page title"))
        }
 
        @Test
index fe76737..1af2f72 100644 (file)
@@ -43,7 +43,7 @@ class UploadImagePageTest: WebPageTest(::UploadImagePage) {
        @Test
        fun `page returns correct title`() {
            addTranslation("Page.UploadImage.Title", "upload image page title")
-               assertThat(page.getPageTitle(freenetRequest), equalTo("upload image page title"))
+               assertThat(page.getPageTitle(soneRequest), equalTo("upload image page title"))
        }
 
        @Test
index 58b039a..cf92bde 100644 (file)
@@ -76,14 +76,14 @@ class ViewPostPageTest: WebPageTest(::ViewPostPage) {
        @Test
        fun `page title for request without parameters is default title`() {
                addTranslation("Page.ViewPost.Title", "view post title")
-               assertThat(page.getPageTitle(freenetRequest), equalTo("view post title"))
+               assertThat(page.getPageTitle(soneRequest), equalTo("view post title"))
        }
 
        @Test
        fun `page title for request with invalid post is default title`() {
                addHttpRequestParameter("post", "invalid-post-id")
                addTranslation("Page.ViewPost.Title", "view post title")
-               assertThat(page.getPageTitle(freenetRequest), equalTo("view post title"))
+               assertThat(page.getPageTitle(soneRequest), equalTo("view post title"))
        }
 
        @Test
@@ -98,7 +98,7 @@ class ViewPostPageTest: WebPageTest(::ViewPostPage) {
                addPost("post-id", post)
                addHttpRequestParameter("post", "post-id")
                addTranslation("Page.ViewPost.Title", "view post title")
-               assertThat(page.getPageTitle(freenetRequest), equalTo("This is a text that … - First M. Last - view post title"))
+               assertThat(page.getPageTitle(soneRequest), equalTo("This is a text that … - First M. Last - view post title"))
        }
 
        @Test
index 22cba9f..ee311e2 100644 (file)
@@ -180,14 +180,14 @@ class ViewSonePageTest: WebPageTest(::ViewSonePage) {
        @Test
        fun `page title is default for request without parameters`() {
                addTranslation("Page.ViewSone.Page.TitleWithoutSone", "view sone page without sone")
-               assertThat(page.getPageTitle(freenetRequest), equalTo("view sone page without sone"))
+               assertThat(page.getPageTitle(soneRequest), equalTo("view sone page without sone"))
        }
 
        @Test
        fun `page title is default for request with invalid sone parameters`() {
                addHttpRequestParameter("sone", "invalid-sone-id")
                addTranslation("Page.ViewSone.Page.TitleWithoutSone", "view sone page without sone")
-               assertThat(page.getPageTitle(freenetRequest), equalTo("view sone page without sone"))
+               assertThat(page.getPageTitle(soneRequest), equalTo("view sone page without sone"))
        }
 
        @Test
@@ -200,7 +200,7 @@ class ViewSonePageTest: WebPageTest(::ViewSonePage) {
                        lastName = "Last"
                })
                addTranslation("Page.ViewSone.Title", "view sone page")
-               assertThat(page.getPageTitle(freenetRequest), equalTo("First M. Last - view sone page"))
+               assertThat(page.getPageTitle(soneRequest), equalTo("First M. Last - view sone page"))
        }
 
        @Test
index d654b09..e3d3410 100644 (file)
@@ -59,6 +59,7 @@ open class WebPageTest(pageSupplier: (Template, WebInterface) -> SoneTemplatePag
                whenever(freenetRequest.l10n).thenReturn(l10n)
                whenever(freenetRequest.uri).thenReturn(mock())
        }
+       val soneRequest by lazy { freenetRequest.toSoneRequest(core, webInterface) }
        val templateContext = TemplateContext()
        val toadletContext = deepMock<ToadletContext>()
        val responseContent = ByteArrayOutputStream()