2 * Sone - ImageBrowserPage.java - Copyright © 2011 David Roden
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 package net.pterodactylus.sone.web;
21 import java.util.HashSet;
24 import net.pterodactylus.sone.data.Album;
25 import net.pterodactylus.sone.data.Image;
26 import net.pterodactylus.sone.data.Sone;
27 import net.pterodactylus.sone.web.page.FreenetRequest;
28 import net.pterodactylus.util.template.Template;
29 import net.pterodactylus.util.template.TemplateContext;
32 * The image browser page is the entry page for the image management.
34 * @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
36 public class ImageBrowserPage extends SoneTemplatePage {
39 * Creates a new image browser page.
42 * The template to render
44 * The Sone web interface
46 public ImageBrowserPage(Template template, WebInterface webInterface) {
47 super("imageBrowser.html", template, "Page.ImageBrowser.Title", webInterface, true);
51 // SONETEMPLATEPAGE METHODS
58 protected void processTemplate(FreenetRequest request, TemplateContext templateContext) throws RedirectException {
59 super.processTemplate(request, templateContext);
60 String albumId = request.getHttpRequest().getParam("album", null);
61 if (albumId != null) {
62 Album album = webInterface.getCore().getAlbum(albumId, false);
63 templateContext.set("albumRequested", true);
64 templateContext.set("album", album);
67 String imageId = request.getHttpRequest().getParam("image", null);
68 if (imageId != null) {
69 Image image = webInterface.getCore().getImage(imageId, false);
70 templateContext.set("imageRequested", true);
71 templateContext.set("image", image);
74 String soneId = request.getHttpRequest().getParam("sone", null);
76 Sone sone = webInterface.getCore().getSone(soneId, false);
77 templateContext.set("soneRequested", true);
78 templateContext.set("sone", sone);
81 String mode = request.getHttpRequest().getParam("mode", null);
82 if ("gallery".equals(mode)) {
83 templateContext.set("galleryRequested", true);
84 Set<Album> albums = new HashSet<Album>();
85 for (Sone sone : webInterface.getCore().getSones()) {
86 albums.addAll(sone.getAllAlbums());
88 templateContext.set("albums", albums);
91 Sone sone = getCurrentSone(request.getToadletContext(), false);
92 templateContext.set("soneRequested", true);
93 templateContext.set("sone", sone);
100 public boolean isLinkExcepted(URI link) {