Merge branch 'release-0.4.3'
[Sone.git] / src / main / java / net / pterodactylus / sone / web / WebInterface.java
index dbba1dd..9023ccf 100644 (file)
@@ -95,6 +95,7 @@ import net.pterodactylus.util.notify.Notification;
 import net.pterodactylus.util.notify.NotificationManager;
 import net.pterodactylus.util.notify.TemplateNotification;
 import net.pterodactylus.util.template.DateFilter;
+import net.pterodactylus.util.template.FormatFilter;
 import net.pterodactylus.util.template.HtmlFilter;
 import net.pterodactylus.util.template.MatchFilter;
 import net.pterodactylus.util.template.PaginationPlugin;
@@ -199,6 +200,7 @@ public class WebInterface implements CoreListener {
                templateContextFactory.addFilter("js", new JavascriptFilter());
                templateContextFactory.addFilter("parse", new ParserFilter(templateContextFactory));
                templateContextFactory.addFilter("unknown", new UnknownDateFilter(getL10n(), "View.Sone.Text.UnknownDate"));
+               templateContextFactory.addFilter("format", new FormatFilter());
                templateContextFactory.addPlugin("getpage", new GetPagePlugin());
                templateContextFactory.addPlugin("paginate", new PaginationPlugin());
                templateContextFactory.addProvider(Provider.TEMPLATE_CONTEXT_PROVIDER);
@@ -307,6 +309,10 @@ public class WebInterface implements CoreListener {
         *         currently logged in
         */
        public Sone getCurrentSone(ToadletContext toadletContext, boolean create) {
+               Set<Sone> localSones = getCore().getLocalSones();
+               if (localSones.size() == 1) {
+                       return localSones.iterator().next();
+               }
                return getCurrentSone(getCurrentSession(toadletContext, create));
        }
 
@@ -759,8 +765,9 @@ public class WebInterface implements CoreListener {
         * {@inheritDoc}
         */
        @Override
-       public void updateFound(Version version, long releaseTime) {
-               newVersionNotification.getTemplateContext().set("version", version);
+       public void updateFound(Version version, long releaseTime, long latestEdition) {
+               newVersionNotification.getTemplateContext().set("latestVersion", version);
+               newVersionNotification.getTemplateContext().set("latestEdition", latestEdition);
                newVersionNotification.getTemplateContext().set("releaseTime", releaseTime);
                notificationManager.addNotification(newVersionNotification);
        }