[% INCLUDE header %]
[% SET tab = request.params.active || "comment" %]
[% SET url = base _ "/photo/view/" _ photo.id; %]
<table width="100%">
    <tr valign="top">
    <td width="70%">
<h1>[% photo.title %]</h1>
[% IF request.user == photo.uploader %]
    <p><a href="[%base%]/photo/delete/[%photo.id%]">Delete this
    photo</a></p>
    <form action="[%base%]/photo/do_edit/[%photo.id%]">
        <input name="title" value="[%photo.title |html%]">
        <input type="submit" name="Rename" value="Rename">
    </form>
[% END %]
</td>
<td align="right" class="tagbrowse">
[% FOR tag = photo.tags;
    "<a href=\""; base;"/tag/view/";tag.name | html | uri;"\">";
    tag;
    "</a>&nbsp;(";
    tag.taggings.size; ")";
    ", " UNLESS tag == photo.tags.last;
END %]
</td>
</tr>
<tr>
<td>
[% IF photo.albums %]
In albums:
[% FOR album = photo.albums; %]
<a href="[%base%]/album/view/[%album.id%]">[%album.name%]</a> ([%album.photos.size%])
[% ";" UNLESS album == photo.albums.last %]
[% END %]
[% END %]

</td>
<td align="right" class="tagbrowse"><small>
<i>Photo shot on [% photo.shot.ymd %] </i> <br>
Uploaded by <a href="[%base%]/user/view/[%photo.uploader.id%]"> [%
photo.uploader %] </a>
</small></td>
</tr>
</table>
<div class="photoview">
    [% SET sizes = request.config.sizes %]
    [% IF request.params.exists("scale") %]
        [% SET size =  request.params.scale  %]
    [% ELSIF request.session.scale %]
        [% SET size =  request.session.scale  %]
    [% ELSE; SET size =  1; END; %]
    <img src="[% photo.sized_url(size) %]">
    <p> (Original size [%photo.dimensions %]) </p>
    <p>
    Size: 
    [% SET i = 0; WHILE i < sizes.size %]
        [% IF photo.is_bigger(sizes.$i);  %]
            [% IF i == size %]
                [% sizes.$i %]
            [% ELSE %]
                <a href="[%url%]?scale=[% i %]&active=[%tab%]">[% sizes.$i %]</a>
            [% END %]
        [% END; %] 
    [% SET i = i + 1 %]
    [% END %]
    </p>
    [%# Now put it back in the session %]
    [% SET request.session.scale = size %]
</div>

[% MACRO do_tab(tabname, label) BLOCK; %]
<li>
    [% IF tab == tabname %]<a class="active">
    [% ELSE %]<a href="[%url%]?scale=[%size%]&active=[%tabname%]"> 
    [% END %]
    [%label%]</a>
</li>
[% END %]

<ul id="tabmenu">
    [%do_tab("comment", "Comments") %]
    [%do_tab("exif", "Photo info") %]
    [%do_tab("tagedit", "Edit tags") %]
</ul>
<div id="content">
[%
IF request.params.active == "tagedit"; INCLUDE tagedit; 
ELSIF request.params.active == "exif"; INCLUDE exif;
ELSE;                                  INCLUDE comment; END;
%]
</div>
[%
INCLUDE footer;
%]
