import freenet.clients.http.*
import net.pterodactylus.sone.data.*
+import net.pterodactylus.sone.freenet.*
import net.pterodactylus.sone.main.*
import net.pterodactylus.sone.utils.*
import net.pterodactylus.sone.web.*
/**
* Base page for the Sone web interface.
*/
-open class SoneTemplatePage @JvmOverloads constructor(
- path: String,
+open class SoneTemplatePage(
private val webInterface: WebInterface,
loaders: Loaders,
templateRenderer: TemplateRenderer,
private val pageTitleKey: String? = null,
private val requiresLogin: Boolean = false,
- private val pageTitle: (FreenetRequest) -> String = { pageTitleKey?.let(webInterface.l10n::getString) ?: "" }
-) : FreenetTemplatePage(path, templateRenderer, loaders, "noPermission.html") {
+ private val pageTitle: (FreenetRequest) -> String = { pageTitleKey?.let(webInterface.translation::translate) ?: "" }
+) : FreenetTemplatePage(templateRenderer, loaders, "noPermission.html") {
private val core = webInterface.core
private val sessionProvider: SessionProvider = webInterface
+ protected val translation: Translation = webInterface.translation
protected fun getCurrentSone(toadletContext: ToadletContext, createSession: Boolean = true) =
- sessionProvider.getCurrentSone(toadletContext, createSession)
+ sessionProvider.getCurrentSone(toadletContext)
protected fun setCurrentSone(toadletContext: ToadletContext, sone: Sone?) =
sessionProvider.setCurrentSone(toadletContext, sone)
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, webInterface.sessionManager, core, webInterface))
+ isEnabled(SoneRequest(toadletContext.uri, Method.GET, HTTPRequestImpl(toadletContext.uri, "GET"), toadletContext, core, webInterface))
open fun isEnabled(soneRequest: SoneRequest) = when {
requiresLogin && getCurrentSone(soneRequest.toadletContext) == null -> false