From 3af098881713ac16350da6decf652b97e6cba4ce Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Sun, 9 Jan 2011 21:50:51 +0100 Subject: [PATCH] =?utf8?q?Add=20=E2=80=9Cnew=20version=E2=80=9D=20notifica?= =?utf8?q?tion,=20set=20current=20and=20latest=20version=20in=20all=20temp?= =?utf8?q?lates.?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- pom.xml | 2 +- src/main/java/net/pterodactylus/sone/web/SoneTemplatePage.java | 5 +++++ src/main/java/net/pterodactylus/sone/web/WebInterface.java | 9 +++++++++ src/main/resources/i18n/sone.en.properties | 1 + src/main/resources/templates/notify/newVersionNotification.html | 1 + 5 files changed, 17 insertions(+), 1 deletion(-) create mode 100644 src/main/resources/templates/notify/newVersionNotification.html 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>
-- 2.7.4