import net.pterodactylus.sone.web.pages.EditImagePage;
import net.pterodactylus.sone.web.pages.EditProfileFieldPage;
import net.pterodactylus.sone.web.pages.EditProfilePage;
+import net.pterodactylus.sone.web.pages.EmptyAlbumTitlePage;
+import net.pterodactylus.sone.web.pages.EmptyImageTitlePage;
import net.pterodactylus.sone.web.pages.FollowSonePage;
import net.pterodactylus.sone.web.pages.GetImagePage;
import net.pterodactylus.sone.web.pages.ImageBrowserPage;
import net.pterodactylus.sone.web.pages.IndexPage;
+import net.pterodactylus.sone.web.pages.InvalidPage;
import net.pterodactylus.sone.web.pages.KnownSonesPage;
import net.pterodactylus.sone.web.pages.LikePage;
import net.pterodactylus.sone.web.pages.LockSonePage;
import net.pterodactylus.sone.web.pages.LogoutPage;
import net.pterodactylus.sone.web.pages.MarkAsKnownPage;
import net.pterodactylus.sone.web.pages.NewPage;
+import net.pterodactylus.sone.web.pages.NoPermissionPage;
import net.pterodactylus.sone.web.pages.OptionsPage;
import net.pterodactylus.sone.web.pages.RescuePage;
import net.pterodactylus.sone.web.pages.SearchPage;
Template createAlbumTemplate = loaders.loadTemplate("/templates/createAlbum.html");
Template deleteAlbumTemplate = loaders.loadTemplate("/templates/deleteAlbum.html");
Template deleteImageTemplate = loaders.loadTemplate("/templates/deleteImage.html");
- Template noPermissionTemplate = loaders.loadTemplate("/templates/noPermission.html");
- Template emptyImageTitleTemplate = loaders.loadTemplate("/templates/emptyImageTitle.html");
- Template emptyAlbumTitleTemplate = loaders.loadTemplate("/templates/emptyAlbumTitle.html");
Template optionsTemplate = loaders.loadTemplate("/templates/options.html");
Template rescueTemplate = loaders.loadTemplate("/templates/rescue.html");
Template aboutTemplate = loaders.loadTemplate("/templates/about.html");
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 SoneTemplatePage("noPermission.html", this, loaders, noPermissionTemplate, templateRenderer, "Page.NoPermission.Title"));
- pageToadletRegistry.addPage(new SoneTemplatePage("emptyImageTitle.html", this, loaders, emptyImageTitleTemplate, templateRenderer, "Page.EmptyImageTitle.Title"));
- pageToadletRegistry.addPage(new SoneTemplatePage("emptyAlbumTitle.html", this, loaders, emptyAlbumTitleTemplate, templateRenderer, "Page.EmptyAlbumTitle.Title"));
+ 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 SoneTemplatePage("invalid.html", this, loaders, invalidTemplate, templateRenderer, "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"));
--- /dev/null
+package net.pterodactylus.sone.web.pages
+
+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")
+
+@TemplatePath("/templates/noPermission.html")
+class NoPermissionPage(webInterface: WebInterface, loaders: Loaders, templateRenderer: TemplateRenderer) : SoneTemplatePage("noPermission.html", webInterface, loaders, Template(), 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")
+
+@TemplatePath("/templates/emptyAlbumTitle.html")
+class EmptyAlbumTitlePage(webInterface: WebInterface, loaders: Loaders, templateRenderer: TemplateRenderer) : SoneTemplatePage("emptyAlbumTitle.html", webInterface, loaders, Template(), templateRenderer, "Page.EmptyAlbumTitle.Title")
--- /dev/null
+package net.pterodactylus.sone.web.pages
+
+import net.pterodactylus.sone.main.*
+import net.pterodactylus.sone.web.*
+import net.pterodactylus.sone.web.page.*
+import org.hamcrest.MatcherAssert.*
+import org.hamcrest.Matchers.*
+import org.junit.*
+
+class ErrorPagesTest {
+
+ private val webPageTest = WebPageTest()
+
+ private fun testPage(page: (WebInterface, Loaders, TemplateRenderer) -> FreenetTemplatePage, test: (FreenetTemplatePage) -> Unit) =
+ with(webPageTest) {
+ test(page(webInterface, loaders, templateRenderer))
+ }
+
+ @Test
+ fun `invalid page returns correct path`() {
+ testPage(::InvalidPage) { page ->
+ assertThat(page.path, equalTo("invalid.html"))
+ }
+ }
+
+ @Test
+ fun `invalid page returns correct title`() {
+ testPage(::InvalidPage) { page ->
+ assertThat(page.getPageTitle(webPageTest.freenetRequest), equalTo("Page.Invalid.Title"))
+ }
+ }
+
+ @Test
+ fun `invalid page is annotated with correct template path`() {
+ testPage(::InvalidPage) { page ->
+ assertThat(page.templatePath, equalTo("/templates/invalid.html"))
+ }
+ }
+
+ @Test
+ fun `no permission page returns correct path`() {
+ testPage(::NoPermissionPage) { page ->
+ assertThat(page.path, equalTo("noPermission.html"))
+ }
+ }
+
+ @Test
+ fun `no permission page returns correct title`() {
+ testPage(::NoPermissionPage) { page ->
+ assertThat(page.getPageTitle(webPageTest.freenetRequest), equalTo("Page.NoPermission.Title"))
+ }
+ }
+
+ @Test
+ fun `no permission page is annotated with correct template path`() {
+ testPage(::NoPermissionPage) { page ->
+ assertThat(page.templatePath, equalTo("/templates/noPermission.html"))
+ }
+ }
+
+ @Test
+ fun `empty image title page returns correct path`() {
+ testPage(::EmptyImageTitlePage) { page ->
+ assertThat(page.path, equalTo("emptyImageTitle.html"))
+ }
+ }
+
+ @Test
+ fun `empty image title page returns correct page title`() {
+ testPage(::EmptyImageTitlePage) { page ->
+ assertThat(page.getPageTitle(webPageTest.freenetRequest), equalTo("Page.EmptyImageTitle.Title"))
+ }
+ }
+
+ @Test
+ fun `empty image title page is annotated with correct template path`() {
+ testPage(::EmptyImageTitlePage) { page ->
+ assertThat(page.templatePath, equalTo("/templates/emptyImageTitle.html"))
+ }
+ }
+
+ @Test
+ fun `empty album title page returns correct path`() {
+ testPage(::EmptyAlbumTitlePage) { page ->
+ assertThat(page.path, equalTo("emptyAlbumTitle.html"))
+ }
+ }
+
+ @Test
+ fun `empty album title page returns correct page title`() {
+ testPage(::EmptyAlbumTitlePage) { page ->
+ assertThat(page.getPageTitle(webPageTest.freenetRequest), equalTo("Page.EmptyAlbumTitle.Title"))
+ }
+ }
+
+ @Test
+ fun `empty album title page is annotated with correct template path`() {
+ testPage(::EmptyAlbumTitlePage) { page ->
+ assertThat(page.templatePath, equalTo("/templates/emptyAlbumTitle.html"))
+ }
+ }
+
+}