Use new template engine.
[Sone.git] / src / main / java / net / pterodactylus / sone / web / DeletePostPage.java
index 18262a2..ecbb368 100644 (file)
@@ -21,6 +21,7 @@ import net.pterodactylus.sone.data.Post;
 import net.pterodactylus.sone.data.Sone;
 import net.pterodactylus.sone.web.page.Page.Request.Method;
 import net.pterodactylus.util.template.Template;
+import net.pterodactylus.util.template.TemplateContext;
 
 /**
  * Lets the user delete a post they made.
@@ -38,7 +39,7 @@ public class DeletePostPage extends SoneTemplatePage {
         *            The Sone web interface
         */
        public DeletePostPage(Template template, WebInterface webInterface) {
-               super("deletePost.html", template, "Page.DeletePost.Title", webInterface);
+               super("deletePost.html", template, "Page.DeletePost.Title", webInterface, true);
        }
 
        //
@@ -49,19 +50,19 @@ public class DeletePostPage extends SoneTemplatePage {
         * {@inheritDoc}
         */
        @Override
-       protected void processTemplate(Request request, Template template) throws RedirectException {
-               super.processTemplate(request, template);
+       protected void processTemplate(Request request, TemplateContext templateContext) throws RedirectException {
+               super.processTemplate(request, templateContext);
                if (request.getMethod() == Method.GET) {
                        String postId = request.getHttpRequest().getParam("post");
                        String returnPage = request.getHttpRequest().getParam("returnPage");
-                       Post post = webInterface.core().getPost(postId);
-                       template.set("post", post);
-                       template.set("returnPage", returnPage);
+                       Post post = webInterface.getCore().getPost(postId);
+                       templateContext.set("post", post);
+                       templateContext.set("returnPage", returnPage);
                        return;
                } else if (request.getMethod() == Method.POST) {
                        String postId = request.getHttpRequest().getPartAsStringFailsafe("post", 36);
-                       String returnPage = request.getHttpRequest().getPartAsStringFailsafe("returnPage", 64);
-                       Post post = webInterface.core().getPost(postId);
+                       String returnPage = request.getHttpRequest().getPartAsStringFailsafe("returnPage", 256);
+                       Post post = webInterface.getCore().getPost(postId);
                        Sone currentSone = getCurrentSone(request.getToadletContext());
                        if (!post.getSone().equals(currentSone)) {
                                throw new RedirectException("noPermission.html");
@@ -72,21 +73,9 @@ public class DeletePostPage extends SoneTemplatePage {
                        } else if (request.getHttpRequest().isPartSet("abortDelete")) {
                                throw new RedirectException(returnPage);
                        }
-                       template.set("post", post);
-                       template.set("returnPage", returnPage);
+                       templateContext.set("post", post);
+                       templateContext.set("returnPage", returnPage);
                }
        }
 
-       //
-       // SONETEMPLATEPAGE METHODS
-       //
-
-       /**
-        * {@inheritDoc}
-        */
-       @Override
-       protected boolean requiresLogin() {
-               return true;
-       }
-
 }