Use list notification.
[Sone.git] / src / main / java / net / pterodactylus / sone / web / WebInterface.java
index f68fec2..db1880b 100644 (file)
@@ -37,9 +37,7 @@ import net.pterodactylus.sone.data.Sone;
 import net.pterodactylus.sone.freenet.L10nFilter;
 import net.pterodactylus.sone.freenet.wot.Identity;
 import net.pterodactylus.sone.main.SonePlugin;
-import net.pterodactylus.sone.notify.NewPostNotification;
-import net.pterodactylus.sone.notify.NewReplyNotification;
-import net.pterodactylus.sone.notify.NewSoneNotification;
+import net.pterodactylus.sone.notify.ListNotification;
 import net.pterodactylus.sone.template.CollectionAccessor;
 import net.pterodactylus.sone.template.CssClassNameFilter;
 import net.pterodactylus.sone.template.GetPagePlugin;
@@ -61,8 +59,10 @@ import net.pterodactylus.sone.web.ajax.GetReplyAjaxPage;
 import net.pterodactylus.sone.web.ajax.GetSoneStatusPage;
 import net.pterodactylus.sone.web.ajax.GetTranslationPage;
 import net.pterodactylus.sone.web.ajax.LikeAjaxPage;
+import net.pterodactylus.sone.web.ajax.LockSoneAjaxPage;
 import net.pterodactylus.sone.web.ajax.UnfollowSoneAjaxPage;
 import net.pterodactylus.sone.web.ajax.UnlikeAjaxPage;
+import net.pterodactylus.sone.web.ajax.UnlockSoneAjaxPage;
 import net.pterodactylus.sone.web.page.PageToadlet;
 import net.pterodactylus.sone.web.page.PageToadletFactory;
 import net.pterodactylus.sone.web.page.StaticPage;
@@ -111,13 +111,13 @@ public class WebInterface implements CoreListener {
        private DefaultTemplateFactory templateFactory;
 
        /** The “new Sone” notification. */
-       private final NewSoneNotification newSoneNotification;
+       private final ListNotification<Sone> newSoneNotification;
 
        /** The “new post” notification. */
-       private final NewPostNotification newPostNotification;
+       private final ListNotification<Post> newPostNotification;
 
        /** The “new reply” notification. */
-       private final NewReplyNotification newReplyNotification;
+       private final ListNotification<Reply> newReplyNotification;
 
        /**
         * Creates a new web interface.
@@ -151,13 +151,13 @@ public class WebInterface implements CoreListener {
 
                /* create notifications. */
                Template newSoneNotificationTemplate = templateFactory.createTemplate(createReader("/templates/notify/newSoneNotification.html"));
-               newSoneNotification = new NewSoneNotification(newSoneNotificationTemplate);
+               newSoneNotification = new ListNotification<Sone>("new-sone-notification", "sones", newSoneNotificationTemplate);
 
                Template newPostNotificationTemplate = templateFactory.createTemplate(createReader("/templates/notify/newPostNotification.html"));
-               newPostNotification = new NewPostNotification(newPostNotificationTemplate);
+               newPostNotification = new ListNotification<Post>("new-post-notification", "posts", newPostNotificationTemplate);
 
                Template newReplyNotificationTemplate = templateFactory.createTemplate(createReader("/templates/notify/newReplyNotification.html"));
-               newReplyNotification = new NewReplyNotification(newReplyNotificationTemplate);
+               newReplyNotification = new ListNotification<Reply>("new-replies-notification", "replies", newReplyNotificationTemplate);
        }
 
        //
@@ -285,6 +285,8 @@ public class WebInterface implements CoreListener {
                Template unlikePostTemplate = templateFactory.createTemplate(createReader("/templates/unlike.html"));
                Template deletePostTemplate = templateFactory.createTemplate(createReader("/templates/deletePost.html"));
                Template deleteReplyTemplate = templateFactory.createTemplate(createReader("/templates/deleteReply.html"));
+               Template lockSoneTemplate = templateFactory.createTemplate(createReader("/templates/lockSone.html"));
+               Template unlockSoneTemplate = templateFactory.createTemplate(createReader("/templates/unlockSone.html"));
                Template followSoneTemplate = templateFactory.createTemplate(createReader("/templates/followSone.html"));
                Template unfollowSoneTemplate = templateFactory.createTemplate(createReader("/templates/unfollowSone.html"));
                Template deleteSoneTemplate = templateFactory.createTemplate(createReader("/templates/deleteSone.html"));
@@ -308,6 +310,8 @@ public class WebInterface implements CoreListener {
                pageToadlets.add(pageToadletFactory.createPageToadlet(new UnlikePage(unlikePostTemplate, this)));
                pageToadlets.add(pageToadletFactory.createPageToadlet(new DeletePostPage(deletePostTemplate, this)));
                pageToadlets.add(pageToadletFactory.createPageToadlet(new DeleteReplyPage(deleteReplyTemplate, this)));
+               pageToadlets.add(pageToadletFactory.createPageToadlet(new LockSonePage(lockSoneTemplate, this)));
+               pageToadlets.add(pageToadletFactory.createPageToadlet(new UnlockSonePage(unlockSoneTemplate, this)));
                pageToadlets.add(pageToadletFactory.createPageToadlet(new FollowSonePage(followSoneTemplate, this)));
                pageToadlets.add(pageToadletFactory.createPageToadlet(new UnfollowSonePage(unfollowSoneTemplate, this)));
                pageToadlets.add(pageToadletFactory.createPageToadlet(new DeleteSonePage(deleteSoneTemplate, this), "DeleteSone"));
@@ -328,6 +332,8 @@ public class WebInterface implements CoreListener {
                pageToadlets.add(pageToadletFactory.createPageToadlet(new GetReplyAjaxPage(this, replyTemplate)));
                pageToadlets.add(pageToadletFactory.createPageToadlet(new DeletePostAjaxPage(this)));
                pageToadlets.add(pageToadletFactory.createPageToadlet(new DeleteReplyAjaxPage(this)));
+               pageToadlets.add(pageToadletFactory.createPageToadlet(new LockSoneAjaxPage(this)));
+               pageToadlets.add(pageToadletFactory.createPageToadlet(new UnlockSoneAjaxPage(this)));
                pageToadlets.add(pageToadletFactory.createPageToadlet(new FollowSoneAjaxPage(this)));
                pageToadlets.add(pageToadletFactory.createPageToadlet(new UnfollowSoneAjaxPage(this)));
                pageToadlets.add(pageToadletFactory.createPageToadlet(new LikeAjaxPage(this)));
@@ -382,7 +388,7 @@ public class WebInterface implements CoreListener {
         */
        @Override
        public void newSoneFound(Sone sone) {
-               newSoneNotification.addSone(sone);
+               newSoneNotification.add(sone);
                notificationManager.addNotification(newSoneNotification);
        }
 
@@ -391,7 +397,7 @@ public class WebInterface implements CoreListener {
         */
        @Override
        public void newPostFound(Post post) {
-               newPostNotification.addPost(post);
+               newPostNotification.add(post);
                notificationManager.addNotification(newPostNotification);
        }
 
@@ -403,7 +409,7 @@ public class WebInterface implements CoreListener {
                if (reply.getPost().getSone() == null) {
                        return;
                }
-               newReplyNotification.addReply(reply);
+               newReplyNotification.add(reply);
                notificationManager.addNotification(newReplyNotification);
        }
 
@@ -412,7 +418,7 @@ public class WebInterface implements CoreListener {
         */
        @Override
        public void markSoneKnown(Sone sone) {
-               newSoneNotification.removeSone(sone);
+               newSoneNotification.remove(sone);
                if (newSoneNotification.isEmpty()) {
                        newSoneNotification.dismiss();
                }
@@ -423,7 +429,7 @@ public class WebInterface implements CoreListener {
         */
        @Override
        public void markPostKnown(Post post) {
-               newPostNotification.removePost(post);
+               newPostNotification.remove(post);
                if (newPostNotification.isEmpty()) {
                        newPostNotification.dismiss();
                }
@@ -434,7 +440,7 @@ public class WebInterface implements CoreListener {
         */
        @Override
        public void markReplyKnown(Reply reply) {
-               newReplyNotification.removeReply(reply);
+               newReplyNotification.remove(reply);
                if (newReplyNotification.isEmpty()) {
                        newReplyNotification.dismiss();
                }