From 6916e15b5cf42461f7e49c787bf7d1f85c1de2ed Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Tue, 23 Jun 2015 06:45:35 +0200 Subject: [PATCH] Create link to homepage using the latest edition at time of release --- src/main/java/net/pterodactylus/sone/core/UpdateChecker.java | 8 +------- src/main/java/net/pterodactylus/sone/main/SonePlugin.java | 6 ++++++ src/main/java/net/pterodactylus/sone/web/AboutPage.java | 5 ++++- src/main/java/net/pterodactylus/sone/web/WebInterface.java | 2 +- src/main/resources/templates/about.html | 2 +- 5 files changed, 13 insertions(+), 10 deletions(-) diff --git a/src/main/java/net/pterodactylus/sone/core/UpdateChecker.java b/src/main/java/net/pterodactylus/sone/core/UpdateChecker.java index 85c5841..8114118 100644 --- a/src/main/java/net/pterodactylus/sone/core/UpdateChecker.java +++ b/src/main/java/net/pterodactylus/sone/core/UpdateChecker.java @@ -50,12 +50,6 @@ public class UpdateChecker { /** The logger. */ private static final Logger logger = getLogger("Sone.UpdateChecker"); - /** The key of the Sone homepage. */ - private static final String SONE_HOMEPAGE = "USK@nwa8lHa271k2QvJ8aa0Ov7IHAV-DFOCFgmDt3X6BpCI,DuQSUZiI~agF8c-6tjsFFGuZ8eICrzWCILB60nT8KKo,AQACAAE/sone/"; - - /** The current latest known edition. */ - private static final int LATEST_EDITION = 65; - /** The event bus. */ private final EventBus eventBus; @@ -141,7 +135,7 @@ public class UpdateChecker { */ public void start() { try { - currentUri = new FreenetURI(SONE_HOMEPAGE + LATEST_EDITION); + currentUri = new FreenetURI(SonePlugin.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 ff72f86..a4fcd76 100644 --- a/src/main/java/net/pterodactylus/sone/main/SonePlugin.java +++ b/src/main/java/net/pterodactylus/sone/main/SonePlugin.java @@ -120,6 +120,8 @@ public class SonePlugin implements FredPlugin, FredPluginFCP, FredPluginL10n, Fr /** The current year at time of release. */ private static final int YEAR = 2015; + private static final String SONE_HOMEPAGE = "USK@nwa8lHa271k2QvJ8aa0Ov7IHAV-DFOCFgmDt3X6BpCI,DuQSUZiI~agF8c-6tjsFFGuZ8eICrzWCILB60nT8KKo,AQACAAE/sone/"; + private static final int LATEST_EDITION = 65; /** The logger. */ private static final Logger logger = getLogger("Sone.Plugin"); @@ -177,6 +179,10 @@ public class SonePlugin implements FredPlugin, FredPluginFCP, FredPluginL10n, Fr return YEAR; } + public static String getHomepage() { + return SONE_HOMEPAGE + LATEST_EDITION; + } + // // FREDPLUGIN METHODS // diff --git a/src/main/java/net/pterodactylus/sone/web/AboutPage.java b/src/main/java/net/pterodactylus/sone/web/AboutPage.java index 74c6a03..4b54a4b 100644 --- a/src/main/java/net/pterodactylus/sone/web/AboutPage.java +++ b/src/main/java/net/pterodactylus/sone/web/AboutPage.java @@ -31,11 +31,13 @@ public class AboutPage extends SoneTemplatePage { private final Version version; private final int year; + private final String homepage; - public AboutPage(Template template, WebInterface webInterface, Version version, int year) { + public AboutPage(Template template, WebInterface webInterface, Version version, int year, String homepage) { super("about.html", template, "Page.About.Title", webInterface, false); this.version = version; this.year = year; + this.homepage = homepage; } @Override @@ -43,6 +45,7 @@ public class AboutPage extends SoneTemplatePage { super.processTemplate(request, templateContext); templateContext.set("version", version); templateContext.set("year", year); + templateContext.set("homepage", homepage); } } diff --git a/src/main/java/net/pterodactylus/sone/web/WebInterface.java b/src/main/java/net/pterodactylus/sone/web/WebInterface.java index bd6a604..1ce8f8e 100644 --- a/src/main/java/net/pterodactylus/sone/web/WebInterface.java +++ b/src/main/java/net/pterodactylus/sone/web/WebInterface.java @@ -692,7 +692,7 @@ public class WebInterface { 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, SonePlugin.VERSION, SonePlugin.getYear()), "About")); + pageToadlets.add(pageToadletFactory.createPageToadlet(new AboutPage(aboutTemplate, this, SonePlugin.VERSION, SonePlugin.getYear(), SonePlugin.getHomepage()), "About")); pageToadlets.add(pageToadletFactory.createPageToadlet(new SoneTemplatePage("noPermission.html", noPermissionTemplate, "Page.NoPermission.Title", this))); pageToadlets.add(pageToadletFactory.createPageToadlet(new SoneTemplatePage("emptyImageTitle.html", emptyImageTitleTemplate, "Page.EmptyImageTitle.Title", this))); pageToadlets.add(pageToadletFactory.createPageToadlet(new SoneTemplatePage("emptyAlbumTitle.html", emptyAlbumTitleTemplate, "Page.EmptyAlbumTitle.Title", this))); diff --git a/src/main/resources/templates/about.html b/src/main/resources/templates/about.html index e6f809b..f38db21 100644 --- a/src/main/resources/templates/about.html +++ b/src/main/resources/templates/about.html @@ -11,7 +11,7 @@

<%= Page.About.Homepage.Title|l10n|html>

- <%= Page.About.Homepage.Description|l10n|html|replace needle=="{link}" replacement==''|replace needle=="{/link}" replacement==''> + <%= Page.About.Homepage.Description|l10n|html|replace needle=="{link}" replacement==''|replace needle=="{/link}" replacement==''>

<%= Page.About.License.Title|l10n|html>

-- 2.7.4