Template openSearchTemplate = loaders.loadTemplate("/templates/xml/OpenSearch.xml");
pageToadletRegistry.addPage(new RedirectPage<FreenetRequest>("", "index.html"));
- pageToadletRegistry.addPage(new IndexPage(indexTemplate, this, postVisibilityFilter));
- pageToadletRegistry.addPage(new NewPage(newTemplate, this));
- pageToadletRegistry.addPage(new CreateSonePage(createSoneTemplate, this));
- pageToadletRegistry.addPage(new KnownSonesPage(knownSonesTemplate, this));
- pageToadletRegistry.addPage(new EditProfilePage(editProfileTemplate, this));
- pageToadletRegistry.addPage(new EditProfileFieldPage(editProfileFieldTemplate, this));
- pageToadletRegistry.addPage(new DeleteProfileFieldPage(deleteProfileFieldTemplate, this));
- pageToadletRegistry.addPage(new CreatePostPage(createPostTemplate, this));
- pageToadletRegistry.addPage(new CreateReplyPage(createReplyTemplate, this));
- pageToadletRegistry.addPage(new ViewSonePage(viewSoneTemplate, this));
- pageToadletRegistry.addPage(new ViewPostPage(viewPostTemplate, this));
- pageToadletRegistry.addPage(new LikePage(emptyTemplate, this));
- pageToadletRegistry.addPage(new UnlikePage(emptyTemplate, this));
- pageToadletRegistry.addPage(new DeletePostPage(deletePostTemplate, this));
- pageToadletRegistry.addPage(new DeleteReplyPage(deleteReplyTemplate, this));
- pageToadletRegistry.addPage(new LockSonePage(emptyTemplate, this));
- pageToadletRegistry.addPage(new UnlockSonePage(emptyTemplate, this));
- pageToadletRegistry.addPage(new FollowSonePage(emptyTemplate, this));
- pageToadletRegistry.addPage(new UnfollowSonePage(emptyTemplate, this));
- pageToadletRegistry.addPage(new ImageBrowserPage(imageBrowserTemplate, this));
- pageToadletRegistry.addPage(new CreateAlbumPage(createAlbumTemplate, this));
- pageToadletRegistry.addPage(new EditAlbumPage(emptyTemplate, this));
- pageToadletRegistry.addPage(new DeleteAlbumPage(deleteAlbumTemplate, this));
- pageToadletRegistry.addPage(new UploadImagePage(invalidTemplate, this));
- pageToadletRegistry.addPage(new EditImagePage(emptyTemplate, this));
- pageToadletRegistry.addPage(new DeleteImagePage(deleteImageTemplate, this));
- pageToadletRegistry.addPage(new TrustPage(emptyTemplate, this));
- pageToadletRegistry.addPage(new DistrustPage(emptyTemplate, this));
- pageToadletRegistry.addPage(new UntrustPage(emptyTemplate, this));
- pageToadletRegistry.addPage(new MarkAsKnownPage(emptyTemplate, this));
- pageToadletRegistry.addPage(new BookmarkPage(emptyTemplate, this));
- pageToadletRegistry.addPage(new UnbookmarkPage(emptyTemplate, this));
- pageToadletRegistry.addPage(new BookmarksPage(bookmarksTemplate, this));
- pageToadletRegistry.addPage(new SearchPage(searchTemplate, this));
- pageToadletRegistry.addPage(new DeleteSonePage(deleteSoneTemplate, this));
- pageToadletRegistry.addPage(new LoginPage(loginTemplate, this));
- pageToadletRegistry.addPage(new LogoutPage(emptyTemplate, this));
- pageToadletRegistry.addPage(new OptionsPage(optionsTemplate, this));
- pageToadletRegistry.addPage(new RescuePage(rescueTemplate, this));
- pageToadletRegistry.addPage(new AboutPage(aboutTemplate, this, new PluginVersion(SonePlugin.getPluginVersion()), new PluginYear(sonePlugin.getYear()), new PluginHomepage(sonePlugin.getHomepage())));
- pageToadletRegistry.addPage(new SoneTemplatePage("noPermission.html", this, noPermissionTemplate, "Page.NoPermission.Title"));
- pageToadletRegistry.addPage(new SoneTemplatePage("emptyImageTitle.html", this, emptyImageTitleTemplate, "Page.EmptyImageTitle.Title"));
- pageToadletRegistry.addPage(new SoneTemplatePage("emptyAlbumTitle.html", this, emptyAlbumTitleTemplate, "Page.EmptyAlbumTitle.Title"));
- pageToadletRegistry.addPage(new DismissNotificationPage(emptyTemplate, this));
- pageToadletRegistry.addPage(new SoneTemplatePage("invalid.html", this, invalidTemplate, "Page.Invalid.Title"));
+ pageToadletRegistry.addPage(new IndexPage(indexTemplate, this, loaders, postVisibilityFilter));
+ pageToadletRegistry.addPage(new NewPage(newTemplate, this, loaders));
+ pageToadletRegistry.addPage(new CreateSonePage(createSoneTemplate, this, loaders));
+ pageToadletRegistry.addPage(new KnownSonesPage(knownSonesTemplate, this, loaders));
+ pageToadletRegistry.addPage(new EditProfilePage(editProfileTemplate, this, loaders));
+ pageToadletRegistry.addPage(new EditProfileFieldPage(editProfileFieldTemplate, this, loaders));
+ pageToadletRegistry.addPage(new DeleteProfileFieldPage(deleteProfileFieldTemplate, this, loaders));
+ pageToadletRegistry.addPage(new CreatePostPage(createPostTemplate, this, loaders));
+ pageToadletRegistry.addPage(new CreateReplyPage(createReplyTemplate, this, loaders));
+ pageToadletRegistry.addPage(new ViewSonePage(viewSoneTemplate, this, loaders));
+ pageToadletRegistry.addPage(new ViewPostPage(viewPostTemplate, this, loaders));
+ pageToadletRegistry.addPage(new LikePage(emptyTemplate, this, loaders));
+ pageToadletRegistry.addPage(new UnlikePage(emptyTemplate, this, loaders));
+ pageToadletRegistry.addPage(new DeletePostPage(deletePostTemplate, this, loaders));
+ pageToadletRegistry.addPage(new DeleteReplyPage(deleteReplyTemplate, this, loaders));
+ pageToadletRegistry.addPage(new LockSonePage(emptyTemplate, this, loaders));
+ pageToadletRegistry.addPage(new UnlockSonePage(emptyTemplate, this, loaders));
+ pageToadletRegistry.addPage(new FollowSonePage(emptyTemplate, this, loaders));
+ pageToadletRegistry.addPage(new UnfollowSonePage(emptyTemplate, this, loaders));
+ pageToadletRegistry.addPage(new ImageBrowserPage(imageBrowserTemplate, this, loaders));
+ pageToadletRegistry.addPage(new CreateAlbumPage(createAlbumTemplate, this, loaders));
+ pageToadletRegistry.addPage(new EditAlbumPage(emptyTemplate, this, loaders));
+ pageToadletRegistry.addPage(new DeleteAlbumPage(deleteAlbumTemplate, this, loaders));
+ pageToadletRegistry.addPage(new UploadImagePage(invalidTemplate, this, loaders));
+ pageToadletRegistry.addPage(new EditImagePage(emptyTemplate, this, loaders));
+ pageToadletRegistry.addPage(new DeleteImagePage(deleteImageTemplate, this, loaders));
+ pageToadletRegistry.addPage(new TrustPage(emptyTemplate, this, loaders));
+ pageToadletRegistry.addPage(new DistrustPage(emptyTemplate, this, loaders));
+ pageToadletRegistry.addPage(new UntrustPage(emptyTemplate, this, loaders));
+ pageToadletRegistry.addPage(new MarkAsKnownPage(emptyTemplate, this, loaders));
+ pageToadletRegistry.addPage(new BookmarkPage(emptyTemplate, this, loaders));
+ pageToadletRegistry.addPage(new UnbookmarkPage(emptyTemplate, this, loaders));
+ pageToadletRegistry.addPage(new BookmarksPage(bookmarksTemplate, this, loaders));
+ pageToadletRegistry.addPage(new SearchPage(searchTemplate, this, loaders));
+ pageToadletRegistry.addPage(new DeleteSonePage(deleteSoneTemplate, this, loaders));
+ pageToadletRegistry.addPage(new LoginPage(loginTemplate, this, loaders));
+ pageToadletRegistry.addPage(new LogoutPage(emptyTemplate, this, loaders));
+ pageToadletRegistry.addPage(new OptionsPage(optionsTemplate, this, loaders));
+ pageToadletRegistry.addPage(new RescuePage(rescueTemplate, this, loaders));
+ pageToadletRegistry.addPage(new AboutPage(aboutTemplate, this, loaders, new PluginVersion(SonePlugin.getPluginVersion()), new PluginYear(sonePlugin.getYear()), new PluginHomepage(sonePlugin.getHomepage())));
+ pageToadletRegistry.addPage(new SoneTemplatePage("noPermission.html", this, loaders, noPermissionTemplate, "Page.NoPermission.Title"));
+ pageToadletRegistry.addPage(new SoneTemplatePage("emptyImageTitle.html", this, loaders, emptyImageTitleTemplate, "Page.EmptyImageTitle.Title"));
+ pageToadletRegistry.addPage(new SoneTemplatePage("emptyAlbumTitle.html", this, loaders, emptyAlbumTitleTemplate, "Page.EmptyAlbumTitle.Title"));
+ pageToadletRegistry.addPage(new DismissNotificationPage(emptyTemplate, this, loaders));
+ pageToadletRegistry.addPage(new SoneTemplatePage("invalid.html", this, loaders, invalidTemplate, "Page.Invalid.Title"));
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"));
import java.util.logging.Level;
import java.util.logging.Logger;
+import net.pterodactylus.sone.main.Loaders;
import net.pterodactylus.util.template.Template;
import net.pterodactylus.util.template.TemplateContext;
import net.pterodactylus.util.template.TemplateContextFactory;
/** The template to render. */
private final Template template;
+ private final Loaders loaders;
/** Where to redirect for invalid form passwords. */
private final String invalidFormPasswordRedirectTarget;
- /**
- * Creates a new template page.
- *
- * @param path
- * The path of the page
- * @param templateContextFactory
- * The template context factory
- * @param template
- * The template to render
- * @param invalidFormPasswordRedirectTarget
- * The target to redirect to if a POST request does not contain
- * the correct form password
- */
- public FreenetTemplatePage(String path, TemplateContextFactory templateContextFactory, Template template, String invalidFormPasswordRedirectTarget) {
+ public FreenetTemplatePage(String path, TemplateContextFactory templateContextFactory, Loaders loaders, Template template, String invalidFormPasswordRedirectTarget) {
this.path = path;
this.templateContextFactory = templateContextFactory;
+ this.loaders = loaders;
this.template = template;
this.invalidFormPasswordRedirectTarget = invalidFormPasswordRedirectTarget;
}
* A [SoneTemplatePage] that stores information about Sone in the [TemplateContext].
*/
@MenuName("About")
-class AboutPage @Inject constructor(template: Template, webInterface: WebInterface,
+class AboutPage @Inject constructor(template: Template, webInterface: WebInterface, loaders: Loaders,
private val pluginVersion: PluginVersion,
private val pluginYear: PluginYear,
- private val pluginHomepage: PluginHomepage): SoneTemplatePage("about.html", webInterface, template, "Page.About.Title") {
+ private val pluginHomepage: PluginHomepage): SoneTemplatePage("about.html", webInterface, loaders, template = template, pageTitleKey = "Page.About.Title") {
override fun handleRequest(freenetRequest: FreenetRequest, templateContext: TemplateContext) {
templateContext["version"] = pluginVersion.version
package net.pterodactylus.sone.web.pages
+import net.pterodactylus.sone.main.*
import net.pterodactylus.sone.utils.isPOST
import net.pterodactylus.sone.web.WebInterface
import net.pterodactylus.sone.web.page.*
/**
* Page that lets the user bookmark a post.
*/
-class BookmarkPage @Inject constructor(template: Template, webInterface: WebInterface)
- : SoneTemplatePage("bookmark.html", webInterface, template, "Page.Bookmark.Title") {
+class BookmarkPage @Inject constructor(template: Template, webInterface: WebInterface, loaders: Loaders)
+ : SoneTemplatePage("bookmark.html", webInterface, loaders, template = template, pageTitleKey = "Page.Bookmark.Title") {
override fun handleRequest(soneRequest: SoneRequest, templateContext: TemplateContext) {
if (soneRequest.isPOST) {
package net.pterodactylus.sone.web.pages
import net.pterodactylus.sone.data.Post
+import net.pterodactylus.sone.main.*
import net.pterodactylus.sone.utils.paginate
import net.pterodactylus.sone.web.WebInterface
import net.pterodactylus.sone.web.page.*
* Page that lets the user browse all his bookmarked posts.
*/
@MenuName("Bookmarks")
-class BookmarksPage @Inject constructor(template: Template, webInterface: WebInterface) :
- SoneTemplatePage("bookmarks.html", webInterface, template, "Page.Bookmarks.Title") {
+class BookmarksPage @Inject constructor(template: Template, webInterface: WebInterface, loaders: Loaders) :
+ SoneTemplatePage("bookmarks.html", webInterface, loaders, template = template, pageTitleKey = "Page.Bookmarks.Title") {
override fun handleRequest(soneRequest: SoneRequest, templateContext: TemplateContext) {
soneRequest.core.bookmarkedPosts.let { posts ->
import net.pterodactylus.sone.data.Album.Modifier.AlbumTitleMustNotBeEmpty
import net.pterodactylus.sone.data.Sone
+import net.pterodactylus.sone.main.*
import net.pterodactylus.sone.text.TextFilter
import net.pterodactylus.sone.utils.isPOST
import net.pterodactylus.sone.web.WebInterface
/**
* Page that lets the user create a new album.
*/
-class CreateAlbumPage @Inject constructor(template: Template, webInterface: WebInterface):
- LoggedInPage("createAlbum.html", template, "Page.CreateAlbum.Title", webInterface) {
+class CreateAlbumPage @Inject constructor(template: Template, webInterface: WebInterface, loaders: Loaders):
+ LoggedInPage("createAlbum.html", template, "Page.CreateAlbum.Title", webInterface, loaders) {
override fun handleRequest(soneRequest: SoneRequest, currentSone: Sone, templateContext: TemplateContext) {
if (soneRequest.isPOST) {
package net.pterodactylus.sone.web.pages
import net.pterodactylus.sone.data.Sone
+import net.pterodactylus.sone.main.*
import net.pterodactylus.sone.text.TextFilter
import net.pterodactylus.sone.utils.asOptional
import net.pterodactylus.sone.utils.isPOST
/**
* This page lets the user create a new [Post].
*/
-class CreatePostPage @Inject constructor(template: Template, webInterface: WebInterface):
- LoggedInPage("createPost.html", template, "Page.CreatePost.Title", webInterface) {
+class CreatePostPage @Inject constructor(template: Template, webInterface: WebInterface, loaders: Loaders):
+ LoggedInPage("createPost.html", template, "Page.CreatePost.Title", webInterface, loaders) {
override fun handleRequest(soneRequest: SoneRequest, currentSone: Sone, templateContext: TemplateContext) {
val returnPage = soneRequest.httpRequest.getPartAsStringFailsafe("returnPage", 256)
package net.pterodactylus.sone.web.pages
import net.pterodactylus.sone.data.Sone
+import net.pterodactylus.sone.main.*
import net.pterodactylus.sone.text.TextFilter
import net.pterodactylus.sone.utils.isPOST
import net.pterodactylus.sone.web.WebInterface
/**
* This page lets the user post a reply to a post.
*/
-class CreateReplyPage @Inject constructor(template: Template, webInterface: WebInterface):
- LoggedInPage("createReply.html", template, "Page.CreateReply.Title", webInterface) {
+class CreateReplyPage @Inject constructor(template: Template, webInterface: WebInterface, loaders: Loaders):
+ LoggedInPage("createReply.html", template, "Page.CreateReply.Title", webInterface, loaders) {
override fun handleRequest(soneRequest: SoneRequest, currentSone: Sone, templateContext: TemplateContext) {
val postId = soneRequest.httpRequest.getPartAsStringFailsafe("post", 36).apply { templateContext["postId"] = this }
import freenet.clients.http.ToadletContext
import net.pterodactylus.sone.data.Sone
+import net.pterodactylus.sone.main.*
import net.pterodactylus.sone.utils.isPOST
import net.pterodactylus.sone.web.WebInterface
import net.pterodactylus.sone.web.page.*
* The “create Sone” page lets the user create a new Sone.
*/
@MenuName("CreateSone")
-class CreateSonePage @Inject constructor(template: Template, webInterface: WebInterface):
- SoneTemplatePage("createSone.html", webInterface, template, "Page.CreateSone.Title") {
+class CreateSonePage @Inject constructor(template: Template, webInterface: WebInterface, loaders: Loaders):
+ SoneTemplatePage("createSone.html", webInterface, loaders, template = template, pageTitleKey = "Page.CreateSone.Title") {
private val logger = Logger.getLogger(CreateSonePage::class.java.name)
package net.pterodactylus.sone.web.pages
import net.pterodactylus.sone.data.Sone
+import net.pterodactylus.sone.main.*
import net.pterodactylus.sone.utils.isPOST
import net.pterodactylus.sone.web.WebInterface
import net.pterodactylus.sone.web.page.*
/**
* Page that lets the user delete an {@link Album}.
*/
-class DeleteAlbumPage @Inject constructor(template: Template, webInterface: WebInterface):
- LoggedInPage("deleteAlbum.html", template, "Page.DeleteAlbum.Title", webInterface) {
+class DeleteAlbumPage @Inject constructor(template: Template, webInterface: WebInterface, loaders: Loaders):
+ LoggedInPage("deleteAlbum.html", template, "Page.DeleteAlbum.Title", webInterface, loaders) {
override fun handleRequest(soneRequest: SoneRequest, currentSone: Sone, templateContext: TemplateContext) {
if (soneRequest.isPOST) {
package net.pterodactylus.sone.web.pages
import net.pterodactylus.sone.data.Sone
+import net.pterodactylus.sone.main.*
import net.pterodactylus.sone.utils.isPOST
import net.pterodactylus.sone.web.WebInterface
import net.pterodactylus.sone.web.page.*
/**
* Page that lets the user delete an {@link Image}.
*/
-class DeleteImagePage @Inject constructor(template: Template, webInterface: WebInterface):
- LoggedInPage("deleteImage.html", template, "Page.DeleteImage.Title", webInterface) {
+class DeleteImagePage @Inject constructor(template: Template, webInterface: WebInterface, loaders: Loaders):
+ LoggedInPage("deleteImage.html", template, "Page.DeleteImage.Title", webInterface, loaders) {
override fun handleRequest(soneRequest: SoneRequest, currentSone: Sone, templateContext: TemplateContext) {
if (soneRequest.isPOST) {
package net.pterodactylus.sone.web.pages
import net.pterodactylus.sone.data.Sone
+import net.pterodactylus.sone.main.*
import net.pterodactylus.sone.utils.isPOST
import net.pterodactylus.sone.web.WebInterface
import net.pterodactylus.sone.web.page.*
/**
* Lets the user delete a post they made.
*/
-class DeletePostPage @Inject constructor(template: Template, webInterface: WebInterface):
- LoggedInPage("deletePost.html", template, "Page.DeletePost.Title", webInterface) {
+class DeletePostPage @Inject constructor(template: Template, webInterface: WebInterface, loaders: Loaders):
+ LoggedInPage("deletePost.html", template, "Page.DeletePost.Title", webInterface, loaders) {
override fun handleRequest(soneRequest: SoneRequest, currentSone: Sone, templateContext: TemplateContext) {
if (soneRequest.isPOST) {
package net.pterodactylus.sone.web.pages
import net.pterodactylus.sone.data.Sone
+import net.pterodactylus.sone.main.*
import net.pterodactylus.sone.utils.isPOST
import net.pterodactylus.sone.web.WebInterface
import net.pterodactylus.sone.web.page.*
/**
* Page that lets the user confirm the deletion of a profile field.
*/
-class DeleteProfileFieldPage @Inject constructor(template: Template, webInterface: WebInterface):
- LoggedInPage("deleteProfileField.html", template, "Page.DeleteProfileField.Title", webInterface) {
+class DeleteProfileFieldPage @Inject constructor(template: Template, webInterface: WebInterface, loaders: Loaders):
+ LoggedInPage("deleteProfileField.html", template, "Page.DeleteProfileField.Title", webInterface, loaders) {
override fun handleRequest(soneRequest: SoneRequest, currentSone: Sone, templateContext: TemplateContext) {
if (soneRequest.isPOST) {
package net.pterodactylus.sone.web.pages
import net.pterodactylus.sone.data.Sone
+import net.pterodactylus.sone.main.*
import net.pterodactylus.sone.utils.isPOST
import net.pterodactylus.sone.web.WebInterface
import net.pterodactylus.sone.web.page.*
/**
* This page lets the user delete a reply.
*/
-class DeleteReplyPage @Inject constructor(template: Template, webInterface: WebInterface):
- LoggedInPage("deleteReply.html", template, "Page.DeleteReply.Title", webInterface) {
+class DeleteReplyPage @Inject constructor(template: Template, webInterface: WebInterface, loaders: Loaders):
+ LoggedInPage("deleteReply.html", template, "Page.DeleteReply.Title", webInterface, loaders) {
override fun handleRequest(soneRequest: SoneRequest, currentSone: Sone, templateContext: TemplateContext) {
if (soneRequest.isPOST) {
package net.pterodactylus.sone.web.pages
import net.pterodactylus.sone.data.Sone
+import net.pterodactylus.sone.main.*
import net.pterodactylus.sone.utils.isPOST
import net.pterodactylus.sone.web.WebInterface
import net.pterodactylus.sone.web.page.*
* installation.
*/
@MenuName("DeleteSone")
-class DeleteSonePage @Inject constructor(template: Template, webInterface: WebInterface):
- LoggedInPage("deleteSone.html", template, "Page.DeleteSone.Title", webInterface) {
+class DeleteSonePage @Inject constructor(template: Template, webInterface: WebInterface, loaders: Loaders):
+ LoggedInPage("deleteSone.html", template, "Page.DeleteSone.Title", webInterface, loaders) {
override fun handleRequest(soneRequest: SoneRequest, currentSone: Sone, templateContext: TemplateContext) {
if (soneRequest.isPOST) {
package net.pterodactylus.sone.web.pages
+import net.pterodactylus.sone.main.*
import net.pterodactylus.sone.web.WebInterface
import net.pterodactylus.sone.web.page.*
import net.pterodactylus.util.template.Template
/**
* Page that lets the user dismiss a notification.
*/
-class DismissNotificationPage @Inject constructor(template: Template, webInterface: WebInterface):
- SoneTemplatePage("dismissNotification.html", webInterface, template, "Page.DismissNotification.Title") {
+class DismissNotificationPage @Inject constructor(template: Template, webInterface: WebInterface, loaders: Loaders):
+ SoneTemplatePage("dismissNotification.html", webInterface, loaders, template = template, pageTitleKey = "Page.DismissNotification.Title") {
override fun handleRequest(soneRequest: SoneRequest, templateContext: TemplateContext) {
val returnPage = soneRequest.httpRequest.getPartAsStringFailsafe("returnPage", 256)
package net.pterodactylus.sone.web.pages
import net.pterodactylus.sone.data.Sone
+import net.pterodactylus.sone.main.*
import net.pterodactylus.sone.utils.isPOST
import net.pterodactylus.sone.web.WebInterface
import net.pterodactylus.sone.web.page.*
*
* @see net.pterodactylus.sone.core.Core#distrustSone(Sone, Sone)
*/
-class DistrustPage @Inject constructor(template: Template, webInterface: WebInterface):
- LoggedInPage("distrust.html", template, "Page.Distrust.Title", webInterface) {
+class DistrustPage @Inject constructor(template: Template, webInterface: WebInterface, loaders: Loaders):
+ LoggedInPage("distrust.html", template, "Page.Distrust.Title", webInterface, loaders) {
override fun handleRequest(soneRequest: SoneRequest, currentSone: Sone, templateContext: TemplateContext) {
if (soneRequest.isPOST) {
import net.pterodactylus.sone.data.Album.Modifier.AlbumTitleMustNotBeEmpty
import net.pterodactylus.sone.data.Sone
+import net.pterodactylus.sone.main.*
import net.pterodactylus.sone.utils.isPOST
import net.pterodactylus.sone.web.WebInterface
import net.pterodactylus.sone.web.page.*
/**
* Page that lets the user edit the name and description of an album.
*/
-class EditAlbumPage @Inject constructor(template: Template, webInterface: WebInterface):
- LoggedInPage("editAlbum.html", template, "Page.EditAlbum.Title", webInterface) {
+class EditAlbumPage @Inject constructor(template: Template, webInterface: WebInterface, loaders: Loaders):
+ LoggedInPage("editAlbum.html", template, "Page.EditAlbum.Title", webInterface, loaders) {
override fun handleRequest(soneRequest: SoneRequest, currentSone: Sone, templateContext: TemplateContext) {
if (soneRequest.isPOST) {
import net.pterodactylus.sone.data.Image.Modifier.ImageTitleMustNotBeEmpty
import net.pterodactylus.sone.data.Sone
+import net.pterodactylus.sone.main.*
import net.pterodactylus.sone.text.TextFilter
import net.pterodactylus.sone.utils.isPOST
import net.pterodactylus.sone.web.WebInterface
/**
* Page that lets the user edit title and description of an {@link Image}.
*/
-class EditImagePage @Inject constructor(template: Template, webInterface: WebInterface):
- LoggedInPage("editImage.html", template, "Page.EditImage.Title", webInterface) {
+class EditImagePage @Inject constructor(template: Template, webInterface: WebInterface, loaders: Loaders):
+ LoggedInPage("editImage.html", template, "Page.EditImage.Title", webInterface, loaders) {
override fun handleRequest(soneRequest: SoneRequest, currentSone: Sone, templateContext: TemplateContext) {
if (soneRequest.isPOST) {
package net.pterodactylus.sone.web.pages
import net.pterodactylus.sone.data.Sone
+import net.pterodactylus.sone.main.*
import net.pterodactylus.sone.utils.isPOST
import net.pterodactylus.sone.web.WebInterface
import net.pterodactylus.sone.web.page.*
/**
* Page that lets the user edit the name of a profile field.
*/
-class EditProfileFieldPage @Inject constructor(template: Template, webInterface: WebInterface) :
- LoggedInPage("editProfileField.html", template, "Page.EditProfileField.Title", webInterface) {
+class EditProfileFieldPage @Inject constructor(template: Template, webInterface: WebInterface, loaders: Loaders) :
+ LoggedInPage("editProfileField.html", template, "Page.EditProfileField.Title", webInterface, loaders) {
override fun handleRequest(soneRequest: SoneRequest, currentSone: Sone, templateContext: TemplateContext) {
currentSone.profile.let { profile ->
import net.pterodactylus.sone.data.Profile.DuplicateField
import net.pterodactylus.sone.data.Sone
+import net.pterodactylus.sone.main.*
import net.pterodactylus.sone.text.TextFilter
import net.pterodactylus.sone.utils.isPOST
import net.pterodactylus.sone.web.WebInterface
* This page lets the user edit her profile.
*/
@MenuName("EditProfile")
-class EditProfilePage @Inject constructor(template: Template, webInterface: WebInterface) :
- LoggedInPage("editProfile.html", template, "Page.EditProfile.Title", webInterface) {
+class EditProfilePage @Inject constructor(template: Template, webInterface: WebInterface, loaders: Loaders) :
+ LoggedInPage("editProfile.html", template, "Page.EditProfile.Title", webInterface, loaders) {
override fun handleRequest(soneRequest: SoneRequest, currentSone: Sone, templateContext: TemplateContext) {
currentSone.profile.let { profile ->
package net.pterodactylus.sone.web.pages
import net.pterodactylus.sone.data.Sone
+import net.pterodactylus.sone.main.*
import net.pterodactylus.sone.utils.isPOST
import net.pterodactylus.sone.web.WebInterface
import net.pterodactylus.sone.web.page.*
/**
* This page lets the user follow another Sone.
*/
-class FollowSonePage @Inject constructor(template: Template, webInterface: WebInterface):
- LoggedInPage("followSone.html", template, "Page.FollowSone.Title", webInterface) {
+class FollowSonePage @Inject constructor(template: Template, webInterface: WebInterface, loaders: Loaders):
+ LoggedInPage("followSone.html", template, "Page.FollowSone.Title", webInterface, loaders) {
override fun handleRequest(soneRequest: SoneRequest, currentSone: Sone, templateContext: TemplateContext) {
if (soneRequest.isPOST) {
import net.pterodactylus.sone.data.Album
import net.pterodactylus.sone.data.Sone
+import net.pterodactylus.sone.main.*
import net.pterodactylus.sone.utils.paginate
import net.pterodactylus.sone.utils.parameters
import net.pterodactylus.sone.web.WebInterface
* The image browser page is the entry page for the image management.
*/
@MenuName("ImageBrowser")
-class ImageBrowserPage @Inject constructor(template: Template, webInterface: WebInterface):
- LoggedInPage("imageBrowser.html", template, "Page.ImageBrowser.Title", webInterface) {
+class ImageBrowserPage @Inject constructor(template: Template, webInterface: WebInterface, loaders: Loaders):
+ LoggedInPage("imageBrowser.html", template, "Page.ImageBrowser.Title", webInterface, loaders) {
override fun handleRequest(soneRequest: SoneRequest, currentSone: Sone, templateContext: TemplateContext) {
if ("album" in soneRequest.parameters) {
package net.pterodactylus.sone.web.pages
import net.pterodactylus.sone.data.Sone
+import net.pterodactylus.sone.main.*
import net.pterodactylus.sone.notify.PostVisibilityFilter
import net.pterodactylus.sone.utils.paginate
import net.pterodactylus.sone.utils.parameters
* of all friends of the current user.
*/
@MenuName("Index")
-class IndexPage @Inject constructor(template: Template, webInterface: WebInterface, private val postVisibilityFilter: PostVisibilityFilter) :
- LoggedInPage("index.html", template, "Page.Index.Title", webInterface) {
+class IndexPage @Inject constructor(template: Template, webInterface: WebInterface, loaders: Loaders, private val postVisibilityFilter: PostVisibilityFilter) :
+ LoggedInPage("index.html", template, "Page.Index.Title", webInterface, loaders) {
override fun handleRequest(soneRequest: SoneRequest, currentSone: Sone, templateContext: TemplateContext) {
(currentSone.posts +
package net.pterodactylus.sone.web.pages
import net.pterodactylus.sone.data.Sone
+import net.pterodactylus.sone.main.*
import net.pterodactylus.sone.utils.paginate
import net.pterodactylus.sone.utils.parameters
import net.pterodactylus.sone.web.WebInterface
* This page shows all known Sones.
*/
@MenuName("KnownSones")
-class KnownSonesPage @Inject constructor(template: Template, webInterface: WebInterface):
- SoneTemplatePage("knownSones.html", webInterface, template, "Page.KnownSones.Title") {
+class KnownSonesPage @Inject constructor(template: Template, webInterface: WebInterface, loaders: Loaders):
+ SoneTemplatePage("knownSones.html", webInterface, loaders, template = template, pageTitleKey = "Page.KnownSones.Title") {
override fun handleRequest(soneRequest: SoneRequest, templateContext: TemplateContext) {
getCurrentSone(soneRequest.toadletContext).let { currentSone ->
package net.pterodactylus.sone.web.pages
import net.pterodactylus.sone.data.Sone
+import net.pterodactylus.sone.main.*
import net.pterodactylus.sone.utils.isPOST
import net.pterodactylus.sone.utils.parameters
import net.pterodactylus.sone.web.WebInterface
/**
* 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) :
- LoggedInPage("like.html", template, "Page.Like.Title", webInterface) {
+class LikePage @Inject constructor(template: Template, webInterface: WebInterface, loaders: Loaders) :
+ LoggedInPage("like.html", template, "Page.Like.Title", webInterface, loaders) {
override fun handleRequest(soneRequest: SoneRequest, currentSone: Sone, templateContext: TemplateContext) {
if (soneRequest.isPOST) {
package net.pterodactylus.sone.web.pages
+import net.pterodactylus.sone.main.*
import net.pterodactylus.sone.utils.parameters
import net.pterodactylus.sone.web.WebInterface
import net.pterodactylus.sone.web.page.*
/**
* 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):
- SoneTemplatePage("lockSone.html", webInterface, template, "Page.LockSone.Title") {
+class LockSonePage @Inject constructor(template: Template, webInterface: WebInterface, loaders: Loaders):
+ SoneTemplatePage("lockSone.html", webInterface, loaders, template = template, pageTitleKey = "Page.LockSone.Title") {
override fun handleRequest(soneRequest: SoneRequest, templateContext: TemplateContext) {
soneRequest.parameters["returnPage", 256]!!.let { returnPage ->
package net.pterodactylus.sone.web.pages
import net.pterodactylus.sone.data.Sone
+import net.pterodactylus.sone.main.*
import net.pterodactylus.sone.web.WebInterface
import net.pterodactylus.sone.web.page.*
import net.pterodactylus.util.template.Template
/**
* Base class for [SoneTemplatePage] implementations that require a logged in user.
*/
-abstract class LoggedInPage(path: String, template: Template, pageTitleKey: String, webInterface: WebInterface) :
- SoneTemplatePage(path, webInterface, template, pageTitleKey, true) {
+abstract class LoggedInPage(path: String, template: Template, pageTitleKey: String, webInterface: WebInterface, loaders: Loaders) :
+ SoneTemplatePage(path, webInterface, loaders, template = template, pageTitleKey = pageTitleKey, requiresLogin = true) {
final override fun handleRequest(soneRequest: SoneRequest, templateContext: TemplateContext) {
handleRequest(soneRequest, getCurrentSone(soneRequest.toadletContext, false)!!, templateContext)
import freenet.clients.http.ToadletContext
import net.pterodactylus.sone.data.Sone
+import net.pterodactylus.sone.main.*
import net.pterodactylus.sone.utils.emptyToNull
import net.pterodactylus.sone.utils.isPOST
import net.pterodactylus.sone.web.WebInterface
* The login page lets the user log in.
*/
@MenuName("Login")
-class LoginPage @Inject constructor(template: Template, webInterface: WebInterface):
- SoneTemplatePage("login.html", webInterface, template, "Page.Login.Title") {
+class LoginPage @Inject constructor(template: Template, webInterface: WebInterface, loaders: Loaders):
+ SoneTemplatePage("login.html", webInterface, loaders, template = template, pageTitleKey = "Page.Login.Title") {
override fun handleRequest(soneRequest: SoneRequest, templateContext: TemplateContext) {
if (soneRequest.isPOST) {
import freenet.clients.http.ToadletContext
import net.pterodactylus.sone.data.Sone
+import net.pterodactylus.sone.main.*
import net.pterodactylus.sone.web.WebInterface
import net.pterodactylus.sone.web.page.*
import net.pterodactylus.util.template.Template
* Logs a user out.
*/
@MenuName("Logout")
-class LogoutPage @Inject constructor(template: Template, webInterface: WebInterface):
- LoggedInPage("logout.html", template, "Page.Logout.Title", webInterface) {
+class LogoutPage @Inject constructor(template: Template, webInterface: WebInterface, loaders: Loaders):
+ LoggedInPage("logout.html", template, "Page.Logout.Title", webInterface, loaders) {
override fun handleRequest(soneRequest: SoneRequest, currentSone: Sone, templateContext: TemplateContext) {
setCurrentSone(soneRequest.toadletContext, null)
package net.pterodactylus.sone.web.pages
import net.pterodactylus.sone.data.*
+import net.pterodactylus.sone.main.*
import net.pterodactylus.sone.utils.*
import net.pterodactylus.sone.web.*
import net.pterodactylus.sone.web.page.*
* 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):
- SoneTemplatePage("markAsKnown.html", webInterface, template, "Page.MarkAsKnown.Title") {
+class MarkAsKnownPage @Inject constructor(template: Template, webInterface: WebInterface, loaders: Loaders):
+ SoneTemplatePage("markAsKnown.html", webInterface, loaders, template = template, pageTitleKey = "Page.MarkAsKnown.Title") {
override fun handleRequest(soneRequest: SoneRequest, templateContext: TemplateContext) {
val ids = soneRequest.parameters["id", 65536]!!.split(" ")
package net.pterodactylus.sone.web.pages
+import net.pterodactylus.sone.main.*
import net.pterodactylus.sone.utils.mapPresent
import net.pterodactylus.sone.utils.paginate
import net.pterodactylus.sone.utils.parameters
* [PostVisibilityFilter.isPostVisible(Sone, Post)] and sorted by time.
*/
@MenuName("New")
-class NewPage @Inject constructor( template: Template, webInterface: WebInterface):
- SoneTemplatePage("new.html", webInterface, template, "Page.New.Title") {
+class NewPage @Inject constructor( template: Template, webInterface: WebInterface, loaders: Loaders):
+ SoneTemplatePage("new.html", webInterface, loaders, template = template, pageTitleKey = "Page.New.Title") {
override fun handleRequest(soneRequest: SoneRequest, templateContext: TemplateContext) =
getCurrentSone(soneRequest.toadletContext).let { currentSone ->
import net.pterodactylus.sone.core.Preferences
import net.pterodactylus.sone.data.SoneOptions.LoadExternalContent
import net.pterodactylus.sone.fcp.FcpInterface.FullAccessRequired
+import net.pterodactylus.sone.main.*
import net.pterodactylus.sone.utils.emptyToNull
import net.pterodactylus.sone.utils.isPOST
import net.pterodactylus.sone.utils.parameters
* This page lets the user edit the options of the Sone plugin.
*/
@MenuName("Options")
-class OptionsPage @Inject constructor(template: Template, webInterface: WebInterface):
- SoneTemplatePage("options.html", webInterface, template, "Page.Options.Title") {
+class OptionsPage @Inject constructor(template: Template, webInterface: WebInterface, loaders: Loaders):
+ SoneTemplatePage("options.html", webInterface, loaders, template = template, pageTitleKey = "Page.Options.Title") {
override fun handleRequest(soneRequest: SoneRequest, templateContext: TemplateContext) {
if (soneRequest.isPOST) {
package net.pterodactylus.sone.web.pages
import net.pterodactylus.sone.data.Sone
+import net.pterodactylus.sone.main.*
import net.pterodactylus.sone.utils.isPOST
import net.pterodactylus.sone.utils.parameters
import net.pterodactylus.sone.web.WebInterface
* Page that lets the user control the rescue mode for a Sone.
*/
@MenuName("Rescue")
-class RescuePage @Inject constructor(template: Template, webInterface: WebInterface):
- LoggedInPage("rescue.html", template, "Page.Rescue.Title", webInterface) {
+class RescuePage @Inject constructor(template: Template, webInterface: WebInterface, loaders: Loaders):
+ LoggedInPage("rescue.html", template, "Page.Rescue.Title", webInterface, loaders) {
override fun handleRequest(soneRequest: SoneRequest, currentSone: Sone, templateContext: TemplateContext) {
val soneRescuer = soneRequest.core.getSoneRescuer(currentSone)
import net.pterodactylus.sone.data.Post
import net.pterodactylus.sone.data.PostReply
import net.pterodactylus.sone.data.Sone
+import net.pterodactylus.sone.main.*
import net.pterodactylus.sone.utils.Pagination
import net.pterodactylus.sone.utils.emptyToNull
import net.pterodactylus.sone.utils.memoize
* This page lets the user search for posts and replies that contain certain
* words.
*/
-class SearchPage(template: Template, webInterface: WebInterface, ticker: Ticker = Ticker.systemTicker()) :
- SoneTemplatePage("search.html", webInterface, template, "Page.Search.Title") {
+class SearchPage(template: Template, webInterface: WebInterface, loaders: Loaders, ticker: Ticker = Ticker.systemTicker()) :
+ SoneTemplatePage("search.html", webInterface, loaders, template = template, pageTitleKey = "Page.Search.Title") {
- @Inject constructor(template: Template, webInterface: WebInterface) :
- this(template, webInterface, Ticker.systemTicker())
+ @Inject constructor(template: Template, webInterface: WebInterface, loaders: Loaders) :
+ this(template, webInterface, loaders, Ticker.systemTicker())
private val cache: Cache<Iterable<Phrase>, Pagination<Post>> = CacheBuilder.newBuilder().ticker(ticker).expireAfterAccess(5, MINUTES).build()
import freenet.clients.http.*
import net.pterodactylus.sone.data.Sone
-import net.pterodactylus.sone.main.SonePlugin
+import net.pterodactylus.sone.main.*
import net.pterodactylus.sone.utils.emptyToNull
import net.pterodactylus.sone.web.SessionProvider
import net.pterodactylus.sone.web.WebInterface
open class SoneTemplatePage @JvmOverloads constructor(
path: String,
private val webInterface: WebInterface,
+ loaders: Loaders,
template: Template,
private val pageTitleKey: String? = null,
private val requiresLogin: Boolean = false,
private val pageTitle: (FreenetRequest) -> String = { pageTitleKey?.let(webInterface.l10n::getString) ?: "" }
-) : FreenetTemplatePage(path, webInterface.templateContextFactory, template, "noPermission.html") {
+) : FreenetTemplatePage(path, webInterface.templateContextFactory, loaders, template, "noPermission.html") {
private val core = webInterface.core
private val sessionProvider: SessionProvider = webInterface
package net.pterodactylus.sone.web.pages
import net.pterodactylus.sone.data.Sone
+import net.pterodactylus.sone.main.*
import net.pterodactylus.sone.utils.isPOST
import net.pterodactylus.sone.utils.parameters
import net.pterodactylus.sone.web.WebInterface
* 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) :
- LoggedInPage("trust.html", template, "Page.Trust.Title", webInterface) {
+class TrustPage @Inject constructor(template: Template, webInterface: WebInterface, loaders: Loaders) :
+ LoggedInPage("trust.html", template, "Page.Trust.Title", webInterface, loaders) {
override fun handleRequest(soneRequest: SoneRequest, currentSone: Sone, templateContext: TemplateContext) {
if (soneRequest.isPOST) {
package net.pterodactylus.sone.web.pages
import net.pterodactylus.sone.data.*
+import net.pterodactylus.sone.main.*
import net.pterodactylus.sone.utils.*
import net.pterodactylus.sone.web.*
import net.pterodactylus.sone.web.page.*
/**
* Page that lets the user unbookmark a post.
*/
-class UnbookmarkPage @Inject constructor(template: Template, webInterface: WebInterface):
- SoneTemplatePage("unbookmark.html", webInterface, template, "Page.Unbookmark.Title") {
+class UnbookmarkPage @Inject constructor(template: Template, webInterface: WebInterface, loaders: Loaders):
+ SoneTemplatePage("unbookmark.html", webInterface, loaders, template = template, pageTitleKey = "Page.Unbookmark.Title") {
override fun handleRequest(soneRequest: SoneRequest, templateContext: TemplateContext) {
when {
package net.pterodactylus.sone.web.pages
import net.pterodactylus.sone.data.Sone
+import net.pterodactylus.sone.main.*
import net.pterodactylus.sone.utils.isPOST
import net.pterodactylus.sone.utils.parameters
import net.pterodactylus.sone.web.WebInterface
/**
* This page lets the user unfollow another Sone.
*/
-class UnfollowSonePage @Inject constructor(template: Template, webInterface: WebInterface) :
- LoggedInPage("unfollowSone.html", template, "Page.UnfollowSone.Title", webInterface) {
+class UnfollowSonePage @Inject constructor(template: Template, webInterface: WebInterface, loaders: Loaders) :
+ LoggedInPage("unfollowSone.html", template, "Page.UnfollowSone.Title", webInterface, loaders) {
override fun handleRequest(soneRequest: SoneRequest, currentSone: Sone, templateContext: TemplateContext) {
if (soneRequest.isPOST) {
package net.pterodactylus.sone.web.pages
import net.pterodactylus.sone.data.Sone
+import net.pterodactylus.sone.main.*
import net.pterodactylus.sone.utils.isPOST
import net.pterodactylus.sone.utils.parameters
import net.pterodactylus.sone.web.WebInterface
/**
* 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):
- LoggedInPage("unlike.html", template, "Page.Unlike.Title", webInterface) {
+class UnlikePage @Inject constructor(template: Template, webInterface: WebInterface, loaders: Loaders):
+ LoggedInPage("unlike.html", template, "Page.Unlike.Title", webInterface, loaders) {
override fun handleRequest(soneRequest: SoneRequest, currentSone: Sone, templateContext: TemplateContext) {
if (soneRequest.isPOST) {
package net.pterodactylus.sone.web.pages
+import net.pterodactylus.sone.main.*
import net.pterodactylus.sone.utils.isPOST
import net.pterodactylus.sone.utils.parameters
import net.pterodactylus.sone.web.WebInterface
/**
* This page lets the user unlock a [net.pterodactylus.sone.data.Sone] to allow its insertion.
*/
-class UnlockSonePage @Inject constructor(template: Template, webInterface: WebInterface):
- SoneTemplatePage("unlockSone.html", webInterface, template, "Page.UnlockSone.Title") {
+class UnlockSonePage @Inject constructor(template: Template, webInterface: WebInterface, loaders: Loaders):
+ SoneTemplatePage("unlockSone.html", webInterface, loaders, template = template, pageTitleKey = "Page.UnlockSone.Title") {
override fun handleRequest(soneRequest: SoneRequest, templateContext: TemplateContext) {
if (soneRequest.isPOST) {
package net.pterodactylus.sone.web.pages
import net.pterodactylus.sone.data.Sone
+import net.pterodactylus.sone.main.*
import net.pterodactylus.sone.utils.isPOST
import net.pterodactylus.sone.utils.parameters
import net.pterodactylus.sone.web.WebInterface
* 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) :
- LoggedInPage("untrust.html", template, "Page.Untrust.Title", webInterface) {
+class UntrustPage @Inject constructor(template: Template, webInterface: WebInterface, loaders: Loaders) :
+ LoggedInPage("untrust.html", template, "Page.Untrust.Title", webInterface, loaders) {
override fun handleRequest(soneRequest: SoneRequest, currentSone: Sone, templateContext: TemplateContext) {
if (soneRequest.isPOST) {
import freenet.support.api.Bucket
import net.pterodactylus.sone.data.Sone
+import net.pterodactylus.sone.main.*
import net.pterodactylus.sone.text.TextFilter
import net.pterodactylus.sone.utils.emptyToNull
import net.pterodactylus.sone.utils.headers
/**
* Page implementation that lets the user upload an image.
*/
-class UploadImagePage @Inject constructor(template: Template, webInterface: WebInterface):
- LoggedInPage("uploadImage.html", template, "Page.UploadImage.Title", webInterface) {
+class UploadImagePage @Inject constructor(template: Template, webInterface: WebInterface, loaders: Loaders):
+ LoggedInPage("uploadImage.html", template, "Page.UploadImage.Title", webInterface, loaders) {
override fun handleRequest(soneRequest: SoneRequest, currentSone: Sone, templateContext: TemplateContext) {
if (soneRequest.isPOST) {
package net.pterodactylus.sone.web.pages
+import net.pterodactylus.sone.main.*
import net.pterodactylus.sone.template.*
import net.pterodactylus.sone.utils.*
import net.pterodactylus.sone.web.*
/**
* This page lets the user view a post and all its replies.
*/
-class ViewPostPage @Inject constructor(template: Template, webInterface: WebInterface):
- SoneTemplatePage("viewPost.html", webInterface, template, "Page.ViewPost.Title") {
+class ViewPostPage @Inject constructor(template: Template, webInterface: WebInterface, loaders: Loaders):
+ SoneTemplatePage("viewPost.html", webInterface, loaders, template = template, pageTitleKey = "Page.ViewPost.Title") {
override fun handleRequest(soneRequest: SoneRequest, templateContext: TemplateContext) {
templateContext["post"] = soneRequest.parameters["post"]?.let(soneRequest.core::getPost)
import net.pterodactylus.sone.data.Post
import net.pterodactylus.sone.data.PostReply
+import net.pterodactylus.sone.main.*
import net.pterodactylus.sone.template.SoneAccessor
import net.pterodactylus.sone.utils.mapPresent
import net.pterodactylus.sone.utils.paginate
/**
* Lets the user browser another Sone.
*/
-class ViewSonePage @Inject constructor(template: Template, webInterface: WebInterface):
- SoneTemplatePage("viewSone.html", webInterface, template) {
+class ViewSonePage @Inject constructor(template: Template, webInterface: WebInterface, loaders: Loaders):
+ SoneTemplatePage("viewSone.html", webInterface, loaders, template = template) {
override fun handleRequest(soneRequest: SoneRequest, templateContext: TemplateContext) {
templateContext["soneId"] = soneRequest.parameters["sone"]
class FreenetTemplatePageTest {
- private val page = FreenetTemplatePage("/test/path", null, null, "invalid-form-password")
+ private val page = FreenetTemplatePage("/test/path", null, null, null, "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", null, null, null) {
+ val page = object : FreenetTemplatePage("/test/path", null, null, null, null) {
override fun 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", null, null, null) {
+ val page = object : FreenetTemplatePage("/test/path", null, null, null, null) {
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", null, null, null) {
+ val page = object : FreenetTemplatePage("/test/path", null, null, null, null) {
override fun isFullAccessOnly() = true
}
val request = deepMock<FreenetRequest>()
/**
* Unit test for [AboutPage].
*/
-class AboutPageTest : WebPageTest({ template, webInterface -> AboutPage(template, webInterface, PluginVersion(version), PluginYear(year), PluginHomepage(homepage)) }) {
+class AboutPageTest : WebPageTest({ template, webInterface, loaders -> AboutPage(template, webInterface, loaders, PluginVersion(version), PluginYear(year), PluginHomepage(homepage)) }) {
companion object {
private const val version = "0.1.2"
/**
* Unit test for [IndexPage].
*/
-class IndexPageTest: WebPageTest({ template, webInterface -> IndexPage(template, webInterface, postVisibilityFilter) }) {
+class IndexPageTest: WebPageTest({ template, webInterface, loaders -> IndexPage(template, webInterface, loaders, postVisibilityFilter) }) {
companion object {
private val postVisibilityFilter = mock<PostVisibilityFilter>()
/**
* Unit test for [SearchPage].
*/
-class SearchPageTest: WebPageTest({ template, webInterface -> SearchPage(template, webInterface, ticker) }) {
+class SearchPageTest: WebPageTest({ template, webInterface, loaders -> SearchPage(template, webInterface, loaders, ticker) }) {
companion object {
val ticker = mock<Ticker>()
/**
* Unit test for [SoneTemplatePage].
*/
-class SoneTemplatePageTest : WebPageTest({ template, webInterface -> object : SoneTemplatePage("path.html", webInterface, template, requiresLogin = true) {} }) {
+class SoneTemplatePageTest : WebPageTest({ template, webInterface, loaders -> object : SoneTemplatePage("path.html", webInterface, loaders, template = template, requiresLogin = true) {} }) {
init {
request("index.html")
@Test
fun `page title is empty string if no page title key was given`() {
- SoneTemplatePage("path.html", webInterface, template, requiresLogin = false).let { page ->
+ SoneTemplatePage("path.html", webInterface, loaders, template = template, 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, template, "page.title", false).let { page ->
+ SoneTemplatePage("path.html", webInterface, loaders, template = template, 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, template, requiresLogin = true) {
+ val page = object : SoneTemplatePage("path.html", webInterface, loaders, template = template, 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, template, requiresLogin = false)
+ val page = SoneTemplatePage("page.html", webInterface, loaders, template = template, 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, template, requiresLogin = false).let { page ->
+ SoneTemplatePage("path.html", webInterface, loaders, template = template, 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, template) {
+ val page = object : SoneTemplatePage("path.html", webInterface, loaders, template = template) {
override fun handleRequest(soneRequest: SoneRequest, templateContext: TemplateContext) {
called = true
}
import net.pterodactylus.sone.data.Sone
import net.pterodactylus.sone.data.TemporaryImage
import net.pterodactylus.sone.freenet.wot.OwnIdentity
+import net.pterodactylus.sone.main.*
import net.pterodactylus.sone.test.deepMock
import net.pterodactylus.sone.test.get
import net.pterodactylus.sone.test.mock
/**
* Base class for web page tests.
*/
-open class WebPageTest(pageSupplier: (Template, WebInterface) -> SoneTemplatePage = { _, _ -> mock() }) {
+open class WebPageTest(pageSupplier: (Template, WebInterface, Loaders) -> SoneTemplatePage = { _, _, _ -> mock() }) {
val currentSone = mock<Sone>()
+ val loaders = mock<Loaders>()
val template = mock<Template>()
val webInterface = deepMock<WebInterface>()
val core = webInterface.core
val l10n = webInterface.l10n!!
val sessionManager = mock<SessionManager>()
- val page by lazy { pageSupplier(template, webInterface) }
+ val page by lazy { pageSupplier(template, webInterface, loaders) }
val httpRequest = mock<HTTPRequest>()
val freenetRequest = mock<FreenetRequest>()