From: David ‘Bombe’ Roden Date: Wed, 13 Apr 2011 04:36:01 +0000 (+0200) Subject: Add confirmation for image deletion. X-Git-Tag: beta-freefall-0.6.2-1~9 X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=b8545de14af229c6b557ef2229ee0166459d3a16;p=Sone.git Add confirmation for image deletion. --- diff --git a/src/main/java/net/pterodactylus/sone/web/DeleteImagePage.java b/src/main/java/net/pterodactylus/sone/web/DeleteImagePage.java index 84222ee..999a38a 100644 --- a/src/main/java/net/pterodactylus/sone/web/DeleteImagePage.java +++ b/src/main/java/net/pterodactylus/sone/web/DeleteImagePage.java @@ -51,18 +51,22 @@ public class DeleteImagePage extends SoneTemplatePage { @Override protected void processTemplate(Request request, TemplateContext templateContext) throws RedirectException { super.processTemplate(request, templateContext); + String imageId = (request.getMethod() == Method.POST) ? request.getHttpRequest().getPartAsStringFailsafe("image", 36) : request.getHttpRequest().getParam("image"); + Image image = webInterface.getCore().getImage(imageId, false); + if (image == null) { + throw new RedirectException("invalid.html"); + } + if (!webInterface.getCore().isLocalSone(image.getSone())) { + throw new RedirectException("noPermission.html"); + } if (request.getMethod() == Method.POST) { - String imageId = request.getHttpRequest().getPartAsStringFailsafe("image", 36); - Image image = webInterface.getCore().getImage(imageId, false); - if (image == null) { - throw new RedirectException("invalid.html"); - } - if (!webInterface.getCore().isLocalSone(image.getSone())) { - throw new RedirectException("noPermission.html"); + if (request.getHttpRequest().isPartSet("abortDelete")) { + throw new RedirectException("imageBrowser.html?image=" + image.getId()); } webInterface.getCore().deleteImage(image); throw new RedirectException("imageBrowser.html?album=" + image.getAlbum().getId()); } + templateContext.set("image", image); } } diff --git a/src/main/java/net/pterodactylus/sone/web/WebInterface.java b/src/main/java/net/pterodactylus/sone/web/WebInterface.java index 7ad32fd..376ff09 100644 --- a/src/main/java/net/pterodactylus/sone/web/WebInterface.java +++ b/src/main/java/net/pterodactylus/sone/web/WebInterface.java @@ -556,6 +556,7 @@ public class WebInterface implements CoreListener { Template imageBrowserTemplate = TemplateParser.parse(createReader("/templates/imageBrowser.html")); Template createAlbumTemplate = TemplateParser.parse(createReader("/templates/createAlbum.html")); Template deleteAlbumTemplate = TemplateParser.parse(createReader("/templates/deleteAlbum.html")); + Template deleteImageTemplate = TemplateParser.parse(createReader("/templates/deleteImage.html")); Template noPermissionTemplate = TemplateParser.parse(createReader("/templates/noPermission.html")); Template optionsTemplate = TemplateParser.parse(createReader("/templates/options.html")); Template aboutTemplate = TemplateParser.parse(createReader("/templates/about.html")); @@ -588,7 +589,7 @@ public class WebInterface implements CoreListener { pageToadlets.add(pageToadletFactory.createPageToadlet(new DeleteAlbumPage(deleteAlbumTemplate, this))); pageToadlets.add(pageToadletFactory.createPageToadlet(new UploadImagePage(invalidTemplate, this))); pageToadlets.add(pageToadletFactory.createPageToadlet(new EditImagePage(emptyTemplate, this))); - pageToadlets.add(pageToadletFactory.createPageToadlet(new DeleteImagePage(emptyTemplate, this))); + pageToadlets.add(pageToadletFactory.createPageToadlet(new DeleteImagePage(deleteImageTemplate, this))); pageToadlets.add(pageToadletFactory.createPageToadlet(new TrustPage(emptyTemplate, this))); pageToadlets.add(pageToadletFactory.createPageToadlet(new DistrustPage(emptyTemplate, this))); pageToadlets.add(pageToadletFactory.createPageToadlet(new UntrustPage(emptyTemplate, this))); diff --git a/src/main/resources/i18n/sone.en.properties b/src/main/resources/i18n/sone.en.properties index b112f72..a5ab0c1 100644 --- a/src/main/resources/i18n/sone.en.properties +++ b/src/main/resources/i18n/sone.en.properties @@ -182,7 +182,13 @@ Page.UploadImage.Title=Upload Image - Sone Page.UploadImage.Error.InvalidImage=The image you were trying to upload could not be recognized. Please upload only JPEG (*.jpg or *.jpeg), or PNG (*.png) images. Page.EditImage.Title=Edit Image + Page.DeleteImage.Title=Delete Image +Page.DeleteImage.Page.Title=Delete Image +Page.DeleteImage.Text.ImageWillBeGone=This will remove the image “{image}” from your album “{album}”. If it has already been inserted into Freenet it can not be removed from there forcefully. Do you want to do delete the image? +Page.DeleteImage.Button.Yes=Yes, delete image. +Page.DeleteImage.Button.No=No, don’t delete image. + Page.EditAlbum.Title=Edit Album Page.DeleteAlbum.Title=Delete Album diff --git a/src/main/resources/templates/deleteImage.html b/src/main/resources/templates/deleteImage.html new file mode 100644 index 0000000..68b403e --- /dev/null +++ b/src/main/resources/templates/deleteImage.html @@ -0,0 +1,14 @@ +<%include include/head.html> + +

<%= Page.DeleteImage.Page.Title|l10n|html>

+ +

<%= Page.DeleteImage.Text.ImageWillBeGone|l10n|replace needle="{image}" replacementKey=image.title|replace needle="{album}" replacementKey=image.album.title|html>

+ +
+ + + + +
+ +<%include include/tail.html> diff --git a/src/main/resources/templates/imageBrowser.html b/src/main/resources/templates/imageBrowser.html index 6faea11..9bcaa9d 100644 --- a/src/main/resources/templates/imageBrowser.html +++ b/src/main/resources/templates/imageBrowser.html @@ -191,8 +191,7 @@

<%= Page.ImageBrowser.Image.Delete.Title|l10n|html>

-
- +