From 369ba7692f167e5b7f9a27898a06a5d7920904ed Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Sat, 13 Apr 2019 00:13:46 +0200 Subject: [PATCH] =?utf8?q?=F0=9F=8E=A8=20Replace=20FreenetPage=20with=20Ko?= =?utf8?q?tlin=20version?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../pterodactylus/sone/web/page/FreenetPage.java | 40 ---------------------- .../net/pterodactylus/sone/web/page/FreenetPage.kt | 27 +++++++++++++++ .../pterodactylus/sone/web/pages/GetImagePage.kt | 2 +- .../sone/web/pages/ImageBrowserPage.kt | 2 +- .../pterodactylus/sone/web/pages/ViewPostPage.kt | 2 +- .../pterodactylus/sone/web/pages/ViewSonePage.kt | 2 +- .../sone/web/pages/GetImagePageTest.kt | 3 +- .../sone/web/pages/ImageBrowserPageTest.kt | 3 +- .../sone/web/pages/ViewPostPageTest.kt | 3 +- .../sone/web/pages/ViewSonePageTest.kt | 3 +- 10 files changed, 39 insertions(+), 48 deletions(-) delete mode 100644 src/main/java/net/pterodactylus/sone/web/page/FreenetPage.java create mode 100644 src/main/kotlin/net/pterodactylus/sone/web/page/FreenetPage.kt diff --git a/src/main/java/net/pterodactylus/sone/web/page/FreenetPage.java b/src/main/java/net/pterodactylus/sone/web/page/FreenetPage.java deleted file mode 100644 index 8619f4c..0000000 --- a/src/main/java/net/pterodactylus/sone/web/page/FreenetPage.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Sone - FreenetPage.java - Copyright © 2011–2019 David Roden - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -package net.pterodactylus.sone.web.page; - -import java.net.URI; - -import net.pterodactylus.util.web.Page; - -/** - * Freenet-specific {@link Page} extension that adds the capability to allow a - * link to a page to be unharmed by Freenet’s content filter. - */ -public interface FreenetPage extends Page { - - /** - * Returns whether the given should be excepted from being filtered. - * - * @param link - * The link to check - * @return {@code true} if the link should not be filtered, {@code false} if - * it should be filtered - */ - public boolean isLinkExcepted(URI link); - -} diff --git a/src/main/kotlin/net/pterodactylus/sone/web/page/FreenetPage.kt b/src/main/kotlin/net/pterodactylus/sone/web/page/FreenetPage.kt new file mode 100644 index 0000000..23b398c --- /dev/null +++ b/src/main/kotlin/net/pterodactylus/sone/web/page/FreenetPage.kt @@ -0,0 +1,27 @@ +/* + * Sone - FreenetPage.java - Copyright © 2011–2019 David Roden + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package net.pterodactylus.sone.web.page + +import net.pterodactylus.util.web.* +import java.net.* + +interface FreenetPage : Page { + + fun isLinkExcepted(link: URI): Boolean + +} diff --git a/src/main/kotlin/net/pterodactylus/sone/web/pages/GetImagePage.kt b/src/main/kotlin/net/pterodactylus/sone/web/pages/GetImagePage.kt index 196b0b4..8778a61 100644 --- a/src/main/kotlin/net/pterodactylus/sone/web/pages/GetImagePage.kt +++ b/src/main/kotlin/net/pterodactylus/sone/web/pages/GetImagePage.kt @@ -36,7 +36,7 @@ class GetImagePage @Inject constructor(webInterface: WebInterface): FreenetPage } } - override fun isLinkExcepted(link: URI?): Boolean { + override fun isLinkExcepted(link: URI): Boolean { return false } diff --git a/src/main/kotlin/net/pterodactylus/sone/web/pages/ImageBrowserPage.kt b/src/main/kotlin/net/pterodactylus/sone/web/pages/ImageBrowserPage.kt index 6bbde00..84634fc 100644 --- a/src/main/kotlin/net/pterodactylus/sone/web/pages/ImageBrowserPage.kt +++ b/src/main/kotlin/net/pterodactylus/sone/web/pages/ImageBrowserPage.kt @@ -47,6 +47,6 @@ class ImageBrowserPage @Inject constructor(template: Template, webInterface: Web } } - override fun isLinkExcepted(link: URI?) = true + override fun isLinkExcepted(link: URI) = true } diff --git a/src/main/kotlin/net/pterodactylus/sone/web/pages/ViewPostPage.kt b/src/main/kotlin/net/pterodactylus/sone/web/pages/ViewPostPage.kt index 04a60b0..c6b0952 100644 --- a/src/main/kotlin/net/pterodactylus/sone/web/pages/ViewPostPage.kt +++ b/src/main/kotlin/net/pterodactylus/sone/web/pages/ViewPostPage.kt @@ -19,7 +19,7 @@ class ViewPostPage @Inject constructor(template: Template, webInterface: WebInte templateContext["raw"] = freenetRequest.parameters["raw"] == "true" } - override fun isLinkExcepted(link: URI?) = true + override fun isLinkExcepted(link: URI) = true override fun getPageTitle(freenetRequest: FreenetRequest) = (freenetRequest.parameters["post"]?.let(webInterface.core::getPost)?.let { diff --git a/src/main/kotlin/net/pterodactylus/sone/web/pages/ViewSonePage.kt b/src/main/kotlin/net/pterodactylus/sone/web/pages/ViewSonePage.kt index 145be72..027373f 100644 --- a/src/main/kotlin/net/pterodactylus/sone/web/pages/ViewSonePage.kt +++ b/src/main/kotlin/net/pterodactylus/sone/web/pages/ViewSonePage.kt @@ -48,7 +48,7 @@ class ViewSonePage @Inject constructor(template: Template, webInterface: WebInte } } - override fun isLinkExcepted(link: URI?) = true + override fun isLinkExcepted(link: URI) = true override fun getPageTitle(freenetRequest: FreenetRequest): String = freenetRequest.parameters["sone"]!!.let(webInterface.core::getSone)?.let { sone -> diff --git a/src/test/kotlin/net/pterodactylus/sone/web/pages/GetImagePageTest.kt b/src/test/kotlin/net/pterodactylus/sone/web/pages/GetImagePageTest.kt index ec0cd99..9de2c90 100644 --- a/src/test/kotlin/net/pterodactylus/sone/web/pages/GetImagePageTest.kt +++ b/src/test/kotlin/net/pterodactylus/sone/web/pages/GetImagePageTest.kt @@ -8,6 +8,7 @@ import org.hamcrest.Matchers.contains import org.hamcrest.Matchers.equalTo import org.hamcrest.Matchers.notNullValue import org.junit.Test +import java.net.* /** * Unit test for [GetImagePage]. @@ -32,7 +33,7 @@ class GetImagePageTest { @Test fun `page is not link-excepted`() { - assertThat(page.isLinkExcepted(null), equalTo(false)) + assertThat(page.isLinkExcepted(URI("")), equalTo(false)) } @Test diff --git a/src/test/kotlin/net/pterodactylus/sone/web/pages/ImageBrowserPageTest.kt b/src/test/kotlin/net/pterodactylus/sone/web/pages/ImageBrowserPageTest.kt index 0411030..c21adee 100644 --- a/src/test/kotlin/net/pterodactylus/sone/web/pages/ImageBrowserPageTest.kt +++ b/src/test/kotlin/net/pterodactylus/sone/web/pages/ImageBrowserPageTest.kt @@ -12,6 +12,7 @@ import org.hamcrest.Matchers.contains import org.hamcrest.Matchers.equalTo import org.hamcrest.Matchers.notNullValue import org.junit.Test +import java.net.* /** * Unit test for [ImageBrowserPage]. @@ -133,7 +134,7 @@ class ImageBrowserPageTest: WebPageTest(::ImageBrowserPage) { @Test fun `page is link-excepted`() { - assertThat(page.isLinkExcepted(null), equalTo(true)) + assertThat(page.isLinkExcepted(URI("")), equalTo(true)) } @Test diff --git a/src/test/kotlin/net/pterodactylus/sone/web/pages/ViewPostPageTest.kt b/src/test/kotlin/net/pterodactylus/sone/web/pages/ViewPostPageTest.kt index a4bd4b6..58b039a 100644 --- a/src/test/kotlin/net/pterodactylus/sone/web/pages/ViewPostPageTest.kt +++ b/src/test/kotlin/net/pterodactylus/sone/web/pages/ViewPostPageTest.kt @@ -11,6 +11,7 @@ import org.hamcrest.Matchers.equalTo import org.hamcrest.Matchers.notNullValue import org.hamcrest.Matchers.nullValue import org.junit.Test +import java.net.* /** * Unit test for [ViewPostPage]. @@ -31,7 +32,7 @@ class ViewPostPageTest: WebPageTest(::ViewPostPage) { @Test fun `the view post page is link-excepted`() { - assertThat(page.isLinkExcepted(null), equalTo(true)) + assertThat(page.isLinkExcepted(URI("")), equalTo(true)) } @Test diff --git a/src/test/kotlin/net/pterodactylus/sone/web/pages/ViewSonePageTest.kt b/src/test/kotlin/net/pterodactylus/sone/web/pages/ViewSonePageTest.kt index a8e59be..22cba9f 100644 --- a/src/test/kotlin/net/pterodactylus/sone/web/pages/ViewSonePageTest.kt +++ b/src/test/kotlin/net/pterodactylus/sone/web/pages/ViewSonePageTest.kt @@ -18,6 +18,7 @@ import org.hamcrest.Matchers.notNullValue import org.hamcrest.Matchers.nullValue import org.junit.Before import org.junit.Test +import java.net.* /** * Unit test for [ViewSonePage]. @@ -204,7 +205,7 @@ class ViewSonePageTest: WebPageTest(::ViewSonePage) { @Test fun `page is link-excepted`() { - assertThat(page.isLinkExcepted(null), equalTo(true)) + assertThat(page.isLinkExcepted(URI("")), equalTo(true)) } @Test -- 2.7.4