/*
- * Sone - ImageBrowserPage.java - Copyright © 2011 David Roden
+ * Sone - ImageBrowserPage.java - Copyright © 2011–2013 David Roden
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
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;
import net.pterodactylus.sone.data.Sone;
import net.pterodactylus.sone.web.page.FreenetRequest;
+import net.pterodactylus.util.collection.Pagination;
+import net.pterodactylus.util.number.Numbers;
import net.pterodactylus.util.template.Template;
import net.pterodactylus.util.template.TemplateContext;
Album album = webInterface.getCore().getAlbum(albumId, false);
templateContext.set("albumRequested", true);
templateContext.set("album", album);
+ templateContext.set("page", request.getHttpRequest().getParam("page"));
return;
}
String imageId = request.getHttpRequest().getParam("image", null);
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);
+ Pagination<Album> albumPagination = new Pagination<Album>(albums, 12).setPage(Numbers.safeParseInteger(request.getHttpRequest().getParam("page"), 0));
+ templateContext.set("albumPagination", albumPagination);
+ templateContext.set("albums", albumPagination.getItems());
+ return;
+ }
+ Sone sone = getCurrentSone(request.getToadletContext(), false);
templateContext.set("soneRequested", true);
templateContext.set("sone", sone);
}
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public boolean isLinkExcepted(URI link) {
+ return true;
+ }
+
}