]> git.decadent.org.uk Git - memories.git/blob - templates/photo/view
Rejig the output to cope with cases of lots of tags.
[memories.git] / templates / photo / view
1 [% INCLUDE header %]
2 [% SET tab = request.params.active || "comment" %]
3 [% SET url = base _ "/photo/view/" _ photo.id; %]
4 <table width="100%">
5     <tr valign="top">
6     <td width="70%">
7     [% IF prev %]
8         <small><a href="[%base%]/photo/view/[%prev.id%]">&lt;&lt; [% prev %]</a></small>
9     [% END %]
10 <h1>[% photo.title %]</h1>
11     [% IF next %]
12         <small><a href="[%base%]/photo/view/[%next.id%]"> [% next %] &gt;&gt;</a></small>
13     [% END %]
14 [% IF request.user == photo.uploader %]
15     <p><a href="[%base%]/photo/delete/[%photo.id%]">Delete this
16     photo</a></p>
17     <form action="[%base%]/photo/do_edit/[%photo.id%]">
18         <input name="title" value="[%photo.title |html%]">
19         <input type="submit" name="Rename" value="Rename">
20     </form>
21 [% END %]
22 </td>
23 <td align="right">
24 [% IF photo.albums %]
25 In albums:
26 [% FOR album = photo.albums; %]
27 <a href="[%base%]/album/view/[%album.id%]">[%album.name%]</a> ([%album.photos.size%])
28 [% ";" UNLESS album == photo.albums.last %]
29 [% END %]
30 <br>
31 [% END %]
32 <small>
33 <i>Photo shot on [% photo.shot.ymd %] </i> <br>
34 Uploaded by <a href="[%base%]/user/view/[%photo.uploader.id%]"> [%
35 photo.uploader %] </a>
36 </small></td>
37 </tr>
38 </table>
39
40 <div class="tagbrowse smaller">
41 [% SET tagset = {}; FOR tag = photo.tags;
42     SET name = tag.name; tagset.$name = tag.taggings.size;
43   END;
44   SET sorted = tagset.nsort.reverse;
45 %]
46 [% SET counter = 0;
47   FOR tag = sorted;
48     counter = counter + 1;
49     IF tagset.$tag > 1; 
50         "<a href=\""; base;"/tag/view/";tag | html | uri;"\">";
51         tag;
52         "</a>&nbsp;(";
53         tagset.$tag; ")";
54     ELSE; 
55         tag; 
56         IF counter > 20; "..."; LAST; END;
57     END;
58     ", " UNLESS tag == sorted.last;
59 END %]
60 </div>
61
62 <div class="photoview">
63     [% SET sizes = request.config.sizes %]
64     [% IF request.params.exists("scale") %]
65         [% SET size =  request.params.scale  %]
66     [% ELSIF request.session.scale %]
67         [% SET size =  request.session.scale  %]
68     [% ELSE; SET size =  1; END; %]
69     <img src="[% photo.sized_url(size) %]">
70     <p> (Original size [%photo.dimensions %]) </p>
71     <p>
72     Size: 
73     [% SET i = 0; WHILE i < sizes.size %]
74         [% IF photo.is_bigger(sizes.$i);  %]
75             [% IF i == size %]
76                 [% sizes.$i %]
77             [% ELSIF sizes.$i == "full" %]
78                 <a href="[%photo.path("url")%]">full</a>
79             [% ELSE %]
80                 <a href="[%url%]?scale=[% i %]&active=[%tab%]">[% sizes.$i %]</a>
81             [% END %]
82         [% END; %] 
83     [% SET i = i + 1 %]
84     [% END %]
85     </p>
86     [%# Now put it back in the session %]
87     [% SET request.session.scale = size %]
88 </div>
89
90 [% IF photo.description OR photo.copyright OR photo.license %]
91 <div class="photodesc"> 
92     [% photo.description | html %] 
93     [% IF photo.copyright %] <div class="photorights"> [% photo.copyright | html %] </div> [% END %]
94     [% IF photo.license %] <div class="photolicense"> [% photo.license | html %] </div> [% END %]
95 </div>
96 [% END %]
97
98 <script>
99 function select_tab(name) {
100     document.getElementsByClassName("active").each(function (x) { x.removeClassName("active")});
101     new Ajax.Updater("content","[%base%]/photo/"+name+"/[%photo.id%]",
102       { method: "get" }
103     )
104     $(name).addClassName("active");
105 }
106 </script>
107 [% MACRO do_tab(tabname, label) BLOCK; %]
108 <li>
109     <a [% IF tab == tabname %] class="active" [% END %] id="[%tabname%]" href="javascript:select_tab('[%tabname%]')">
110     [%label%]</a>
111 </li>
112 [% END %]
113
114 <ul id="tabmenu">
115     [%do_tab("comment", "Comments") %]
116     [%do_tab("exif", "Photo info") %]
117     [%do_tab("tagedit", "Edit tags") %]
118     [%do_tab("similar", "Similar photos") %]
119 </ul>
120 <div id="content">
121 [% INCLUDE comment %]
122 </div>
123 [%
124 INCLUDE footer;
125 %]