Add gallery mode to image browser.
authorDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Tue, 15 Nov 2011 05:54:02 +0000 (06:54 +0100)
committerDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Tue, 15 Nov 2011 05:54:02 +0000 (06:54 +0100)
This resolves #235.

src/main/java/net/pterodactylus/sone/web/ImageBrowserPage.java
src/main/resources/static/css/sone.css
src/main/resources/templates/imageBrowser.html

index 3afaae6..406a762 100644 (file)
@@ -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<Album> albums = new HashSet<Album>();
+                       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);
        }
index f30bb03..e46540a 100644 (file)
@@ -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;
 }
index 66eb33d..58ed8ab 100644 (file)
 
                <%/if>
 
+       <%elseif galleryRequested>
+
+               <%foreach albums album>
+                       <%first><h2><%= Page.ImageBrowser.Header.Albums|l10n|html></h2><%/first>
+                       <%if loop.count|mod divisor=3><div class="album-row"><%/if>
+                       <div id="album-<% album.id|html>" class="album">
+                               <div class="album-id hidden"><% album.id|html></div>
+                               <div class="album-container">
+                                       <a href="imageBrowser.html?album=<% album.id|html>" title="<% album.title|html>">
+                                               <%ifnull album.albumImage>
+                                                       <img src="images/unknown-image-0.png" width="333" height="250" alt="<% album.title|html> (<%album.sone.niceName|html>)" title="<% album.title|html> (<%album.sone.niceName|html>)" style="position: relative; top: 0px; left: -41px;" />
+                                               <%else><!-- TODO -->
+                                                       <% album.albumImage|image-link max-width=250 max-height=250 mode=enlarge title==album.title>
+                                               <%/if>
+                                       </a>
+                               </div>
+                               <div class="show-data">
+                                       <div class="album-sone"><a href="imageBrowser.html?sone=<%album.sone.id|html>"><%album.sone.niceName|html></a></div>
+                                       <div class="album-title"><% album.title|html> (<%= View.Sone.Stats.Images|l10n 0=album.images.size>)</div>
+                                       <div class="album-description"><% album.description|parse sone=album.sone></div>
+                               </div>
+                       </div>
+                       <%= 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></div><%/if>
+               <%/foreach>
+
        <%/if>
 
 <%include include/tail.html>