* fit into Freenet’s web interface.
*/
open class FreenetTemplatePage(
- path: String,
private val templateRenderer: TemplateRenderer,
loaders: Loaders,
private val invalidFormPasswordRedirectTarget: String
class AboutPage @Inject constructor(webInterface: WebInterface, loaders: Loaders, templateRenderer: TemplateRenderer,
private val pluginVersion: PluginVersion,
private val pluginYear: PluginYear,
- private val pluginHomepage: PluginHomepage) : SoneTemplatePage("about.html", webInterface, loaders, templateRenderer, pageTitleKey = "Page.About.Title") {
+ private val pluginHomepage: PluginHomepage) : SoneTemplatePage(webInterface, loaders, templateRenderer, pageTitleKey = "Page.About.Title") {
override fun handleRequest(freenetRequest: FreenetRequest, templateContext: TemplateContext) {
templateContext["version"] = pluginVersion.version
*/
@ToadletPath("bookmark.html")
class BookmarkPage @Inject constructor(webInterface: WebInterface, loaders: Loaders, templateRenderer: TemplateRenderer)
- : SoneTemplatePage("bookmark.html", webInterface, loaders, templateRenderer, pageTitleKey = "Page.Bookmark.Title") {
+ : SoneTemplatePage(webInterface, loaders, templateRenderer, pageTitleKey = "Page.Bookmark.Title") {
override fun handleRequest(soneRequest: SoneRequest, templateContext: TemplateContext) {
if (soneRequest.isPOST) {
@TemplatePath("/templates/bookmarks.html")
@ToadletPath("bookmarks.html")
class BookmarksPage @Inject constructor(webInterface: WebInterface, loaders: Loaders, templateRenderer: TemplateRenderer) :
- SoneTemplatePage("bookmarks.html", webInterface, loaders, templateRenderer, pageTitleKey = "Page.Bookmarks.Title") {
+ SoneTemplatePage(webInterface, loaders, templateRenderer, pageTitleKey = "Page.Bookmarks.Title") {
override fun handleRequest(soneRequest: SoneRequest, templateContext: TemplateContext) {
soneRequest.core.bookmarkedPosts.let { posts ->
@TemplatePath("/templates/createAlbum.html")
@ToadletPath("createAlbum.html")
class CreateAlbumPage @Inject constructor(webInterface: WebInterface, loaders: Loaders, templateRenderer: TemplateRenderer) :
- LoggedInPage("createAlbum.html", "Page.CreateAlbum.Title", webInterface, loaders, templateRenderer) {
+ LoggedInPage("Page.CreateAlbum.Title", webInterface, loaders, templateRenderer) {
override fun handleRequest(soneRequest: SoneRequest, currentSone: Sone, templateContext: TemplateContext) {
if (soneRequest.isPOST) {
@TemplatePath("/templates/createPost.html")
@ToadletPath("createPost.html")
class CreatePostPage @Inject constructor(webInterface: WebInterface, loaders: Loaders, templateRenderer: TemplateRenderer) :
- LoggedInPage("createPost.html", "Page.CreatePost.Title", webInterface, loaders, templateRenderer) {
+ LoggedInPage("Page.CreatePost.Title", webInterface, loaders, templateRenderer) {
override fun handleRequest(soneRequest: SoneRequest, currentSone: Sone, templateContext: TemplateContext) {
val returnPage = soneRequest.httpRequest.getPartAsStringFailsafe("returnPage", 256)
@TemplatePath("/templates/createReply.html")
@ToadletPath("createReply.html")
class CreateReplyPage @Inject constructor(webInterface: WebInterface, loaders: Loaders, templateRenderer: TemplateRenderer) :
- LoggedInPage("createReply.html", "Page.CreateReply.Title", webInterface, loaders, templateRenderer) {
+ LoggedInPage("Page.CreateReply.Title", webInterface, loaders, templateRenderer) {
override fun handleRequest(soneRequest: SoneRequest, currentSone: Sone, templateContext: TemplateContext) {
val postId = soneRequest.httpRequest.getPartAsStringFailsafe("post", 36).apply { templateContext["postId"] = this }
@TemplatePath("/templates/createSone.html")
@ToadletPath("createSone.html")
class CreateSonePage @Inject constructor(webInterface: WebInterface, loaders: Loaders, templateRenderer: TemplateRenderer) :
- SoneTemplatePage("createSone.html", webInterface, loaders, templateRenderer, pageTitleKey = "Page.CreateSone.Title") {
+ SoneTemplatePage(webInterface, loaders, templateRenderer, pageTitleKey = "Page.CreateSone.Title") {
private val logger = Logger.getLogger(CreateSonePage::class.java.name)
@TemplatePath("/templates/deleteAlbum.html")
@ToadletPath("deleteAlbum.html")
class DeleteAlbumPage @Inject constructor(webInterface: WebInterface, loaders: Loaders, templateRenderer: TemplateRenderer) :
- LoggedInPage("deleteAlbum.html", "Page.DeleteAlbum.Title", webInterface, loaders, templateRenderer) {
+ LoggedInPage("Page.DeleteAlbum.Title", webInterface, loaders, templateRenderer) {
override fun handleRequest(soneRequest: SoneRequest, currentSone: Sone, templateContext: TemplateContext) {
if (soneRequest.isPOST) {
@TemplatePath("/templates/deleteImage.html")
@ToadletPath("deleteImage.html")
class DeleteImagePage @Inject constructor(webInterface: WebInterface, loaders: Loaders, templateRenderer: TemplateRenderer) :
- LoggedInPage("deleteImage.html", "Page.DeleteImage.Title", webInterface, loaders, templateRenderer) {
+ LoggedInPage("Page.DeleteImage.Title", webInterface, loaders, templateRenderer) {
override fun handleRequest(soneRequest: SoneRequest, currentSone: Sone, templateContext: TemplateContext) {
if (soneRequest.isPOST) {
@TemplatePath("/templates/deletePost.html")
@ToadletPath("deletePost.html")
class DeletePostPage @Inject constructor(webInterface: WebInterface, loaders: Loaders, templateRenderer: TemplateRenderer) :
- LoggedInPage("deletePost.html", "Page.DeletePost.Title", webInterface, loaders, templateRenderer) {
+ LoggedInPage("Page.DeletePost.Title", webInterface, loaders, templateRenderer) {
override fun handleRequest(soneRequest: SoneRequest, currentSone: Sone, templateContext: TemplateContext) {
if (soneRequest.isPOST) {
@TemplatePath("/templates/deleteProfileField.html")
@ToadletPath("deleteProfileField.html")
class DeleteProfileFieldPage @Inject constructor(webInterface: WebInterface, loaders: Loaders, templateRenderer: TemplateRenderer) :
- LoggedInPage("deleteProfileField.html", "Page.DeleteProfileField.Title", webInterface, loaders, templateRenderer) {
+ LoggedInPage("Page.DeleteProfileField.Title", webInterface, loaders, templateRenderer) {
override fun handleRequest(soneRequest: SoneRequest, currentSone: Sone, templateContext: TemplateContext) {
if (soneRequest.isPOST) {
@TemplatePath("/templates/deleteReply.html")
@ToadletPath("deleteReply.html")
class DeleteReplyPage @Inject constructor(webInterface: WebInterface, loaders: Loaders, templateRenderer: TemplateRenderer) :
- LoggedInPage("deleteReply.html", "Page.DeleteReply.Title", webInterface, loaders, templateRenderer) {
+ LoggedInPage("Page.DeleteReply.Title", webInterface, loaders, templateRenderer) {
override fun handleRequest(soneRequest: SoneRequest, currentSone: Sone, templateContext: TemplateContext) {
if (soneRequest.isPOST) {
@TemplatePath("/templates/deleteSone.html")
@ToadletPath("deleteSone.html")
class DeleteSonePage @Inject constructor(webInterface: WebInterface, loaders: Loaders, templateRenderer: TemplateRenderer) :
- LoggedInPage("deleteSone.html", "Page.DeleteSone.Title", webInterface, loaders, templateRenderer) {
+ LoggedInPage("Page.DeleteSone.Title", webInterface, loaders, templateRenderer) {
override fun handleRequest(soneRequest: SoneRequest, currentSone: Sone, templateContext: TemplateContext) {
if (soneRequest.isPOST) {
*/
@ToadletPath("dismissNotification.html")
class DismissNotificationPage @Inject constructor(webInterface: WebInterface, loaders: Loaders, templateRenderer: TemplateRenderer) :
- SoneTemplatePage("dismissNotification.html", webInterface, loaders, templateRenderer, pageTitleKey = "Page.DismissNotification.Title") {
+ SoneTemplatePage(webInterface, loaders, templateRenderer, pageTitleKey = "Page.DismissNotification.Title") {
override fun handleRequest(soneRequest: SoneRequest, templateContext: TemplateContext) {
val returnPage = soneRequest.httpRequest.getPartAsStringFailsafe("returnPage", 256)
*/
@ToadletPath("distrust.html")
class DistrustPage @Inject constructor(webInterface: WebInterface, loaders: Loaders, templateRenderer: TemplateRenderer) :
- LoggedInPage("distrust.html", "Page.Distrust.Title", webInterface, loaders, templateRenderer) {
+ LoggedInPage("Page.Distrust.Title", webInterface, loaders, templateRenderer) {
override fun handleRequest(soneRequest: SoneRequest, currentSone: Sone, templateContext: TemplateContext) {
if (soneRequest.isPOST) {
*/
@ToadletPath("editAlbum.html")
class EditAlbumPage @Inject constructor(webInterface: WebInterface, loaders: Loaders, templateRenderer: TemplateRenderer) :
- LoggedInPage("editAlbum.html", "Page.EditAlbum.Title", webInterface, loaders, templateRenderer) {
+ LoggedInPage("Page.EditAlbum.Title", webInterface, loaders, templateRenderer) {
override fun handleRequest(soneRequest: SoneRequest, currentSone: Sone, templateContext: TemplateContext) {
if (soneRequest.isPOST) {
*/
@ToadletPath("editImage.html")
class EditImagePage @Inject constructor(webInterface: WebInterface, loaders: Loaders, templateRenderer: TemplateRenderer) :
- LoggedInPage("editImage.html", "Page.EditImage.Title", webInterface, loaders, templateRenderer) {
+ LoggedInPage("Page.EditImage.Title", webInterface, loaders, templateRenderer) {
override fun handleRequest(soneRequest: SoneRequest, currentSone: Sone, templateContext: TemplateContext) {
if (soneRequest.isPOST) {
@TemplatePath("/templates/editProfileField.html")
@ToadletPath("editProfileField.html")
class EditProfileFieldPage @Inject constructor(webInterface: WebInterface, loaders: Loaders, templateRenderer: TemplateRenderer) :
- LoggedInPage("editProfileField.html", "Page.EditProfileField.Title", webInterface, loaders, templateRenderer) {
+ LoggedInPage("Page.EditProfileField.Title", webInterface, loaders, templateRenderer) {
override fun handleRequest(soneRequest: SoneRequest, currentSone: Sone, templateContext: TemplateContext) {
currentSone.profile.let { profile ->
@TemplatePath("/templates/editProfile.html")
@ToadletPath("editProfile.html")
class EditProfilePage @Inject constructor(webInterface: WebInterface, loaders: Loaders, templateRenderer: TemplateRenderer) :
- LoggedInPage("editProfile.html", "Page.EditProfile.Title", webInterface, loaders, templateRenderer) {
+ LoggedInPage("Page.EditProfile.Title", webInterface, loaders, templateRenderer) {
override fun handleRequest(soneRequest: SoneRequest, currentSone: Sone, templateContext: TemplateContext) {
currentSone.profile.let { profile ->
@TemplatePath("/templates/invalid.html")
@ToadletPath("invalid.html")
-class InvalidPage(webInterface: WebInterface, loaders: Loaders, templateRenderer: TemplateRenderer) : SoneTemplatePage("invalid.html", webInterface, loaders, templateRenderer, "Page.Invalid.Title")
+class InvalidPage(webInterface: WebInterface, loaders: Loaders, templateRenderer: TemplateRenderer) : SoneTemplatePage(webInterface, loaders, templateRenderer, "Page.Invalid.Title")
@TemplatePath("/templates/noPermission.html")
@ToadletPath("noPermission.html")
-class NoPermissionPage(webInterface: WebInterface, loaders: Loaders, templateRenderer: TemplateRenderer) : SoneTemplatePage("noPermission.html", webInterface, loaders, templateRenderer, "Page.NoPermission.Title")
+class NoPermissionPage(webInterface: WebInterface, loaders: Loaders, templateRenderer: TemplateRenderer) : SoneTemplatePage(webInterface, loaders, templateRenderer, "Page.NoPermission.Title")
@TemplatePath("/templates/emptyImageTitle.html")
@ToadletPath("emptyImageTitle.html")
-class EmptyImageTitlePage(webInterface: WebInterface, loaders: Loaders, templateRenderer: TemplateRenderer) : SoneTemplatePage("emptyImageTitle.html", webInterface, loaders, templateRenderer, "Page.EmptyImageTitle.Title")
+class EmptyImageTitlePage(webInterface: WebInterface, loaders: Loaders, templateRenderer: TemplateRenderer) : SoneTemplatePage(webInterface, loaders, templateRenderer, "Page.EmptyImageTitle.Title")
@TemplatePath("/templates/emptyAlbumTitle.html")
@ToadletPath("emptyAlbumTitle.html")
-class EmptyAlbumTitlePage(webInterface: WebInterface, loaders: Loaders, templateRenderer: TemplateRenderer) : SoneTemplatePage("emptyAlbumTitle.html", webInterface, loaders, templateRenderer, "Page.EmptyAlbumTitle.Title")
+class EmptyAlbumTitlePage(webInterface: WebInterface, loaders: Loaders, templateRenderer: TemplateRenderer) : SoneTemplatePage(webInterface, loaders, templateRenderer, "Page.EmptyAlbumTitle.Title")
*/
@ToadletPath("followSone.html")
class FollowSonePage @Inject constructor(webInterface: WebInterface, loaders: Loaders, templateRenderer: TemplateRenderer) :
- LoggedInPage("followSone.html", "Page.FollowSone.Title", webInterface, loaders, templateRenderer) {
+ LoggedInPage("Page.FollowSone.Title", webInterface, loaders, templateRenderer) {
override fun handleRequest(soneRequest: SoneRequest, currentSone: Sone, templateContext: TemplateContext) {
if (soneRequest.isPOST) {
@TemplatePath("/templates/imageBrowser.html")
@ToadletPath("imageBrowser.html")
class ImageBrowserPage @Inject constructor(webInterface: WebInterface, loaders: Loaders, templateRenderer: TemplateRenderer) :
- LoggedInPage("imageBrowser.html", "Page.ImageBrowser.Title", webInterface, loaders, templateRenderer) {
+ LoggedInPage("Page.ImageBrowser.Title", webInterface, loaders, templateRenderer) {
override fun handleRequest(soneRequest: SoneRequest, currentSone: Sone, templateContext: TemplateContext) {
if ("album" in soneRequest.parameters) {
@TemplatePath("/templates/index.html")
@ToadletPath("index.html")
class IndexPage @Inject constructor(webInterface: WebInterface, loaders: Loaders, templateRenderer: TemplateRenderer, private val postVisibilityFilter: PostVisibilityFilter) :
- LoggedInPage("index.html", "Page.Index.Title", webInterface, loaders, templateRenderer) {
+ LoggedInPage("Page.Index.Title", webInterface, loaders, templateRenderer) {
override fun handleRequest(soneRequest: SoneRequest, currentSone: Sone, templateContext: TemplateContext) {
(currentSone.posts +
@TemplatePath("/templates/knownSones.html")
@ToadletPath("knownSones.html")
class KnownSonesPage @Inject constructor(webInterface: WebInterface, loaders: Loaders, templateRenderer: TemplateRenderer) :
- SoneTemplatePage("knownSones.html", webInterface, loaders, templateRenderer, pageTitleKey = "Page.KnownSones.Title") {
+ SoneTemplatePage(webInterface, loaders, templateRenderer, pageTitleKey = "Page.KnownSones.Title") {
override fun handleRequest(soneRequest: SoneRequest, templateContext: TemplateContext) {
getCurrentSone(soneRequest.toadletContext).let { currentSone ->
*/
@ToadletPath("like.html")
class LikePage @Inject constructor(webInterface: WebInterface, loaders: Loaders, templateRenderer: TemplateRenderer) :
- LoggedInPage("like.html", "Page.Like.Title", webInterface, loaders, templateRenderer) {
+ LoggedInPage("Page.Like.Title", webInterface, loaders, templateRenderer) {
override fun handleRequest(soneRequest: SoneRequest, currentSone: Sone, templateContext: TemplateContext) {
if (soneRequest.isPOST) {
*/
@ToadletPath("lockSone.html")
class LockSonePage @Inject constructor(webInterface: WebInterface, loaders: Loaders, templateRenderer: TemplateRenderer) :
- SoneTemplatePage("lockSone.html", webInterface, loaders, templateRenderer, pageTitleKey = "Page.LockSone.Title") {
+ SoneTemplatePage(webInterface, loaders, templateRenderer, pageTitleKey = "Page.LockSone.Title") {
override fun handleRequest(soneRequest: SoneRequest, templateContext: TemplateContext) {
soneRequest.parameters["returnPage", 256]!!.let { returnPage ->
/**
* Base class for [SoneTemplatePage] implementations that require a logged in user.
*/
-abstract class LoggedInPage(path: String, pageTitleKey: String, webInterface: WebInterface, loaders: Loaders, templateRenderer: TemplateRenderer) :
- SoneTemplatePage(path, webInterface, loaders, templateRenderer, pageTitleKey = pageTitleKey, requiresLogin = true) {
+abstract class LoggedInPage(pageTitleKey: String, webInterface: WebInterface, loaders: Loaders, templateRenderer: TemplateRenderer) :
+ SoneTemplatePage(webInterface, loaders, templateRenderer, pageTitleKey = pageTitleKey, requiresLogin = true) {
final override fun handleRequest(soneRequest: SoneRequest, templateContext: TemplateContext) {
handleRequest(soneRequest, getCurrentSone(soneRequest.toadletContext, false)!!, templateContext)
@TemplatePath("/templates/login.html")
@ToadletPath("login.html")
class LoginPage @Inject constructor(webInterface: WebInterface, loaders: Loaders, templateRenderer: TemplateRenderer) :
- SoneTemplatePage("login.html", webInterface, loaders, templateRenderer, pageTitleKey = "Page.Login.Title") {
+ SoneTemplatePage(webInterface, loaders, templateRenderer, pageTitleKey = "Page.Login.Title") {
override fun handleRequest(soneRequest: SoneRequest, templateContext: TemplateContext) {
if (soneRequest.isPOST) {
@MenuName("Logout")
@ToadletPath("logout.html")
class LogoutPage @Inject constructor(webInterface: WebInterface, loaders: Loaders, templateRenderer: TemplateRenderer) :
- LoggedInPage("logout.html", "Page.Logout.Title", webInterface, loaders, templateRenderer) {
+ LoggedInPage("Page.Logout.Title", webInterface, loaders, templateRenderer) {
override fun handleRequest(soneRequest: SoneRequest, currentSone: Sone, templateContext: TemplateContext) {
setCurrentSone(soneRequest.toadletContext, null)
*/
@ToadletPath("markAsKnown.html")
class MarkAsKnownPage @Inject constructor(webInterface: WebInterface, loaders: Loaders, templateRenderer: TemplateRenderer) :
- SoneTemplatePage("markAsKnown.html", webInterface, loaders, templateRenderer, pageTitleKey = "Page.MarkAsKnown.Title") {
+ SoneTemplatePage(webInterface, loaders, templateRenderer, pageTitleKey = "Page.MarkAsKnown.Title") {
override fun handleRequest(soneRequest: SoneRequest, templateContext: TemplateContext) {
val ids = soneRequest.parameters["id", 65536]!!.split(" ")
@TemplatePath("/templates/new.html")
@ToadletPath("new.html")
class NewPage @Inject constructor(webInterface: WebInterface, loaders: Loaders, templateRenderer: TemplateRenderer) :
- SoneTemplatePage("new.html", webInterface, loaders, templateRenderer, pageTitleKey = "Page.New.Title") {
+ SoneTemplatePage(webInterface, loaders, templateRenderer, pageTitleKey = "Page.New.Title") {
override fun handleRequest(soneRequest: SoneRequest, templateContext: TemplateContext) =
getCurrentSone(soneRequest.toadletContext).let { currentSone ->
@TemplatePath("/templates/options.html")
@ToadletPath("options.html")
class OptionsPage @Inject constructor(webInterface: WebInterface, loaders: Loaders, templateRenderer: TemplateRenderer) :
- SoneTemplatePage("options.html", webInterface, loaders, templateRenderer, pageTitleKey = "Page.Options.Title") {
+ SoneTemplatePage(webInterface, loaders, templateRenderer, pageTitleKey = "Page.Options.Title") {
override fun handleRequest(soneRequest: SoneRequest, templateContext: TemplateContext) {
if (soneRequest.isPOST) {
@TemplatePath("/templates/rescue.html")
@ToadletPath("rescue.html")
class RescuePage @Inject constructor(webInterface: WebInterface, loaders: Loaders, templateRenderer: TemplateRenderer) :
- LoggedInPage("rescue.html", "Page.Rescue.Title", webInterface, loaders, templateRenderer) {
+ LoggedInPage("Page.Rescue.Title", webInterface, loaders, templateRenderer) {
override fun handleRequest(soneRequest: SoneRequest, currentSone: Sone, templateContext: TemplateContext) {
val soneRescuer = soneRequest.core.getSoneRescuer(currentSone)
@TemplatePath("/templates/search.html")
@ToadletPath("search.html")
class SearchPage(webInterface: WebInterface, loaders: Loaders, templateRenderer: TemplateRenderer, ticker: Ticker = Ticker.systemTicker()) :
- SoneTemplatePage("search.html", webInterface, loaders, templateRenderer, pageTitleKey = "Page.Search.Title") {
+ SoneTemplatePage(webInterface, loaders, templateRenderer, pageTitleKey = "Page.Search.Title") {
@Inject
constructor(webInterface: WebInterface, loaders: Loaders, templateRenderer: TemplateRenderer) :
* Base page for the Sone web interface.
*/
open class SoneTemplatePage @JvmOverloads constructor(
- path: String,
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") {
+) : FreenetTemplatePage(templateRenderer, loaders, "noPermission.html") {
private val core = webInterface.core
private val sessionProvider: SessionProvider = webInterface
*/
@ToadletPath("trust.html")
class TrustPage @Inject constructor(webInterface: WebInterface, loaders: Loaders, templateRenderer: TemplateRenderer) :
- LoggedInPage("trust.html", "Page.Trust.Title", webInterface, loaders, templateRenderer) {
+ LoggedInPage("Page.Trust.Title", webInterface, loaders, templateRenderer) {
override fun handleRequest(soneRequest: SoneRequest, currentSone: Sone, templateContext: TemplateContext) {
if (soneRequest.isPOST) {
*/
@ToadletPath("unbookmark.html")
class UnbookmarkPage @Inject constructor(webInterface: WebInterface, loaders: Loaders, templateRenderer: TemplateRenderer) :
- SoneTemplatePage("unbookmark.html", webInterface, loaders, templateRenderer, pageTitleKey = "Page.Unbookmark.Title") {
+ SoneTemplatePage(webInterface, loaders, templateRenderer, pageTitleKey = "Page.Unbookmark.Title") {
override fun handleRequest(soneRequest: SoneRequest, templateContext: TemplateContext) {
when {
*/
@ToadletPath("unfollowSone.html")
class UnfollowSonePage @Inject constructor(webInterface: WebInterface, loaders: Loaders, templateRenderer: TemplateRenderer) :
- LoggedInPage("unfollowSone.html", "Page.UnfollowSone.Title", webInterface, loaders, templateRenderer) {
+ LoggedInPage("Page.UnfollowSone.Title", webInterface, loaders, templateRenderer) {
override fun handleRequest(soneRequest: SoneRequest, currentSone: Sone, templateContext: TemplateContext) {
if (soneRequest.isPOST) {
*/
@ToadletPath("unlike.html")
class UnlikePage @Inject constructor(webInterface: WebInterface, loaders: Loaders, templateRenderer: TemplateRenderer) :
- LoggedInPage("unlike.html", "Page.Unlike.Title", webInterface, loaders, templateRenderer) {
+ LoggedInPage("Page.Unlike.Title", webInterface, loaders, templateRenderer) {
override fun handleRequest(soneRequest: SoneRequest, currentSone: Sone, templateContext: TemplateContext) {
if (soneRequest.isPOST) {
*/
@ToadletPath("unlockSone.html")
class UnlockSonePage @Inject constructor(webInterface: WebInterface, loaders: Loaders, templateRenderer: TemplateRenderer) :
- SoneTemplatePage("unlockSone.html", webInterface, loaders, templateRenderer, pageTitleKey = "Page.UnlockSone.Title") {
+ SoneTemplatePage(webInterface, loaders, templateRenderer, pageTitleKey = "Page.UnlockSone.Title") {
override fun handleRequest(soneRequest: SoneRequest, templateContext: TemplateContext) {
if (soneRequest.isPOST) {
*/
@ToadletPath("untrust.html")
class UntrustPage @Inject constructor(webInterface: WebInterface, loaders: Loaders, templateRenderer: TemplateRenderer) :
- LoggedInPage("untrust.html", "Page.Untrust.Title", webInterface, loaders, templateRenderer) {
+ LoggedInPage("Page.Untrust.Title", webInterface, loaders, templateRenderer) {
override fun handleRequest(soneRequest: SoneRequest, currentSone: Sone, templateContext: TemplateContext) {
if (soneRequest.isPOST) {
@TemplatePath("/templates/invalid.html")
@ToadletPath("uploadImage.html")
class UploadImagePage @Inject constructor(webInterface: WebInterface, loaders: Loaders, templateRenderer: TemplateRenderer) :
- LoggedInPage("uploadImage.html", "Page.UploadImage.Title", webInterface, loaders, templateRenderer) {
+ LoggedInPage("Page.UploadImage.Title", webInterface, loaders, templateRenderer) {
override fun handleRequest(soneRequest: SoneRequest, currentSone: Sone, templateContext: TemplateContext) {
if (soneRequest.isPOST) {
@TemplatePath("/templates/viewPost.html")
@ToadletPath("viewPost.html")
class ViewPostPage @Inject constructor(webInterface: WebInterface, loaders: Loaders, templateRenderer: TemplateRenderer) :
- SoneTemplatePage("viewPost.html", webInterface, loaders, templateRenderer, pageTitleKey = "Page.ViewPost.Title") {
+ SoneTemplatePage(webInterface, loaders, templateRenderer, pageTitleKey = "Page.ViewPost.Title") {
override fun handleRequest(soneRequest: SoneRequest, templateContext: TemplateContext) {
templateContext["post"] = soneRequest.parameters["post"]?.let(soneRequest.core::getPost)
@TemplatePath("/templates/viewSone.html")
@ToadletPath("viewSone.html")
class ViewSonePage @Inject constructor(webInterface: WebInterface, loaders: Loaders, templateRenderer: TemplateRenderer) :
- SoneTemplatePage("viewSone.html", webInterface, loaders, templateRenderer) {
+ SoneTemplatePage(webInterface, loaders, templateRenderer) {
override fun handleRequest(soneRequest: SoneRequest, templateContext: TemplateContext) {
templateContext["soneId"] = soneRequest.parameters["sone"]
@TemplatePath("template-path")
@ToadletPath("/test/path")
- private open class TestPage(templateRenderer: TemplateRenderer, loaders: Loaders) : FreenetTemplatePage("/", templateRenderer, loaders, "invalid-form-password")
+ private open class TestPage(templateRenderer: TemplateRenderer, loaders: Loaders) : FreenetTemplatePage(templateRenderer, loaders, "invalid-form-password")
}
/**
* Unit test for [SoneTemplatePage].
*/
-class SoneTemplatePageTest : WebPageTest({ webInterface, loaders, templateRenderer -> object : SoneTemplatePage("path.html", webInterface, loaders, templateRenderer, requiresLogin = true) {} }) {
+class SoneTemplatePageTest : WebPageTest({ webInterface, loaders, templateRenderer -> object : SoneTemplatePage(webInterface, loaders, templateRenderer, requiresLogin = true) {} }) {
init {
request("index.html")
@Test
fun `page title is empty string if no page title key was given`() {
- SoneTemplatePage("path.html", webInterface, loaders, templateRenderer, requiresLogin = false).let { page ->
+ SoneTemplatePage(webInterface, loaders, templateRenderer, requiresLogin = false).let { page ->
assertThat(page.getPageTitle(soneRequest), equalTo(""))
}
}
@Test
fun `page title is retrieved from l10n if page title key is given`() {
- SoneTemplatePage("path.html", webInterface, loaders, templateRenderer, pageTitleKey = "page.title", requiresLogin = false).let { page ->
+ SoneTemplatePage(webInterface, loaders, templateRenderer, pageTitleKey = "page.title", requiresLogin = false).let { page ->
whenever(l10n.getString("page.title")).thenReturn("Page Title")
assertThat(page.getPageTitle(soneRequest), equalTo("Page Title"))
}
@Test
fun `handleRequest method is called`() {
var called = false
- val page = object : SoneTemplatePage("path.html", webInterface, loaders, templateRenderer, requiresLogin = true) {
+ val page = object : SoneTemplatePage(webInterface, loaders, templateRenderer, requiresLogin = true) {
override fun handleRequest(freenetRequest: FreenetRequest, templateContext: TemplateContext) {
called = true
}
@Test
fun `redirect does not happen if login is not required`() {
- val page = SoneTemplatePage("page.html", webInterface, loaders, templateRenderer, requiresLogin = false)
+ val page = SoneTemplatePage(webInterface, loaders, templateRenderer, requiresLogin = false)
assertThat(page.getRedirectTarget(freenetRequest), nullValue())
}
@Test
fun `page is enabled if no full access is required and login is not required`() {
- SoneTemplatePage("path.html", webInterface, loaders, templateRenderer, requiresLogin = false).let { page ->
+ SoneTemplatePage(webInterface, loaders, templateRenderer, requiresLogin = false).let { page ->
assertThat(page.isEnabled(toadletContext), equalTo(true))
}
}
@Test
fun `handle request with sone request is called`() {
var called = false
- val page = object : SoneTemplatePage("path.html", webInterface, loaders, templateRenderer) {
+ val page = object : SoneTemplatePage(webInterface, loaders, templateRenderer) {
override fun handleRequest(soneRequest: SoneRequest, templateContext: TemplateContext) {
called = true
}