X-Git-Url: https://git.pterodactylus.net/?p=Sone.git;a=blobdiff_plain;f=src%2Fmain%2Fkotlin%2Fnet%2Fpterodactylus%2Fsone%2Fweb%2Fpages%2FSoneTemplatePage.kt;h=3c3e98a1aca5306bfb0790b67aa84e94f63a68f8;hp=abc58f5d9f0270d7525eda66e7aae908d5990b25;hb=e3da46d8947ab8a542a156069b3b24c13fd011df;hpb=cd72add62ab407336b471d4b7cda8e33dd2df5c6 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 abc58f5..3c3e98a 100644 --- a/src/main/kotlin/net/pterodactylus/sone/web/pages/SoneTemplatePage.kt +++ b/src/main/kotlin/net/pterodactylus/sone/web/pages/SoneTemplatePage.kt @@ -2,7 +2,7 @@ package net.pterodactylus.sone.web.pages import freenet.clients.http.* import net.pterodactylus.sone.data.Sone -import net.pterodactylus.sone.main.SonePlugin +import net.pterodactylus.sone.main.* import net.pterodactylus.sone.utils.emptyToNull import net.pterodactylus.sone.web.SessionProvider import net.pterodactylus.sone.web.WebInterface @@ -19,14 +19,16 @@ import java.net.URLEncoder open class SoneTemplatePage @JvmOverloads constructor( path: String, private val webInterface: WebInterface, + loaders: Loaders, template: Template, + templateRenderer: TemplateRenderer, private val pageTitleKey: String? = null, private val requiresLogin: Boolean = false, private val pageTitle: (FreenetRequest) -> String = { pageTitleKey?.let(webInterface.l10n::getString) ?: "" } -) : FreenetTemplatePage(path, webInterface.templateContextFactory, template, "noPermission.html") { +) : FreenetTemplatePage(path, templateRenderer, loaders, template, "noPermission.html") { private val core = webInterface.core - protected val sessionProvider: SessionProvider = webInterface + private val sessionProvider: SessionProvider = webInterface protected fun getCurrentSone(toadletContext: ToadletContext, createSession: Boolean = true) = sessionProvider.getCurrentSone(toadletContext, createSession) @@ -40,10 +42,9 @@ open class SoneTemplatePage @JvmOverloads constructor( open fun getPageTitle(soneRequest: SoneRequest) = pageTitle(soneRequest) - override public fun getStyleSheets() = - listOf("css/sone.css") + override val styleSheets = listOf("css/sone.css") - override public fun getShortcutIcon() = "images/icon.png" + override val shortcutIcon = "images/icon.png" override public fun getAdditionalLinkNodes(request: FreenetRequest) = listOf(mapOf( @@ -92,7 +93,7 @@ open class SoneTemplatePage @JvmOverloads constructor( private val String.urlEncode: String get() = URLEncoder.encode(this, "UTF-8") override fun isEnabled(toadletContext: ToadletContext) = - isEnabled(SoneRequest(toadletContext.uri, Method.GET, HTTPRequestImpl(toadletContext.uri, "GET"), toadletContext, webInterface.l10n, core, webInterface)) + isEnabled(SoneRequest(toadletContext.uri, Method.GET, HTTPRequestImpl(toadletContext.uri, "GET"), toadletContext, webInterface.l10n, webInterface.sessionManager, core, webInterface)) open fun isEnabled(soneRequest: SoneRequest) = when { requiresLogin && getCurrentSone(soneRequest.toadletContext) == null -> false