Fix ALL the logging!
[Sone.git] / src / main / java / net / pterodactylus / sone / web / ImageBrowserPage.java
index 3afaae6..5bb75d1 100644 (file)
@@ -18,6 +18,9 @@
 package net.pterodactylus.sone.web;
 
 import java.net.URI;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
 
 import net.pterodactylus.sone.data.Album;
 import net.pterodactylus.sone.data.Image;
@@ -69,11 +72,25 @@ 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);
+                       List<Album> albums = new ArrayList<Album>();
+                       for (Sone sone : webInterface.getCore().getSones()) {
+                               albums.addAll(sone.getAllAlbums());
+                       }
+                       Collections.sort(albums, Album.TITLE_COMPARATOR);
+                       templateContext.set("albums", albums);
+                       return;
+               }
+               Sone sone = getCurrentSone(request.getToadletContext(), false);
                templateContext.set("soneRequested", true);
                templateContext.set("sone", sone);
        }