✨ Use @ToadletPath for JSON pages, too
authorDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Sat, 18 May 2019 09:34:53 +0000 (11:34 +0200)
committerDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Sat, 18 May 2019 09:34:53 +0000 (11:34 +0200)
34 files changed:
src/main/kotlin/net/pterodactylus/sone/web/ajax/BookmarkAjaxPage.kt
src/main/kotlin/net/pterodactylus/sone/web/ajax/CreatePostAjaxPage.kt
src/main/kotlin/net/pterodactylus/sone/web/ajax/CreateReplyAjaxPage.kt
src/main/kotlin/net/pterodactylus/sone/web/ajax/DeletePostAjaxPage.kt
src/main/kotlin/net/pterodactylus/sone/web/ajax/DeleteProfileFieldAjaxPage.kt
src/main/kotlin/net/pterodactylus/sone/web/ajax/DeleteReplyAjaxPage.kt
src/main/kotlin/net/pterodactylus/sone/web/ajax/DismissNotificationAjaxPage.kt
src/main/kotlin/net/pterodactylus/sone/web/ajax/DistrustAjaxPage.kt
src/main/kotlin/net/pterodactylus/sone/web/ajax/EditAlbumAjaxPage.kt
src/main/kotlin/net/pterodactylus/sone/web/ajax/EditImageAjaxPage.kt
src/main/kotlin/net/pterodactylus/sone/web/ajax/EditProfileFieldAjaxPage.kt
src/main/kotlin/net/pterodactylus/sone/web/ajax/FollowSoneAjaxPage.kt
src/main/kotlin/net/pterodactylus/sone/web/ajax/GetLikesAjaxPage.kt
src/main/kotlin/net/pterodactylus/sone/web/ajax/GetLinkedElementAjaxPage.kt
src/main/kotlin/net/pterodactylus/sone/web/ajax/GetNotificationsAjaxPage.kt
src/main/kotlin/net/pterodactylus/sone/web/ajax/GetPostAjaxPage.kt
src/main/kotlin/net/pterodactylus/sone/web/ajax/GetReplyAjaxPage.kt
src/main/kotlin/net/pterodactylus/sone/web/ajax/GetStatusAjaxPage.kt
src/main/kotlin/net/pterodactylus/sone/web/ajax/GetTimesAjaxPage.kt
src/main/kotlin/net/pterodactylus/sone/web/ajax/GetTranslationAjaxPage.kt
src/main/kotlin/net/pterodactylus/sone/web/ajax/JsonPage.kt
src/main/kotlin/net/pterodactylus/sone/web/ajax/LikeAjaxPage.kt
src/main/kotlin/net/pterodactylus/sone/web/ajax/LockSoneAjaxPage.kt
src/main/kotlin/net/pterodactylus/sone/web/ajax/LoggedInJsonPage.kt
src/main/kotlin/net/pterodactylus/sone/web/ajax/MarkAsKnownAjaxPage.kt
src/main/kotlin/net/pterodactylus/sone/web/ajax/MoveProfileFieldAjaxPage.kt
src/main/kotlin/net/pterodactylus/sone/web/ajax/TrustAjaxPage.kt
src/main/kotlin/net/pterodactylus/sone/web/ajax/UnbookmarkAjaxPage.kt
src/main/kotlin/net/pterodactylus/sone/web/ajax/UnfollowSoneAjaxPage.kt
src/main/kotlin/net/pterodactylus/sone/web/ajax/UnlikeAjaxPage.kt
src/main/kotlin/net/pterodactylus/sone/web/ajax/UnlockSoneAjaxPage.kt
src/main/kotlin/net/pterodactylus/sone/web/ajax/UntrustAjaxPage.kt
src/test/kotlin/net/pterodactylus/sone/web/ajax/JsonPageBaseTest.kt
src/test/kotlin/net/pterodactylus/sone/web/ajax/LoggedInJsonPageTest.kt

index 74fec61..e9a1a50 100644 (file)
@@ -3,13 +3,14 @@ package net.pterodactylus.sone.web.ajax
 import net.pterodactylus.sone.utils.emptyToNull
 import net.pterodactylus.sone.utils.parameters
 import net.pterodactylus.sone.web.WebInterface
 import net.pterodactylus.sone.utils.emptyToNull
 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 javax.inject.Inject
 
 /**
  * AJAX page that lets the user bookmark a post.
  */
 import javax.inject.Inject
 
 /**
  * AJAX page that lets the user bookmark a post.
  */
-class BookmarkAjaxPage @Inject constructor(webInterface: WebInterface) : JsonPage("bookmark.ajax", webInterface) {
+@ToadletPath("bookmark.ajax")
+class BookmarkAjaxPage @Inject constructor(webInterface: WebInterface) : JsonPage(webInterface) {
 
        override val requiresLogin = false
 
 
        override val requiresLogin = false
 
index 00bc6c2..79e66ad 100644 (file)
@@ -10,7 +10,8 @@ import javax.inject.*
 /**
  * AJAX handler that creates a new post.
  */
 /**
  * AJAX handler that creates a new post.
  */
-class CreatePostAjaxPage @Inject constructor(webInterface: WebInterface) : LoggedInJsonPage("createPost.ajax", webInterface) {
+@ToadletPath("createPost.ajax")
+class CreatePostAjaxPage @Inject constructor(webInterface: WebInterface) : LoggedInJsonPage(webInterface) {
 
        override fun createJsonObject(currentSone: Sone, request: FreenetRequest) =
                        request.parameters["text"].emptyToNull
 
        override fun createJsonObject(currentSone: Sone, request: FreenetRequest) =
                        request.parameters["text"].emptyToNull
index 7cb9752..df86dc0 100644 (file)
@@ -10,7 +10,8 @@ import javax.inject.*
 /**
  * This AJAX page create a reply.
  */
 /**
  * This AJAX page create a reply.
  */
-class CreateReplyAjaxPage @Inject constructor(webInterface: WebInterface) : LoggedInJsonPage("createReply.ajax", webInterface) {
+@ToadletPath("createReply.ajax")
+class CreateReplyAjaxPage @Inject constructor(webInterface: WebInterface) : LoggedInJsonPage(webInterface) {
 
        override fun createJsonObject(currentSone: Sone, request: FreenetRequest): JsonReturnObject =
                        request.parameters["post"].emptyToNull
 
        override fun createJsonObject(currentSone: Sone, request: FreenetRequest): JsonReturnObject =
                        request.parameters["post"].emptyToNull
index 4696cc5..3dca438 100644 (file)
@@ -9,7 +9,8 @@ import javax.inject.*
 /**
  * This AJAX page deletes a post.
  */
 /**
  * This AJAX page deletes a post.
  */
-class DeletePostAjaxPage @Inject constructor(webInterface: WebInterface) : LoggedInJsonPage("deletePost.ajax", webInterface) {
+@ToadletPath("deletePost.ajax")
+class DeletePostAjaxPage @Inject constructor(webInterface: WebInterface) : LoggedInJsonPage(webInterface) {
 
        override fun createJsonObject(currentSone: Sone, request: FreenetRequest) =
                        request.parameters["post"]
 
        override fun createJsonObject(currentSone: Sone, request: FreenetRequest) =
                        request.parameters["post"]
index 0697320..6daa4da 100644 (file)
@@ -3,14 +3,14 @@ package net.pterodactylus.sone.web.ajax
 import net.pterodactylus.sone.data.Sone
 import net.pterodactylus.sone.utils.parameters
 import net.pterodactylus.sone.web.WebInterface
 import net.pterodactylus.sone.data.Sone
 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 javax.inject.Inject
 
 /**
  * AJAX page that lets the user delete a profile field.
  */
 import javax.inject.Inject
 
 /**
  * AJAX page that lets the user delete a profile field.
  */
-class DeleteProfileFieldAjaxPage @Inject constructor(webInterface: WebInterface) :
-               LoggedInJsonPage("deleteProfileField.ajax", webInterface) {
+@ToadletPath("deleteProfileField.ajax")
+class DeleteProfileFieldAjaxPage @Inject constructor(webInterface: WebInterface) : LoggedInJsonPage(webInterface) {
 
        override fun createJsonObject(currentSone: Sone, request: FreenetRequest) =
                        currentSone.profile.let { profile ->
 
        override fun createJsonObject(currentSone: Sone, request: FreenetRequest) =
                        currentSone.profile.let { profile ->
index a7ef1a1..b558356 100644 (file)
@@ -9,8 +9,8 @@ import javax.inject.*
 /**
  * This AJAX page deletes a reply.
  */
 /**
  * This AJAX page deletes a reply.
  */
-class DeleteReplyAjaxPage @Inject constructor(webInterface: WebInterface) :
-               LoggedInJsonPage("deleteReply.ajax", webInterface) {
+@ToadletPath("deleteReply.ajax")
+class DeleteReplyAjaxPage @Inject constructor(webInterface: WebInterface) : LoggedInJsonPage(webInterface) {
 
        override fun createJsonObject(currentSone: Sone, request: FreenetRequest) =
                        request.parameters["reply"]
 
        override fun createJsonObject(currentSone: Sone, request: FreenetRequest) =
                        request.parameters["reply"]
index d755060..06fe51b 100644 (file)
@@ -4,14 +4,14 @@ import net.pterodactylus.sone.utils.ifTrue
 import net.pterodactylus.sone.utils.let
 import net.pterodactylus.sone.utils.parameters
 import net.pterodactylus.sone.web.WebInterface
 import net.pterodactylus.sone.utils.let
 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 javax.inject.Inject
 
 /**
  * AJAX page that lets the user dismiss a notification.
  */
 import javax.inject.Inject
 
 /**
  * AJAX page that lets the user dismiss a notification.
  */
-class DismissNotificationAjaxPage @Inject constructor(webInterface: WebInterface) :
-               JsonPage("dismissNotification.ajax", webInterface) {
+@ToadletPath("dismissNotification.ajax")
+class DismissNotificationAjaxPage @Inject constructor(webInterface: WebInterface) : JsonPage(webInterface) {
 
        override val requiresLogin = false
 
 
        override val requiresLogin = false
 
index e4f2327..cbeed6e 100644 (file)
@@ -12,8 +12,8 @@ import javax.inject.*
  *
  * @see Core.distrustSone(Sone, Sone)
  */
  *
  * @see Core.distrustSone(Sone, Sone)
  */
-class DistrustAjaxPage @Inject constructor(webInterface: WebInterface) :
-               LoggedInJsonPage("distrustSone.ajax", webInterface) {
+@ToadletPath("distrustSone.ajax")
+class DistrustAjaxPage @Inject constructor(webInterface: WebInterface) : LoggedInJsonPage(webInterface) {
 
        override fun createJsonObject(currentSone: Sone, request: FreenetRequest) =
                        request.parameters["sone"]
 
        override fun createJsonObject(currentSone: Sone, request: FreenetRequest) =
                        request.parameters["sone"]
index 9cb3acf..39442f0 100644 (file)
@@ -5,13 +5,14 @@ import net.pterodactylus.sone.utils.headers
 import net.pterodactylus.sone.utils.ifTrue
 import net.pterodactylus.sone.utils.parameters
 import net.pterodactylus.sone.web.WebInterface
 import net.pterodactylus.sone.utils.ifTrue
 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 javax.inject.Inject
 
 /**
  * Page that stores a user’s album modifications.
  */
 import javax.inject.Inject
 
 /**
  * Page that stores a user’s album modifications.
  */
-class EditAlbumAjaxPage @Inject constructor(webInterface: WebInterface) : JsonPage("editAlbum.ajax", webInterface) {
+@ToadletPath("editAlbum.ajax")
+class EditAlbumAjaxPage @Inject constructor(webInterface: WebInterface) : JsonPage(webInterface) {
 
        override fun createJsonObject(request: FreenetRequest) =
                        request.parameters["album"]!!
 
        override fun createJsonObject(request: FreenetRequest) =
                        request.parameters["album"]!!
index b0ce048..7012cdc 100644 (file)
@@ -8,17 +8,18 @@ import net.pterodactylus.sone.utils.headers
 import net.pterodactylus.sone.utils.ifTrue
 import net.pterodactylus.sone.utils.parameters
 import net.pterodactylus.sone.web.WebInterface
 import net.pterodactylus.sone.utils.ifTrue
 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.TemplateContext
 import javax.inject.Inject
 
 /**
  * Page that stores a user’s image modifications.
  */
 import net.pterodactylus.util.template.TemplateContext
 import javax.inject.Inject
 
 /**
  * Page that stores a user’s image modifications.
  */
+@ToadletPath("editImage.ajax")
 class EditImageAjaxPage @Inject constructor(webInterface: WebInterface,
                private val parserFilter: ParserFilter,
                private val shortenFilter: ShortenFilter,
 class EditImageAjaxPage @Inject constructor(webInterface: WebInterface,
                private val parserFilter: ParserFilter,
                private val shortenFilter: ShortenFilter,
-               private val renderFilter: RenderFilter) : JsonPage("editImage.ajax", webInterface) {
+               private val renderFilter: RenderFilter) : JsonPage(webInterface) {
 
        override fun createJsonObject(request: FreenetRequest) =
                        request.parameters["image"]
 
        override fun createJsonObject(request: FreenetRequest) =
                        request.parameters["image"]
index 7e7581d..9d5346c 100644 (file)
@@ -4,14 +4,14 @@ import net.pterodactylus.sone.data.Sone
 import net.pterodactylus.sone.utils.ifFalse
 import net.pterodactylus.sone.utils.parameters
 import net.pterodactylus.sone.web.WebInterface
 import net.pterodactylus.sone.utils.ifFalse
 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 javax.inject.Inject
 
 /**
  * AJAX page that lets the user rename a profile field.
  */
 import javax.inject.Inject
 
 /**
  * AJAX page that lets the user rename a profile field.
  */
-class EditProfileFieldAjaxPage @Inject constructor(webInterface: WebInterface) :
-               LoggedInJsonPage("editProfileField.ajax", webInterface) {
+@ToadletPath("editProfileField.ajax")
+class EditProfileFieldAjaxPage @Inject constructor(webInterface: WebInterface) : LoggedInJsonPage(webInterface) {
 
        override fun createJsonObject(currentSone: Sone, request: FreenetRequest) =
                        currentSone.profile.let { profile ->
 
        override fun createJsonObject(currentSone: Sone, request: FreenetRequest) =
                        currentSone.profile.let { profile ->
index 32591b5..eea5120 100644 (file)
@@ -3,14 +3,14 @@ package net.pterodactylus.sone.web.ajax
 import net.pterodactylus.sone.data.Sone
 import net.pterodactylus.sone.utils.parameters
 import net.pterodactylus.sone.web.WebInterface
 import net.pterodactylus.sone.data.Sone
 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 javax.inject.Inject
 
 /**
  * AJAX page that lets a Sone follow another Sone.
  */
 import javax.inject.Inject
 
 /**
  * AJAX page that lets a Sone follow another Sone.
  */
-class FollowSoneAjaxPage @Inject constructor(webInterface: WebInterface) :
-               LoggedInJsonPage("followSone.ajax", webInterface) {
+@ToadletPath("followSone.ajax")
+class FollowSoneAjaxPage @Inject constructor(webInterface: WebInterface) : LoggedInJsonPage(webInterface) {
 
        override fun createJsonObject(currentSone: Sone, request: FreenetRequest) =
                        request.parameters["sone"]
 
        override fun createJsonObject(currentSone: Sone, request: FreenetRequest) =
                        request.parameters["sone"]
index f0b0012..1175b2b 100644 (file)
@@ -6,15 +6,15 @@ import net.pterodactylus.sone.utils.jsonArray
 import net.pterodactylus.sone.utils.jsonObject
 import net.pterodactylus.sone.utils.parameters
 import net.pterodactylus.sone.web.WebInterface
 import net.pterodactylus.sone.utils.jsonObject
 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 javax.inject.Inject
 
 /**
  * AJAX page that retrieves the number of “likes” a [net.pterodactylus.sone.data.Post]
  * or [net.pterodactylus.sone.data.PostReply] has.
  */
 import javax.inject.Inject
 
 /**
  * AJAX page that retrieves the number of “likes” a [net.pterodactylus.sone.data.Post]
  * or [net.pterodactylus.sone.data.PostReply] has.
  */
-class GetLikesAjaxPage @Inject constructor(webInterface: WebInterface) :
-               JsonPage("getLikes.ajax", webInterface) {
+@ToadletPath("getLikes.ajax")
+class GetLikesAjaxPage @Inject constructor(webInterface: WebInterface) : JsonPage(webInterface) {
 
        override val needsFormPassword = false
 
 
        override val needsFormPassword = false
 
index 760c1de..115370a 100644 (file)
@@ -8,14 +8,15 @@ import net.pterodactylus.sone.template.LinkedElementRenderFilter
 import net.pterodactylus.sone.utils.jsonArray
 import net.pterodactylus.sone.utils.jsonObject
 import net.pterodactylus.sone.web.WebInterface
 import net.pterodactylus.sone.utils.jsonArray
 import net.pterodactylus.sone.utils.jsonObject
 import net.pterodactylus.sone.web.WebInterface
-import net.pterodactylus.sone.web.page.FreenetRequest
+import net.pterodactylus.sone.web.page.*
 import javax.inject.Inject
 
 /**
  * Renders linked elements after they have been loaded.
  */
 import javax.inject.Inject
 
 /**
  * Renders linked elements after they have been loaded.
  */
+@ToadletPath("getLinkedElement.ajax")
 class GetLinkedElementAjaxPage @Inject constructor(webInterface: WebInterface, private val elementLoader: ElementLoader, private val linkedElementRenderFilter: LinkedElementRenderFilter):
 class GetLinkedElementAjaxPage @Inject constructor(webInterface: WebInterface, private val elementLoader: ElementLoader, private val linkedElementRenderFilter: LinkedElementRenderFilter):
-               JsonPage("getLinkedElement.ajax", webInterface) {
+               JsonPage(webInterface) {
 
        override val needsFormPassword = false
        override val requiresLogin = false
 
        override val needsFormPassword = false
        override val requiresLogin = false
index f3b370d..db6e5c5 100644 (file)
@@ -6,7 +6,7 @@ import net.pterodactylus.sone.main.SonePlugin
 import net.pterodactylus.sone.utils.jsonArray
 import net.pterodactylus.sone.utils.jsonObject
 import net.pterodactylus.sone.web.WebInterface
 import net.pterodactylus.sone.utils.jsonArray
 import net.pterodactylus.sone.utils.jsonObject
 import net.pterodactylus.sone.web.WebInterface
-import net.pterodactylus.sone.web.page.FreenetRequest
+import net.pterodactylus.sone.web.page.*
 import net.pterodactylus.util.notify.Notification
 import net.pterodactylus.util.notify.TemplateNotification
 import java.io.StringWriter
 import net.pterodactylus.util.notify.Notification
 import net.pterodactylus.util.notify.TemplateNotification
 import java.io.StringWriter
@@ -15,8 +15,8 @@ import javax.inject.Inject
 /**
  * AJAX handler to return all current notifications.
  */
 /**
  * AJAX handler to return all current notifications.
  */
-class GetNotificationsAjaxPage @Inject constructor(webInterface: WebInterface) :
-               JsonPage("getNotifications.ajax", webInterface) {
+@ToadletPath("getNotifications.ajax")
+class GetNotificationsAjaxPage @Inject constructor(webInterface: WebInterface) : JsonPage(webInterface) {
 
        override val needsFormPassword = false
        override val requiresLogin = false
 
        override val needsFormPassword = false
        override val requiresLogin = false
index 7f1ce6e..1aedd49 100644 (file)
@@ -6,15 +6,15 @@ import net.pterodactylus.sone.utils.jsonObject
 import net.pterodactylus.sone.utils.parameters
 import net.pterodactylus.sone.utils.render
 import net.pterodactylus.sone.web.WebInterface
 import net.pterodactylus.sone.utils.parameters
 import net.pterodactylus.sone.utils.render
 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 javax.inject.Inject
 
 /**
  * This AJAX handler retrieves information and rendered representation of a [Post].
  */
 import net.pterodactylus.util.template.Template
 import javax.inject.Inject
 
 /**
  * This AJAX handler retrieves information and rendered representation of a [Post].
  */
-class GetPostAjaxPage @Inject constructor(webInterface: WebInterface, private val postTemplate: Template) :
-               LoggedInJsonPage("getPost.ajax", webInterface) {
+@ToadletPath("getPost.ajax")
+class GetPostAjaxPage @Inject constructor(webInterface: WebInterface, private val postTemplate: Template) : LoggedInJsonPage(webInterface) {
 
        override val needsFormPassword = false
 
 
        override val needsFormPassword = false
 
index 119a622..ec5a5ac 100644 (file)
@@ -6,15 +6,15 @@ import net.pterodactylus.sone.utils.jsonObject
 import net.pterodactylus.sone.utils.parameters
 import net.pterodactylus.sone.utils.render
 import net.pterodactylus.sone.web.WebInterface
 import net.pterodactylus.sone.utils.parameters
 import net.pterodactylus.sone.utils.render
 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 javax.inject.Inject
 
 /**
  * This AJAX page returns the details of a reply.
  */
 import net.pterodactylus.util.template.Template
 import javax.inject.Inject
 
 /**
  * This AJAX page returns the details of a reply.
  */
-class GetReplyAjaxPage @Inject constructor(webInterface: WebInterface, private val template: Template) :
-               LoggedInJsonPage("getReply.ajax", webInterface) {
+@ToadletPath("getReply.ajax")
+class GetReplyAjaxPage @Inject constructor(webInterface: WebInterface, private val template: Template) : LoggedInJsonPage(webInterface) {
 
        override val needsFormPassword = false
 
 
        override val needsFormPassword = false
 
index 0017a32..75f3c3c 100644 (file)
@@ -14,7 +14,7 @@ import net.pterodactylus.sone.text.TimeTextConverter
 import net.pterodactylus.sone.utils.jsonObject
 import net.pterodactylus.sone.utils.toArray
 import net.pterodactylus.sone.web.WebInterface
 import net.pterodactylus.sone.utils.jsonObject
 import net.pterodactylus.sone.utils.toArray
 import net.pterodactylus.sone.web.WebInterface
-import net.pterodactylus.sone.web.page.FreenetRequest
+import net.pterodactylus.sone.web.page.*
 import java.text.SimpleDateFormat
 import java.util.TimeZone
 import javax.inject.Inject
 import java.text.SimpleDateFormat
 import java.util.TimeZone
 import javax.inject.Inject
@@ -23,8 +23,9 @@ import javax.inject.Inject
  * The “get status” AJAX handler returns all information that is necessary to
  * update the web interface in real-time.
  */
  * The “get status” AJAX handler returns all information that is necessary to
  * update the web interface in real-time.
  */
+@ToadletPath("getStatus.ajax")
 class GetStatusAjaxPage(webInterface: WebInterface, private val elementLoader: ElementLoader, private val timeTextConverter: TimeTextConverter, private val l10nFilter: L10nFilter, timeZone: TimeZone):
 class GetStatusAjaxPage(webInterface: WebInterface, private val elementLoader: ElementLoader, private val timeTextConverter: TimeTextConverter, private val l10nFilter: L10nFilter, timeZone: TimeZone):
-               JsonPage("getStatus.ajax", webInterface) {
+               JsonPage(webInterface) {
 
        @Inject constructor(webInterface: WebInterface, elementLoader: ElementLoader, timeTextConverter: TimeTextConverter, l10nFilter: L10nFilter):
                        this(webInterface, elementLoader, timeTextConverter, l10nFilter, TimeZone.getDefault())
 
        @Inject constructor(webInterface: WebInterface, elementLoader: ElementLoader, timeTextConverter: TimeTextConverter, l10nFilter: L10nFilter):
                        this(webInterface, elementLoader, timeTextConverter, l10nFilter, TimeZone.getDefault())
index 233cf75..ef4a0db 100644 (file)
@@ -5,7 +5,7 @@ import net.pterodactylus.sone.text.TimeTextConverter
 import net.pterodactylus.sone.utils.jsonObject
 import net.pterodactylus.sone.utils.parameters
 import net.pterodactylus.sone.web.WebInterface
 import net.pterodactylus.sone.utils.jsonObject
 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 java.text.SimpleDateFormat
 import java.util.TimeZone
 import javax.inject.Inject
 import java.text.SimpleDateFormat
 import java.util.TimeZone
 import javax.inject.Inject
@@ -13,10 +13,11 @@ import javax.inject.Inject
 /**
  * Ajax page that returns a formatted, relative timestamp for replies or posts.
  */
 /**
  * Ajax page that returns a formatted, relative timestamp for replies or posts.
  */
+@ToadletPath("getTimes.ajax")
 class GetTimesAjaxPage @Inject constructor(webInterface: WebInterface,
                private val timeTextConverter: TimeTextConverter,
                private val l10nFilter: L10nFilter,
 class GetTimesAjaxPage @Inject constructor(webInterface: WebInterface,
                private val timeTextConverter: TimeTextConverter,
                private val l10nFilter: L10nFilter,
-               timeZone: TimeZone) : JsonPage("getTimes.ajax", webInterface) {
+               timeZone: TimeZone) : JsonPage(webInterface) {
 
        private val dateTimeFormatter = SimpleDateFormat("MMM d, yyyy, HH:mm:ss").apply {
                this.timeZone = timeZone
 
        private val dateTimeFormatter = SimpleDateFormat("MMM d, yyyy, HH:mm:ss").apply {
                this.timeZone = timeZone
index 99429e4..41188ea 100644 (file)
@@ -2,14 +2,14 @@ package net.pterodactylus.sone.web.ajax
 
 import net.pterodactylus.sone.utils.parameters
 import net.pterodactylus.sone.web.WebInterface
 
 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 javax.inject.Inject
 
 /**
  * Returns the translation for a given key as JSON object.
  */
 import javax.inject.Inject
 
 /**
  * Returns the translation for a given key as JSON object.
  */
-class GetTranslationAjaxPage @Inject constructor(webInterface: WebInterface) :
-               JsonPage("getTranslation.ajax", webInterface) {
+@ToadletPath("getTranslation.ajax")
+class GetTranslationAjaxPage @Inject constructor(webInterface: WebInterface) : JsonPage(webInterface) {
 
        override val needsFormPassword = false
        override val requiresLogin = false
 
        override val needsFormPassword = false
        override val requiresLogin = false
index 5b56031..99c0828 100644 (file)
@@ -5,7 +5,7 @@ import freenet.clients.http.ToadletContext
 import net.pterodactylus.sone.utils.parameters
 import net.pterodactylus.sone.web.SessionProvider
 import net.pterodactylus.sone.web.WebInterface
 import net.pterodactylus.sone.utils.parameters
 import net.pterodactylus.sone.web.SessionProvider
 import net.pterodactylus.sone.web.WebInterface
-import net.pterodactylus.sone.web.page.FreenetRequest
+import net.pterodactylus.sone.web.page.*
 import net.pterodactylus.util.web.Page
 import net.pterodactylus.util.web.Response
 import java.io.ByteArrayOutputStream
 import net.pterodactylus.util.web.Page
 import net.pterodactylus.util.web.Response
 import java.io.ByteArrayOutputStream
@@ -15,13 +15,13 @@ import java.io.PrintStream
  * A JSON page is a specialized [Page] that will always return a JSON
  * object to the browser, e.g. for use with AJAX or other scripting frameworks.
  */
  * A JSON page is a specialized [Page] that will always return a JSON
  * object to the browser, e.g. for use with AJAX or other scripting frameworks.
  */
-abstract class JsonPage(private val path: String, protected val webInterface: WebInterface) : Page<FreenetRequest> {
+abstract class JsonPage(protected val webInterface: WebInterface) : Page<FreenetRequest> {
 
        private val objectMapper = ObjectMapper()
        private val sessionProvider: SessionProvider = webInterface
        protected val core = webInterface.core
 
 
        private val objectMapper = ObjectMapper()
        private val sessionProvider: SessionProvider = webInterface
        protected val core = webInterface.core
 
-       override fun getPath() = path
+       override fun getPath() = toadletPath
        override fun isPrefixPage() = false
 
        open val needsFormPassword = true
        override fun isPrefixPage() = false
 
        open val needsFormPassword = true
index fe52c9d..b2993f4 100644 (file)
@@ -3,14 +3,14 @@ package net.pterodactylus.sone.web.ajax
 import net.pterodactylus.sone.data.Sone
 import net.pterodactylus.sone.utils.parameters
 import net.pterodactylus.sone.web.WebInterface
 import net.pterodactylus.sone.data.Sone
 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 javax.inject.Inject
 
 /**
  * AJAX page that lets the user like a [net.pterodactylus.sone.data.Post].
  */
 import javax.inject.Inject
 
 /**
  * AJAX page that lets the user like a [net.pterodactylus.sone.data.Post].
  */
-class LikeAjaxPage @Inject constructor(webInterface: WebInterface) :
-               LoggedInJsonPage("like.ajax", webInterface) {
+@ToadletPath("like.ajax")
+class LikeAjaxPage @Inject constructor(webInterface: WebInterface) : LoggedInJsonPage(webInterface) {
 
        override fun createJsonObject(currentSone: Sone, request: FreenetRequest) =
                        when (request.parameters["type"]) {
 
        override fun createJsonObject(currentSone: Sone, request: FreenetRequest) =
                        when (request.parameters["type"]) {
index c11dd0c..c177041 100644 (file)
@@ -2,14 +2,14 @@ package net.pterodactylus.sone.web.ajax
 
 import net.pterodactylus.sone.utils.parameters
 import net.pterodactylus.sone.web.WebInterface
 
 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 javax.inject.Inject
 
 /**
  * Lets the user [lock][net.pterodactylus.sone.core.Core.lockSone] a [Sone][net.pterodactylus.sone.data.Sone].
  */
 import javax.inject.Inject
 
 /**
  * Lets the user [lock][net.pterodactylus.sone.core.Core.lockSone] a [Sone][net.pterodactylus.sone.data.Sone].
  */
-class LockSoneAjaxPage @Inject constructor(webInterface: WebInterface) :
-               JsonPage("lockSone.ajax", webInterface) {
+@ToadletPath("lockSone.ajax")
+class LockSoneAjaxPage @Inject constructor(webInterface: WebInterface) : JsonPage(webInterface) {
 
        override val requiresLogin = false
 
 
        override val requiresLogin = false
 
index 388c289..d1afaec 100644 (file)
@@ -7,7 +7,7 @@ import net.pterodactylus.sone.web.page.FreenetRequest
 /**
  * Base JSON page for all pages that require the user to be logged in.
  */
 /**
  * Base JSON page for all pages that require the user to be logged in.
  */
-open class LoggedInJsonPage(path: String, webInterface: WebInterface) : JsonPage(path, webInterface) {
+open class LoggedInJsonPage(webInterface: WebInterface) : JsonPage(webInterface) {
 
        final override val requiresLogin = true
 
 
        final override val requiresLogin = true
 
index 4ab6d18..808d2fa 100644 (file)
@@ -2,15 +2,15 @@ package net.pterodactylus.sone.web.ajax
 
 import net.pterodactylus.sone.utils.parameters
 import net.pterodactylus.sone.web.WebInterface
 
 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 javax.inject.Inject
 
 /**
  * AJAX page that lets the user mark a number of [net.pterodactylus.sone.data.Sone]s,
  * [net.pterodactylus.sone.data.Post]s, or [net.pterodactylus.sone.data.Reply]s as known.
  */
 import javax.inject.Inject
 
 /**
  * AJAX page that lets the user mark a number of [net.pterodactylus.sone.data.Sone]s,
  * [net.pterodactylus.sone.data.Post]s, or [net.pterodactylus.sone.data.Reply]s as known.
  */
-class MarkAsKnownAjaxPage @Inject constructor(webInterface: WebInterface) :
-               JsonPage("markAsKnown.ajax", webInterface) {
+@ToadletPath("markAsKnown.ajax")
+class MarkAsKnownAjaxPage @Inject constructor(webInterface: WebInterface) : JsonPage(webInterface) {
 
        override val requiresLogin = false
 
 
        override val requiresLogin = false
 
index 6bc129b..0b2c5ab 100644 (file)
@@ -5,7 +5,7 @@ import net.pterodactylus.sone.data.Profile.Field
 import net.pterodactylus.sone.data.Sone
 import net.pterodactylus.sone.utils.parameters
 import net.pterodactylus.sone.web.WebInterface
 import net.pterodactylus.sone.data.Sone
 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 javax.inject.Inject
 
 /**
 import javax.inject.Inject
 
 /**
@@ -14,8 +14,8 @@ import javax.inject.Inject
  * @see net.pterodactylus.sone.data.Profile#moveFieldUp(Field)
  * @see net.pterodactylus.sone.data.Profile#moveFieldDown(Field)
  */
  * @see net.pterodactylus.sone.data.Profile#moveFieldUp(Field)
  * @see net.pterodactylus.sone.data.Profile#moveFieldDown(Field)
  */
-class MoveProfileFieldAjaxPage @Inject constructor(webInterface: WebInterface) :
-               LoggedInJsonPage("moveProfileField.ajax", webInterface) {
+@ToadletPath("moveProfileField.ajax")
+class MoveProfileFieldAjaxPage @Inject constructor(webInterface: WebInterface) : LoggedInJsonPage(webInterface) {
 
        override fun createJsonObject(currentSone: Sone, request: FreenetRequest) =
                        currentSone.profile.let { profile ->
 
        override fun createJsonObject(currentSone: Sone, request: FreenetRequest) =
                        currentSone.profile.let { profile ->
index bfb88b7..9f0de87 100644 (file)
@@ -11,8 +11,8 @@ import javax.inject.*
  *
  * @see net.pterodactylus.sone.core.Core.trustSone
  */
  *
  * @see net.pterodactylus.sone.core.Core.trustSone
  */
-class TrustAjaxPage @Inject constructor(webInterface: WebInterface) :
-               LoggedInJsonPage("trustSone.ajax", webInterface) {
+@ToadletPath("trustSone.ajax")
+class TrustAjaxPage @Inject constructor(webInterface: WebInterface) : LoggedInJsonPage(webInterface) {
 
        override fun createJsonObject(currentSone: Sone, request: FreenetRequest) =
                        request.parameters["sone"]
 
        override fun createJsonObject(currentSone: Sone, request: FreenetRequest) =
                        request.parameters["sone"]
index bfab41c..bc61b21 100644 (file)
@@ -2,14 +2,14 @@ package net.pterodactylus.sone.web.ajax
 
 import net.pterodactylus.sone.utils.parameters
 import net.pterodactylus.sone.web.WebInterface
 
 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 javax.inject.Inject
 
 /**
  * AJAX page that lets the user unbookmark a post.
  */
 import javax.inject.Inject
 
 /**
  * AJAX page that lets the user unbookmark a post.
  */
-class UnbookmarkAjaxPage @Inject constructor(webInterface: WebInterface) :
-               JsonPage("unbookmark.ajax", webInterface) {
+@ToadletPath("unbookmark.ajax")
+class UnbookmarkAjaxPage @Inject constructor(webInterface: WebInterface) : JsonPage(webInterface) {
 
        override val requiresLogin = false
 
 
        override val requiresLogin = false
 
index b1bca19..d8b8290 100644 (file)
@@ -3,14 +3,14 @@ package net.pterodactylus.sone.web.ajax
 import net.pterodactylus.sone.data.Sone
 import net.pterodactylus.sone.utils.parameters
 import net.pterodactylus.sone.web.WebInterface
 import net.pterodactylus.sone.data.Sone
 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 javax.inject.Inject
 
 /**
  * AJAX page that lets a Sone unfollow another Sone.
  */
 import javax.inject.Inject
 
 /**
  * AJAX page that lets a Sone unfollow another Sone.
  */
-class UnfollowSoneAjaxPage @Inject constructor(webInterface: WebInterface) :
-               LoggedInJsonPage("unfollowSone.ajax", webInterface) {
+@ToadletPath("unfollowSone.ajax")
+class UnfollowSoneAjaxPage @Inject constructor(webInterface: WebInterface) : LoggedInJsonPage(webInterface) {
 
        override fun createJsonObject(currentSone: Sone, request: FreenetRequest) =
                        request.parameters["sone"]
 
        override fun createJsonObject(currentSone: Sone, request: FreenetRequest) =
                        request.parameters["sone"]
index e2277c9..a8da594 100644 (file)
@@ -4,14 +4,14 @@ import net.pterodactylus.sone.data.Sone
 import net.pterodactylus.sone.utils.emptyToNull
 import net.pterodactylus.sone.utils.parameters
 import net.pterodactylus.sone.web.WebInterface
 import net.pterodactylus.sone.utils.emptyToNull
 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 javax.inject.Inject
 
 /**
  * AJAX page that lets the user unlike a [net.pterodactylus.sone.data.Post].
  */
 import javax.inject.Inject
 
 /**
  * AJAX page that lets the user unlike a [net.pterodactylus.sone.data.Post].
  */
-class UnlikeAjaxPage @Inject constructor(webInterface: WebInterface) :
-               LoggedInJsonPage("unlike.ajax", webInterface) {
+@ToadletPath("unlike.ajax")
+class UnlikeAjaxPage @Inject constructor(webInterface: WebInterface) : LoggedInJsonPage(webInterface) {
 
        override fun createJsonObject(currentSone: Sone, request: FreenetRequest) = when (request.parameters["type"]) {
                "post" -> request.processEntity("post", currentSone::removeLikedPostId)
 
        override fun createJsonObject(currentSone: Sone, request: FreenetRequest) = when (request.parameters["type"]) {
                "post" -> request.processEntity("post", currentSone::removeLikedPostId)
index efa70f1..130d102 100644 (file)
@@ -2,14 +2,14 @@ package net.pterodactylus.sone.web.ajax
 
 import net.pterodactylus.sone.utils.parameters
 import net.pterodactylus.sone.web.WebInterface
 
 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 javax.inject.Inject
 
 /**
  * Lets the user [unlock][net.pterodactylus.sone.core.Core.unlockSone] a [Sone][net.pterodactylus.sone.data.Sone].
  */
 import javax.inject.Inject
 
 /**
  * Lets the user [unlock][net.pterodactylus.sone.core.Core.unlockSone] a [Sone][net.pterodactylus.sone.data.Sone].
  */
-class UnlockSoneAjaxPage @Inject constructor(webInterface: WebInterface) :
-               JsonPage("unlockSone.ajax", webInterface) {
+@ToadletPath("unlockSone.ajax")
+class UnlockSoneAjaxPage @Inject constructor(webInterface: WebInterface) : JsonPage(webInterface) {
 
        override val requiresLogin = false
 
 
        override val requiresLogin = false
 
index 95dca17..e4b5edb 100644 (file)
@@ -3,14 +3,14 @@ package net.pterodactylus.sone.web.ajax
 import net.pterodactylus.sone.data.Sone
 import net.pterodactylus.sone.utils.parameters
 import net.pterodactylus.sone.web.WebInterface
 import net.pterodactylus.sone.data.Sone
 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 javax.inject.Inject
 
 /**
  * AJAX page that lets the user [untrust][net.pterodactylus.sone.core.Core.untrustSone] a [Sone].
  */
 import javax.inject.Inject
 
 /**
  * AJAX page that lets the user [untrust][net.pterodactylus.sone.core.Core.untrustSone] a [Sone].
  */
-class UntrustAjaxPage @Inject constructor(webInterface: WebInterface) :
-               LoggedInJsonPage("untrustSone.ajax", webInterface) {
+@ToadletPath("untrustSone.ajax")
+class UntrustAjaxPage @Inject constructor(webInterface: WebInterface) : LoggedInJsonPage(webInterface) {
 
        override fun createJsonObject(currentSone: Sone, request: FreenetRequest) =
                        request.parameters["sone"]
 
        override fun createJsonObject(currentSone: Sone, request: FreenetRequest) =
                        request.parameters["sone"]
index 5e32a7d..f9554f3 100644 (file)
@@ -23,7 +23,7 @@ class JsonPageBaseTest : TestObjects() {
        private val outputStream = ByteArrayOutputStream()
        private val response = Response(outputStream)
 
        private val outputStream = ByteArrayOutputStream()
        private val response = Response(outputStream)
 
-       private val page = object : JsonPage("path.html", webInterface) {
+       private val page = object : JsonPage(webInterface) {
 
                override val needsFormPassword get() = this@JsonPageBaseTest.needsFormPassword
 
 
                override val needsFormPassword get() = this@JsonPageBaseTest.needsFormPassword
 
index 9578d45..edc8c25 100644 (file)
@@ -1,6 +1,12 @@
 package net.pterodactylus.sone.web.ajax
 
 package net.pterodactylus.sone.web.ajax
 
+import net.pterodactylus.sone.web.*
+import net.pterodactylus.sone.web.page.*
+
 /**
  * Unit test for [LoggedInJsonPageTest].
  */
 /**
  * Unit test for [LoggedInJsonPageTest].
  */
-class LoggedInJsonPageTest : JsonPageTest("path", requiresLogin = true, pageSupplier = { webInterface -> LoggedInJsonPage("path", webInterface) })
+class LoggedInJsonPageTest : JsonPageTest("path", requiresLogin = true, pageSupplier = ::TestPage)
+
+@ToadletPath("path")
+class TestPage(webInterface: WebInterface) : LoggedInJsonPage(webInterface)