Update years in copyright line
[Sone.git] / src / main / java / net / pterodactylus / sone / web / WebInterface.java
index f524e5f..4da2177 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Sone - WebInterface.java - Copyright © 2010–2013 David Roden
+ * Sone - WebInterface.java - Copyright © 2010–2015 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
@@ -129,7 +129,6 @@ import net.pterodactylus.sone.web.page.PageToadletFactory;
 import net.pterodactylus.util.notify.Notification;
 import net.pterodactylus.util.notify.NotificationManager;
 import net.pterodactylus.util.notify.TemplateNotification;
-import net.pterodactylus.util.template.ClassPathTemplateProvider;
 import net.pterodactylus.util.template.CollectionSortFilter;
 import net.pterodactylus.util.template.ContainsFilter;
 import net.pterodactylus.util.template.DateFilter;
@@ -285,7 +284,7 @@ public class WebInterface {
                templateContextFactory.addFilter("mod", new ModFilter());
                templateContextFactory.addFilter("paginate", new PaginationFilter());
                templateContextFactory.addProvider(TemplateProvider.TEMPLATE_CONTEXT_PROVIDER);
-               templateContextFactory.addProvider(new ClassPathTemplateProvider(WebInterface.class, "/templates/"));
+               templateContextFactory.addProvider(loaders.getTemplateProvider());
                templateContextFactory.addTemplateObject("webInterface", this);
                templateContextFactory.addTemplateObject("formPassword", formPassword);
 
@@ -885,72 +884,46 @@ public class WebInterface {
                newSoneNotification.remove(markSoneKnownEvent.sone());
        }
 
-       /**
-        * Notifies the web interface that a {@link Post} was marked as known.
-        *
-        * @param markPostKnownEvent
-        *            The event
-        */
        @Subscribe
        public void markPostKnown(MarkPostKnownEvent markPostKnownEvent) {
-               newPostNotification.remove(markPostKnownEvent.post());
-               localPostNotification.remove(markPostKnownEvent.post());
-               if (!localSoneMentionedInNewPostOrReply(markPostKnownEvent.post())) {
-                       mentionNotification.remove(markPostKnownEvent.post());
-               }
+               removePost(markPostKnownEvent.post());
        }
 
-       /**
-        * Notifies the web interface that a {@link PostReply} was marked as known.
-        *
-        * @param markPostReplyKnownEvent
-        *            The event
-        */
        @Subscribe
        public void markReplyKnown(MarkPostReplyKnownEvent markPostReplyKnownEvent) {
-               PostReply postReply = markPostReplyKnownEvent.postReply();
-               newReplyNotification.remove(postReply);
-               localReplyNotification.remove(postReply);
-               if (postReply.getPost().isPresent() && !localSoneMentionedInNewPostOrReply(postReply.getPost().get())) {
-                       mentionNotification.remove(postReply.getPost().get());
-               }
+               removeReply(markPostReplyKnownEvent.postReply());
        }
 
-       /**
-        * Notifies the web interface that a {@link Sone} was removed.
-        *
-        * @param soneRemovedEvent
-        *            The event
-        */
        @Subscribe
        public void soneRemoved(SoneRemovedEvent soneRemovedEvent) {
                newSoneNotification.remove(soneRemovedEvent.sone());
+               for (Post post : soneRemovedEvent.sone().getPosts()) {
+                       removePost(post);
+               }
+               for (PostReply postReply : soneRemovedEvent.sone().getReplies()) {
+                       removeReply(postReply);
+               }
        }
 
-       /**
-        * Notifies the web interface that a {@link Post} was removed.
-        *
-        * @param postRemovedEvent
-        *            The event
-        */
        @Subscribe
        public void postRemoved(PostRemovedEvent postRemovedEvent) {
-               newPostNotification.remove(postRemovedEvent.post());
-               localPostNotification.remove(postRemovedEvent.post());
-               if (!localSoneMentionedInNewPostOrReply(postRemovedEvent.post())) {
-                       mentionNotification.remove(postRemovedEvent.post());
+               removePost(postRemovedEvent.post());
+       }
+
+       private void removePost(Post post) {
+               newPostNotification.remove(post);
+               localPostNotification.remove(post);
+               if (!localSoneMentionedInNewPostOrReply(post)) {
+                       mentionNotification.remove(post);
                }
        }
 
-       /**
-        * Notifies the web interface that a {@link PostReply} was removed.
-        *
-        * @param postReplyRemovedEvent
-        *            The event
-        */
        @Subscribe
        public void replyRemoved(PostReplyRemovedEvent postReplyRemovedEvent) {
-               PostReply reply = postReplyRemovedEvent.postReply();
+               removeReply(postReplyRemovedEvent.postReply());
+       }
+
+       private void removeReply(PostReply reply) {
                newReplyNotification.remove(reply);
                localReplyNotification.remove(reply);
                if (reply.getPost().isPresent() && !localSoneMentionedInNewPostOrReply(reply.getPost().get())) {