From 03a7fb4f25191e6bcb64bc953572aaf7f5958b19 Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Sat, 12 Nov 2011 13:16:54 +0100 Subject: [PATCH] Add buttons to re-order images and albums without javascript. This resolves #243. --- .../net/pterodactylus/sone/web/EditAlbumPage.java | 21 +++++++++++++++++++++ src/main/resources/templates/imageBrowser.html | 11 +++++++++++ .../resources/templates/include/browseAlbums.html | 5 +++++ 3 files changed, 37 insertions(+) diff --git a/src/main/java/net/pterodactylus/sone/web/EditAlbumPage.java b/src/main/java/net/pterodactylus/sone/web/EditAlbumPage.java index 8f595a7..dc5c8fa 100644 --- a/src/main/java/net/pterodactylus/sone/web/EditAlbumPage.java +++ b/src/main/java/net/pterodactylus/sone/web/EditAlbumPage.java @@ -18,6 +18,7 @@ package net.pterodactylus.sone.web; import net.pterodactylus.sone.data.Album; +import net.pterodactylus.sone.data.Sone; import net.pterodactylus.sone.text.TextFilter; import net.pterodactylus.sone.web.page.FreenetRequest; import net.pterodactylus.util.template.Template; @@ -50,6 +51,7 @@ public class EditAlbumPage extends SoneTemplatePage { protected void processTemplate(FreenetRequest request, TemplateContext templateContext) throws RedirectException { super.processTemplate(request, templateContext); if (request.getMethod() == Method.POST) { + Sone currentSone = getCurrentSone(request.getToadletContext()); String albumId = request.getHttpRequest().getPartAsStringFailsafe("album", 36); Album album = webInterface.getCore().getAlbum(albumId, false); if (album == null) { @@ -58,6 +60,25 @@ public class EditAlbumPage extends SoneTemplatePage { if (!webInterface.getCore().isLocalSone(album.getSone())) { throw new RedirectException("noPermission.html"); } + if ("true".equals(request.getHttpRequest().getPartAsStringFailsafe("moveLeft", 4))) { + if (album.getParent() == null) { + currentSone.moveAlbumUp(album); + webInterface.getCore().touchConfiguration(); + throw new RedirectException("imageBrowser.html?sone=" + currentSone.getId()); + } + album.getParent().moveAlbumUp(album); + webInterface.getCore().touchConfiguration(); + throw new RedirectException("imageBrowser.html?album=" + album.getParent().getId()); + } else if ("true".equals(request.getHttpRequest().getPartAsStringFailsafe("moveRight", 4))) { + if (album.getParent() == null) { + currentSone.moveAlbumDown(album); + webInterface.getCore().touchConfiguration(); + throw new RedirectException("imageBrowser.html?sone=" + currentSone.getId()); + } + album.getParent().moveAlbumDown(album); + webInterface.getCore().touchConfiguration(); + throw new RedirectException("imageBrowser.html?album=" + album.getParent().getId()); + } String albumImageId = request.getHttpRequest().getPartAsStringFailsafe("album-image", 36); if (webInterface.getCore().getImage(albumImageId, false) == null) { albumImageId = null; diff --git a/src/main/resources/templates/imageBrowser.html b/src/main/resources/templates/imageBrowser.html index 1da99ff..755c431 100644 --- a/src/main/resources/templates/imageBrowser.html +++ b/src/main/resources/templates/imageBrowser.html @@ -298,6 +298,9 @@ }); $("#edit-album label").hide(); + /* hide non-js image move buttons. */ + $(".move-buttons").hide(); + hideAndShowBlock("div.edit-album", ".show-edit-album", ".hide-edit-album"); hideAndShowBlock("div.create-album", ".show-create-album", ".hide-create-album"); hideAndShowBlock("div.upload-image", ".show-upload-image", ".hide-upload-image"); @@ -386,6 +389,11 @@ +
+ + +
+