* Register all toadlets.
*/
private void registerToadlets() {
- Template emptyTemplate = parse(new StringReader(""));
- Template loginTemplate = loaders.loadTemplate("/templates/login.html");
- Template indexTemplate = loaders.loadTemplate("/templates/index.html");
- Template newTemplate = loaders.loadTemplate("/templates/new.html");
- Template knownSonesTemplate = loaders.loadTemplate("/templates/knownSones.html");
- Template createSoneTemplate = loaders.loadTemplate("/templates/createSone.html");
- Template createPostTemplate = loaders.loadTemplate("/templates/createPost.html");
- Template createReplyTemplate = loaders.loadTemplate("/templates/createReply.html");
- Template bookmarksTemplate = loaders.loadTemplate("/templates/bookmarks.html");
- Template searchTemplate = loaders.loadTemplate("/templates/search.html");
- Template editProfileTemplate = loaders.loadTemplate("/templates/editProfile.html");
- Template editProfileFieldTemplate = loaders.loadTemplate("/templates/editProfileField.html");
- Template deleteProfileFieldTemplate = loaders.loadTemplate("/templates/deleteProfileField.html");
- Template viewSoneTemplate = loaders.loadTemplate("/templates/viewSone.html");
- Template viewPostTemplate = loaders.loadTemplate("/templates/viewPost.html");
- Template deletePostTemplate = loaders.loadTemplate("/templates/deletePost.html");
- Template deleteReplyTemplate = loaders.loadTemplate("/templates/deleteReply.html");
- Template deleteSoneTemplate = loaders.loadTemplate("/templates/deleteSone.html");
- Template imageBrowserTemplate = loaders.loadTemplate("/templates/imageBrowser.html");
- Template createAlbumTemplate = loaders.loadTemplate("/templates/createAlbum.html");
- Template deleteAlbumTemplate = loaders.loadTemplate("/templates/deleteAlbum.html");
- Template deleteImageTemplate = loaders.loadTemplate("/templates/deleteImage.html");
- Template optionsTemplate = loaders.loadTemplate("/templates/options.html");
- Template rescueTemplate = loaders.loadTemplate("/templates/rescue.html");
- Template aboutTemplate = loaders.loadTemplate("/templates/about.html");
- Template invalidTemplate = loaders.loadTemplate("/templates/invalid.html");
Template postTemplate = loaders.loadTemplate("/templates/include/viewPost.html");
Template replyTemplate = loaders.loadTemplate("/templates/include/viewReply.html");
Template openSearchTemplate = loaders.loadTemplate("/templates/xml/OpenSearch.xml");
pageToadletRegistry.addPage(new RedirectPage<FreenetRequest>("", "index.html"));
- pageToadletRegistry.addPage(new IndexPage(indexTemplate, this, loaders, templateRenderer, postVisibilityFilter));
- pageToadletRegistry.addPage(new NewPage(newTemplate, this, loaders, templateRenderer));
- pageToadletRegistry.addPage(new CreateSonePage(createSoneTemplate, this, loaders, templateRenderer));
- pageToadletRegistry.addPage(new KnownSonesPage(knownSonesTemplate, this, loaders, templateRenderer));
- pageToadletRegistry.addPage(new EditProfilePage(editProfileTemplate, this, loaders, templateRenderer));
- pageToadletRegistry.addPage(new EditProfileFieldPage(editProfileFieldTemplate, this, loaders, templateRenderer));
- pageToadletRegistry.addPage(new DeleteProfileFieldPage(deleteProfileFieldTemplate, this, loaders, templateRenderer));
- pageToadletRegistry.addPage(new CreatePostPage(createPostTemplate, this, loaders, templateRenderer));
- pageToadletRegistry.addPage(new CreateReplyPage(createReplyTemplate, this, loaders, templateRenderer));
- pageToadletRegistry.addPage(new ViewSonePage(viewSoneTemplate, this, loaders, templateRenderer));
- pageToadletRegistry.addPage(new ViewPostPage(viewPostTemplate, this, loaders, templateRenderer));
- pageToadletRegistry.addPage(new LikePage(emptyTemplate, this, loaders, templateRenderer));
- pageToadletRegistry.addPage(new UnlikePage(emptyTemplate, this, loaders, templateRenderer));
- pageToadletRegistry.addPage(new DeletePostPage(deletePostTemplate, this, loaders, templateRenderer));
- pageToadletRegistry.addPage(new DeleteReplyPage(deleteReplyTemplate, this, loaders, templateRenderer));
- pageToadletRegistry.addPage(new LockSonePage(emptyTemplate, this, loaders, templateRenderer));
- pageToadletRegistry.addPage(new UnlockSonePage(emptyTemplate, this, loaders, templateRenderer));
- pageToadletRegistry.addPage(new FollowSonePage(emptyTemplate, this, loaders, templateRenderer));
- pageToadletRegistry.addPage(new UnfollowSonePage(emptyTemplate, this, loaders, templateRenderer));
- pageToadletRegistry.addPage(new ImageBrowserPage(imageBrowserTemplate, this, loaders, templateRenderer));
- pageToadletRegistry.addPage(new CreateAlbumPage(createAlbumTemplate, this, loaders, templateRenderer));
- pageToadletRegistry.addPage(new EditAlbumPage(emptyTemplate, this, loaders, templateRenderer));
- pageToadletRegistry.addPage(new DeleteAlbumPage(deleteAlbumTemplate, this, loaders, templateRenderer));
- pageToadletRegistry.addPage(new UploadImagePage(invalidTemplate, this, loaders, templateRenderer));
- pageToadletRegistry.addPage(new EditImagePage(emptyTemplate, this, loaders, templateRenderer));
- pageToadletRegistry.addPage(new DeleteImagePage(deleteImageTemplate, this, loaders, templateRenderer));
- pageToadletRegistry.addPage(new TrustPage(emptyTemplate, this, loaders, templateRenderer));
- pageToadletRegistry.addPage(new DistrustPage(emptyTemplate, this, loaders, templateRenderer));
- pageToadletRegistry.addPage(new UntrustPage(emptyTemplate, this, loaders, templateRenderer));
- pageToadletRegistry.addPage(new MarkAsKnownPage(emptyTemplate, this, loaders, templateRenderer));
- pageToadletRegistry.addPage(new BookmarkPage(emptyTemplate, this, loaders, templateRenderer));
- pageToadletRegistry.addPage(new UnbookmarkPage(emptyTemplate, this, loaders, templateRenderer));
- pageToadletRegistry.addPage(new BookmarksPage(bookmarksTemplate, this, loaders, templateRenderer));
- pageToadletRegistry.addPage(new SearchPage(searchTemplate, this, loaders, templateRenderer));
- pageToadletRegistry.addPage(new DeleteSonePage(deleteSoneTemplate, this, loaders, templateRenderer));
- pageToadletRegistry.addPage(new LoginPage(loginTemplate, this, loaders, templateRenderer));
- pageToadletRegistry.addPage(new LogoutPage(emptyTemplate, this, loaders, templateRenderer));
- pageToadletRegistry.addPage(new OptionsPage(optionsTemplate, this, loaders, templateRenderer));
- pageToadletRegistry.addPage(new RescuePage(rescueTemplate, this, loaders, templateRenderer));
- pageToadletRegistry.addPage(new AboutPage(aboutTemplate, this, loaders, templateRenderer, new PluginVersion(SonePlugin.getPluginVersion()), new PluginYear(sonePlugin.getYear()), new PluginHomepage(sonePlugin.getHomepage())));
+ pageToadletRegistry.addPage(new IndexPage(this, loaders, templateRenderer, postVisibilityFilter));
+ pageToadletRegistry.addPage(new NewPage(this, loaders, templateRenderer));
+ pageToadletRegistry.addPage(new CreateSonePage(this, loaders, templateRenderer));
+ pageToadletRegistry.addPage(new KnownSonesPage(this, loaders, templateRenderer));
+ pageToadletRegistry.addPage(new EditProfilePage(this, loaders, templateRenderer));
+ pageToadletRegistry.addPage(new EditProfileFieldPage(this, loaders, templateRenderer));
+ pageToadletRegistry.addPage(new DeleteProfileFieldPage(this, loaders, templateRenderer));
+ pageToadletRegistry.addPage(new CreatePostPage(this, loaders, templateRenderer));
+ pageToadletRegistry.addPage(new CreateReplyPage(this, loaders, templateRenderer));
+ pageToadletRegistry.addPage(new ViewSonePage(this, loaders, templateRenderer));
+ pageToadletRegistry.addPage(new ViewPostPage(this, loaders, templateRenderer));
+ pageToadletRegistry.addPage(new LikePage(this, loaders, templateRenderer));
+ pageToadletRegistry.addPage(new UnlikePage(this, loaders, templateRenderer));
+ pageToadletRegistry.addPage(new DeletePostPage(this, loaders, templateRenderer));
+ pageToadletRegistry.addPage(new DeleteReplyPage(this, loaders, templateRenderer));
+ pageToadletRegistry.addPage(new LockSonePage(this, loaders, templateRenderer));
+ pageToadletRegistry.addPage(new UnlockSonePage(this, loaders, templateRenderer));
+ pageToadletRegistry.addPage(new FollowSonePage(this, loaders, templateRenderer));
+ pageToadletRegistry.addPage(new UnfollowSonePage(this, loaders, templateRenderer));
+ pageToadletRegistry.addPage(new ImageBrowserPage(this, loaders, templateRenderer));
+ pageToadletRegistry.addPage(new CreateAlbumPage(this, loaders, templateRenderer));
+ pageToadletRegistry.addPage(new EditAlbumPage(this, loaders, templateRenderer));
+ pageToadletRegistry.addPage(new DeleteAlbumPage(this, loaders, templateRenderer));
+ pageToadletRegistry.addPage(new UploadImagePage(this, loaders, templateRenderer));
+ pageToadletRegistry.addPage(new EditImagePage(this, loaders, templateRenderer));
+ pageToadletRegistry.addPage(new DeleteImagePage(this, loaders, templateRenderer));
+ pageToadletRegistry.addPage(new TrustPage(this, loaders, templateRenderer));
+ pageToadletRegistry.addPage(new DistrustPage(this, loaders, templateRenderer));
+ pageToadletRegistry.addPage(new UntrustPage(this, loaders, templateRenderer));
+ pageToadletRegistry.addPage(new MarkAsKnownPage(this, loaders, templateRenderer));
+ pageToadletRegistry.addPage(new BookmarkPage(this, loaders, templateRenderer));
+ pageToadletRegistry.addPage(new UnbookmarkPage(this, loaders, templateRenderer));
+ pageToadletRegistry.addPage(new BookmarksPage(this, loaders, templateRenderer));
+ pageToadletRegistry.addPage(new SearchPage(this, loaders, templateRenderer));
+ pageToadletRegistry.addPage(new DeleteSonePage(this, loaders, templateRenderer));
+ pageToadletRegistry.addPage(new LoginPage(this, loaders, templateRenderer));
+ pageToadletRegistry.addPage(new LogoutPage(this, loaders, templateRenderer));
+ pageToadletRegistry.addPage(new OptionsPage(this, loaders, templateRenderer));
+ pageToadletRegistry.addPage(new RescuePage(this, loaders, templateRenderer));
+ pageToadletRegistry.addPage(new AboutPage(this, loaders, templateRenderer, new PluginVersion(SonePlugin.getPluginVersion()), new PluginYear(sonePlugin.getYear()), new PluginHomepage(sonePlugin.getHomepage())));
pageToadletRegistry.addPage(new InvalidPage(this, loaders, templateRenderer));
pageToadletRegistry.addPage(new NoPermissionPage(this, loaders, templateRenderer));
pageToadletRegistry.addPage(new EmptyImageTitlePage(this, loaders, templateRenderer));
pageToadletRegistry.addPage(new EmptyAlbumTitlePage(this, loaders, templateRenderer));
- pageToadletRegistry.addPage(new DismissNotificationPage(emptyTemplate, this, loaders, templateRenderer));
+ pageToadletRegistry.addPage(new DismissNotificationPage(this, loaders, templateRenderer));
pageToadletRegistry.addPage(loaders.<FreenetRequest>loadStaticPage("css/", "/static/css/", "text/css"));
pageToadletRegistry.addPage(loaders.<FreenetRequest>loadStaticPage("javascript/", "/static/javascript/", "text/javascript"));
pageToadletRegistry.addPage(loaders.<FreenetRequest>loadStaticPage("images/", "/static/images/", "image/png"));
private val path: String,
private val templateRenderer: TemplateRenderer,
loaders: Loaders,
- template: Template,
private val invalidFormPasswordRedirectTarget: String
) : FreenetPage, LinkEnabledCallback {
override fun isEnabled(toadletContext: ToadletContext) = !isFullAccessOnly
- private val template = templatePath?.let(loaders::loadTemplate) ?: template
+ private val template = templatePath?.let(loaders::loadTemplate) ?: Template()
override fun handleRequest(request: FreenetRequest, response: Response): Response {
getRedirectTarget(request)?.let { redirectTarget -> return RedirectResponse(redirectTarget) }
import net.pterodactylus.sone.main.*
import net.pterodactylus.sone.web.WebInterface
import net.pterodactylus.sone.web.page.*
-import net.pterodactylus.util.template.Template
import net.pterodactylus.util.template.TemplateContext
import javax.inject.Inject
*/
@MenuName("About")
@TemplatePath("/templates/about.html")
-class AboutPage @Inject constructor(template: Template, webInterface: WebInterface, loaders: Loaders, templateRenderer: TemplateRenderer,
+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, template, templateRenderer, pageTitleKey = "Page.About.Title") {
+ private val pluginHomepage: PluginHomepage): SoneTemplatePage("about.html", webInterface, loaders, templateRenderer, pageTitleKey = "Page.About.Title") {
override fun handleRequest(freenetRequest: FreenetRequest, templateContext: TemplateContext) {
templateContext["version"] = pluginVersion.version
import net.pterodactylus.sone.utils.isPOST
import net.pterodactylus.sone.web.WebInterface
import net.pterodactylus.sone.web.page.*
-import net.pterodactylus.util.template.Template
import net.pterodactylus.util.template.TemplateContext
import javax.inject.Inject
/**
* Page that lets the user bookmark a post.
*/
-class BookmarkPage @Inject constructor(template: Template, webInterface: WebInterface, loaders: Loaders, templateRenderer: TemplateRenderer)
- : SoneTemplatePage("bookmark.html", webInterface, loaders, template, templateRenderer, pageTitleKey = "Page.Bookmark.Title") {
+class BookmarkPage @Inject constructor(webInterface: WebInterface, loaders: Loaders, templateRenderer: TemplateRenderer)
+ : SoneTemplatePage("bookmark.html", webInterface, loaders, templateRenderer, pageTitleKey = "Page.Bookmark.Title") {
override fun handleRequest(soneRequest: SoneRequest, templateContext: TemplateContext) {
if (soneRequest.isPOST) {
import net.pterodactylus.sone.utils.paginate
import net.pterodactylus.sone.web.WebInterface
import net.pterodactylus.sone.web.page.*
-import net.pterodactylus.util.template.Template
import net.pterodactylus.util.template.TemplateContext
import javax.inject.Inject
*/
@MenuName("Bookmarks")
@TemplatePath("/templates/bookmarks.html")
-class BookmarksPage @Inject constructor(template: Template, webInterface: WebInterface, loaders: Loaders, templateRenderer: TemplateRenderer) :
- SoneTemplatePage("bookmarks.html", webInterface, loaders, template, templateRenderer, pageTitleKey = "Page.Bookmarks.Title") {
+class BookmarksPage @Inject constructor(webInterface: WebInterface, loaders: Loaders, templateRenderer: TemplateRenderer) :
+ SoneTemplatePage("bookmarks.html", webInterface, loaders, templateRenderer, pageTitleKey = "Page.Bookmarks.Title") {
override fun handleRequest(soneRequest: SoneRequest, templateContext: TemplateContext) {
soneRequest.core.bookmarkedPosts.let { posts ->
import net.pterodactylus.sone.utils.isPOST
import net.pterodactylus.sone.web.WebInterface
import net.pterodactylus.sone.web.page.*
-import net.pterodactylus.util.template.Template
import net.pterodactylus.util.template.TemplateContext
import javax.inject.Inject
* Page that lets the user create a new album.
*/
@TemplatePath("/templates/createAlbum.html")
-class CreateAlbumPage @Inject constructor(template: Template, webInterface: WebInterface, loaders: Loaders, templateRenderer: TemplateRenderer):
- LoggedInPage("createAlbum.html", template, "Page.CreateAlbum.Title", webInterface, loaders, templateRenderer) {
+class CreateAlbumPage @Inject constructor(webInterface: WebInterface, loaders: Loaders, templateRenderer: TemplateRenderer):
+ LoggedInPage("createAlbum.html", "Page.CreateAlbum.Title", webInterface, loaders, templateRenderer) {
override fun handleRequest(soneRequest: SoneRequest, currentSone: Sone, templateContext: TemplateContext) {
if (soneRequest.isPOST) {
import net.pterodactylus.sone.utils.isPOST
import net.pterodactylus.sone.web.WebInterface
import net.pterodactylus.sone.web.page.*
-import net.pterodactylus.util.template.Template
import net.pterodactylus.util.template.TemplateContext
import javax.inject.Inject
* This page lets the user create a new [Post].
*/
@TemplatePath("/templates/createPost.html")
-class CreatePostPage @Inject constructor(template: Template, webInterface: WebInterface, loaders: Loaders, templateRenderer: TemplateRenderer):
- LoggedInPage("createPost.html", template, "Page.CreatePost.Title", webInterface, loaders, templateRenderer) {
+class CreatePostPage @Inject constructor(webInterface: WebInterface, loaders: Loaders, templateRenderer: TemplateRenderer):
+ LoggedInPage("createPost.html", "Page.CreatePost.Title", webInterface, loaders, templateRenderer) {
override fun handleRequest(soneRequest: SoneRequest, currentSone: Sone, templateContext: TemplateContext) {
val returnPage = soneRequest.httpRequest.getPartAsStringFailsafe("returnPage", 256)
import net.pterodactylus.sone.utils.isPOST
import net.pterodactylus.sone.web.WebInterface
import net.pterodactylus.sone.web.page.*
-import net.pterodactylus.util.template.Template
import net.pterodactylus.util.template.TemplateContext
import javax.inject.Inject
* This page lets the user post a reply to a post.
*/
@TemplatePath("/templates/createReply.html")
-class CreateReplyPage @Inject constructor(template: Template, webInterface: WebInterface, loaders: Loaders, templateRenderer: TemplateRenderer):
- LoggedInPage("createReply.html", template, "Page.CreateReply.Title", webInterface, loaders, templateRenderer) {
+class CreateReplyPage @Inject constructor(webInterface: WebInterface, loaders: Loaders, templateRenderer: TemplateRenderer):
+ LoggedInPage("createReply.html", "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 }
import net.pterodactylus.sone.utils.isPOST
import net.pterodactylus.sone.web.WebInterface
import net.pterodactylus.sone.web.page.*
-import net.pterodactylus.util.template.Template
import net.pterodactylus.util.template.TemplateContext
import java.util.logging.Level
import java.util.logging.Logger
*/
@MenuName("CreateSone")
@TemplatePath("/templates/createSone.html")
-class CreateSonePage @Inject constructor(template: Template, webInterface: WebInterface, loaders: Loaders, templateRenderer: TemplateRenderer):
- SoneTemplatePage("createSone.html", webInterface, loaders, template, templateRenderer, pageTitleKey = "Page.CreateSone.Title") {
+class CreateSonePage @Inject constructor(webInterface: WebInterface, loaders: Loaders, templateRenderer: TemplateRenderer):
+ SoneTemplatePage("createSone.html", webInterface, loaders, templateRenderer, pageTitleKey = "Page.CreateSone.Title") {
private val logger = Logger.getLogger(CreateSonePage::class.java.name)
import net.pterodactylus.sone.utils.isPOST
import net.pterodactylus.sone.web.WebInterface
import net.pterodactylus.sone.web.page.*
-import net.pterodactylus.util.template.Template
import net.pterodactylus.util.template.TemplateContext
import javax.inject.Inject
* Page that lets the user delete an {@link Album}.
*/
@TemplatePath("/templates/deleteAlbum.html")
-class DeleteAlbumPage @Inject constructor(template: Template, webInterface: WebInterface, loaders: Loaders, templateRenderer: TemplateRenderer):
- LoggedInPage("deleteAlbum.html", template, "Page.DeleteAlbum.Title", webInterface, loaders, templateRenderer) {
+class DeleteAlbumPage @Inject constructor(webInterface: WebInterface, loaders: Loaders, templateRenderer: TemplateRenderer):
+ LoggedInPage("deleteAlbum.html", "Page.DeleteAlbum.Title", webInterface, loaders, templateRenderer) {
override fun handleRequest(soneRequest: SoneRequest, currentSone: Sone, templateContext: TemplateContext) {
if (soneRequest.isPOST) {
import net.pterodactylus.sone.utils.isPOST
import net.pterodactylus.sone.web.WebInterface
import net.pterodactylus.sone.web.page.*
-import net.pterodactylus.util.template.Template
import net.pterodactylus.util.template.TemplateContext
import javax.inject.Inject
* Page that lets the user delete an {@link Image}.
*/
@TemplatePath("/templates/deleteImage.html")
-class DeleteImagePage @Inject constructor(template: Template, webInterface: WebInterface, loaders: Loaders, templateRenderer: TemplateRenderer):
- LoggedInPage("deleteImage.html", template, "Page.DeleteImage.Title", webInterface, loaders, templateRenderer) {
+class DeleteImagePage @Inject constructor(webInterface: WebInterface, loaders: Loaders, templateRenderer: TemplateRenderer):
+ LoggedInPage("deleteImage.html", "Page.DeleteImage.Title", webInterface, loaders, templateRenderer) {
override fun handleRequest(soneRequest: SoneRequest, currentSone: Sone, templateContext: TemplateContext) {
if (soneRequest.isPOST) {
import net.pterodactylus.sone.utils.isPOST
import net.pterodactylus.sone.web.WebInterface
import net.pterodactylus.sone.web.page.*
-import net.pterodactylus.util.template.Template
import net.pterodactylus.util.template.TemplateContext
import javax.inject.Inject
* Lets the user delete a post they made.
*/
@TemplatePath("/templates/deletePost.html")
-class DeletePostPage @Inject constructor(template: Template, webInterface: WebInterface, loaders: Loaders, templateRenderer: TemplateRenderer):
- LoggedInPage("deletePost.html", template, "Page.DeletePost.Title", webInterface, loaders, templateRenderer) {
+class DeletePostPage @Inject constructor(webInterface: WebInterface, loaders: Loaders, templateRenderer: TemplateRenderer):
+ LoggedInPage("deletePost.html", "Page.DeletePost.Title", webInterface, loaders, templateRenderer) {
override fun handleRequest(soneRequest: SoneRequest, currentSone: Sone, templateContext: TemplateContext) {
if (soneRequest.isPOST) {
import net.pterodactylus.sone.utils.isPOST
import net.pterodactylus.sone.web.WebInterface
import net.pterodactylus.sone.web.page.*
-import net.pterodactylus.util.template.Template
import net.pterodactylus.util.template.TemplateContext
import javax.inject.Inject
* Page that lets the user confirm the deletion of a profile field.
*/
@TemplatePath("/templates/deleteProfileField.html")
-class DeleteProfileFieldPage @Inject constructor(template: Template, webInterface: WebInterface, loaders: Loaders, templateRenderer: TemplateRenderer):
- LoggedInPage("deleteProfileField.html", template, "Page.DeleteProfileField.Title", webInterface, loaders, templateRenderer) {
+class DeleteProfileFieldPage @Inject constructor(webInterface: WebInterface, loaders: Loaders, templateRenderer: TemplateRenderer):
+ LoggedInPage("deleteProfileField.html", "Page.DeleteProfileField.Title", webInterface, loaders, templateRenderer) {
override fun handleRequest(soneRequest: SoneRequest, currentSone: Sone, templateContext: TemplateContext) {
if (soneRequest.isPOST) {
import net.pterodactylus.sone.utils.isPOST
import net.pterodactylus.sone.web.WebInterface
import net.pterodactylus.sone.web.page.*
-import net.pterodactylus.util.template.Template
import net.pterodactylus.util.template.TemplateContext
import javax.inject.Inject
* This page lets the user delete a reply.
*/
@TemplatePath("/templates/deleteReply.html")
-class DeleteReplyPage @Inject constructor(template: Template, webInterface: WebInterface, loaders: Loaders, templateRenderer: TemplateRenderer):
- LoggedInPage("deleteReply.html", template, "Page.DeleteReply.Title", webInterface, loaders, templateRenderer) {
+class DeleteReplyPage @Inject constructor(webInterface: WebInterface, loaders: Loaders, templateRenderer: TemplateRenderer):
+ LoggedInPage("deleteReply.html", "Page.DeleteReply.Title", webInterface, loaders, templateRenderer) {
override fun handleRequest(soneRequest: SoneRequest, currentSone: Sone, templateContext: TemplateContext) {
if (soneRequest.isPOST) {
import net.pterodactylus.sone.utils.isPOST
import net.pterodactylus.sone.web.WebInterface
import net.pterodactylus.sone.web.page.*
-import net.pterodactylus.util.template.Template
import net.pterodactylus.util.template.TemplateContext
import javax.inject.Inject
*/
@MenuName("DeleteSone")
@TemplatePath("/templates/deleteSone.html")
-class DeleteSonePage @Inject constructor(template: Template, webInterface: WebInterface, loaders: Loaders, templateRenderer: TemplateRenderer):
- LoggedInPage("deleteSone.html", template, "Page.DeleteSone.Title", webInterface, loaders, templateRenderer) {
+class DeleteSonePage @Inject constructor(webInterface: WebInterface, loaders: Loaders, templateRenderer: TemplateRenderer):
+ LoggedInPage("deleteSone.html", "Page.DeleteSone.Title", webInterface, loaders, templateRenderer) {
override fun handleRequest(soneRequest: SoneRequest, currentSone: Sone, templateContext: TemplateContext) {
if (soneRequest.isPOST) {
import net.pterodactylus.sone.main.*
import net.pterodactylus.sone.web.WebInterface
import net.pterodactylus.sone.web.page.*
-import net.pterodactylus.util.template.Template
import net.pterodactylus.util.template.TemplateContext
import javax.inject.Inject
/**
* Page that lets the user dismiss a notification.
*/
-class DismissNotificationPage @Inject constructor(template: Template, webInterface: WebInterface, loaders: Loaders, templateRenderer: TemplateRenderer):
- SoneTemplatePage("dismissNotification.html", webInterface, loaders, template, templateRenderer, pageTitleKey = "Page.DismissNotification.Title") {
+class DismissNotificationPage @Inject constructor(webInterface: WebInterface, loaders: Loaders, templateRenderer: TemplateRenderer):
+ SoneTemplatePage("dismissNotification.html", webInterface, loaders, templateRenderer, pageTitleKey = "Page.DismissNotification.Title") {
override fun handleRequest(soneRequest: SoneRequest, templateContext: TemplateContext) {
val returnPage = soneRequest.httpRequest.getPartAsStringFailsafe("returnPage", 256)
import net.pterodactylus.sone.utils.isPOST
import net.pterodactylus.sone.web.WebInterface
import net.pterodactylus.sone.web.page.*
-import net.pterodactylus.util.template.Template
import net.pterodactylus.util.template.TemplateContext
import javax.inject.Inject
*
* @see net.pterodactylus.sone.core.Core#distrustSone(Sone, Sone)
*/
-class DistrustPage @Inject constructor(template: Template, webInterface: WebInterface, loaders: Loaders, templateRenderer: TemplateRenderer):
- LoggedInPage("distrust.html", template, "Page.Distrust.Title", webInterface, loaders, templateRenderer) {
+class DistrustPage @Inject constructor(webInterface: WebInterface, loaders: Loaders, templateRenderer: TemplateRenderer):
+ LoggedInPage("distrust.html", "Page.Distrust.Title", webInterface, loaders, templateRenderer) {
override fun handleRequest(soneRequest: SoneRequest, currentSone: Sone, templateContext: TemplateContext) {
if (soneRequest.isPOST) {
import net.pterodactylus.sone.utils.isPOST
import net.pterodactylus.sone.web.WebInterface
import net.pterodactylus.sone.web.page.*
-import net.pterodactylus.util.template.Template
import net.pterodactylus.util.template.TemplateContext
import javax.inject.Inject
/**
* Page that lets the user edit the name and description of an album.
*/
-class EditAlbumPage @Inject constructor(template: Template, webInterface: WebInterface, loaders: Loaders, templateRenderer: TemplateRenderer):
- LoggedInPage("editAlbum.html", template, "Page.EditAlbum.Title", webInterface, loaders, templateRenderer) {
+class EditAlbumPage @Inject constructor(webInterface: WebInterface, loaders: Loaders, templateRenderer: TemplateRenderer):
+ LoggedInPage("editAlbum.html", "Page.EditAlbum.Title", webInterface, loaders, templateRenderer) {
override fun handleRequest(soneRequest: SoneRequest, currentSone: Sone, templateContext: TemplateContext) {
if (soneRequest.isPOST) {
import net.pterodactylus.sone.utils.isPOST
import net.pterodactylus.sone.web.WebInterface
import net.pterodactylus.sone.web.page.*
-import net.pterodactylus.util.template.Template
import net.pterodactylus.util.template.TemplateContext
import javax.inject.Inject
/**
* Page that lets the user edit title and description of an {@link Image}.
*/
-class EditImagePage @Inject constructor(template: Template, webInterface: WebInterface, loaders: Loaders, templateRenderer: TemplateRenderer):
- LoggedInPage("editImage.html", template, "Page.EditImage.Title", webInterface, loaders, templateRenderer) {
+class EditImagePage @Inject constructor(webInterface: WebInterface, loaders: Loaders, templateRenderer: TemplateRenderer):
+ LoggedInPage("editImage.html", "Page.EditImage.Title", webInterface, loaders, templateRenderer) {
override fun handleRequest(soneRequest: SoneRequest, currentSone: Sone, templateContext: TemplateContext) {
if (soneRequest.isPOST) {
import net.pterodactylus.sone.utils.isPOST
import net.pterodactylus.sone.web.WebInterface
import net.pterodactylus.sone.web.page.*
-import net.pterodactylus.util.template.Template
import net.pterodactylus.util.template.TemplateContext
import javax.inject.Inject
* Page that lets the user edit the name of a profile field.
*/
@TemplatePath("/templates/editProfileField.html")
-class EditProfileFieldPage @Inject constructor(template: Template, webInterface: WebInterface, loaders: Loaders, templateRenderer: TemplateRenderer) :
- LoggedInPage("editProfileField.html", template, "Page.EditProfileField.Title", webInterface, loaders, templateRenderer) {
+class EditProfileFieldPage @Inject constructor(webInterface: WebInterface, loaders: Loaders, templateRenderer: TemplateRenderer) :
+ LoggedInPage("editProfileField.html", "Page.EditProfileField.Title", webInterface, loaders, templateRenderer) {
override fun handleRequest(soneRequest: SoneRequest, currentSone: Sone, templateContext: TemplateContext) {
currentSone.profile.let { profile ->
import net.pterodactylus.sone.utils.isPOST
import net.pterodactylus.sone.web.WebInterface
import net.pterodactylus.sone.web.page.*
-import net.pterodactylus.util.template.Template
import net.pterodactylus.util.template.TemplateContext
import javax.inject.Inject
*/
@MenuName("EditProfile")
@TemplatePath("/templates/editProfile.html")
-class EditProfilePage @Inject constructor(template: Template, webInterface: WebInterface, loaders: Loaders, templateRenderer: TemplateRenderer) :
- LoggedInPage("editProfile.html", template, "Page.EditProfile.Title", webInterface, loaders, templateRenderer) {
+class EditProfilePage @Inject constructor(webInterface: WebInterface, loaders: Loaders, templateRenderer: TemplateRenderer) :
+ LoggedInPage("editProfile.html", "Page.EditProfile.Title", webInterface, loaders, templateRenderer) {
override fun handleRequest(soneRequest: SoneRequest, currentSone: Sone, templateContext: TemplateContext) {
currentSone.profile.let { profile ->
import net.pterodactylus.sone.main.*
import net.pterodactylus.sone.web.*
import net.pterodactylus.sone.web.page.*
-import net.pterodactylus.util.template.*
@TemplatePath("/templates/invalid.html")
-class InvalidPage(webInterface: WebInterface, loaders: Loaders, templateRenderer: TemplateRenderer) : SoneTemplatePage("invalid.html", webInterface, loaders, Template(), templateRenderer, "Page.Invalid.Title")
+class InvalidPage(webInterface: WebInterface, loaders: Loaders, templateRenderer: TemplateRenderer) : SoneTemplatePage("invalid.html", webInterface, loaders, templateRenderer, "Page.Invalid.Title")
@TemplatePath("/templates/noPermission.html")
-class NoPermissionPage(webInterface: WebInterface, loaders: Loaders, templateRenderer: TemplateRenderer) : SoneTemplatePage("noPermission.html", webInterface, loaders, Template(), templateRenderer, "Page.NoPermission.Title")
+class NoPermissionPage(webInterface: WebInterface, loaders: Loaders, templateRenderer: TemplateRenderer) : SoneTemplatePage("noPermission.html", webInterface, loaders, templateRenderer, "Page.NoPermission.Title")
@TemplatePath("/templates/emptyImageTitle.html")
-class EmptyImageTitlePage(webInterface: WebInterface, loaders: Loaders, templateRenderer: TemplateRenderer) : SoneTemplatePage("emptyImageTitle.html", webInterface, loaders, Template(), templateRenderer, "Page.EmptyImageTitle.Title")
+class EmptyImageTitlePage(webInterface: WebInterface, loaders: Loaders, templateRenderer: TemplateRenderer) : SoneTemplatePage("emptyImageTitle.html", webInterface, loaders, templateRenderer, "Page.EmptyImageTitle.Title")
@TemplatePath("/templates/emptyAlbumTitle.html")
-class EmptyAlbumTitlePage(webInterface: WebInterface, loaders: Loaders, templateRenderer: TemplateRenderer) : SoneTemplatePage("emptyAlbumTitle.html", webInterface, loaders, Template(), templateRenderer, "Page.EmptyAlbumTitle.Title")
+class EmptyAlbumTitlePage(webInterface: WebInterface, loaders: Loaders, templateRenderer: TemplateRenderer) : SoneTemplatePage("emptyAlbumTitle.html", webInterface, loaders, templateRenderer, "Page.EmptyAlbumTitle.Title")
import net.pterodactylus.sone.utils.isPOST
import net.pterodactylus.sone.web.WebInterface
import net.pterodactylus.sone.web.page.*
-import net.pterodactylus.util.template.Template
import net.pterodactylus.util.template.TemplateContext
import javax.inject.Inject
/**
* This page lets the user follow another Sone.
*/
-class FollowSonePage @Inject constructor(template: Template, webInterface: WebInterface, loaders: Loaders, templateRenderer: TemplateRenderer):
- LoggedInPage("followSone.html", template, "Page.FollowSone.Title", webInterface, loaders, templateRenderer) {
+class FollowSonePage @Inject constructor(webInterface: WebInterface, loaders: Loaders, templateRenderer: TemplateRenderer):
+ LoggedInPage("followSone.html", "Page.FollowSone.Title", webInterface, loaders, templateRenderer) {
override fun handleRequest(soneRequest: SoneRequest, currentSone: Sone, templateContext: TemplateContext) {
if (soneRequest.isPOST) {
import net.pterodactylus.sone.utils.parameters
import net.pterodactylus.sone.web.WebInterface
import net.pterodactylus.sone.web.page.*
-import net.pterodactylus.util.template.Template
import net.pterodactylus.util.template.TemplateContext
import java.net.URI
import javax.inject.Inject
*/
@MenuName("ImageBrowser")
@TemplatePath("/templates/imageBrowser.html")
-class ImageBrowserPage @Inject constructor(template: Template, webInterface: WebInterface, loaders: Loaders, templateRenderer: TemplateRenderer):
- LoggedInPage("imageBrowser.html", template, "Page.ImageBrowser.Title", webInterface, loaders, templateRenderer) {
+class ImageBrowserPage @Inject constructor(webInterface: WebInterface, loaders: Loaders, templateRenderer: TemplateRenderer):
+ LoggedInPage("imageBrowser.html", "Page.ImageBrowser.Title", webInterface, loaders, templateRenderer) {
override fun handleRequest(soneRequest: SoneRequest, currentSone: Sone, templateContext: TemplateContext) {
if ("album" in soneRequest.parameters) {
import net.pterodactylus.sone.utils.parameters
import net.pterodactylus.sone.web.WebInterface
import net.pterodactylus.sone.web.page.*
-import net.pterodactylus.util.template.Template
import net.pterodactylus.util.template.TemplateContext
import javax.inject.Inject
*/
@MenuName("Index")
@TemplatePath("/templates/index.html")
-class IndexPage @Inject constructor(template: Template, webInterface: WebInterface, loaders: Loaders, templateRenderer: TemplateRenderer, private val postVisibilityFilter: PostVisibilityFilter) :
- LoggedInPage("index.html", template, "Page.Index.Title", webInterface, loaders, templateRenderer) {
+class IndexPage @Inject constructor(webInterface: WebInterface, loaders: Loaders, templateRenderer: TemplateRenderer, private val postVisibilityFilter: PostVisibilityFilter) :
+ LoggedInPage("index.html", "Page.Index.Title", webInterface, loaders, templateRenderer) {
override fun handleRequest(soneRequest: SoneRequest, currentSone: Sone, templateContext: TemplateContext) {
(currentSone.posts +
import net.pterodactylus.sone.utils.parameters
import net.pterodactylus.sone.web.WebInterface
import net.pterodactylus.sone.web.page.*
-import net.pterodactylus.util.template.Template
import net.pterodactylus.util.template.TemplateContext
import javax.inject.Inject
*/
@MenuName("KnownSones")
@TemplatePath("/templates/knownSones.html")
-class KnownSonesPage @Inject constructor(template: Template, webInterface: WebInterface, loaders: Loaders, templateRenderer: TemplateRenderer):
- SoneTemplatePage("knownSones.html", webInterface, loaders, template, templateRenderer, pageTitleKey = "Page.KnownSones.Title") {
+class KnownSonesPage @Inject constructor(webInterface: WebInterface, loaders: Loaders, templateRenderer: TemplateRenderer):
+ SoneTemplatePage("knownSones.html", webInterface, loaders, templateRenderer, pageTitleKey = "Page.KnownSones.Title") {
override fun handleRequest(soneRequest: SoneRequest, templateContext: TemplateContext) {
getCurrentSone(soneRequest.toadletContext).let { currentSone ->
import net.pterodactylus.sone.utils.parameters
import net.pterodactylus.sone.web.WebInterface
import net.pterodactylus.sone.web.page.*
-import net.pterodactylus.util.template.Template
import net.pterodactylus.util.template.TemplateContext
import javax.inject.Inject
/**
* Page that lets the user like [net.pterodactylus.sone.data.Post]s and [net.pterodactylus.sone.data.Reply]s.
*/
-class LikePage @Inject constructor(template: Template, webInterface: WebInterface, loaders: Loaders, templateRenderer: TemplateRenderer) :
- LoggedInPage("like.html", template, "Page.Like.Title", webInterface, loaders, templateRenderer) {
+class LikePage @Inject constructor(webInterface: WebInterface, loaders: Loaders, templateRenderer: TemplateRenderer) :
+ LoggedInPage("like.html", "Page.Like.Title", webInterface, loaders, templateRenderer) {
override fun handleRequest(soneRequest: SoneRequest, currentSone: Sone, templateContext: TemplateContext) {
if (soneRequest.isPOST) {
import net.pterodactylus.sone.utils.parameters
import net.pterodactylus.sone.web.WebInterface
import net.pterodactylus.sone.web.page.*
-import net.pterodactylus.util.template.Template
import net.pterodactylus.util.template.TemplateContext
import javax.inject.Inject
/**
* This page lets the user lock a [net.pterodactylus.sone.data.Sone] to prevent it from being inserted.
*/
-class LockSonePage @Inject constructor(template: Template, webInterface: WebInterface, loaders: Loaders, templateRenderer: TemplateRenderer):
- SoneTemplatePage("lockSone.html", webInterface, loaders, template, templateRenderer, pageTitleKey = "Page.LockSone.Title") {
+class LockSonePage @Inject constructor(webInterface: WebInterface, loaders: Loaders, templateRenderer: TemplateRenderer):
+ SoneTemplatePage("lockSone.html", webInterface, loaders, templateRenderer, pageTitleKey = "Page.LockSone.Title") {
override fun handleRequest(soneRequest: SoneRequest, templateContext: TemplateContext) {
soneRequest.parameters["returnPage", 256]!!.let { returnPage ->
import net.pterodactylus.sone.main.*
import net.pterodactylus.sone.web.WebInterface
import net.pterodactylus.sone.web.page.*
-import net.pterodactylus.util.template.Template
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, loaders: Loaders, templateRenderer: TemplateRenderer) :
- SoneTemplatePage(path, webInterface, loaders, template, templateRenderer, pageTitleKey = pageTitleKey, requiresLogin = true) {
+abstract class LoggedInPage(path: String, pageTitleKey: String, webInterface: WebInterface, loaders: Loaders, templateRenderer: TemplateRenderer) :
+ SoneTemplatePage(path, webInterface, loaders, templateRenderer, pageTitleKey = pageTitleKey, requiresLogin = true) {
final override fun handleRequest(soneRequest: SoneRequest, templateContext: TemplateContext) {
handleRequest(soneRequest, getCurrentSone(soneRequest.toadletContext, false)!!, templateContext)
import net.pterodactylus.sone.utils.isPOST
import net.pterodactylus.sone.web.WebInterface
import net.pterodactylus.sone.web.page.*
-import net.pterodactylus.util.template.Template
import net.pterodactylus.util.template.TemplateContext
import javax.inject.Inject
*/
@MenuName("Login")
@TemplatePath("/templates/login.html")
-class LoginPage @Inject constructor(template: Template, webInterface: WebInterface, loaders: Loaders, templateRenderer: TemplateRenderer):
- SoneTemplatePage("login.html", webInterface, loaders, template, templateRenderer, pageTitleKey = "Page.Login.Title") {
+class LoginPage @Inject constructor(webInterface: WebInterface, loaders: Loaders, templateRenderer: TemplateRenderer):
+ SoneTemplatePage("login.html", webInterface, loaders, templateRenderer, pageTitleKey = "Page.Login.Title") {
override fun handleRequest(soneRequest: SoneRequest, templateContext: TemplateContext) {
if (soneRequest.isPOST) {
import net.pterodactylus.sone.main.*
import net.pterodactylus.sone.web.WebInterface
import net.pterodactylus.sone.web.page.*
-import net.pterodactylus.util.template.Template
import net.pterodactylus.util.template.TemplateContext
import javax.inject.Inject
* Logs a user out.
*/
@MenuName("Logout")
-class LogoutPage @Inject constructor(template: Template, webInterface: WebInterface, loaders: Loaders, templateRenderer: TemplateRenderer):
- LoggedInPage("logout.html", template, "Page.Logout.Title", webInterface, loaders, templateRenderer) {
+class LogoutPage @Inject constructor(webInterface: WebInterface, loaders: Loaders, templateRenderer: TemplateRenderer):
+ LoggedInPage("logout.html", "Page.Logout.Title", webInterface, loaders, templateRenderer) {
override fun handleRequest(soneRequest: SoneRequest, currentSone: Sone, templateContext: TemplateContext) {
setCurrentSone(soneRequest.toadletContext, null)
* Page that lets the user mark a number of [net.pterodactylus.sone.data.Sone]s, [Post]s, or
* [Replie][net.pterodactylus.sone.data.Reply]s as known.
*/
-class MarkAsKnownPage @Inject constructor(template: Template, webInterface: WebInterface, loaders: Loaders, templateRenderer: TemplateRenderer):
- SoneTemplatePage("markAsKnown.html", webInterface, loaders, template, templateRenderer, pageTitleKey = "Page.MarkAsKnown.Title") {
+class MarkAsKnownPage @Inject constructor(webInterface: WebInterface, loaders: Loaders, templateRenderer: TemplateRenderer):
+ SoneTemplatePage("markAsKnown.html", webInterface, loaders, templateRenderer, pageTitleKey = "Page.MarkAsKnown.Title") {
override fun handleRequest(soneRequest: SoneRequest, templateContext: TemplateContext) {
val ids = soneRequest.parameters["id", 65536]!!.split(" ")
import net.pterodactylus.sone.utils.parameters
import net.pterodactylus.sone.web.WebInterface
import net.pterodactylus.sone.web.page.*
-import net.pterodactylus.util.template.Template
import net.pterodactylus.util.template.TemplateContext
import javax.inject.Inject
*/
@MenuName("New")
@TemplatePath("/templates/new.html")
-class NewPage @Inject constructor(template: Template, webInterface: WebInterface, loaders: Loaders, templateRenderer: TemplateRenderer):
- SoneTemplatePage("new.html", webInterface, loaders, template, templateRenderer, pageTitleKey = "Page.New.Title") {
+class NewPage @Inject constructor(webInterface: WebInterface, loaders: Loaders, templateRenderer: TemplateRenderer):
+ SoneTemplatePage("new.html", webInterface, loaders, templateRenderer, pageTitleKey = "Page.New.Title") {
override fun handleRequest(soneRequest: SoneRequest, templateContext: TemplateContext) =
getCurrentSone(soneRequest.toadletContext).let { currentSone ->
import net.pterodactylus.sone.utils.parameters
import net.pterodactylus.sone.web.WebInterface
import net.pterodactylus.sone.web.page.*
-import net.pterodactylus.util.template.Template
import net.pterodactylus.util.template.TemplateContext
import javax.inject.Inject
*/
@MenuName("Options")
@TemplatePath("/templates/options.html")
-class OptionsPage @Inject constructor(template: Template, webInterface: WebInterface, loaders: Loaders, templateRenderer: TemplateRenderer):
- SoneTemplatePage("options.html", webInterface, loaders, template, templateRenderer, pageTitleKey = "Page.Options.Title") {
+class OptionsPage @Inject constructor(webInterface: WebInterface, loaders: Loaders, templateRenderer: TemplateRenderer):
+ SoneTemplatePage("options.html", webInterface, loaders, templateRenderer, pageTitleKey = "Page.Options.Title") {
override fun handleRequest(soneRequest: SoneRequest, templateContext: TemplateContext) {
if (soneRequest.isPOST) {
import net.pterodactylus.sone.utils.parameters
import net.pterodactylus.sone.web.WebInterface
import net.pterodactylus.sone.web.page.*
-import net.pterodactylus.util.template.Template
import net.pterodactylus.util.template.TemplateContext
import javax.inject.Inject
*/
@MenuName("Rescue")
@TemplatePath("/templates/rescue.html")
-class RescuePage @Inject constructor(template: Template, webInterface: WebInterface, loaders: Loaders, templateRenderer: TemplateRenderer):
- LoggedInPage("rescue.html", template, "Page.Rescue.Title", webInterface, loaders, templateRenderer) {
+class RescuePage @Inject constructor(webInterface: WebInterface, loaders: Loaders, templateRenderer: TemplateRenderer):
+ LoggedInPage("rescue.html", "Page.Rescue.Title", webInterface, loaders, templateRenderer) {
override fun handleRequest(soneRequest: SoneRequest, currentSone: Sone, templateContext: TemplateContext) {
val soneRescuer = soneRequest.core.getSoneRescuer(currentSone)
import net.pterodactylus.sone.web.pages.SearchPage.Optionality.FORBIDDEN
import net.pterodactylus.sone.web.pages.SearchPage.Optionality.OPTIONAL
import net.pterodactylus.sone.web.pages.SearchPage.Optionality.REQUIRED
-import net.pterodactylus.util.template.Template
import net.pterodactylus.util.template.TemplateContext
import net.pterodactylus.util.text.StringEscaper
import net.pterodactylus.util.text.TextException
* words.
*/
@TemplatePath("/templates/search.html")
-class SearchPage(template: Template, webInterface: WebInterface, loaders: Loaders, templateRenderer: TemplateRenderer, ticker: Ticker = Ticker.systemTicker()) :
- SoneTemplatePage("search.html", webInterface, loaders, template, templateRenderer, pageTitleKey = "Page.Search.Title") {
+class SearchPage(webInterface: WebInterface, loaders: Loaders, templateRenderer: TemplateRenderer, ticker: Ticker = Ticker.systemTicker()) :
+ SoneTemplatePage("search.html", webInterface, loaders, templateRenderer, pageTitleKey = "Page.Search.Title") {
- @Inject constructor(template: Template, webInterface: WebInterface, loaders: Loaders, templateRenderer: TemplateRenderer) :
- this(template, webInterface, loaders, templateRenderer, Ticker.systemTicker())
+ @Inject constructor(webInterface: WebInterface, loaders: Loaders, templateRenderer: TemplateRenderer) :
+ this(webInterface, loaders, templateRenderer, Ticker.systemTicker())
private val cache: Cache<Iterable<Phrase>, Pagination<Post>> = CacheBuilder.newBuilder().ticker(ticker).expireAfterAccess(5, MINUTES).build()
import net.pterodactylus.sone.web.WebInterface
import net.pterodactylus.sone.web.page.*
import net.pterodactylus.util.notify.Notification
-import net.pterodactylus.util.template.Template
import net.pterodactylus.util.template.TemplateContext
import net.pterodactylus.util.web.*
import java.net.URLEncoder
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, templateRenderer, loaders, template, "noPermission.html") {
+) : FreenetTemplatePage(path, templateRenderer, loaders, "noPermission.html") {
private val core = webInterface.core
private val sessionProvider: SessionProvider = webInterface
import net.pterodactylus.sone.utils.parameters
import net.pterodactylus.sone.web.WebInterface
import net.pterodactylus.sone.web.page.*
-import net.pterodactylus.util.template.Template
import net.pterodactylus.util.template.TemplateContext
import javax.inject.Inject
* Page that lets the user trust another Sone. This will assign a configurable
* amount of trust to an identity.
*/
-class TrustPage @Inject constructor(template: Template, webInterface: WebInterface, loaders: Loaders, templateRenderer: TemplateRenderer) :
- LoggedInPage("trust.html", template, "Page.Trust.Title", webInterface, loaders, templateRenderer) {
+class TrustPage @Inject constructor(webInterface: WebInterface, loaders: Loaders, templateRenderer: TemplateRenderer) :
+ LoggedInPage("trust.html", "Page.Trust.Title", webInterface, loaders, templateRenderer) {
override fun handleRequest(soneRequest: SoneRequest, currentSone: Sone, templateContext: TemplateContext) {
if (soneRequest.isPOST) {
/**
* Page that lets the user unbookmark a post.
*/
-class UnbookmarkPage @Inject constructor(template: Template, webInterface: WebInterface, loaders: Loaders, templateRenderer: TemplateRenderer):
- SoneTemplatePage("unbookmark.html", webInterface, loaders, template, templateRenderer, pageTitleKey = "Page.Unbookmark.Title") {
+class UnbookmarkPage @Inject constructor(webInterface: WebInterface, loaders: Loaders, templateRenderer: TemplateRenderer):
+ SoneTemplatePage("unbookmark.html", webInterface, loaders, templateRenderer, pageTitleKey = "Page.Unbookmark.Title") {
override fun handleRequest(soneRequest: SoneRequest, templateContext: TemplateContext) {
when {
import net.pterodactylus.sone.utils.parameters
import net.pterodactylus.sone.web.WebInterface
import net.pterodactylus.sone.web.page.*
-import net.pterodactylus.util.template.Template
import net.pterodactylus.util.template.TemplateContext
import javax.inject.Inject
/**
* This page lets the user unfollow another Sone.
*/
-class UnfollowSonePage @Inject constructor(template: Template, webInterface: WebInterface, loaders: Loaders, templateRenderer: TemplateRenderer) :
- LoggedInPage("unfollowSone.html", template, "Page.UnfollowSone.Title", webInterface, loaders, templateRenderer) {
+class UnfollowSonePage @Inject constructor(webInterface: WebInterface, loaders: Loaders, templateRenderer: TemplateRenderer) :
+ LoggedInPage("unfollowSone.html", "Page.UnfollowSone.Title", webInterface, loaders, templateRenderer) {
override fun handleRequest(soneRequest: SoneRequest, currentSone: Sone, templateContext: TemplateContext) {
if (soneRequest.isPOST) {
import net.pterodactylus.sone.utils.parameters
import net.pterodactylus.sone.web.WebInterface
import net.pterodactylus.sone.web.page.*
-import net.pterodactylus.util.template.Template
import net.pterodactylus.util.template.TemplateContext
import javax.inject.Inject
/**
* Page that lets the user unlike a [net.pterodactylus.sone.data.Post] or [net.pterodactylus.sone.data.Reply].
*/
-class UnlikePage @Inject constructor(template: Template, webInterface: WebInterface, loaders: Loaders, templateRenderer: TemplateRenderer):
- LoggedInPage("unlike.html", template, "Page.Unlike.Title", webInterface, loaders, templateRenderer) {
+class UnlikePage @Inject constructor(webInterface: WebInterface, loaders: Loaders, templateRenderer: TemplateRenderer):
+ LoggedInPage("unlike.html", "Page.Unlike.Title", webInterface, loaders, templateRenderer) {
override fun handleRequest(soneRequest: SoneRequest, currentSone: Sone, templateContext: TemplateContext) {
if (soneRequest.isPOST) {
import net.pterodactylus.sone.utils.parameters
import net.pterodactylus.sone.web.WebInterface
import net.pterodactylus.sone.web.page.*
-import net.pterodactylus.util.template.Template
import net.pterodactylus.util.template.TemplateContext
import javax.inject.Inject
/**
* This page lets the user unlock a [net.pterodactylus.sone.data.Sone] to allow its insertion.
*/
-class UnlockSonePage @Inject constructor(template: Template, webInterface: WebInterface, loaders: Loaders, templateRenderer: TemplateRenderer):
- SoneTemplatePage("unlockSone.html", webInterface, loaders, template, templateRenderer, pageTitleKey = "Page.UnlockSone.Title") {
+class UnlockSonePage @Inject constructor(webInterface: WebInterface, loaders: Loaders, templateRenderer: TemplateRenderer):
+ SoneTemplatePage("unlockSone.html", webInterface, loaders, templateRenderer, pageTitleKey = "Page.UnlockSone.Title") {
override fun handleRequest(soneRequest: SoneRequest, templateContext: TemplateContext) {
if (soneRequest.isPOST) {
import net.pterodactylus.sone.utils.parameters
import net.pterodactylus.sone.web.WebInterface
import net.pterodactylus.sone.web.page.*
-import net.pterodactylus.util.template.Template
import net.pterodactylus.util.template.TemplateContext
import javax.inject.Inject
* Page that lets the user untrust another Sone. This will remove all trust
* assignments for an identity.
*/
-class UntrustPage @Inject constructor(template: Template, webInterface: WebInterface, loaders: Loaders, templateRenderer: TemplateRenderer) :
- LoggedInPage("untrust.html", template, "Page.Untrust.Title", webInterface, loaders, templateRenderer) {
+class UntrustPage @Inject constructor(webInterface: WebInterface, loaders: Loaders, templateRenderer: TemplateRenderer) :
+ LoggedInPage("untrust.html", "Page.Untrust.Title", webInterface, loaders, templateRenderer) {
override fun handleRequest(soneRequest: SoneRequest, currentSone: Sone, templateContext: TemplateContext) {
if (soneRequest.isPOST) {
import net.pterodactylus.sone.utils.use
import net.pterodactylus.sone.web.WebInterface
import net.pterodactylus.sone.web.page.*
-import net.pterodactylus.util.template.Template
import net.pterodactylus.util.template.TemplateContext
import java.awt.image.BufferedImage
import java.io.ByteArrayInputStream
* Page implementation that lets the user upload an image.
*/
@TemplatePath("/templates/invalid.html")
-class UploadImagePage @Inject constructor(template: Template, webInterface: WebInterface, loaders: Loaders, templateRenderer: TemplateRenderer):
- LoggedInPage("uploadImage.html", template, "Page.UploadImage.Title", webInterface, loaders, templateRenderer) {
+class UploadImagePage @Inject constructor(webInterface: WebInterface, loaders: Loaders, templateRenderer: TemplateRenderer):
+ LoggedInPage("uploadImage.html", "Page.UploadImage.Title", webInterface, loaders, templateRenderer) {
override fun handleRequest(soneRequest: SoneRequest, currentSone: Sone, templateContext: TemplateContext) {
if (soneRequest.isPOST) {
* This page lets the user view a post and all its replies.
*/
@TemplatePath("/templates/viewPost.html")
-class ViewPostPage @Inject constructor(template: Template, webInterface: WebInterface, loaders: Loaders, templateRenderer: TemplateRenderer):
- SoneTemplatePage("viewPost.html", webInterface, loaders, template, templateRenderer, pageTitleKey = "Page.ViewPost.Title") {
+class ViewPostPage @Inject constructor(webInterface: WebInterface, loaders: Loaders, templateRenderer: TemplateRenderer):
+ SoneTemplatePage("viewPost.html", webInterface, loaders, templateRenderer, pageTitleKey = "Page.ViewPost.Title") {
override fun handleRequest(soneRequest: SoneRequest, templateContext: TemplateContext) {
templateContext["post"] = soneRequest.parameters["post"]?.let(soneRequest.core::getPost)
import net.pterodactylus.sone.utils.parameters
import net.pterodactylus.sone.web.WebInterface
import net.pterodactylus.sone.web.page.*
-import net.pterodactylus.util.template.Template
import net.pterodactylus.util.template.TemplateContext
import java.net.URI
import javax.inject.Inject
* Lets the user browser another Sone.
*/
@TemplatePath("/templates/viewSone.html")
-class ViewSonePage @Inject constructor(template: Template, webInterface: WebInterface, loaders: Loaders, templateRenderer: TemplateRenderer):
- SoneTemplatePage("viewSone.html", webInterface, loaders, template, templateRenderer) {
+class ViewSonePage @Inject constructor(webInterface: WebInterface, loaders: Loaders, templateRenderer: TemplateRenderer):
+ SoneTemplatePage("viewSone.html", webInterface, loaders, templateRenderer) {
override fun handleRequest(soneRequest: SoneRequest, templateContext: TemplateContext) {
templateContext["soneId"] = soneRequest.parameters["sone"]
private val templateRenderer = deepMock<TemplateRenderer>()
private val loaders = mock<Loaders>()
private val template = mock<Template>()
- private val page = FreenetTemplatePage("/test/path", templateRenderer, loaders, template, "invalid-form-password")
+ private val page = FreenetTemplatePage("/test/path", templateRenderer, loaders, "invalid-form-password")
@Test
fun `path is exposed correctly`() {
@Test
fun `isEnabled() returns false if full access only is true`() {
- val page = object : FreenetTemplatePage("/test/path", templateRenderer, loaders, template, "invalid-form-password") {
+ val page = object : FreenetTemplatePage("/test/path", templateRenderer, loaders, "invalid-form-password") {
override val isFullAccessOnly = true
}
assertThat(page.isEnabled(mock()), equalTo(false))
@Test
fun `page with redirect target throws redirect exception on handleRequest`() {
- val page = object : FreenetTemplatePage("/test/path", templateRenderer, loaders, template, "invalid-form-password") {
+ val page = object : FreenetTemplatePage("/test/path", templateRenderer, loaders, "invalid-form-password") {
override fun getRedirectTarget(request: FreenetRequest) = "foo"
}
val request = mock<FreenetRequest>()
@Test
fun `page with full access only returns unauthorized on handleRequest with non-full access request`() {
- val page = object : FreenetTemplatePage("/test/path", templateRenderer, loaders, template, "invalid-form-password") {
+ val page = object : FreenetTemplatePage("/test/path", templateRenderer, loaders, "invalid-form-password") {
override val isFullAccessOnly = true
}
val request = deepMock<FreenetRequest>()
}
@TemplatePath("template-path")
- private class TestPage(templateRenderer: TemplateRenderer, loaders: Loaders) : FreenetTemplatePage("/", templateRenderer, loaders, Template(), "") {
+ private class TestPage(templateRenderer: TemplateRenderer, loaders: Loaders) : FreenetTemplatePage("/", templateRenderer, loaders, "") {
override fun getPath() = ""
override fun isPrefixPage() = false
override fun handleRequest(request: FreenetRequest, response: Response) = response
/**
* Unit test for [AboutPage].
*/
-class AboutPageTest : WebPageTest({ template, webInterface, loaders, templateRenderer -> AboutPage(template, webInterface, loaders, templateRenderer, PluginVersion(version), PluginYear(year), PluginHomepage(homepage)) }) {
+class AboutPageTest : WebPageTest({ webInterface, loaders, templateRenderer -> AboutPage(webInterface, loaders, templateRenderer, PluginVersion(version), PluginYear(year), PluginHomepage(homepage)) }) {
companion object {
private const val version = "0.1.2"
/**
* Unit test for [IndexPage].
*/
-class IndexPageTest: WebPageTest({ template, webInterface, loaders, templateRenderer -> IndexPage(template, webInterface, loaders, templateRenderer, postVisibilityFilter) }) {
+class IndexPageTest: WebPageTest({ webInterface, loaders, templateRenderer -> IndexPage(webInterface, loaders, templateRenderer, postVisibilityFilter) }) {
companion object {
private val postVisibilityFilter = mock<PostVisibilityFilter>()
/**
* Unit test for [SearchPage].
*/
-class SearchPageTest: WebPageTest({ template, webInterface, loaders, templateRenderer -> SearchPage(template, webInterface, loaders, templateRenderer, ticker) }) {
+class SearchPageTest: WebPageTest({ webInterface, loaders, templateRenderer -> SearchPage(webInterface, loaders, templateRenderer, ticker) }) {
companion object {
val ticker = mock<Ticker>()
/**
* Unit test for [SoneTemplatePage].
*/
-class SoneTemplatePageTest : WebPageTest({ template, webInterface, loaders, templateRenderer -> object : SoneTemplatePage("path.html", webInterface, loaders, template, templateRenderer, requiresLogin = true) {} }) {
+class SoneTemplatePageTest : WebPageTest({ webInterface, loaders, templateRenderer -> object : SoneTemplatePage("path.html", 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, template, templateRenderer, requiresLogin = false).let { page ->
+ SoneTemplatePage("path.html", 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, template, templateRenderer, pageTitleKey = "page.title", requiresLogin = false).let { page ->
+ SoneTemplatePage("path.html", 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, template, templateRenderer, requiresLogin = true) {
+ val page = object : SoneTemplatePage("path.html", 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, template, templateRenderer, requiresLogin = false)
+ val page = SoneTemplatePage("page.html", 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, template, templateRenderer, requiresLogin = false).let { page ->
+ SoneTemplatePage("path.html", 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, template, templateRenderer) {
+ val page = object : SoneTemplatePage("path.html", webInterface, loaders, templateRenderer) {
override fun handleRequest(soneRequest: SoneRequest, templateContext: TemplateContext) {
called = true
}
import net.pterodactylus.sone.web.page.*
import net.pterodactylus.sone.web.page.FreenetTemplatePage.RedirectException
import net.pterodactylus.util.notify.Notification
-import net.pterodactylus.util.template.Template
import net.pterodactylus.util.template.TemplateContext
import net.pterodactylus.util.web.Method
import net.pterodactylus.util.web.Method.GET
/**
* Base class for web page tests.
*/
-open class WebPageTest(pageSupplier: (Template, WebInterface, Loaders, TemplateRenderer) -> SoneTemplatePage = { _, _, _, _ -> mock() }) {
+open class WebPageTest(pageSupplier: (WebInterface, Loaders, TemplateRenderer) -> SoneTemplatePage = { _, _, _ -> mock() }) {
val currentSone = mock<Sone>()
val loaders = mock<Loaders>()
- val template = mock<Template>()
val templateRenderer = mock<TemplateRenderer>()
val webInterface = deepMock<WebInterface>()
val core = webInterface.core
val l10n = webInterface.l10n!!
val sessionManager = mock<SessionManager>()
- val page by lazy { pageSupplier(template, webInterface, loaders, templateRenderer) }
+ val page by lazy { pageSupplier(webInterface, loaders, templateRenderer) }
val httpRequest = mock<HTTPRequest>()
val freenetRequest = mock<FreenetRequest>()