Create link to homepage using the latest edition at time of release
authorDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Tue, 23 Jun 2015 04:45:35 +0000 (06:45 +0200)
committerDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Tue, 23 Jun 2015 04:45:35 +0000 (06:45 +0200)
src/main/java/net/pterodactylus/sone/core/UpdateChecker.java
src/main/java/net/pterodactylus/sone/main/SonePlugin.java
src/main/java/net/pterodactylus/sone/web/AboutPage.java
src/main/java/net/pterodactylus/sone/web/WebInterface.java
src/main/resources/templates/about.html

index 85c5841..8114118 100644 (file)
@@ -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);
index ff72f86..a4fcd76 100644 (file)
@@ -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
        //
index 74c6a03..4b54a4b 100644 (file)
@@ -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);
        }
 
 }
index bd6a604..1ce8f8e 100644 (file)
@@ -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)));
index e6f809b..f38db21 100644 (file)
@@ -11,7 +11,7 @@
        <h2><%= Page.About.Homepage.Title|l10n|html></h2>
 
        <p>
-               <%= Page.About.Homepage.Description|l10n|html|replace needle=="{link}" replacement=='<a href="/USK@nwa8lHa271k2QvJ8aa0Ov7IHAV-DFOCFgmDt3X6BpCI,DuQSUZiI~agF8c-6tjsFFGuZ8eICrzWCILB60nT8KKo,AQACAAE/sone/49/">'|replace needle=="{/link}" replacement=='</a>'>
+               <%= Page.About.Homepage.Description|l10n|html|replace needle=="{link}" replacement=='<a href="/<% homepage|html>/">'|replace needle=="{/link}" replacement=='</a>'>
        </p>
 
        <h2><%= Page.About.License.Title|l10n|html></h2>