X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Fmain%2Fjava%2Fnet%2Fpterodactylus%2Fsone%2Fweb%2FSoneTemplatePage.java;h=9df00b770eba537410e9d611d813969c6912ea76;hb=2e03e9dddbea4b81aacaf1aa316f5c3ccffd4bf9;hp=095db9e75e08b49ff7cb30a755893f60e9d1bcca;hpb=0df5e91852f737d760c5a9f54c5667309fbadcc2;p=Sone.git diff --git a/src/main/java/net/pterodactylus/sone/web/SoneTemplatePage.java b/src/main/java/net/pterodactylus/sone/web/SoneTemplatePage.java index 095db9e..9df00b7 100644 --- a/src/main/java/net/pterodactylus/sone/web/SoneTemplatePage.java +++ b/src/main/java/net/pterodactylus/sone/web/SoneTemplatePage.java @@ -1,5 +1,5 @@ /* - * Sone - SoneTemplatePage.java - Copyright © 2010 David Roden + * Sone - SoneTemplatePage.java - Copyright © 2010–2013 David Roden * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -21,6 +21,7 @@ import java.io.UnsupportedEncodingException; import java.net.URLEncoder; import java.util.Arrays; import java.util.Collection; +import java.util.Collections; import java.util.List; import java.util.Map; @@ -29,14 +30,17 @@ import net.pterodactylus.sone.main.SonePlugin; import net.pterodactylus.sone.notify.ListNotificationFilters; import net.pterodactylus.sone.web.page.FreenetRequest; import net.pterodactylus.sone.web.page.FreenetTemplatePage; -import net.pterodactylus.util.collection.ListBuilder; -import net.pterodactylus.util.collection.MapBuilder; +import net.pterodactylus.util.notify.Notification; import net.pterodactylus.util.template.Template; import net.pterodactylus.util.template.TemplateContext; + import freenet.clients.http.SessionManager.Session; import freenet.clients.http.ToadletContext; import freenet.support.api.HTTPRequest; +import com.google.common.collect.ImmutableList; +import com.google.common.collect.ImmutableMap; + /** * Base page for the Sone web interface. * @@ -198,9 +202,6 @@ public class SoneTemplatePage extends FreenetTemplatePage { // TEMPLATEPAGE METHODS // - /** - * {@inheritDoc} - */ @Override protected String getPageTitle(FreenetRequest request) { if (pageTitleKey != null) { @@ -209,25 +210,16 @@ public class SoneTemplatePage extends FreenetTemplatePage { return ""; } - /** - * {@inheritDoc} - */ @Override protected List> getAdditionalLinkNodes(FreenetRequest request) { - return new ListBuilder>().add(new MapBuilder().put("rel", "search").put("type", "application/opensearchdescription+xml").put("title", "Sone").put("href", "http://" + request.getHttpRequest().getHeader("host") + "/Sone/OpenSearch.xml").get()).get(); + return ImmutableList.> builder().add(ImmutableMap. builder().put("rel", "search").put("type", "application/opensearchdescription+xml").put("title", "Sone").put("href", "http://" + request.getHttpRequest().getHeader("host") + "/Sone/OpenSearch.xml").build()).build(); } - /** - * {@inheritDoc} - */ @Override protected Collection getStyleSheets() { return Arrays.asList("css/sone.css"); } - /** - * {@inheritDoc} - */ @Override protected String getShortcutIcon() { return "images/icon.png"; @@ -243,9 +235,6 @@ public class SoneTemplatePage extends FreenetTemplatePage { return requireLogin; } - /** - * {@inheritDoc} - */ @Override protected void processTemplate(FreenetRequest request, TemplateContext templateContext) throws RedirectException { super.processTemplate(request, templateContext); @@ -259,12 +248,12 @@ public class SoneTemplatePage extends FreenetTemplatePage { templateContext.set("latestEdition", webInterface.getCore().getUpdateChecker().getLatestEdition()); templateContext.set("latestVersion", webInterface.getCore().getUpdateChecker().getLatestVersion()); templateContext.set("latestVersionTime", webInterface.getCore().getUpdateChecker().getLatestVersionDate()); - templateContext.set("notifications", ListNotificationFilters.filterNotifications(webInterface.getNotifications().getNotifications(), currentSone)); + List notifications = ListNotificationFilters.filterNotifications(webInterface.getNotifications().getNotifications(), currentSone); + Collections.sort(notifications, Notification.CREATED_TIME_SORTER); + templateContext.set("notifications", notifications); + templateContext.set("notificationHash", notifications.hashCode()); } - /** - * {@inheritDoc} - */ @Override protected String getRedirectTarget(FreenetRequest request) { if (requiresLogin() && (getCurrentSone(request.getToadletContext(), false) == null)) { @@ -292,17 +281,11 @@ public class SoneTemplatePage extends FreenetTemplatePage { return null; } - /** - * {@inheritDoc} - */ @Override protected boolean isFullAccessOnly() { return webInterface.getCore().getPreferences().isRequireFullAccess(); } - /** - * {@inheritDoc} - */ @Override public boolean isEnabled(ToadletContext toadletContext) { if (webInterface.getCore().getPreferences().isRequireFullAccess() && !toadletContext.isAllowedFullAccess()) {