From: David ‘Bombe’ Roden Date: Fri, 6 May 2011 20:12:24 +0000 (+0200) Subject: Remove notification manager accessor, and displayed notifications from the template... X-Git-Tag: 0.6.4^2~20 X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=581c1ea0557c172560d4b203c6c34f71bdae5109;p=Sone.git Remove notification manager accessor, and displayed notifications from the template context. --- diff --git a/src/main/java/net/pterodactylus/sone/template/NotificationManagerAccessor.java b/src/main/java/net/pterodactylus/sone/template/NotificationManagerAccessor.java deleted file mode 100644 index c4468ea..0000000 --- a/src/main/java/net/pterodactylus/sone/template/NotificationManagerAccessor.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Sone - NotificationManagerAccessor.java - Copyright © 2010 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 - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -package net.pterodactylus.sone.template; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; - -import net.pterodactylus.sone.data.Sone; -import net.pterodactylus.sone.notify.ListNotificationFilters; -import net.pterodactylus.util.notify.Notification; -import net.pterodactylus.util.notify.NotificationManager; -import net.pterodactylus.util.template.ReflectionAccessor; -import net.pterodactylus.util.template.TemplateContext; - -/** - * Adds additional properties to a {@link NotificationManager}. - *
- *
all
- *
Returns all notifications, sorted by creation time, oldest first.
- *
new
- *
Returns all changed notifications, sorted by last updated time, newest - * first.
- *
- * - * @author David ‘Bombe’ Roden - */ -public class NotificationManagerAccessor extends ReflectionAccessor { - - /** - * {@inheritDoc} - */ - @Override - public Object get(TemplateContext templateContext, Object object, String member) { - NotificationManager notificationManager = (NotificationManager) object; - if ("all".equals(member)) { - List notifications = ListNotificationFilters.filterNotifications(new ArrayList(notificationManager.getNotifications()), (Sone) templateContext.get("currentSone")); - Collections.sort(notifications, Notification.CREATED_TIME_SORTER); - return notifications; - } - return super.get(templateContext, object, member); - } - -} diff --git a/src/main/java/net/pterodactylus/sone/web/WebInterface.java b/src/main/java/net/pterodactylus/sone/web/WebInterface.java index fd09f33..871a2eb 100644 --- a/src/main/java/net/pterodactylus/sone/web/WebInterface.java +++ b/src/main/java/net/pterodactylus/sone/web/WebInterface.java @@ -49,7 +49,6 @@ import net.pterodactylus.sone.template.CssClassNameFilter; import net.pterodactylus.sone.template.HttpRequestAccessor; import net.pterodactylus.sone.template.IdentityAccessor; import net.pterodactylus.sone.template.JavascriptFilter; -import net.pterodactylus.sone.template.NotificationManagerAccessor; import net.pterodactylus.sone.template.ParserFilter; import net.pterodactylus.sone.template.PostAccessor; import net.pterodactylus.sone.template.ReplyAccessor; @@ -193,7 +192,6 @@ public class WebInterface implements CoreListener { templateContextFactory.addAccessor(Post.class, new PostAccessor(getCore())); templateContextFactory.addAccessor(Reply.class, new ReplyAccessor(getCore())); templateContextFactory.addAccessor(Identity.class, new IdentityAccessor(getCore())); - templateContextFactory.addAccessor(NotificationManager.class, new NotificationManagerAccessor()); templateContextFactory.addAccessor(Trust.class, new TrustAccessor()); templateContextFactory.addAccessor(HTTPRequest.class, new HttpRequestAccessor()); templateContextFactory.addFilter("date", new DateFilter()); diff --git a/src/main/resources/templates/include/head.html b/src/main/resources/templates/include/head.html index ef3b34b..d76a63f 100644 --- a/src/main/resources/templates/include/head.html +++ b/src/main/resources/templates/include/head.html @@ -18,7 +18,7 @@ - <%foreach webInterface.notifications.all notification> + <%foreach notifications notification>
<%if notification.dismissable>