From bf6507766c997f89bb2415e837fc11ba01829433 Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Wed, 13 Apr 2011 06:16:23 +0200 Subject: [PATCH] Add confirmation before deleting album. --- .../java/net/pterodactylus/sone/web/DeleteAlbumPage.java | 9 +++++++++ src/main/java/net/pterodactylus/sone/web/WebInterface.java | 3 ++- src/main/resources/i18n/sone.en.properties | 5 +++++ src/main/resources/templates/deleteAlbum.html | 14 ++++++++++++++ src/main/resources/templates/imageBrowser.html | 3 +-- 5 files changed, 31 insertions(+), 3 deletions(-) create mode 100644 src/main/resources/templates/deleteAlbum.html diff --git a/src/main/java/net/pterodactylus/sone/web/DeleteAlbumPage.java b/src/main/java/net/pterodactylus/sone/web/DeleteAlbumPage.java index b7c7267..6855e38 100644 --- a/src/main/java/net/pterodactylus/sone/web/DeleteAlbumPage.java +++ b/src/main/java/net/pterodactylus/sone/web/DeleteAlbumPage.java @@ -56,6 +56,9 @@ public class DeleteAlbumPage extends SoneTemplatePage { if (!webInterface.getCore().isLocalSone(album.getSone())) { throw new RedirectException("noPermission.html"); } + if (request.getHttpRequest().isPartSet("abortDelete")) { + throw new RedirectException("imageBrowser.html?album=" + album.getId()); + } Album parentAlbum = album.getParent(); webInterface.getCore().deleteAlbum(album); if (parentAlbum == null) { @@ -63,6 +66,12 @@ public class DeleteAlbumPage extends SoneTemplatePage { } throw new RedirectException("imageBrowser.html?album=" + parentAlbum.getId()); } + String albumId = request.getHttpRequest().getParam("album"); + Album album = webInterface.getCore().getAlbum(albumId, false); + if (album == null) { + throw new RedirectException("invalid.html"); + } + templateContext.set("album", album); } } diff --git a/src/main/java/net/pterodactylus/sone/web/WebInterface.java b/src/main/java/net/pterodactylus/sone/web/WebInterface.java index 5fab260..7ad32fd 100644 --- a/src/main/java/net/pterodactylus/sone/web/WebInterface.java +++ b/src/main/java/net/pterodactylus/sone/web/WebInterface.java @@ -555,6 +555,7 @@ public class WebInterface implements CoreListener { Template deleteSoneTemplate = TemplateParser.parse(createReader("/templates/deleteSone.html")); 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 noPermissionTemplate = TemplateParser.parse(createReader("/templates/noPermission.html")); Template optionsTemplate = TemplateParser.parse(createReader("/templates/options.html")); Template aboutTemplate = TemplateParser.parse(createReader("/templates/about.html")); @@ -584,7 +585,7 @@ public class WebInterface implements CoreListener { pageToadlets.add(pageToadletFactory.createPageToadlet(new ImageBrowserPage(imageBrowserTemplate, this), "ImageBrowser")); pageToadlets.add(pageToadletFactory.createPageToadlet(new CreateAlbumPage(createAlbumTemplate, this))); pageToadlets.add(pageToadletFactory.createPageToadlet(new EditAlbumPage(emptyTemplate, this))); - pageToadlets.add(pageToadletFactory.createPageToadlet(new DeleteAlbumPage(emptyTemplate, this))); + 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))); diff --git a/src/main/resources/i18n/sone.en.properties b/src/main/resources/i18n/sone.en.properties index da15a37..b112f72 100644 --- a/src/main/resources/i18n/sone.en.properties +++ b/src/main/resources/i18n/sone.en.properties @@ -184,7 +184,12 @@ Page.UploadImage.Error.InvalidImage=The image you were trying to upload could no Page.EditImage.Title=Edit Image Page.DeleteImage.Title=Delete Image Page.EditAlbum.Title=Edit Album + Page.DeleteAlbum.Title=Delete Album +Page.DeleteAlbum.Page.Title=Delete Album +Page.DeleteAlbum.Text.AlbumWillBeGone=This will remove your album “{title}”. Do you really want to do that? +Page.DeleteAlbum.Button.Yes=Yes, delete album. +Page.DeleteAlbum.Button.No=No, don’t delete album. Page.Trust.Title=Trust Sone - Sone diff --git a/src/main/resources/templates/deleteAlbum.html b/src/main/resources/templates/deleteAlbum.html new file mode 100644 index 0000000..cb27c19 --- /dev/null +++ b/src/main/resources/templates/deleteAlbum.html @@ -0,0 +1,14 @@ +<%include include/head.html> + +

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

+ +

<%= Page.DeleteAlbum.Text.AlbumWillBeGone|l10n|replace needle="{title}" replacementKey=album.title|html>

+ +
+ + + + +
+ +<%include include/tail.html> diff --git a/src/main/resources/templates/imageBrowser.html b/src/main/resources/templates/imageBrowser.html index fd4c224..6faea11 100644 --- a/src/main/resources/templates/imageBrowser.html +++ b/src/main/resources/templates/imageBrowser.html @@ -111,8 +111,7 @@ <%if album.empty> -
- +
-- 2.7.4