From: David ‘Bombe’ Roden Date: Sun, 9 Jan 2011 20:50:51 +0000 (+0100) Subject: Add “new version” notification, set current and latest version in all templates. X-Git-Tag: 0.3.7^2~8^2~2 X-Git-Url: https://git.pterodactylus.net/?p=Sone.git;a=commitdiff_plain;h=3af098881713ac16350da6decf652b97e6cba4ce Add “new version” notification, set current and latest version in all templates. --- diff --git a/pom.xml b/pom.xml index e1fe047..e9ff09c 100644 --- a/pom.xml +++ b/pom.xml @@ -7,7 +7,7 @@ net.pterodactylus utils - 0.7.6 + 0.7.7 junit diff --git a/src/main/java/net/pterodactylus/sone/web/SoneTemplatePage.java b/src/main/java/net/pterodactylus/sone/web/SoneTemplatePage.java index 23ca247..3d4cb80 100644 --- a/src/main/java/net/pterodactylus/sone/web/SoneTemplatePage.java +++ b/src/main/java/net/pterodactylus/sone/web/SoneTemplatePage.java @@ -21,6 +21,7 @@ import java.util.Arrays; import java.util.Collection; import net.pterodactylus.sone.data.Sone; +import net.pterodactylus.sone.main.SonePlugin; import net.pterodactylus.sone.web.page.Page; import net.pterodactylus.sone.web.page.TemplatePage; import net.pterodactylus.util.template.Template; @@ -188,6 +189,10 @@ public class SoneTemplatePage extends TemplatePage { super.processTemplate(request, template); template.set("currentSone", getCurrentSone(request.getToadletContext(), false)); template.set("request", request); + template.set("currentVersion", SonePlugin.VERSION); + template.set("hasLatestVersion", webInterface.getCore().getUpdateChecker().hasLatestVersion()); + template.set("latestVersion", webInterface.getCore().getUpdateChecker().getLatestVersion()); + template.set("latestVersionTime", webInterface.getCore().getUpdateChecker().getLatestVersionDate()); } /** diff --git a/src/main/java/net/pterodactylus/sone/web/WebInterface.java b/src/main/java/net/pterodactylus/sone/web/WebInterface.java index c11a3cc..6085ff8 100644 --- a/src/main/java/net/pterodactylus/sone/web/WebInterface.java +++ b/src/main/java/net/pterodactylus/sone/web/WebInterface.java @@ -142,6 +142,9 @@ public class WebInterface implements CoreListener { /** The “Sone locked” notification. */ private final ListNotification lockedSonesNotification; + /** The “new version” notification. */ + private final TemplateNotification newVersionNotification; + /** * Creates a new web interface. * @@ -190,6 +193,9 @@ public class WebInterface implements CoreListener { Template lockedSonesTemplate = templateFactory.createTemplate(createReader("/templates/notify/lockedSonesNotification.html")); lockedSonesNotification = new ListNotification("sones-locked-notification", "sones", lockedSonesTemplate); + + Template newVersionTemplate = templateFactory.createTemplate(createReader("/templates/notify/newVersionNotification.html")); + newVersionNotification = new TemplateNotification("new-version-notification", newVersionTemplate); } // @@ -706,6 +712,9 @@ public class WebInterface implements CoreListener { */ @Override public void updateFound(Version version, long releaseTime) { + newVersionNotification.set("version", version); + newVersionNotification.set("releaseTime", releaseTime); + notificationManager.addNotification(newVersionNotification); } /** diff --git a/src/main/resources/i18n/sone.en.properties b/src/main/resources/i18n/sone.en.properties index 533a01b..1dbfabc 100644 --- a/src/main/resources/i18n/sone.en.properties +++ b/src/main/resources/i18n/sone.en.properties @@ -191,3 +191,4 @@ Notification.SoneIsBeingRescued.Text=The following Sones are currently being res Notification.SoneRescued.Text=The following Sones have been rescued: Notification.SoneRescued.Text.RememberToUnlock=Please remember to control the posts and replies you have given and don’t forget to unlock your Sones! Notification.LockedSones.Text=The following Sones have been locked for more than 5 minutes. Please check if you really want to keep these Sones locked: +Notification.NewVersion.Text=A new version of the Sone plugin was found: Version {version}. diff --git a/src/main/resources/templates/notify/newVersionNotification.html b/src/main/resources/templates/notify/newVersionNotification.html new file mode 100644 index 0000000..23a5855 --- /dev/null +++ b/src/main/resources/templates/notify/newVersionNotification.html @@ -0,0 +1 @@ +
<%= Notification.NewVersion.Text|l10n|html|replace needle="{version}" replacementKey=version>