From: David ‘Bombe’ Roden Date: Sun, 12 Dec 2010 13:33:04 +0000 (+0100) Subject: Add notification on a first start of Sone. X-Git-Tag: beta-freefall-0.6.2-1~197^2~8 X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=03b402bcc630ed09db52f9c16ec9950e01255a71;p=Sone.git Add notification on a first start of Sone. --- diff --git a/src/main/java/net/pterodactylus/sone/main/SonePlugin.java b/src/main/java/net/pterodactylus/sone/main/SonePlugin.java index fbf8b1a..ca629fa 100644 --- a/src/main/java/net/pterodactylus/sone/main/SonePlugin.java +++ b/src/main/java/net/pterodactylus/sone/main/SonePlugin.java @@ -147,6 +147,7 @@ public class SonePlugin implements FredPlugin, FredPluginL10n, FredPluginBaseL10 /* create a configuration. */ Configuration oldConfiguration; Configuration newConfiguration = null; + boolean firstStart = !new File("sone.properties").exists(); try { oldConfiguration = new Configuration(new MapConfigurationBackend(new File("sone.properties"), false)); newConfiguration = oldConfiguration; @@ -181,6 +182,7 @@ public class SonePlugin implements FredPlugin, FredPluginL10n, FredPluginBaseL10 /* create the web interface. */ webInterface = new WebInterface(this); + webInterface.setFirstStart(firstStart); core.addCoreListener(webInterface); /* create the identity manager. */ diff --git a/src/main/java/net/pterodactylus/sone/web/WebInterface.java b/src/main/java/net/pterodactylus/sone/web/WebInterface.java index dc09d78..0e7905d 100644 --- a/src/main/java/net/pterodactylus/sone/web/WebInterface.java +++ b/src/main/java/net/pterodactylus/sone/web/WebInterface.java @@ -70,6 +70,7 @@ import net.pterodactylus.sone.web.page.PageToadlet; import net.pterodactylus.sone.web.page.PageToadletFactory; import net.pterodactylus.sone.web.page.StaticPage; import net.pterodactylus.util.logging.Logging; +import net.pterodactylus.util.notify.Notification; import net.pterodactylus.util.notify.NotificationManager; import net.pterodactylus.util.notify.TemplateNotification; import net.pterodactylus.util.template.DateFilter; @@ -244,6 +245,22 @@ public class WebInterface implements CoreListener { return new HashSet(newReplyNotification.getElements()); } + /** + * Sets whether the current start of the plugin is the first start. It is + * considered a first start if the configuration file does not exist. + * + * @param firstStart + * {@code true} if no configuration file existed when Sone was + * loaded, {@code false} otherwise + */ + public void setFirstStart(boolean firstStart) { + if (firstStart) { + Template firstStartNotificationTemplate = new Template(createReader("/templates/notify/firstStartNotification.html")); + Notification firstStartNotification = new TemplateNotification("first-start-notification", firstStartNotificationTemplate); + notificationManager.addNotification(firstStartNotification); + } + } + // // ACTIONS // diff --git a/src/main/resources/i18n/sone.en.properties b/src/main/resources/i18n/sone.en.properties index d0c44f5..1a69477 100644 --- a/src/main/resources/i18n/sone.en.properties +++ b/src/main/resources/i18n/sone.en.properties @@ -176,6 +176,7 @@ WebInterface.SelectBox.Yes=Yes WebInterface.SelectBox.No=No WebInterface.ClickToShow.Replies=Click here to show hidden replies. +Notification.FirstStart.Text=This seems to be the first time you start Sone. To start, create a new Sone from a web of trust identity and start following other Sones. Notification.Startup.Text=Sone is currently starting up. It may take a while to retrieve all identities and Sones from the web of trust. If you are missing some elements, please be patient, they will probably reappear very soon. Notification.Button.Dismiss=Dismiss Notification.NewSone.Text=New Sones have been discovered: diff --git a/src/main/resources/templates/notify/firstStartNotification.html b/src/main/resources/templates/notify/firstStartNotification.html new file mode 100644 index 0000000..b4ce468 --- /dev/null +++ b/src/main/resources/templates/notify/firstStartNotification.html @@ -0,0 +1 @@ +
<%= Notification.FirstStart.Text|l10n|html>