Add “toggle parser” link to posts and replies to deactivate the parser.
[Sone.git] / src / main / java / net / pterodactylus / sone / web / ViewPostPage.java
index cdbc6da..967b9c5 100644 (file)
@@ -52,8 +52,10 @@ public class ViewPostPage extends SoneTemplatePage {
        protected void processTemplate(Request request, TemplateContext templateContext) throws RedirectException {
                super.processTemplate(request, templateContext);
                String postId = request.getHttpRequest().getParam("post");
+               boolean raw = request.getHttpRequest().getParam("raw").equals("true");
                Post post = webInterface.getCore().getPost(postId);
                templateContext.set("post", post);
+               templateContext.set("raw", raw);
        }
 
        /**
@@ -62,6 +64,9 @@ public class ViewPostPage extends SoneTemplatePage {
        @Override
        protected void postProcess(Request request, TemplateContext templateContext) {
                Post post = (Post) templateContext.get("post");
+               if (post == null) {
+                       return;
+               }
                webInterface.getCore().markPostKnown(post);
                for (Reply reply : webInterface.getCore().getReplies(post)) {
                        webInterface.getCore().markReplyKnown(reply);