Mercurial > hg > montage
changeset 27:e5336ec2ee02
make sequence template better and more error resistant
author | Jeff Hammel <jhammel@mozilla.com> |
---|---|
date | Sun, 30 Oct 2011 14:45:35 -0700 |
parents | ee74cf1e444b |
children | 2df31d088583 |
files | montage/templates/sequence.html setup.py |
diffstat | 2 files changed, 9 insertions(+), 8 deletions(-) [+] |
line wrap: on
line diff
--- a/montage/templates/sequence.html Wed Oct 27 09:48:04 2010 -0700 +++ b/montage/templates/sequence.html Sun Oct 30 14:45:35 2011 -0700 @@ -11,7 +11,7 @@ <xi:include py:if="include" href="${include}"/> <center py:if="files" py:with="index = int(request.GET.get('index', 0))"> - <div py:with="image = files[index]" class="image"> + <div py:if="index in range(len(files))" py:with="image = files[index]" class="image"> <a name="${image['path']}"></a> <a href="${image['link']}"> <img src="${image['path']}" width="${width or None}" height="${height or None}"/> @@ -19,14 +19,15 @@ <br/> ${image.get('title', image['description'])} </div> - <py:if test="index > 0"> - <a href="?index=${index - 1}" - py:with="image=files[index - 1]"> - ${image.get("title", image.get("description", "»»"))} + <py:if test="(index - 1) in range(len(files))"> + <a href="?index=${index - 1}" py:with="image=files[index - 1]"> + ${image.get('title') or image.get('description') or '««'} </a> </py:if> - <py:if test="index < len(files)"> - <a href="?index=${index + 1}" py:with="image=files[index + 1]">${image.get('title', image.get('description', '««'))}</a> + <py:if test="(index + 1) in range(len(files))"> + <a href="?index=${index + 1}" py:with="image=files[index + 1]"> + ${image.get('title') or image.get('description') or '»»'} + </a> </py:if> </center>