From: David ‘Bombe’ Roden Date: Tue, 5 Mar 2019 10:06:02 +0000 (+0100) Subject: ♻️ Turn plugin homepage into instance method X-Git-Tag: v79^2~83 X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=1adece79f07bd6ae78855c24e775661508a24e81;p=Sone.git ♻️ Turn plugin homepage into instance method --- diff --git a/src/main/java/net/pterodactylus/sone/core/UpdateChecker.java b/src/main/java/net/pterodactylus/sone/core/UpdateChecker.java index 2c2f121..9f6963f 100644 --- a/src/main/java/net/pterodactylus/sone/core/UpdateChecker.java +++ b/src/main/java/net/pterodactylus/sone/core/UpdateChecker.java @@ -31,6 +31,7 @@ import java.util.logging.Logger; import javax.inject.Singleton; import net.pterodactylus.sone.core.event.UpdateFoundEvent; +import net.pterodactylus.sone.main.PluginHomepage; import net.pterodactylus.sone.main.SonePlugin; import net.pterodactylus.util.io.Closer; import net.pterodactylus.util.version.Version; @@ -69,6 +70,8 @@ public class UpdateChecker { /** The release date of the latest version. */ private long latestVersionDate; + private final PluginHomepage pluginHomepage; + /** * Creates a new update checker. * @@ -78,11 +81,12 @@ public class UpdateChecker { * The freenet interface to use */ @Inject - public UpdateChecker(EventBus eventBus, FreenetInterface freenetInterface, Version currentVersion) { + public UpdateChecker(EventBus eventBus, FreenetInterface freenetInterface, Version currentVersion, PluginHomepage pluginHomepage) { this.eventBus = eventBus; this.freenetInterface = freenetInterface; this.currentRunningVersion = currentVersion; this.currentLatestVersion = currentVersion; + this.pluginHomepage = pluginHomepage; } // @@ -138,7 +142,7 @@ public class UpdateChecker { */ public void start() { try { - currentUri = new FreenetURI(SonePlugin.getHomepage()); + currentUri = new FreenetURI(pluginHomepage.getHomepage()); } catch (MalformedURLException mue1) { /* this can not really happen unless I screw up. */ logger.log(Level.SEVERE, "Sone Homepage URI invalid!", mue1); diff --git a/src/main/java/net/pterodactylus/sone/main/SonePlugin.java b/src/main/java/net/pterodactylus/sone/main/SonePlugin.java index 82a0217..f9bbe05 100644 --- a/src/main/java/net/pterodactylus/sone/main/SonePlugin.java +++ b/src/main/java/net/pterodactylus/sone/main/SonePlugin.java @@ -182,7 +182,7 @@ public class SonePlugin implements FredPlugin, FredPluginFCP, FredPluginL10n, Fr return YEAR; } - public static String getHomepage() { + public String getHomepage() { return SONE_HOMEPAGE + LATEST_EDITION; } diff --git a/src/main/java/net/pterodactylus/sone/web/WebInterface.java b/src/main/java/net/pterodactylus/sone/web/WebInterface.java index 92e5034..125f496 100644 --- a/src/main/java/net/pterodactylus/sone/web/WebInterface.java +++ b/src/main/java/net/pterodactylus/sone/web/WebInterface.java @@ -753,7 +753,7 @@ public class WebInterface implements SessionProvider { pageToadlets.add(pageToadletFactory.createPageToadlet(new LogoutPage(emptyTemplate, this), "Logout")); pageToadlets.add(pageToadletFactory.createPageToadlet(new OptionsPage(optionsTemplate, this), "Options")); pageToadlets.add(pageToadletFactory.createPageToadlet(new RescuePage(rescueTemplate, this), "Rescue")); - pageToadlets.add(pageToadletFactory.createPageToadlet(new AboutPage(aboutTemplate, this, new PluginVersion(SonePlugin.getPluginVersion()), new PluginYear(sonePlugin.getYear()), new PluginHomepage(SonePlugin.getHomepage())), "About")); + pageToadlets.add(pageToadletFactory.createPageToadlet(new AboutPage(aboutTemplate, this, new PluginVersion(SonePlugin.getPluginVersion()), new PluginYear(sonePlugin.getYear()), new PluginHomepage(sonePlugin.getHomepage())), "About")); pageToadlets.add(pageToadletFactory.createPageToadlet(new SoneTemplatePage("noPermission.html", this, noPermissionTemplate, "Page.NoPermission.Title"))); pageToadlets.add(pageToadletFactory.createPageToadlet(new SoneTemplatePage("emptyImageTitle.html", this, emptyImageTitleTemplate, "Page.EmptyImageTitle.Title"))); pageToadlets.add(pageToadletFactory.createPageToadlet(new SoneTemplatePage("emptyAlbumTitle.html", this, emptyAlbumTitleTemplate, "Page.EmptyAlbumTitle.Title"))); diff --git a/src/test/java/net/pterodactylus/sone/core/UpdateCheckerTest.java b/src/test/java/net/pterodactylus/sone/core/UpdateCheckerTest.java index 663b709..e7f1afe 100644 --- a/src/test/java/net/pterodactylus/sone/core/UpdateCheckerTest.java +++ b/src/test/java/net/pterodactylus/sone/core/UpdateCheckerTest.java @@ -18,6 +18,7 @@ import java.io.InputStream; import net.pterodactylus.sone.core.FreenetInterface.Callback; import net.pterodactylus.sone.core.event.UpdateFoundEvent; +import net.pterodactylus.sone.main.PluginHomepage; import net.pterodactylus.util.version.Version; import freenet.client.ClientMetadata; @@ -41,7 +42,8 @@ public class UpdateCheckerTest { private final EventBus eventBus = mock(EventBus.class); private final FreenetInterface freenetInterface = mock(FreenetInterface.class); private final Version currentVersion = new Version(1, 0, 0); - private final UpdateChecker updateChecker = new UpdateChecker(eventBus, freenetInterface, currentVersion); + private final PluginHomepage pluginHomepage = new PluginHomepage("KSK@homepage"); + private final UpdateChecker updateChecker = new UpdateChecker(eventBus, freenetInterface, currentVersion, pluginHomepage); @Before public void startUpdateChecker() {