Store the form password.
[Sone.git] / src / main / java / net / pterodactylus / sone / web / WebInterface.java
index 427570d..ec20785 100644 (file)
@@ -33,6 +33,7 @@ import net.pterodactylus.sone.data.Post;
 import net.pterodactylus.sone.data.Sone;
 import net.pterodactylus.sone.freenet.L10nFilter;
 import net.pterodactylus.sone.main.SonePlugin;
+import net.pterodactylus.sone.template.GetPagePlugin;
 import net.pterodactylus.sone.template.PostAccessor;
 import net.pterodactylus.sone.template.RequestChangeFilter;
 import net.pterodactylus.sone.template.SoneAccessor;
@@ -46,6 +47,7 @@ import net.pterodactylus.util.logging.Logging;
 import net.pterodactylus.util.service.AbstractService;
 import net.pterodactylus.util.template.DateFilter;
 import net.pterodactylus.util.template.DefaultTemplateFactory;
+import net.pterodactylus.util.template.PaginationPlugin;
 import net.pterodactylus.util.template.ReflectionAccessor;
 import net.pterodactylus.util.template.Template;
 import net.pterodactylus.util.template.TemplateException;
@@ -73,6 +75,9 @@ public class WebInterface extends AbstractService {
        /** The registered toadlets. */
        private final List<PageToadlet> pageToadlets = new ArrayList<PageToadlet>();
 
+       /** The form password. */
+       private final String formPassword;
+
        /**
         * Creates a new web interface.
         *
@@ -82,6 +87,7 @@ public class WebInterface extends AbstractService {
        public WebInterface(SonePlugin sonePlugin) {
                super("Sone Web Interface", false);
                this.sonePlugin = sonePlugin;
+               formPassword = sonePlugin.pluginRespirator().getToadletContainer().getFormPassword();
        }
 
        //
@@ -120,6 +126,15 @@ public class WebInterface extends AbstractService {
                }
        }
 
+       /**
+        * Returns the node’s form password.
+        *
+        * @return The form password
+        */
+       public String formPassword() {
+               return formPassword;
+       }
+
        //
        // SERVICE METHODS
        //
@@ -157,8 +172,10 @@ public class WebInterface extends AbstractService {
                templateFactory.addFilter("substring", new SubstringFilter());
                templateFactory.addFilter("xml", new XmlFilter());
                templateFactory.addFilter("change", new RequestChangeFilter());
+               templateFactory.addPlugin("getpage", new GetPagePlugin());
+               templateFactory.addPlugin("paginate", new PaginationPlugin());
                templateFactory.setTemplateProvider(new ClassPathTemplateProvider(templateFactory));
-               templateFactory.addTemplateObject("formPassword", sonePlugin.pluginRespirator().getToadletContainer().getFormPassword());
+               templateFactory.addTemplateObject("formPassword", formPassword);
 
                Template loginTemplate = templateFactory.createTemplate(createReader("/templates/login.html"));
                Template indexTemplate = templateFactory.createTemplate(createReader("/templates/index.html"));