From d63b7445567b65ffdbd50fa8f7ffbfea1304dff9 Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Thu, 4 Jan 2018 21:22:25 +0100 Subject: [PATCH] =?utf8?q?Clean=20up=20SoneTemplatePage=E2=80=99s=20constr?= =?utf8?q?uctors?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../java/net/pterodactylus/sone/web/WebInterface.java | 8 ++++---- .../kotlin/net/pterodactylus/sone/web/pages/AboutPage.kt | 2 +- .../net/pterodactylus/sone/web/pages/BookmarkPage.kt | 2 +- .../net/pterodactylus/sone/web/pages/BookmarksPage.kt | 3 ++- .../net/pterodactylus/sone/web/pages/CreateSonePage.kt | 2 +- .../sone/web/pages/DismissNotificationPage.kt | 2 +- .../net/pterodactylus/sone/web/pages/KnownSonesPage.kt | 2 +- .../net/pterodactylus/sone/web/pages/LockSonePage.kt | 2 +- .../net/pterodactylus/sone/web/pages/LoggedInPage.kt | 2 +- .../kotlin/net/pterodactylus/sone/web/pages/LoginPage.kt | 2 +- .../net/pterodactylus/sone/web/pages/MarkAsKnownPage.kt | 2 +- .../kotlin/net/pterodactylus/sone/web/pages/NewPage.kt | 2 +- .../net/pterodactylus/sone/web/pages/OptionsPage.kt | 2 +- .../kotlin/net/pterodactylus/sone/web/pages/SearchPage.kt | 2 +- .../net/pterodactylus/sone/web/pages/SoneTemplatePage.kt | 15 ++++----------- .../net/pterodactylus/sone/web/pages/UnbookmarkPage.kt | 2 +- .../net/pterodactylus/sone/web/pages/UnlockSonePage.kt | 2 +- .../net/pterodactylus/sone/web/pages/ViewPostPage.kt | 2 +- .../net/pterodactylus/sone/web/pages/ViewSonePage.kt | 2 +- .../pterodactylus/sone/web/pages/SoneTemplatePageTest.kt | 12 ++++++------ 20 files changed, 32 insertions(+), 38 deletions(-) diff --git a/src/main/java/net/pterodactylus/sone/web/WebInterface.java b/src/main/java/net/pterodactylus/sone/web/WebInterface.java index 6401b43..4396f0e 100644 --- a/src/main/java/net/pterodactylus/sone/web/WebInterface.java +++ b/src/main/java/net/pterodactylus/sone/web/WebInterface.java @@ -756,11 +756,11 @@ public class WebInterface implements SessionProvider { pageToadlets.add(pageToadletFactory.createPageToadlet(new OptionsPage(optionsTemplate, this), "Options")); pageToadlets.add(pageToadletFactory.createPageToadlet(new RescuePage(rescueTemplate, this), "Rescue")); pageToadlets.add(pageToadletFactory.createPageToadlet(new AboutPage(aboutTemplate, this, new PluginVersion(SonePlugin.getPluginVersion()), new PluginYear(SonePlugin.getYear()), new PluginHomepage(SonePlugin.getHomepage())), "About")); - pageToadlets.add(pageToadletFactory.createPageToadlet(new SoneTemplatePage("noPermission.html", noPermissionTemplate, "Page.NoPermission.Title", this))); - pageToadlets.add(pageToadletFactory.createPageToadlet(new SoneTemplatePage("emptyImageTitle.html", emptyImageTitleTemplate, "Page.EmptyImageTitle.Title", this))); - pageToadlets.add(pageToadletFactory.createPageToadlet(new SoneTemplatePage("emptyAlbumTitle.html", emptyAlbumTitleTemplate, "Page.EmptyAlbumTitle.Title", this))); + pageToadlets.add(pageToadletFactory.createPageToadlet(new SoneTemplatePage("noPermission.html", this, noPermissionTemplate, "Page.NoPermission.Title"))); + pageToadlets.add(pageToadletFactory.createPageToadlet(new SoneTemplatePage("emptyImageTitle.html", this, emptyImageTitleTemplate, "Page.EmptyImageTitle.Title"))); + pageToadlets.add(pageToadletFactory.createPageToadlet(new SoneTemplatePage("emptyAlbumTitle.html", this, emptyAlbumTitleTemplate, "Page.EmptyAlbumTitle.Title"))); pageToadlets.add(pageToadletFactory.createPageToadlet(new DismissNotificationPage(emptyTemplate, this))); - pageToadlets.add(pageToadletFactory.createPageToadlet(new SoneTemplatePage("invalid.html", invalidTemplate, "Page.Invalid.Title", this))); + pageToadlets.add(pageToadletFactory.createPageToadlet(new SoneTemplatePage("invalid.html", this, invalidTemplate, "Page.Invalid.Title"))); pageToadlets.add(pageToadletFactory.createPageToadlet(loaders.loadStaticPage("css/", "/static/css/", "text/css"))); pageToadlets.add(pageToadletFactory.createPageToadlet(loaders.loadStaticPage("javascript/", "/static/javascript/", "text/javascript"))); pageToadlets.add(pageToadletFactory.createPageToadlet(loaders.loadStaticPage("images/", "/static/images/", "image/png"))); diff --git a/src/main/kotlin/net/pterodactylus/sone/web/pages/AboutPage.kt b/src/main/kotlin/net/pterodactylus/sone/web/pages/AboutPage.kt index d3382b4..148f10e 100644 --- a/src/main/kotlin/net/pterodactylus/sone/web/pages/AboutPage.kt +++ b/src/main/kotlin/net/pterodactylus/sone/web/pages/AboutPage.kt @@ -14,7 +14,7 @@ import net.pterodactylus.util.template.TemplateContext class AboutPage(template: Template, webInterface: WebInterface, private val pluginVersion: PluginVersion, private val pluginYear: PluginYear, - private val pluginHomepage: PluginHomepage): SoneTemplatePage("about.html", template, "Page.About.Title", webInterface, false) { + private val pluginHomepage: PluginHomepage): SoneTemplatePage("about.html", webInterface, template, "Page.About.Title") { override fun handleRequest(freenetRequest: FreenetRequest, templateContext: TemplateContext) { templateContext["version"] = pluginVersion.version diff --git a/src/main/kotlin/net/pterodactylus/sone/web/pages/BookmarkPage.kt b/src/main/kotlin/net/pterodactylus/sone/web/pages/BookmarkPage.kt index 7fb2320..a5c82cd 100644 --- a/src/main/kotlin/net/pterodactylus/sone/web/pages/BookmarkPage.kt +++ b/src/main/kotlin/net/pterodactylus/sone/web/pages/BookmarkPage.kt @@ -10,7 +10,7 @@ import net.pterodactylus.util.template.TemplateContext * Page that lets the user bookmark a post. */ class BookmarkPage(template: Template, webInterface: WebInterface) - : SoneTemplatePage("bookmark.html", template, "Page.Bookmark.Title", webInterface) { + : SoneTemplatePage("bookmark.html", webInterface, template, "Page.Bookmark.Title") { override fun handleRequest(freenetRequest: FreenetRequest, templateContext: TemplateContext) { if (freenetRequest.isPOST) { diff --git a/src/main/kotlin/net/pterodactylus/sone/web/pages/BookmarksPage.kt b/src/main/kotlin/net/pterodactylus/sone/web/pages/BookmarksPage.kt index fbfc7d3..8d33977 100644 --- a/src/main/kotlin/net/pterodactylus/sone/web/pages/BookmarksPage.kt +++ b/src/main/kotlin/net/pterodactylus/sone/web/pages/BookmarksPage.kt @@ -10,7 +10,8 @@ import net.pterodactylus.util.template.TemplateContext /** * Page that lets the user browse all his bookmarked posts. */ -class BookmarksPage(template: Template, webInterface: WebInterface): SoneTemplatePage("bookmarks.html", template, "Page.Bookmarks.Title", webInterface) { +class BookmarksPage(template: Template, webInterface: WebInterface) : + SoneTemplatePage("bookmarks.html", webInterface, template, "Page.Bookmarks.Title") { override fun handleRequest(freenetRequest: FreenetRequest, templateContext: TemplateContext) { webInterface.core.bookmarkedPosts.let { posts -> diff --git a/src/main/kotlin/net/pterodactylus/sone/web/pages/CreateSonePage.kt b/src/main/kotlin/net/pterodactylus/sone/web/pages/CreateSonePage.kt index efa6f1d..2732aac 100644 --- a/src/main/kotlin/net/pterodactylus/sone/web/pages/CreateSonePage.kt +++ b/src/main/kotlin/net/pterodactylus/sone/web/pages/CreateSonePage.kt @@ -14,7 +14,7 @@ import java.util.logging.Logger * The “create Sone” page lets the user create a new Sone. */ class CreateSonePage(template: Template, webInterface: WebInterface): - SoneTemplatePage("createSone.html", template, "Page.CreateSone.Title", webInterface, false) { + SoneTemplatePage("createSone.html", webInterface, template, "Page.CreateSone.Title") { private val logger = Logger.getLogger(CreateSonePage::class.java.name) diff --git a/src/main/kotlin/net/pterodactylus/sone/web/pages/DismissNotificationPage.kt b/src/main/kotlin/net/pterodactylus/sone/web/pages/DismissNotificationPage.kt index 78cdb83..9f8eeb4 100644 --- a/src/main/kotlin/net/pterodactylus/sone/web/pages/DismissNotificationPage.kt +++ b/src/main/kotlin/net/pterodactylus/sone/web/pages/DismissNotificationPage.kt @@ -9,7 +9,7 @@ import net.pterodactylus.util.template.TemplateContext * Page that lets the user dismiss a notification. */ class DismissNotificationPage(template: Template, webInterface: WebInterface): - SoneTemplatePage("dismissNotification.html", template, "Page.DismissNotification.Title", webInterface) { + SoneTemplatePage("dismissNotification.html", webInterface, template, "Page.DismissNotification.Title") { override fun handleRequest(freenetRequest: FreenetRequest, templateContext: TemplateContext) { val returnPage = freenetRequest.httpRequest.getPartAsStringFailsafe("returnPage", 256) diff --git a/src/main/kotlin/net/pterodactylus/sone/web/pages/KnownSonesPage.kt b/src/main/kotlin/net/pterodactylus/sone/web/pages/KnownSonesPage.kt index 9d6930d..a3969b2 100644 --- a/src/main/kotlin/net/pterodactylus/sone/web/pages/KnownSonesPage.kt +++ b/src/main/kotlin/net/pterodactylus/sone/web/pages/KnownSonesPage.kt @@ -12,7 +12,7 @@ import net.pterodactylus.util.template.TemplateContext * This page shows all known Sones. */ class KnownSonesPage(template: Template, webInterface: WebInterface): - SoneTemplatePage("knownSones.html", template, "Page.KnownSones.Title", webInterface, false) { + SoneTemplatePage("knownSones.html", webInterface, template, "Page.KnownSones.Title") { override fun handleRequest(freenetRequest: FreenetRequest, templateContext: TemplateContext) { getCurrentSone(freenetRequest.toadletContext).let { currentSone -> diff --git a/src/main/kotlin/net/pterodactylus/sone/web/pages/LockSonePage.kt b/src/main/kotlin/net/pterodactylus/sone/web/pages/LockSonePage.kt index 835fe23..bb4c98a 100644 --- a/src/main/kotlin/net/pterodactylus/sone/web/pages/LockSonePage.kt +++ b/src/main/kotlin/net/pterodactylus/sone/web/pages/LockSonePage.kt @@ -10,7 +10,7 @@ import net.pterodactylus.util.template.TemplateContext * This page lets the user lock a [net.pterodactylus.sone.data.Sone] to prevent it from being inserted. */ class LockSonePage(template: Template, webInterface: WebInterface): - SoneTemplatePage("lockSone.html", template, "Page.LockSone.Title", webInterface, false) { + SoneTemplatePage("lockSone.html", webInterface, template, "Page.LockSone.Title") { override fun handleRequest(freenetRequest: FreenetRequest, templateContext: TemplateContext) { freenetRequest.parameters["returnPage", 256]!!.let { returnPage -> diff --git a/src/main/kotlin/net/pterodactylus/sone/web/pages/LoggedInPage.kt b/src/main/kotlin/net/pterodactylus/sone/web/pages/LoggedInPage.kt index c88499e..ffe65d1 100644 --- a/src/main/kotlin/net/pterodactylus/sone/web/pages/LoggedInPage.kt +++ b/src/main/kotlin/net/pterodactylus/sone/web/pages/LoggedInPage.kt @@ -10,7 +10,7 @@ import net.pterodactylus.util.template.TemplateContext * Base class for [SoneTemplatePage] implementations that require a logged in user. */ abstract class LoggedInPage(path: String, template: Template, pageTitleKey: String, webInterface: WebInterface) : - SoneTemplatePage(path, template, pageTitleKey, webInterface, true) { + SoneTemplatePage(path, webInterface, template, pageTitleKey, true) { final override fun handleRequest(freenetRequest: FreenetRequest, templateContext: TemplateContext) { handleRequest(freenetRequest, getCurrentSone(freenetRequest.toadletContext, false)!!, templateContext) diff --git a/src/main/kotlin/net/pterodactylus/sone/web/pages/LoginPage.kt b/src/main/kotlin/net/pterodactylus/sone/web/pages/LoginPage.kt index 0e0fee5..905cff4 100644 --- a/src/main/kotlin/net/pterodactylus/sone/web/pages/LoginPage.kt +++ b/src/main/kotlin/net/pterodactylus/sone/web/pages/LoginPage.kt @@ -13,7 +13,7 @@ import net.pterodactylus.util.template.TemplateContext * The login page lets the user log in. */ class LoginPage(template: Template, webInterface: WebInterface): - SoneTemplatePage("login.html", template, "Page.Login.Title", webInterface) { + SoneTemplatePage("login.html", webInterface, template, "Page.Login.Title") { override fun handleRequest(freenetRequest: FreenetRequest, templateContext: TemplateContext) { if (freenetRequest.isPOST) { diff --git a/src/main/kotlin/net/pterodactylus/sone/web/pages/MarkAsKnownPage.kt b/src/main/kotlin/net/pterodactylus/sone/web/pages/MarkAsKnownPage.kt index 49c1075..da609a6 100644 --- a/src/main/kotlin/net/pterodactylus/sone/web/pages/MarkAsKnownPage.kt +++ b/src/main/kotlin/net/pterodactylus/sone/web/pages/MarkAsKnownPage.kt @@ -13,7 +13,7 @@ import net.pterodactylus.util.template.TemplateContext * [Replie][net.pterodactylus.sone.data.Reply]s as known. */ class MarkAsKnownPage(template: Template, webInterface: WebInterface): - SoneTemplatePage("markAsKnown.html", template, "Page.MarkAsKnown.Title", webInterface, false) { + SoneTemplatePage("markAsKnown.html", webInterface, template, "Page.MarkAsKnown.Title") { override fun handleRequest(freenetRequest: FreenetRequest, templateContext: TemplateContext) { val ids = freenetRequest.parameters["id", 65536]!!.split(" ") diff --git a/src/main/kotlin/net/pterodactylus/sone/web/pages/NewPage.kt b/src/main/kotlin/net/pterodactylus/sone/web/pages/NewPage.kt index 55df67a..c774ceb 100644 --- a/src/main/kotlin/net/pterodactylus/sone/web/pages/NewPage.kt +++ b/src/main/kotlin/net/pterodactylus/sone/web/pages/NewPage.kt @@ -13,7 +13,7 @@ import net.pterodactylus.util.template.TemplateContext * [PostVisibilityFilter.isPostVisible(Sone, Post)] and sorted by time. */ class NewPage(template: Template, webInterface: WebInterface): - SoneTemplatePage("new.html", template, "Page.New.Title", webInterface, false) { + SoneTemplatePage("new.html", webInterface, template, "Page.New.Title") { override fun handleRequest(freenetRequest: FreenetRequest, templateContext: TemplateContext) = getCurrentSone(freenetRequest.toadletContext).let { currentSone -> diff --git a/src/main/kotlin/net/pterodactylus/sone/web/pages/OptionsPage.kt b/src/main/kotlin/net/pterodactylus/sone/web/pages/OptionsPage.kt index 7cf1bb3..5205457 100644 --- a/src/main/kotlin/net/pterodactylus/sone/web/pages/OptionsPage.kt +++ b/src/main/kotlin/net/pterodactylus/sone/web/pages/OptionsPage.kt @@ -15,7 +15,7 @@ import net.pterodactylus.util.template.TemplateContext * This page lets the user edit the options of the Sone plugin. */ class OptionsPage(template: Template, webInterface: WebInterface): - SoneTemplatePage("options.html", template, "Page.Options.Title", webInterface, false) { + SoneTemplatePage("options.html", webInterface, template, "Page.Options.Title") { override fun handleRequest(freenetRequest: FreenetRequest, templateContext: TemplateContext) { if (freenetRequest.isPOST) { diff --git a/src/main/kotlin/net/pterodactylus/sone/web/pages/SearchPage.kt b/src/main/kotlin/net/pterodactylus/sone/web/pages/SearchPage.kt index f296e03..7cddc35 100644 --- a/src/main/kotlin/net/pterodactylus/sone/web/pages/SearchPage.kt +++ b/src/main/kotlin/net/pterodactylus/sone/web/pages/SearchPage.kt @@ -28,7 +28,7 @@ import java.util.concurrent.TimeUnit.MINUTES * words. */ class SearchPage @JvmOverloads constructor(template: Template, webInterface: WebInterface, ticker: Ticker = Ticker.systemTicker()): - SoneTemplatePage("search.html", template, "Page.Search.Title", webInterface, false) { + SoneTemplatePage("search.html", webInterface, template, "Page.Search.Title") { private val cache: Cache, Pagination> = CacheBuilder.newBuilder().ticker(ticker).expireAfterAccess(5, MINUTES).build() diff --git a/src/main/kotlin/net/pterodactylus/sone/web/pages/SoneTemplatePage.kt b/src/main/kotlin/net/pterodactylus/sone/web/pages/SoneTemplatePage.kt index 3f04236..b4178cc 100644 --- a/src/main/kotlin/net/pterodactylus/sone/web/pages/SoneTemplatePage.kt +++ b/src/main/kotlin/net/pterodactylus/sone/web/pages/SoneTemplatePage.kt @@ -16,21 +16,15 @@ import java.net.URLEncoder /** * Base page for the Sone web interface. */ -open class SoneTemplatePage( +open class SoneTemplatePage @JvmOverloads constructor( path: String, protected val webInterface: WebInterface, template: Template, private val pageTitleKey: String? = null, - private val requiresLogin: Boolean = true + private val requiresLogin: Boolean = false, + private val pageTitle: (FreenetRequest) -> String = { pageTitleKey?.let(webInterface.l10n::getString) ?: "" } ) : FreenetTemplatePage(path, webInterface.templateContextFactory, template, "noPermission.html") { - @JvmOverloads - constructor(path: String, template: Template, pageTitleKey: String?, webInterface: WebInterface, requireLogin: Boolean = false) : - this(path, webInterface, template, pageTitleKey, requireLogin) - - constructor(path: String, template: Template, webInterface: WebInterface, requireLogin: Boolean = true) : - this(path, webInterface, template, null, requireLogin) - private val core = webInterface.core protected val sessionProvider: SessionProvider = webInterface @@ -42,8 +36,7 @@ open class SoneTemplatePage( fun requiresLogin() = requiresLogin - override public fun getPageTitle(freenetRequest: FreenetRequest) = - pageTitleKey?.let(webInterface.l10n::getString) ?: "" + override public fun getPageTitle(freenetRequest: FreenetRequest) = pageTitle(freenetRequest) override public fun getStyleSheets() = listOf("css/sone.css") diff --git a/src/main/kotlin/net/pterodactylus/sone/web/pages/UnbookmarkPage.kt b/src/main/kotlin/net/pterodactylus/sone/web/pages/UnbookmarkPage.kt index c742542..ec4242b 100644 --- a/src/main/kotlin/net/pterodactylus/sone/web/pages/UnbookmarkPage.kt +++ b/src/main/kotlin/net/pterodactylus/sone/web/pages/UnbookmarkPage.kt @@ -14,7 +14,7 @@ import net.pterodactylus.util.template.TemplateContext * Page that lets the user unbookmark a post. */ class UnbookmarkPage(template: Template, webInterface: WebInterface): - SoneTemplatePage("unbookmark.html", template, "Page.Unbookmark.Title", webInterface, false) { + SoneTemplatePage("unbookmark.html", webInterface, template, "Page.Unbookmark.Title") { override fun handleRequest(freenetRequest: FreenetRequest, templateContext: TemplateContext) { when { diff --git a/src/main/kotlin/net/pterodactylus/sone/web/pages/UnlockSonePage.kt b/src/main/kotlin/net/pterodactylus/sone/web/pages/UnlockSonePage.kt index e792318..0567af2 100644 --- a/src/main/kotlin/net/pterodactylus/sone/web/pages/UnlockSonePage.kt +++ b/src/main/kotlin/net/pterodactylus/sone/web/pages/UnlockSonePage.kt @@ -11,7 +11,7 @@ import net.pterodactylus.util.template.TemplateContext * This page lets the user unlock a [net.pterodactylus.sone.data.Sone] to allow its insertion. */ class UnlockSonePage(template: Template, webInterface: WebInterface): - SoneTemplatePage("unlockSone.html", template, "Page.UnlockSone.Title", webInterface, false) { + SoneTemplatePage("unlockSone.html", webInterface, template, "Page.UnlockSone.Title") { override fun handleRequest(freenetRequest: FreenetRequest, templateContext: TemplateContext) { if (freenetRequest.isPOST) { diff --git a/src/main/kotlin/net/pterodactylus/sone/web/pages/ViewPostPage.kt b/src/main/kotlin/net/pterodactylus/sone/web/pages/ViewPostPage.kt index 910c939..d3f4540 100644 --- a/src/main/kotlin/net/pterodactylus/sone/web/pages/ViewPostPage.kt +++ b/src/main/kotlin/net/pterodactylus/sone/web/pages/ViewPostPage.kt @@ -13,7 +13,7 @@ import java.net.URI * This page lets the user view a post and all its replies. */ class ViewPostPage(template: Template, webInterface: WebInterface): - SoneTemplatePage("viewPost.html", template, "Page.ViewPost.Title", webInterface, false) { + SoneTemplatePage("viewPost.html", webInterface, template, "Page.ViewPost.Title") { override fun handleRequest(freenetRequest: FreenetRequest, templateContext: TemplateContext) { templateContext["post"] = freenetRequest.parameters["post"]?.let(webInterface.core::getPost) diff --git a/src/main/kotlin/net/pterodactylus/sone/web/pages/ViewSonePage.kt b/src/main/kotlin/net/pterodactylus/sone/web/pages/ViewSonePage.kt index 2e175af..50b2dd7 100644 --- a/src/main/kotlin/net/pterodactylus/sone/web/pages/ViewSonePage.kt +++ b/src/main/kotlin/net/pterodactylus/sone/web/pages/ViewSonePage.kt @@ -16,7 +16,7 @@ import java.net.URI * Lets the user browser another Sone. */ class ViewSonePage(template: Template, webInterface: WebInterface): - SoneTemplatePage("viewSone.html", template, webInterface, false) { + SoneTemplatePage("viewSone.html", webInterface, template) { override fun handleRequest(freenetRequest: FreenetRequest, templateContext: TemplateContext) { templateContext["soneId"] = freenetRequest.parameters["sone"] diff --git a/src/test/kotlin/net/pterodactylus/sone/web/pages/SoneTemplatePageTest.kt b/src/test/kotlin/net/pterodactylus/sone/web/pages/SoneTemplatePageTest.kt index 3cb08e6..d8425d3 100644 --- a/src/test/kotlin/net/pterodactylus/sone/web/pages/SoneTemplatePageTest.kt +++ b/src/test/kotlin/net/pterodactylus/sone/web/pages/SoneTemplatePageTest.kt @@ -20,18 +20,18 @@ import org.junit.Test /** * Unit test for [SoneTemplatePage]. */ -class SoneTemplatePageTest : WebPageTest({ template, webInterface -> object : SoneTemplatePage("path.html", template, webInterface, true) {} }) { +class SoneTemplatePageTest : WebPageTest({ template, webInterface -> object : SoneTemplatePage("path.html", webInterface, template, requiresLogin = true) {} }) { @Test fun `page title is empty string if no page title key was given`() { - SoneTemplatePage("path.html", template, null, webInterface).let { page -> + SoneTemplatePage("path.html", webInterface, template, requiresLogin = false).let { page -> assertThat(page.getPageTitle(freenetRequest), equalTo("")) } } @Test fun `page title is retrieved from l10n if page title key is given`() { - SoneTemplatePage("path.html", template, "page.title", webInterface).let { page -> + 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")) } @@ -144,7 +144,7 @@ class SoneTemplatePageTest : WebPageTest({ template, webInterface -> object : So @Test fun `handleRequest method is called`() { var called = false - val page = object : SoneTemplatePage("path.html", template, webInterface, true) { + val page = object : SoneTemplatePage("path.html", webInterface, template, requiresLogin = true) { override fun handleRequest(freenetRequest: FreenetRequest, templateContext: TemplateContext) { called = true } @@ -155,7 +155,7 @@ class SoneTemplatePageTest : WebPageTest({ template, webInterface -> object : So @Test fun `redirect does not happen if login is not required`() { - val page = SoneTemplatePage("page.html", template, webInterface, false) + val page = SoneTemplatePage("page.html", webInterface, template, requiresLogin = false) assertThat(page.getRedirectTarget(freenetRequest), nullValue()) } @@ -209,7 +209,7 @@ class SoneTemplatePageTest : WebPageTest({ template, webInterface -> object : So @Test fun `page is enabled if no full access is required and login is not required`() { - SoneTemplatePage("path.html", template, webInterface, false).let { page -> + SoneTemplatePage("path.html", webInterface, template, requiresLogin = false).let { page -> assertThat(page.isEnabled(toadletContext), equalTo(true)) } } -- 2.7.4