redirect to proper directory

generate thumbnail for directories when not otherwise specified
This commit is contained in:
erik 2009-01-05 06:09:36 +00:00
parent 2a3f55db82
commit 167e214a38
2 changed files with 12 additions and 4 deletions

View file

@ -153,11 +153,15 @@ public class EntryDao {
Album childAlbum = read(dir); Album childAlbum = read(dir);
Entry childCover = childAlbum.getCover(); Entry childCover = childAlbum.getCover();
if (childCover == null) {
Iterator<Entry> i = childAlbum.getContents().iterator();
childCover = i.hasNext() ? i.next() : null;
}
if (childCover != null) { if (childCover != null) {
childCover.setFile(false); childCover.setFile(false);
childCover.setName(dir.getName()); childCover.setName(dir.getName());
childCover.setPath(dir.getName() + "/" + childCover.getPath()); childCover.setPath(dir.getName() + "/" + childCover.getPath());
album.addContents(childCover); album.addContents(childCover);
} }
} }
} }

View file

@ -65,6 +65,10 @@ public class AlbumServlet
} }
if (file.isDirectory()) { if (file.isDirectory()) {
if (!pathInfo.endsWith("/")) {
res.sendRedirect(req.getContextPath() + req.getRequestURI() + "/");
return;
}
try { try {
List<Entry> entries = dao.read(file).getContents(); List<Entry> entries = dao.read(file).getContents();
res.setContentType("text/html"); res.setContentType("text/html");