--- /dev/null
+/*
+ * Sone - DeleteReplyPage.java - Copyright © 2010 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
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+package net.pterodactylus.sone.web;
+
+import net.pterodactylus.sone.data.Reply;
+import net.pterodactylus.sone.data.Sone;
+import net.pterodactylus.sone.web.page.Page.Request.Method;
+import net.pterodactylus.util.template.Template;
+
+/**
+ * This page lets the user delete a reply.
+ *
+ * @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
+ */
+public class DeleteReplyPage extends SoneTemplatePage {
+
+ /**
+ * Creates a new “delete reply” page.
+ *
+ * @param template
+ * The template to render
+ * @param webInterface
+ * The Sone web interface
+ */
+ public DeleteReplyPage(Template template, WebInterface webInterface) {
+ super("deleteReply.html", template, "Page.DeleteReply.Title", webInterface);
+ }
+
+ //
+ // TEMPLATEPAGE METHODS
+ //
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected void processTemplate(Request request, Template template) throws RedirectException {
+ super.processTemplate(request, template);
+ String replyId = request.getHttpRequest().getPartAsStringFailsafe("reply", 36);
+ Reply reply = webInterface.core().getReply(replyId);
+ String returnPage = request.getHttpRequest().getPartAsStringFailsafe("returnPage", 64);
+ if (request.getMethod() == Method.POST) {
+ Sone currentSone = getCurrentSone(request.getToadletContext());
+ if (!reply.getSone().equals(currentSone)) {
+ throw new RedirectException("noPermission.html");
+ }
+ if (request.getHttpRequest().isPartSet("confirmDelete")) {
+ webInterface.core().deleteReply(reply);
+ throw new RedirectException(returnPage);
+ } else if (request.getHttpRequest().isPartSet("abortDelete")) {
+ throw new RedirectException(returnPage);
+ }
+ }
+ template.set("reply", reply);
+ template.set("returnPage", returnPage);
+ }
+
+ //
+ // SONETEMPLATEPAGE METHODS
+ //
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected boolean requiresLogin() {
+ return true;
+ }
+
+}
Template unblockSoneTemplate = templateFactory.createTemplate(createReader("/templates/unblockSone.html"));
Template viewPostTemplate = templateFactory.createTemplate(createReader("/templates/viewPost.html"));
Template deletePostTemplate = templateFactory.createTemplate(createReader("/templates/deletePost.html"));
+ Template deleteReplyTemplate = templateFactory.createTemplate(createReader("/templates/deleteReply.html"));
Template followSoneTemplate = templateFactory.createTemplate(createReader("/templates/followSone.html"));
Template unfollowSoneTemplate = templateFactory.createTemplate(createReader("/templates/unfollowSone.html"));
Template deleteSoneTemplate = templateFactory.createTemplate(createReader("/templates/deleteSone.html"));
pageToadlets.add(pageToadletFactory.createPageToadlet(new UnblockSonePage(unblockSoneTemplate, this)));
pageToadlets.add(pageToadletFactory.createPageToadlet(new ViewPostPage(viewPostTemplate, this)));
pageToadlets.add(pageToadletFactory.createPageToadlet(new DeletePostPage(deletePostTemplate, this)));
+ pageToadlets.add(pageToadletFactory.createPageToadlet(new DeleteReplyPage(deleteReplyTemplate, this)));
pageToadlets.add(pageToadletFactory.createPageToadlet(new FollowSonePage(followSoneTemplate, this)));
pageToadlets.add(pageToadletFactory.createPageToadlet(new UnfollowSonePage(unfollowSoneTemplate, this)));
pageToadlets.add(pageToadletFactory.createPageToadlet(new DeleteSonePage(deleteSoneTemplate, this), "DeleteSone"));
Page.DeletePost.Button.Yes=Yes, delete.
Page.DeletePost.Button.No=No, do not delete.
+Page.DeleteReply.Title=Delete Reply - Sone
+Page.DeleteReply.Page.Title=Delete Reply
+Page.DeleteReply.Text.PostWillBeGone=Deleting a reply will remove it from your Sone. It will not remove it from Freenet because that is not possible. Older versions of your Sone will always include the deleted reply.
+Page.DeleteReply.Button.Yes=Yes, delete.
+Page.DeleteReply.Button.No=No, do not delete.
+
Page.FollowSone.Title=Follow Sone - Sone
Page.UnfollowSone.Title=Unfollow Sone - Sone
--- /dev/null
+<%include include/head.html>
+
+ <h1><%= Page.DeleteReply.Page.Title|l10n|html></h1>
+
+ <div><%= Page.DeleteReply.Text.PostWillBeGone|l10n|html></div>
+
+ <form method="post">
+ <input type="hidden" name="formPassword" value="<% formPassword|html>" />
+ <input type="hidden" name="returnPage" value="<% returnPage|html>" />
+ <input type="hidden" name="reply" value="<% reply.id|html>" />
+ <button type="submit" name="confirmDelete" value="1"><%= Page.DeleteReply.Button.Yes|l10n|html></button>
+ <button type="submit" name="abortDelete" value="1"><%= Page.DeleteReply.Button.No|l10n|html></button>
+ </form>
+
+<%include include/tail.html>