From 7bfd17c9c8b2fd5717308019bd2821ca643b4814 Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Tue, 15 Nov 2011 06:54:02 +0100 Subject: [PATCH] Add gallery mode to image browser. This resolves #235. --- .../pterodactylus/sone/web/ImageBrowserPage.java | 19 +++++++++++++-- src/main/resources/static/css/sone.css | 4 ++++ src/main/resources/templates/imageBrowser.html | 28 ++++++++++++++++++++++ 3 files changed, 49 insertions(+), 2 deletions(-) diff --git a/src/main/java/net/pterodactylus/sone/web/ImageBrowserPage.java b/src/main/java/net/pterodactylus/sone/web/ImageBrowserPage.java index 3afaae6..406a762 100644 --- a/src/main/java/net/pterodactylus/sone/web/ImageBrowserPage.java +++ b/src/main/java/net/pterodactylus/sone/web/ImageBrowserPage.java @@ -18,6 +18,8 @@ package net.pterodactylus.sone.web; import java.net.URI; +import java.util.HashSet; +import java.util.Set; import net.pterodactylus.sone.data.Album; import net.pterodactylus.sone.data.Image; @@ -69,11 +71,24 @@ public class ImageBrowserPage extends SoneTemplatePage { templateContext.set("image", image); return; } - Sone sone = getCurrentSone(request.getToadletContext(), false); String soneId = request.getHttpRequest().getParam("sone", null); if (soneId != null) { - sone = webInterface.getCore().getSone(soneId, false); + Sone sone = webInterface.getCore().getSone(soneId, false); + templateContext.set("soneRequested", true); + templateContext.set("sone", sone); + return; } + String mode = request.getHttpRequest().getParam("mode", null); + if ("gallery".equals(mode)) { + templateContext.set("galleryRequested", true); + Set albums = new HashSet(); + for (Sone sone : webInterface.getCore().getSones()) { + albums.addAll(sone.getAllAlbums()); + } + templateContext.set("albums", albums); + return; + } + Sone sone = getCurrentSone(request.getToadletContext(), false); templateContext.set("soneRequested", true); templateContext.set("sone", sone); } diff --git a/src/main/resources/static/css/sone.css b/src/main/resources/static/css/sone.css index f30bb03..e46540a 100644 --- a/src/main/resources/static/css/sone.css +++ b/src/main/resources/static/css/sone.css @@ -684,6 +684,10 @@ textarea { width: 95%; } +#sone .image .album-sone { + font-size: 80%; +} + #sone .image .image-title, #sone .album .album-title { font-weight: bold; } diff --git a/src/main/resources/templates/imageBrowser.html b/src/main/resources/templates/imageBrowser.html index 66eb33d..58ed8ab 100644 --- a/src/main/resources/templates/imageBrowser.html +++ b/src/main/resources/templates/imageBrowser.html @@ -588,6 +588,34 @@ <%/if> + <%elseif galleryRequested> + + <%foreach albums album> + <%first>

<%= Page.ImageBrowser.Header.Albums|l10n|html>

<%/first> + <%if loop.count|mod divisor=3>
<%/if> +
+ + +
+ +
<% album.title|html> (<%= View.Sone.Stats.Images|l10n 0=album.images.size>)
+
<% album.description|parse sone=album.sone>
+
+
+ <%= false|store key=endRow> + <%if loop.count|mod divisor=3 offset=1><%= true|store key=endRow><%/if> + <%last><%= true|store key=endRow><%/last> + <%if endRow>
<%/if> + <%/foreach> + <%/if> <%include include/tail.html> -- 2.7.4