Add return page to form parameters.
[Sone.git] / src / main / resources / templates / imageBrowser.html
1 <%include include/head.html>
2
3         <div class="page-id hidden">image-browser</div>
4
5         <%if albumRequested>
6
7                 <%ifnull album>
8
9                         <p><%= Page.ImageBrowser.Album.Error.NotFound.Text|l10n|html></p>
10
11                 <%elseifnull album.title>
12
13                         <p><%= Page.ImageBrowser.Album.Error.NotFound.Text|l10n|html></p>
14
15                 <%else>
16
17                         <%if album.sone.local>
18                                 <script language="javascript">
19                                         $(function() {
20                                                 getTranslation("WebInterface.DefaultText.UploadImage.Title", function(text) {
21                                                         $("#upload-image :input[name='title']").each(function() {
22                                                                 registerInputTextareaSwap(this, text, "title", false, true);
23                                                         });
24                                                 });
25                                                 getTranslation("WebInterface.DefaultText.UploadImage.Description", function(text) {
26                                                         $("#upload-image :input[name='description']").each(function() {
27                                                                 registerInputTextareaSwap(this, text, "description", true, false);
28                                                         });
29                                                 });
30                                                 $("#upload-image label").hide();
31                                                 getTranslation("WebInterface.DefaultText.CreateAlbum.Name", function(text) {
32                                                         $("#create-album input[name='name']").each(function() {
33                                                                 registerInputTextareaSwap(this, text, "name", false, true);
34                                                         });
35                                                 });
36                                                 getTranslation("WebInterface.DefaultText.CreateAlbum.Description", function(text) {
37                                                         $("#create-album input[name='description']").each(function() {
38                                                                 registerInputTextareaSwap(this, text, "description", true, true);
39                                                         });
40                                                 });
41                                                 $("#create-album label").hide();
42                                                 getTranslation("WebInterface.DefaultText.EditAlbum.Title", function(text) {
43                                                         $("#edit-album input[name='title']").each(function() {
44                                                                 registerInputTextareaSwap(this, text, "title", false, true);
45                                                         });
46                                                 });
47                                                 getTranslation("WebInterface.DefaultText.EditAlbum.Description", function(text) {
48                                                         $("#edit-album :input[name='description']").each(function() {
49                                                                 registerInputTextareaSwap(this, text, "description", true, false);
50                                                         });
51                                                 });
52                                                 $("#edit-album label").hide();
53
54                                                 /* hide all those forms. */
55                                                 hideBlock = function(blockElement, clickElement) {
56                                                         $(blockElement).hide();
57                                                         $(clickElement).removeClass("hidden").click(function() {
58                                                                 $(blockElement).slideDown();
59                                                                 $(this).slideUp();
60                                                                 return false;
61                                                         });
62                                                 };
63
64                                                 hideBlock(".edit-album", ".show-edit-album");
65                                                 hideBlock(".create-album", ".show-create-album");
66                                                 hideBlock(".upload-image", ".show-upload-image");
67                                         });
68                                 </script>
69                         <%/if>
70
71                         <h1 class="backlink"><%= Page.ImageBrowser.Album.Title|l10n|replace needle='{album}' replacementKey=album.title|html></h1>
72
73                         <div class="backlinks">
74                                 <%foreach album.backlinks backlink backlinks>
75                                         <div class="backlink">
76                                                 <a href="<% backlink.target|html>"><% backlink.name|html></a>
77                                         </div>
78                                         <%if ! backlinks.last>
79                                                 <div class="separator">&gt;</div>
80                                         <%/if>
81                                 <%/foreach>
82                         </div>
83
84                         <p id="description"><% album.description|html></p>
85
86                         <%if album.sone.local>
87                                 <p><a class="show-edit-album hidden small-link">» <%= Page.ImageBrowser.Album.Edit.Title|l10n|html></a></p>
88                                 <div class="edit-album">
89                                         <h2><%= Page.ImageBrowser.Album.Edit.Title|l10n|html></h2>
90
91                                         <form id="edit-album" action="editAlbum.html" method="post">
92                                                 <input type="hidden" name="formPassword" value="<%formPassword|html>" />
93                                                 <input type="hidden" name="album" value="<%album.id|html>" />
94
95                                                 <div>
96                                                         <label for="title"><%= Page.ImageBrowser.Album.Label.Title|l10n|html></label>
97                                                         <input type="text" name="title" value="<%album.title|html>" />
98                                                 </div>
99                                                 <div>
100                                                         <label for="description"><%= Page.ImageBrowser.Album.Label.Description|l10n|html></label>
101                                                         <textarea name="description"><%album.description|html></textarea>
102                                                 </div>
103                                                 <button type="submit"><%= Page.ImageBrowser.Album.Button.Save|l10n|html></button>
104                                         </form>
105                                 </div>
106                         <%/if>
107
108                         <%foreach album.albums album>
109                                 <%first><h2><%= Page.ImageBrowser.Header.Albums|l10n|html></h2><%/first>
110                                 <%if loop.count|mod divisor=3><div class="image-row"><%/if>
111                                 <div class="album image">
112                                         <a href="imageBrowser.html?album=<% album.id|html>" title="<% album.title|html>">
113                                                 <%ifnull album.albumImage>
114                                                         <img src="images/unknown-image-0.png" width="200" height="150" alt="<% album.title|html>" title="<% album.title|html>" />
115                                                 <%else><!-- TODO -->
116                                                         <% album.albumImage|image-link max-width=200 max-height=150 title==album.title>
117                                                 <%/if>
118                                                 <br/>
119                                                 <% album.title|html>
120                                         </a>
121                                 </div>
122                                 <%= false|store key=endRow>
123                                 <%if loop.count|mod divisor=3 offset=1><%= true|store key=endRow><%/if>
124                                 <%last><%= true|store key=endRow><%/last>
125                                 <%if endRow></div><%/if>
126                         <%/foreach>
127
128                         <%if album.sone.local>
129                                 <p><a class="show-create-album hidden small-link">» <%= View.CreateAlbum.Title|l10n|html></a></p>
130                                 <div class="create-album">
131                                         <%include include/createAlbum.html>
132                                 </div>
133                         <%/if>
134
135                         <%foreach album.images image>
136                                 <%first><h2><%= Page.ImageBrowser.Header.Images|l10n|html></h2><%/first>
137                                 <%if loop.count|mod divisor=3><div class="image-row"><%/if>
138                                 <div class="image">
139                                         <a href="imageBrowser.html?image=<%image.id|html>"><% image|image-link max-width=200 max-height=150></a>
140                                 </div>
141                                 <%= false|store key=endRow>
142                                 <%if loop.count|mod divisor=3 offset=1><%= true|store key=endRow><%/if>
143                                 <%last><%= true|store key=endRow><%/last>
144                                 <%if endRow></div><%/if>
145                         <%/foreach>
146
147                         <%if album.sone.local>
148                                 <p><a class="show-upload-image hidden small-link">» <%= View.UploadImage.Title|l10n|html></a></p>
149                                 <div class="upload-image">
150                                         <%include include/uploadImage.html>
151                                 </div>
152
153                                 <%if album.empty>
154                                         <form id="delete-album" action="deleteAlbum.html" method="get">
155                                                 <input type="hidden" name="album" value="<%album.id|html>" />
156                                                 <button type="submit"><%= Page.ImageBrowser.Album.Button.Delete|l10n|html></button>
157                                         </form>
158                                 <%/if>
159
160                         <%/if>
161
162                 <%/if>
163
164         <%elseif imageRequested>
165
166                 <h1 class="backlink"><%image.title|html></h1>
167
168                 <div class="backlinks">
169                         <%foreach image.album.backlinks backlink backlinks>
170                                 <div class="backlink">
171                                         <a href="<% backlink.target|html>"><% backlink.name|html></a>
172                                 </div>
173                                 <%if ! backlinks.last>
174                                         <div class="separator">&gt;</div>
175                                 <%/if>
176                         <%/foreach>
177                 </div>
178
179                 <%ifnull image>
180
181                 <%else>
182
183                         <%if image.sone.local>
184                                 <script language="javascript">
185                                         $(function() {
186                                                 getTranslation("WebInterface.DefaultText.EditImage.Title", function(text) {
187                                                         $("#edit-image input[name='title']").each(function() {
188                                                                 registerInputTextareaSwap(this, text, "title", false, true);
189                                                         });
190                                                 });
191                                                 getTranslation("WebInterface.DefaultText.EditImage.Description", function(text) {
192                                                         $("#edit-image :input[name='description']").each(function() {
193                                                                 registerInputTextareaSwap(this, text, "description", true, false);
194                                                         });
195                                                 });
196                                                 $("#edit-image label").hide();
197
198                                                 /* hide all those forms. */
199                                                 hideBlock = function(blockElement, clickElement) {
200                                                         $(blockElement).hide();
201                                                         $(clickElement).removeClass("hidden").click(function() {
202                                                                 $(blockElement).slideDown();
203                                                                 $(this).slideUp();
204                                                                 return false;
205                                                         });
206                                                 };
207
208                                                 hideBlock(".edit-image", ".show-edit-image");
209                                                 hideBlock(".delete-image", ".show-delete-image");
210                                         });
211                                 </script>
212                         <%/if>
213
214                         <div class="single-image">
215                                 <%ifnull !image.key>
216                                         <a href="/<%image.key|html>"><% image|image-link max-width=640 max-height=480></a>
217                                 <%else>
218                                         <a href="imageBrowser.html?image=<%image.id|html>"><% image|image-link max-width=640 max-height=480></a>
219                                 <%/if>
220                         </div>
221
222                         <p class="parsed"><%image.description|parse sone=image.sone></p>
223
224                         <%if image.sone.local>
225
226                                 <p><a class="show-edit-image hidden small-link">» <%= Page.ImageBrowser.Image.Edit.Title|l10n|html></a></p>
227                                 <div class="edit-image">
228                                         <h2><%= Page.ImageBrowser.Image.Edit.Title|l10n|html></h2>
229
230                                         <form id="edit-image" action="editImage.html" method="post">
231                                                 <input type="hidden" name="formPassword" value="<%formPassword|html>" />
232                                                 <input type="hidden" name="returnPage" value="<%request.uri|html>" />
233                                                 <input type="hidden" name="image" value="<%image.id|html>" />
234
235                                                 <div>
236                                                         <label for="title"><%= Page.ImageBrowser.Image.Title.Label|l10n|html></label>
237                                                         <input type="text" name="title" value="<%image.title|html>" />
238                                                 </div>
239                                                 <div>
240                                                         <label for="description"><%= Page.ImageBrowser.Image.Description.Label|l10n|html></label>
241                                                         <textarea name="description"><%image.description|html></textarea>
242                                                 </div>
243                                                 <div>
244                                                         <button type="submit"><%= Page.ImageBrowser.Image.Button.Save|l10n|html></button>
245                                                 </div>
246                                         </form>
247                                 </div>
248
249                                 <p><a class="show-delete-image hidden small-link">» <%= Page.ImageBrowser.Image.Delete.Title|l10n|html></a></p>
250                                 <div class="delete-image">
251                                         <h2><%= Page.ImageBrowser.Image.Delete.Title|l10n|html></h2>
252
253                                         <form id="delete-image" action="deleteImage.html" method="get">
254                                                 <input type="hidden" name="image" value="<%image.id|html>" />
255                                                 <button type="submit"><%= Page.ImageBrowser.Image.Button.Delete|l10n|html></button>
256                                         </form>
257                                 </div>
258
259                         <%/if>
260
261                 <%/if>
262
263         <%elseif soneRequested>
264
265                 <%if sone.local>
266                         <script language="javascript">
267                                 $(function() {
268                                         getTranslation("WebInterface.DefaultText.CreateAlbum.Name", function(text) {
269                                                 $("#create-album input[name='name']").each(function() {
270                                                         registerInputTextareaSwap(this, text, "name", false, true);
271                                                 });
272                                         });
273                                         getTranslation("WebInterface.DefaultText.CreateAlbum.Description", function(text) {
274                                                 $("#create-album input[name='description']").each(function() {
275                                                         registerInputTextareaSwap(this, text, "description", true, true);
276                                                 });
277                                         });
278                                         $("#create-album label").hide();
279
280                                         /* hide all those forms. */
281                                         hideBlock = function(blockElement, clickElement) {
282                                                 $(blockElement).hide();
283                                                 $(clickElement).removeClass("hidden").click(function() {
284                                                         $(blockElement).slideDown();
285                                                         $(this).slideUp();
286                                                         return false;
287                                                 });
288                                         };
289
290                                         hideBlock(".create-album", ".show-create-album");
291                                 });
292                         </script>
293                 <%/if>
294
295                 <%ifnull sone>
296
297                         <p><%= Page.ImageBrowser.Sone.Error.NotFound.Text|l10n|html></p>
298
299                 <%else>
300
301                         <h1><%= Page.ImageBrowser.Sone.Title|l10n|replace needle='{sone}' replacementKey=sone.niceName|html></h1>
302
303                         <%foreach sone.albums album>
304                                 <%if loop.count|mod divisor=3><div class="image-row"><%/if>
305                                 <div class="album image">
306                                         <a href="imageBrowser.html?album=<% album.id|html>" title="<% album.title|html>">
307                                                 <%ifnull album.albumImage>
308                                                         <img src="images/unknown-image-0.png" width="200" height="150" alt="<% album.title|html>" title="<% album.title|html>" />
309                                                 <%else><!-- TODO -->
310                                                         <% album.albumImage|image-link max-width=200 max-height=150 title==album.title>
311                                                 <%/if>
312                                                 <br/>
313                                                 <% album.title|html>
314                                         </a>
315                                 </div>
316                                 <%= false|store key=endRow>
317                                 <%if loop.count|mod divisor=3 offset=1><%= true|store key=endRow><%/if>
318                                 <%last><%= true|store key=endRow><%/last>
319                                 <%if endRow></div><%/if>
320                         <%/foreach>
321
322                         <%if sone.local>
323                                 <p><a class="show-create-album hidden small-link">» <%= View.CreateAlbum.Title|l10n|html></a></p>
324                                 <div class="create-album">
325                                         <%include include/createAlbum.html>
326                                 </div>
327                         <%/if>
328
329                 <%/if>
330
331         <%/if>
332
333 <%include include/tail.html>