Add pagination filter to template context factory.
[Sone.git] / src / main / java / net / pterodactylus / sone / web / WebInterface.java
index 53b9f3b..c2bb1c8 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Sone - WebInterface.java - Copyright © 2010 David Roden
+ * Sone - WebInterface.java - Copyright © 2010–2012 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
@@ -110,7 +110,7 @@ import net.pterodactylus.util.cache.DefaultCacheItem;
 import net.pterodactylus.util.cache.MemoryCache;
 import net.pterodactylus.util.cache.ValueRetriever;
 import net.pterodactylus.util.collection.SetBuilder;
-import net.pterodactylus.util.filter.Filters;
+import net.pterodactylus.util.collection.filter.Filters;
 import net.pterodactylus.util.logging.Logging;
 import net.pterodactylus.util.notify.Notification;
 import net.pterodactylus.util.notify.NotificationManager;
@@ -122,6 +122,7 @@ import net.pterodactylus.util.template.FormatFilter;
 import net.pterodactylus.util.template.HtmlFilter;
 import net.pterodactylus.util.template.MatchFilter;
 import net.pterodactylus.util.template.ModFilter;
+import net.pterodactylus.util.template.PaginationFilter;
 import net.pterodactylus.util.template.Provider;
 import net.pterodactylus.util.template.ReflectionAccessor;
 import net.pterodactylus.util.template.ReplaceFilter;
@@ -138,9 +139,9 @@ import net.pterodactylus.util.web.RedirectPage;
 import net.pterodactylus.util.web.StaticPage;
 import net.pterodactylus.util.web.TemplatePage;
 import freenet.clients.http.SessionManager;
+import freenet.clients.http.SessionManager.Session;
 import freenet.clients.http.ToadletContainer;
 import freenet.clients.http.ToadletContext;
-import freenet.clients.http.SessionManager.Session;
 import freenet.l10n.BaseL10n;
 import freenet.support.api.HTTPRequest;
 
@@ -259,6 +260,7 @@ public class WebInterface implements CoreListener {
                templateContextFactory.addFilter("in", new ContainsFilter());
                templateContextFactory.addFilter("unique", new UniqueElementFilter());
                templateContextFactory.addFilter("mod", new ModFilter());
+               templateContextFactory.addFilter("paginate", new PaginationFilter());
                templateContextFactory.addProvider(Provider.TEMPLATE_CONTEXT_PROVIDER);
                templateContextFactory.addProvider(new ClassPathTemplateProvider());
                templateContextFactory.addTemplateObject("webInterface", this);
@@ -749,7 +751,7 @@ public class WebInterface implements CoreListener {
                                }
                        }
                } catch (IOException ioe1) {
-                       logger.log(Level.WARNING, "Could not parse post text: " + text, ioe1);
+                       logger.log(Level.WARNING, String.format("Could not parse post text: %s", text), ioe1);
                }
                return Filters.filteredSet(mentionedSones, Sone.LOCAL_SONE_FILTER);
        }
@@ -1043,7 +1045,7 @@ public class WebInterface implements CoreListener {
                        try {
                                return templateCache.get(templateName);
                        } catch (CacheException ce1) {
-                               logger.log(Level.WARNING, "Could not get template for " + templateName + "!", ce1);
+                               logger.log(Level.WARNING, String.format("Could not get template for %s!", templateName), ce1);
                                return null;
                        }
                }
@@ -1066,7 +1068,7 @@ public class WebInterface implements CoreListener {
                        try {
                                template = TemplateParser.parse(templateReader);
                        } catch (TemplateException te1) {
-                               logger.log(Level.WARNING, "Could not parse template “" + templateName + "” for inclusion!", te1);
+                               logger.log(Level.WARNING, String.format("Could not parse template “%s” for inclusion!", templateName), te1);
                        }
                        return template;
                }