annotate data/plugin/action/arnica_slides.py @ 239:0b155267080f

arnica_slides: removed unused variables from render
author Reimar Bauer <rb.proj AT googlemail DOT com>
date Tue, 02 Sep 2008 11:19:49 +0200
parents bf11563af202
children d082511f6a3b
rev   line source
0
d164d12d06b8 initial version of arnica (image gallery parser and slideshow action)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
1 # -*- coding: iso-8859-1 -*-
d164d12d06b8 initial version of arnica (image gallery parser and slideshow action)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
2 """
181
b19e4e36a1f2 arnica: cosmetic fixes, improve docstrings, minor i18n bugfixes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 178
diff changeset
3 MoinMoin - arnica_slides action
0
d164d12d06b8 initial version of arnica (image gallery parser and slideshow action)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
4
181
b19e4e36a1f2 arnica: cosmetic fixes, improve docstrings, minor i18n bugfixes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 178
diff changeset
5 This action is used to rotate, move to bak or to slide through the images from arnica.
b19e4e36a1f2 arnica: cosmetic fixes, improve docstrings, minor i18n bugfixes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 178
diff changeset
6
b19e4e36a1f2 arnica: cosmetic fixes, improve docstrings, minor i18n bugfixes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 178
diff changeset
7 Based on gallery2image, (c) 2005-2008 by MoinMoin:ReimarBauer.
28
e71bbef3a837 PEP8 whitespace fix to satisfy test_sourcecode
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 27
diff changeset
8
0
d164d12d06b8 initial version of arnica (image gallery parser and slideshow action)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
9 @copyright: 2008 by MoinMoin:ReimarBauer
d164d12d06b8 initial version of arnica (image gallery parser and slideshow action)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
10 @license: GNU GPL, see COPYING for details.
d164d12d06b8 initial version of arnica (image gallery parser and slideshow action)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
11 """
d164d12d06b8 initial version of arnica (image gallery parser and slideshow action)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
12 import os
24
9d46f04d556a arnica_slides: fixed header for cgi deployment
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 23
diff changeset
13
9d46f04d556a arnica_slides: fixed header for cgi deployment
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 23
diff changeset
14 from MoinMoin import log
9d46f04d556a arnica_slides: fixed header for cgi deployment
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 23
diff changeset
15 logging = log.getLogger(__name__)
9d46f04d556a arnica_slides: fixed header for cgi deployment
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 23
diff changeset
16
199
b82d3ce1764a action cache method used instead of similiar one from caching
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 190
diff changeset
17 from MoinMoin import config, wikiutil
0
d164d12d06b8 initial version of arnica (image gallery parser and slideshow action)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
18 from MoinMoin.Page import Page
166
9817520ac155 text_x_arnica, arnica_slides: refactored sendcached.* to cache.* methods
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 165
diff changeset
19 from MoinMoin.action import ActionBase, AttachFile, cache
40
c208aceb1ebd join and split exchanged on various places to packLine and unpackLine
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 39
diff changeset
20 from MoinMoin.packages import packLine, unpackLine
0
d164d12d06b8 initial version of arnica (image gallery parser and slideshow action)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
21
d164d12d06b8 initial version of arnica (image gallery parser and slideshow action)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
22 try:
d164d12d06b8 initial version of arnica (image gallery parser and slideshow action)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
23 import Image
d164d12d06b8 initial version of arnica (image gallery parser and slideshow action)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
24 except ImportError:
d164d12d06b8 initial version of arnica (image gallery parser and slideshow action)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
25 Image = None
d164d12d06b8 initial version of arnica (image gallery parser and slideshow action)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
26
d164d12d06b8 initial version of arnica (image gallery parser and slideshow action)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
27 action_name = __name__.split('.')[-1]
d164d12d06b8 initial version of arnica (image gallery parser and slideshow action)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
28
181
b19e4e36a1f2 arnica: cosmetic fixes, improve docstrings, minor i18n bugfixes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 178
diff changeset
29
111
2159a14c54ea arnica_slides.image_rotate: rotate only image, purge cache of thumbnail and webnail
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 110
diff changeset
30 def image_rotate(file_name, angle, img_type):
226
9faa8f0e9f86 fixed docstrings and removed some whitespaces
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 225
diff changeset
31 """ rotates the image
36
3f042c1e2509 arnica_slides: image_rotate refactored to a function
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 35
diff changeset
32
181
b19e4e36a1f2 arnica: cosmetic fixes, improve docstrings, minor i18n bugfixes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 178
diff changeset
33 @param file_name: the name of the attachment
b19e4e36a1f2 arnica: cosmetic fixes, improve docstrings, minor i18n bugfixes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 178
diff changeset
34 @param angle: rotation angle
b19e4e36a1f2 arnica: cosmetic fixes, improve docstrings, minor i18n bugfixes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 178
diff changeset
35 @param img_type: type of image (PNG or JPEG)
36
3f042c1e2509 arnica_slides: image_rotate refactored to a function
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 35
diff changeset
36 """
181
b19e4e36a1f2 arnica: cosmetic fixes, improve docstrings, minor i18n bugfixes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 178
diff changeset
37 # only image needs to be rotated, webnail and thumbnail
b19e4e36a1f2 arnica: cosmetic fixes, improve docstrings, minor i18n bugfixes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 178
diff changeset
38 # will be recreated by the arnica parser
36
3f042c1e2509 arnica_slides: image_rotate refactored to a function
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 35
diff changeset
39 image_object = Image.open(file_name)
226
9faa8f0e9f86 fixed docstrings and removed some whitespaces
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 225
diff changeset
40 # we save the old file (don't use .bak here. bak is used for image delete.)
225
c34794a7962b arnica_slides: image_rotate saves a backup of the file before rotating and in case of a problem it returns to the old image
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 224
diff changeset
41 tmp_file = file_name + '.tmp'
c34794a7962b arnica_slides: image_rotate saves a backup of the file before rotating and in case of a problem it returns to the old image
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 224
diff changeset
42 os.rename(file_name, tmp_file)
211
da38f8d6693b ignore truncated broken images
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 199
diff changeset
43 try:
da38f8d6693b ignore truncated broken images
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 199
diff changeset
44 image_object.rotate(angle).save(file_name, img_type)
da38f8d6693b ignore truncated broken images
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 199
diff changeset
45 except IOError:
225
c34794a7962b arnica_slides: image_rotate saves a backup of the file before rotating and in case of a problem it returns to the old image
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 224
diff changeset
46 # in case of trouble rename to the old file
236
0bf8fa325316 arnica_slides: bug fix, typo in var
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 229
diff changeset
47 os.rename(tmp_file, file_name)
225
c34794a7962b arnica_slides: image_rotate saves a backup of the file before rotating and in case of a problem it returns to the old image
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 224
diff changeset
48 else:
c34794a7962b arnica_slides: image_rotate saves a backup of the file before rotating and in case of a problem it returns to the old image
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 224
diff changeset
49 # on success remove the backup file
c34794a7962b arnica_slides: image_rotate saves a backup of the file before rotating and in case of a problem it returns to the old image
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 224
diff changeset
50 os.unlink(tmp_file)
181
b19e4e36a1f2 arnica: cosmetic fixes, improve docstrings, minor i18n bugfixes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 178
diff changeset
51
23
26d9d5f67365 arnica_slides: some more refactoring
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 22
diff changeset
52 def html_js(request, counter):
181
b19e4e36a1f2 arnica: cosmetic fixes, improve docstrings, minor i18n bugfixes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 178
diff changeset
53 """ javascript for the slides
b19e4e36a1f2 arnica: cosmetic fixes, improve docstrings, minor i18n bugfixes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 178
diff changeset
54
23
26d9d5f67365 arnica_slides: some more refactoring
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 22
diff changeset
55 @param request: request object
181
b19e4e36a1f2 arnica: cosmetic fixes, improve docstrings, minor i18n bugfixes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 178
diff changeset
56 @param counter: index of first slide image
0
d164d12d06b8 initial version of arnica (image gallery parser and slideshow action)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
57 """
181
b19e4e36a1f2 arnica: cosmetic fixes, improve docstrings, minor i18n bugfixes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 178
diff changeset
58 html = """
120
65c46d7d48f1 arnica_slides: fixed html to be Valid HTML 4.01 Strict
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 119
diff changeset
59 <script type="text/javascript">
0
d164d12d06b8 initial version of arnica (image gallery parser and slideshow action)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
60 <!-- Original: Ricocheting (ricocheting@hotmail.com) -->
d164d12d06b8 initial version of arnica (image gallery parser and slideshow action)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
61 <!-- Web Site: http://www.ricocheting.com -->
d164d12d06b8 initial version of arnica (image gallery parser and slideshow action)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
62
d164d12d06b8 initial version of arnica (image gallery parser and slideshow action)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
63 <!-- This script and many more are available free online at -->
d164d12d06b8 initial version of arnica (image gallery parser and slideshow action)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
64 <!-- The JavaScript Source!! http://javascript.internet.com -->
d164d12d06b8 initial version of arnica (image gallery parser and slideshow action)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
65
d164d12d06b8 initial version of arnica (image gallery parser and slideshow action)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
66 <!-- Modifications by MoinMoin:ReimarBauer -->
d164d12d06b8 initial version of arnica (image gallery parser and slideshow action)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
67 <!-- 2005-10-29 -->
d164d12d06b8 initial version of arnica (image gallery parser and slideshow action)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
68 <!-- Many thanks to Ricocheting, it is much easier as my own one. I like it -->
d164d12d06b8 initial version of arnica (image gallery parser and slideshow action)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
69 <!-- Some code added and replaced for the MoinMoin:arnica parser-->
d164d12d06b8 initial version of arnica (image gallery parser and slideshow action)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
70
d164d12d06b8 initial version of arnica (image gallery parser and slideshow action)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
71
28
e71bbef3a837 PEP8 whitespace fix to satisfy test_sourcecode
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 27
diff changeset
72 <!-- Begin
0
d164d12d06b8 initial version of arnica (image gallery parser and slideshow action)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
73
d164d12d06b8 initial version of arnica (image gallery parser and slideshow action)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
74 var rotate_delay = 5; // delay in milliseconds (5000 = 5 secs)
d164d12d06b8 initial version of arnica (image gallery parser and slideshow action)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
75 var current = %(counter)s;
d164d12d06b8 initial version of arnica (image gallery parser and slideshow action)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
76 var theImages = new Array();
178
d29abc5e4b4f PEP8 fixes
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 176
diff changeset
77 var preloaded_images = new Array();
168
cf3fef32a87b arnica_slides: link aliastext/filenam to attachment file
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 167
diff changeset
78 var AttachFile_action = '?action=AttachFile&do=get&target=';
0
d164d12d06b8 initial version of arnica (image gallery parser and slideshow action)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
79
176
27039f0d187c arnica_slides: preload of all images changed to load image on demand
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 174
diff changeset
80 function load_image(index) {
27039f0d187c arnica_slides: preload of all images changed to load image on demand
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 174
diff changeset
81 var list = document.slideform.webnail_list.value;
27039f0d187c arnica_slides: preload of all images changed to load image on demand
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 174
diff changeset
82 var value = list.split("|");
27039f0d187c arnica_slides: preload of all images changed to load image on demand
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 174
diff changeset
83 if (preloaded_images[index] == false) {
27039f0d187c arnica_slides: preload of all images changed to load image on demand
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 174
diff changeset
84 theImages[index].src = value[index];
27039f0d187c arnica_slides: preload of all images changed to load image on demand
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 174
diff changeset
85 preloaded_images[index] = true;
27039f0d187c arnica_slides: preload of all images changed to load image on demand
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 174
diff changeset
86 }
27039f0d187c arnica_slides: preload of all images changed to load image on demand
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 174
diff changeset
87 }
178
d29abc5e4b4f PEP8 fixes
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 176
diff changeset
88
0
d164d12d06b8 initial version of arnica (image gallery parser and slideshow action)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
89 function arnica_preload() {
d164d12d06b8 initial version of arnica (image gallery parser and slideshow action)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
90 var list = document.slideform.webnail_list.value;
40
c208aceb1ebd join and split exchanged on various places to packLine and unpackLine
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 39
diff changeset
91 var value = list.split("|");
0
d164d12d06b8 initial version of arnica (image gallery parser and slideshow action)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
92 var n = value.length;
28
e71bbef3a837 PEP8 whitespace fix to satisfy test_sourcecode
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 27
diff changeset
93
0
d164d12d06b8 initial version of arnica (image gallery parser and slideshow action)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
94 for (i = 0; i < n-1; i++){
d164d12d06b8 initial version of arnica (image gallery parser and slideshow action)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
95 theImages[i] = new Image();
176
27039f0d187c arnica_slides: preload of all images changed to load image on demand
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 174
diff changeset
96 preloaded_images[i] = false;
28
e71bbef3a837 PEP8 whitespace fix to satisfy test_sourcecode
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 27
diff changeset
97 }
e71bbef3a837 PEP8 whitespace fix to satisfy test_sourcecode
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 27
diff changeset
98 }
0
d164d12d06b8 initial version of arnica (image gallery parser and slideshow action)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
99
d164d12d06b8 initial version of arnica (image gallery parser and slideshow action)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
100 function arnica_getserver() {
d164d12d06b8 initial version of arnica (image gallery parser and slideshow action)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
101 var value = document.URL;
d164d12d06b8 initial version of arnica (image gallery parser and slideshow action)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
102 var text = value.split("/");
d164d12d06b8 initial version of arnica (image gallery parser and slideshow action)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
103 return text[0]+'//'+text[2];
28
e71bbef3a837 PEP8 whitespace fix to satisfy test_sourcecode
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 27
diff changeset
104 }
0
d164d12d06b8 initial version of arnica (image gallery parser and slideshow action)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
105
d164d12d06b8 initial version of arnica (image gallery parser and slideshow action)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
106 function arnica_add_comments() {
d164d12d06b8 initial version of arnica (image gallery parser and slideshow action)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
107 var alias_text = document.slideform.alias.value;
d164d12d06b8 initial version of arnica (image gallery parser and slideshow action)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
108 var exif_date_text = document.slideform.exif_date.value;
168
cf3fef32a87b arnica_slides: link aliastext/filenam to attachment file
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 167
diff changeset
109 var original_images = document.slideform.original_images.value;
0
d164d12d06b8 initial version of arnica (image gallery parser and slideshow action)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
110 var index = document.slideform.slide.selectedIndex;
40
c208aceb1ebd join and split exchanged on various places to packLine and unpackLine
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 39
diff changeset
111 var alias = alias_text.split("|");
c208aceb1ebd join and split exchanged on various places to packLine and unpackLine
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 39
diff changeset
112 var exif = exif_date_text.split("|");
168
cf3fef32a87b arnica_slides: link aliastext/filenam to attachment file
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 167
diff changeset
113 images = original_images.split("|");
cf3fef32a87b arnica_slides: link aliastext/filenam to attachment file
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 167
diff changeset
114
cf3fef32a87b arnica_slides: link aliastext/filenam to attachment file
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 167
diff changeset
115 document.getElementById("arnica_alias_text").innerHTML = '<a href=' + document.URL + AttachFile_action + images[index] + '>' + alias[index] +'</a>';
0
d164d12d06b8 initial version of arnica (image gallery parser and slideshow action)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
116 document.getElementById("arnica_exif_date_text").innerHTML = exif[index];
d164d12d06b8 initial version of arnica (image gallery parser and slideshow action)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
117 }
d164d12d06b8 initial version of arnica (image gallery parser and slideshow action)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
118
d164d12d06b8 initial version of arnica (image gallery parser and slideshow action)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
119 function arnica_next_slide() {
d164d12d06b8 initial version of arnica (image gallery parser and slideshow action)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
120 if (document.slideform.slide[current+1]) {
176
27039f0d187c arnica_slides: preload of all images changed to load image on demand
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 174
diff changeset
121 load_image(current+1);
0
d164d12d06b8 initial version of arnica (image gallery parser and slideshow action)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
122 document.images.show.src = theImages[current+1].src;
d164d12d06b8 initial version of arnica (image gallery parser and slideshow action)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
123 document.slideform.slide.selectedIndex = ++current;
d164d12d06b8 initial version of arnica (image gallery parser and slideshow action)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
124 arnica_add_comments();
d164d12d06b8 initial version of arnica (image gallery parser and slideshow action)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
125 }
d164d12d06b8 initial version of arnica (image gallery parser and slideshow action)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
126 else arnica_first_slide();
119
0dc7c254c5a8 arnica_slides: images of controls moved to css
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 117
diff changeset
127 document.getElementById("arnica_first_slide").innerHTML = '<a class="first_slide" onclick="arnica_first_slide();" name="fs" title="first slide" >';
0dc7c254c5a8 arnica_slides: images of controls moved to css
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 117
diff changeset
128 document.getElementById("arnica_last_slide").innerHTML = '<a class="last_slide" onclick="arnica_last_slide();" name="fs" title="last slide" >';
0
d164d12d06b8 initial version of arnica (image gallery parser and slideshow action)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
129 }
d164d12d06b8 initial version of arnica (image gallery parser and slideshow action)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
130
d164d12d06b8 initial version of arnica (image gallery parser and slideshow action)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
131 function arnica_previous_slide() {
d164d12d06b8 initial version of arnica (image gallery parser and slideshow action)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
132 if (current-1 >= 0) {
176
27039f0d187c arnica_slides: preload of all images changed to load image on demand
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 174
diff changeset
133 load_image(current-1);
28
e71bbef3a837 PEP8 whitespace fix to satisfy test_sourcecode
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 27
diff changeset
134 document.images.show.src = theImages[current-1].src;
0
d164d12d06b8 initial version of arnica (image gallery parser and slideshow action)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
135 document.slideform.slide.selectedIndex = --current;
28
e71bbef3a837 PEP8 whitespace fix to satisfy test_sourcecode
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 27
diff changeset
136 arnica_add_comments();
0
d164d12d06b8 initial version of arnica (image gallery parser and slideshow action)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
137 }
d164d12d06b8 initial version of arnica (image gallery parser and slideshow action)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
138 else arnica_last_slide();
119
0dc7c254c5a8 arnica_slides: images of controls moved to css
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 117
diff changeset
139 document.getElementById("arnica_first_slide").innerHTML = '<a class="first_slide" onclick="arnica_first_slide();" name="fs" title="first slide" >';
0dc7c254c5a8 arnica_slides: images of controls moved to css
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 117
diff changeset
140 document.getElementById("arnica_last_slide").innerHTML = '<a class="last_slide" onclick="arnica_last_slide();" name="fs" title="last slide" >';
0
d164d12d06b8 initial version of arnica (image gallery parser and slideshow action)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
141 }
d164d12d06b8 initial version of arnica (image gallery parser and slideshow action)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
142
d164d12d06b8 initial version of arnica (image gallery parser and slideshow action)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
143 function arnica_first_slide() {
d164d12d06b8 initial version of arnica (image gallery parser and slideshow action)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
144 current = 0;
176
27039f0d187c arnica_slides: preload of all images changed to load image on demand
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 174
diff changeset
145 load_image(current);
28
e71bbef3a837 PEP8 whitespace fix to satisfy test_sourcecode
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 27
diff changeset
146 document.images.show.src = theImages[0].src;
0
d164d12d06b8 initial version of arnica (image gallery parser and slideshow action)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
147 document.slideform.slide.selectedIndex = 0;
d164d12d06b8 initial version of arnica (image gallery parser and slideshow action)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
148 arnica_add_comments();
119
0dc7c254c5a8 arnica_slides: images of controls moved to css
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 117
diff changeset
149 document.getElementById("arnica_first_slide").innerHTML = '<a class="first_slide_disabled" title="first slide" >';
0dc7c254c5a8 arnica_slides: images of controls moved to css
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 117
diff changeset
150 document.getElementById("arnica_last_slide").innerHTML = '<a class="last_slide" onclick="arnica_last_slide();" name="fs" title="last slide" >';
0
d164d12d06b8 initial version of arnica (image gallery parser and slideshow action)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
151 }
d164d12d06b8 initial version of arnica (image gallery parser and slideshow action)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
152
d164d12d06b8 initial version of arnica (image gallery parser and slideshow action)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
153 function arnica_last_slide() {
d164d12d06b8 initial version of arnica (image gallery parser and slideshow action)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
154 current = document.slideform.slide.length-1;
176
27039f0d187c arnica_slides: preload of all images changed to load image on demand
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 174
diff changeset
155 load_image(current);
28
e71bbef3a837 PEP8 whitespace fix to satisfy test_sourcecode
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 27
diff changeset
156 document.images.show.src = theImages[current].src;
0
d164d12d06b8 initial version of arnica (image gallery parser and slideshow action)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
157 document.slideform.slide.selectedIndex = current;
d164d12d06b8 initial version of arnica (image gallery parser and slideshow action)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
158 arnica_add_comments();
119
0dc7c254c5a8 arnica_slides: images of controls moved to css
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 117
diff changeset
159 document.getElementById("arnica_first_slide").innerHTML = '<a class="first_slide" onclick="arnica_first_slide();" name="fs" title="first slide" >';
0dc7c254c5a8 arnica_slides: images of controls moved to css
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 117
diff changeset
160 document.getElementById("arnica_last_slide").innerHTML = '<a class="last_slide_disabled" title="last slide" >';
0
d164d12d06b8 initial version of arnica (image gallery parser and slideshow action)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
161 }
d164d12d06b8 initial version of arnica (image gallery parser and slideshow action)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
162
d164d12d06b8 initial version of arnica (image gallery parser and slideshow action)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
163 function arnica_ap(text) {
d164d12d06b8 initial version of arnica (image gallery parser and slideshow action)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
164 document.slideform.slidebutton.value = (text == "Stop") ? "Start" : "Stop";
d164d12d06b8 initial version of arnica (image gallery parser and slideshow action)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
165 arnica_rotate();
d164d12d06b8 initial version of arnica (image gallery parser and slideshow action)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
166 }
d164d12d06b8 initial version of arnica (image gallery parser and slideshow action)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
167
d164d12d06b8 initial version of arnica (image gallery parser and slideshow action)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
168 function arnica_change() {
d164d12d06b8 initial version of arnica (image gallery parser and slideshow action)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
169 current = document.slideform.slide.selectedIndex;
176
27039f0d187c arnica_slides: preload of all images changed to load image on demand
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 174
diff changeset
170 load_image(current);
28
e71bbef3a837 PEP8 whitespace fix to satisfy test_sourcecode
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 27
diff changeset
171 document.images.show.src = theImages[current].src;
e71bbef3a837 PEP8 whitespace fix to satisfy test_sourcecode
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 27
diff changeset
172 arnica_add_comments();
119
0dc7c254c5a8 arnica_slides: images of controls moved to css
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 117
diff changeset
173 document.getElementById("arnica_first_slide").innerHTML = '<a class="first_slide" onclick="arnica_first_slide();" name="fs" title="first slide" >';
0dc7c254c5a8 arnica_slides: images of controls moved to css
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 117
diff changeset
174 document.getElementById("arnica_last_slide").innerHTML = '<a class="last_slide" onclick="arnica_last_slide();" name="fs" title="last slide" >';
0
d164d12d06b8 initial version of arnica (image gallery parser and slideshow action)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
175 }
d164d12d06b8 initial version of arnica (image gallery parser and slideshow action)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
176
d164d12d06b8 initial version of arnica (image gallery parser and slideshow action)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
177 function arnica_rotate() {
d164d12d06b8 initial version of arnica (image gallery parser and slideshow action)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
178 if (document.slideform.slidebutton.value == "Stop") {
d164d12d06b8 initial version of arnica (image gallery parser and slideshow action)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
179 current = (current == document.slideform.slide.length-1) ? 0 : current+1;
176
27039f0d187c arnica_slides: preload of all images changed to load image on demand
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 174
diff changeset
180 load_image(current);
28
e71bbef3a837 PEP8 whitespace fix to satisfy test_sourcecode
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 27
diff changeset
181 document.images.show.src = theImages[current].src;
0
d164d12d06b8 initial version of arnica (image gallery parser and slideshow action)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
182 document.slideform.slide.selectedIndex = current;
28
e71bbef3a837 PEP8 whitespace fix to satisfy test_sourcecode
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 27
diff changeset
183 arnica_add_comments();
119
0dc7c254c5a8 arnica_slides: images of controls moved to css
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 117
diff changeset
184 document.getElementById("arnica_first_slide").innerHTML = '<a class="first_slide" onclick="arnica_first_slide();" name="fs" title="first slide" >';
0dc7c254c5a8 arnica_slides: images of controls moved to css
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 117
diff changeset
185 document.getElementById("arnica_last_slide").innerHTML = '<a class="last_slide" onclick="arnica_last_slide();" name="fs" title="last slide" >';
0
d164d12d06b8 initial version of arnica (image gallery parser and slideshow action)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
186 rotate_delay = document.slideform.duration.value * 1000.;
d164d12d06b8 initial version of arnica (image gallery parser and slideshow action)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
187 window.setTimeout("arnica_rotate()", rotate_delay);
d164d12d06b8 initial version of arnica (image gallery parser and slideshow action)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
188 }
d164d12d06b8 initial version of arnica (image gallery parser and slideshow action)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
189 }
d164d12d06b8 initial version of arnica (image gallery parser and slideshow action)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
190 // End -->
181
b19e4e36a1f2 arnica: cosmetic fixes, improve docstrings, minor i18n bugfixes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 178
diff changeset
191 </script>
b19e4e36a1f2 arnica: cosmetic fixes, improve docstrings, minor i18n bugfixes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 178
diff changeset
192 """ % {
b19e4e36a1f2 arnica: cosmetic fixes, improve docstrings, minor i18n bugfixes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 178
diff changeset
193 'htdocs': request.cfg.url_prefix_static,
b19e4e36a1f2 arnica: cosmetic fixes, improve docstrings, minor i18n bugfixes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 178
diff changeset
194 'counter': counter,
b19e4e36a1f2 arnica: cosmetic fixes, improve docstrings, minor i18n bugfixes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 178
diff changeset
195 }
b19e4e36a1f2 arnica: cosmetic fixes, improve docstrings, minor i18n bugfixes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 178
diff changeset
196 return html
0
d164d12d06b8 initial version of arnica (image gallery parser and slideshow action)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
197
227
a16b7c703fd3 flag image_for_webnail mode refactored: the image becomes duplicated as webnail in the cache arena.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 226
diff changeset
198 def html_slideform(request, pagename, alias, exif_date, images, original_images, idx):
23
26d9d5f67365 arnica_slides: some more refactoring
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 22
diff changeset
199 """ html code for the slideform
181
b19e4e36a1f2 arnica: cosmetic fixes, improve docstrings, minor i18n bugfixes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 178
diff changeset
200
23
26d9d5f67365 arnica_slides: some more refactoring
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 22
diff changeset
201 @param request: request object
26d9d5f67365 arnica_slides: some more refactoring
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 22
diff changeset
202 @param pagename: pagename where the attachments are located
26d9d5f67365 arnica_slides: some more refactoring
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 22
diff changeset
203 @param alias: text alias for filename
28
e71bbef3a837 PEP8 whitespace fix to satisfy test_sourcecode
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 27
diff changeset
204 @param exif_date: date information
181
b19e4e36a1f2 arnica: cosmetic fixes, improve docstrings, minor i18n bugfixes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 178
diff changeset
205 @param images: list of webnail image IDs (either cache keys or attachment names)
b19e4e36a1f2 arnica: cosmetic fixes, improve docstrings, minor i18n bugfixes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 178
diff changeset
206 @param original_images: list of original image attachment names (thumbnails and webnails are derived from it)
28
e71bbef3a837 PEP8 whitespace fix to satisfy test_sourcecode
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 27
diff changeset
207 @param idx: index position of the image
227
a16b7c703fd3 flag image_for_webnail mode refactored: the image becomes duplicated as webnail in the cache arena.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 226
diff changeset
208
23
26d9d5f67365 arnica_slides: some more refactoring
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 22
diff changeset
209 """
227
a16b7c703fd3 flag image_for_webnail mode refactored: the image becomes duplicated as webnail in the cache arena.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 226
diff changeset
210 image_url = cache.url(request, images[idx])
a16b7c703fd3 flag image_for_webnail mode refactored: the image becomes duplicated as webnail in the cache arena.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 226
diff changeset
211 this_webnail_list = [cache.url(request, name) for name in images]
189
5edba1f921b7 arnica: reduce code duplication, create URLs the correct way
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 186
diff changeset
212
5edba1f921b7 arnica: reduce code duplication, create URLs the correct way
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 186
diff changeset
213 this_webnail_list = "".join(["%s|" % url for url in this_webnail_list])
178
d29abc5e4b4f PEP8 fixes
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 176
diff changeset
214
167
3311d9f639cf arnica_slides, text_x_arnica: use real image name in the option list
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 166
diff changeset
215 link_to_image = AttachFile.getAttachUrl(pagename, original_images[idx], request)
237
8b80d05224d3 arnica_slides: removed unused parameter pagename from option_list
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 236
diff changeset
216 option_webnail = option_list(image_url, images, original_images, request)
23
26d9d5f67365 arnica_slides: some more refactoring
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 22
diff changeset
217 inner_table_style = ' style="border-style:none; margin:10px;"'
41
edc8b8c5ccdd PEP8 whitespace fix
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 40
diff changeset
218
181
b19e4e36a1f2 arnica: cosmetic fixes, improve docstrings, minor i18n bugfixes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 178
diff changeset
219 html = """
145
f67c48783f20 arnica_slides: renamed duplicated defined class arnica to arnica-slides
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 143
diff changeset
220 <div class="arnica-slides">
139
2aba556fe52d replaced "_" to "-" in css class names
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 132
diff changeset
221 <div class="navigation-animation">
120
65c46d7d48f1 arnica_slides: fixed html to be Valid HTML 4.01 Strict
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 119
diff changeset
222 <form name=slideform method="POST" action="">
65c46d7d48f1 arnica_slides: fixed html to be Valid HTML 4.01 Strict
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 119
diff changeset
223 <div>
82
9bc83f9caf40 arnica_slides: prepared for css
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 81
diff changeset
224 <input type="hidden" name="flag" value="webnail">
104
8cfbd286d1c7 replaced ' with " in html code
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 99
diff changeset
225 <input type="hidden" name="webnail_list" value="%(this_webnail_list)s">
167
3311d9f639cf arnica_slides, text_x_arnica: use real image name in the option list
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 166
diff changeset
226 <input type="hidden" name="original_images" value="%(original_images)s">
104
8cfbd286d1c7 replaced ' with " in html code
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 99
diff changeset
227 <input type="hidden" name="webnail_name" value="%(this_webnail_name)s">
8cfbd286d1c7 replaced ' with " in html code
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 99
diff changeset
228 <input type="hidden" name="alias" value="%(this_alias_list)s">
8cfbd286d1c7 replaced ' with " in html code
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 99
diff changeset
229 <input type="hidden" name="exif_date" value="%(this_exif_date_list)s">
82
9bc83f9caf40 arnica_slides: prepared for css
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 81
diff changeset
230 <label>Slide: <select name="slide" onChange="arnica_change();" >
9bc83f9caf40 arnica_slides: prepared for css
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 81
diff changeset
231 %(option_webnails)s</select></label>
9bc83f9caf40 arnica_slides: prepared for css
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 81
diff changeset
232 <input type="button" name="slidebutton" onClick="arnica_ap(this.value);" value="Start" title="AutoPlay">
120
65c46d7d48f1 arnica_slides: fixed html to be Valid HTML 4.01 Strict
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 119
diff changeset
233 <label>Duration (sec):<input type="text" name="duration" value="3.0" size="3"></label>
65c46d7d48f1 arnica_slides: fixed html to be Valid HTML 4.01 Strict
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 119
diff changeset
234 </div>
99
4762bad57dae arnica_slides: initial version basic css definition
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 97
diff changeset
235 </form>
4762bad57dae arnica_slides: initial version basic css definition
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 97
diff changeset
236 </div>
139
2aba556fe52d replaced "_" to "-" in css class names
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 132
diff changeset
237 <div class="navigation-button">
119
0dc7c254c5a8 arnica_slides: images of controls moved to css
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 117
diff changeset
238 <span id="arnica_first_slide"><a class="first_slide" onclick="arnica_first_slide();" name="fs" title="first slide" ></a></span>
0dc7c254c5a8 arnica_slides: images of controls moved to css
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 117
diff changeset
239 <a class="previous_slide" onclick="arnica_previous_slide();" title="previous slide"></a>
0dc7c254c5a8 arnica_slides: images of controls moved to css
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 117
diff changeset
240 <a class="next_slide" onClick="arnica_next_slide();" title="next slide"></a>
0dc7c254c5a8 arnica_slides: images of controls moved to css
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 117
diff changeset
241 <span id="arnica_last_slide"><a class="last_slide" onClick="arnica_last_slide();" title="last slide" ></a></span>
82
9bc83f9caf40 arnica_slides: prepared for css
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 81
diff changeset
242 </div>
99
4762bad57dae arnica_slides: initial version basic css definition
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 97
diff changeset
243 <div class="image">
120
65c46d7d48f1 arnica_slides: fixed html to be Valid HTML 4.01 Strict
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 119
diff changeset
244 <img src="%(server)s%(this_image)s" name="show" alt="%(this_alias_text)s,%(this_exif_date_text)s">
99
4762bad57dae arnica_slides: initial version basic css definition
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 97
diff changeset
245 </div>
139
2aba556fe52d replaced "_" to "-" in css class names
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 132
diff changeset
246 <div class="image-description">
167
3311d9f639cf arnica_slides, text_x_arnica: use real image name in the option list
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 166
diff changeset
247 <span id="arnica_alias_text"><a href=%(link_url)s>%(this_alias_text)s</a></span>,
99
4762bad57dae arnica_slides: initial version basic css definition
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 97
diff changeset
248 <span id="arnica_exif_date_text">%(this_exif_date_text)s</span>
82
9bc83f9caf40 arnica_slides: prepared for css
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 81
diff changeset
249 </div>
9bc83f9caf40 arnica_slides: prepared for css
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 81
diff changeset
250 </div>
181
b19e4e36a1f2 arnica: cosmetic fixes, improve docstrings, minor i18n bugfixes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 178
diff changeset
251 """ % {
b19e4e36a1f2 arnica: cosmetic fixes, improve docstrings, minor i18n bugfixes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 178
diff changeset
252 "server": request.getQualifiedURL(),
b19e4e36a1f2 arnica: cosmetic fixes, improve docstrings, minor i18n bugfixes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 178
diff changeset
253 "htdocs": request.cfg.url_prefix_static,
b19e4e36a1f2 arnica: cosmetic fixes, improve docstrings, minor i18n bugfixes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 178
diff changeset
254 "base_url": request.getScriptname(),
b19e4e36a1f2 arnica: cosmetic fixes, improve docstrings, minor i18n bugfixes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 178
diff changeset
255 "link_url": link_to_image,
b19e4e36a1f2 arnica: cosmetic fixes, improve docstrings, minor i18n bugfixes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 178
diff changeset
256 "this_webnail_list": this_webnail_list,
b19e4e36a1f2 arnica: cosmetic fixes, improve docstrings, minor i18n bugfixes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 178
diff changeset
257 "this_webnail_name": packLine(images),
b19e4e36a1f2 arnica: cosmetic fixes, improve docstrings, minor i18n bugfixes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 178
diff changeset
258 "original_images": packLine(original_images),
b19e4e36a1f2 arnica: cosmetic fixes, improve docstrings, minor i18n bugfixes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 178
diff changeset
259 "this_alias_text": wikiutil.escape(alias[idx], quote=1),
b19e4e36a1f2 arnica: cosmetic fixes, improve docstrings, minor i18n bugfixes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 178
diff changeset
260 "this_alias_list": wikiutil.escape(packLine(alias), quote=1),
b19e4e36a1f2 arnica: cosmetic fixes, improve docstrings, minor i18n bugfixes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 178
diff changeset
261 "this_exif_date_text": wikiutil.escape(exif_date[idx], quote=1),
b19e4e36a1f2 arnica: cosmetic fixes, improve docstrings, minor i18n bugfixes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 178
diff changeset
262 "this_exif_date_list": wikiutil.escape(packLine(exif_date), quote=1),
b19e4e36a1f2 arnica: cosmetic fixes, improve docstrings, minor i18n bugfixes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 178
diff changeset
263 "this_image": image_url,
b19e4e36a1f2 arnica: cosmetic fixes, improve docstrings, minor i18n bugfixes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 178
diff changeset
264 "pagename": pagename,
b19e4e36a1f2 arnica: cosmetic fixes, improve docstrings, minor i18n bugfixes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 178
diff changeset
265 "tablestyle": inner_table_style,
b19e4e36a1f2 arnica: cosmetic fixes, improve docstrings, minor i18n bugfixes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 178
diff changeset
266 "option_webnails": option_webnail,
b19e4e36a1f2 arnica: cosmetic fixes, improve docstrings, minor i18n bugfixes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 178
diff changeset
267 }
23
26d9d5f67365 arnica_slides: some more refactoring
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 22
diff changeset
268 return html
24
9d46f04d556a arnica_slides: fixed header for cgi deployment
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 23
diff changeset
269
237
8b80d05224d3 arnica_slides: removed unused parameter pagename from option_list
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 236
diff changeset
270 def option_list(this_image, filenames, original_images, request):
23
26d9d5f67365 arnica_slides: some more refactoring
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 22
diff changeset
271 """ generates the pulldown option list
181
b19e4e36a1f2 arnica: cosmetic fixes, improve docstrings, minor i18n bugfixes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 178
diff changeset
272
b19e4e36a1f2 arnica: cosmetic fixes, improve docstrings, minor i18n bugfixes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 178
diff changeset
273 @param this_image: selected image on top
189
5edba1f921b7 arnica: reduce code duplication, create URLs the correct way
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 186
diff changeset
274 @param filenames: list of filenames
181
b19e4e36a1f2 arnica: cosmetic fixes, improve docstrings, minor i18n bugfixes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 178
diff changeset
275 @param original_images: list of original image attachment names (thumbnails and webnails are derived from it)
23
26d9d5f67365 arnica_slides: some more refactoring
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 22
diff changeset
276 @param request: request object
26d9d5f67365 arnica_slides: some more refactoring
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 22
diff changeset
277 """
181
b19e4e36a1f2 arnica: cosmetic fixes, improve docstrings, minor i18n bugfixes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 178
diff changeset
278 # TODO: original image needs to be sent to the action and used instead of the alias
189
5edba1f921b7 arnica: reduce code duplication, create URLs the correct way
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 186
diff changeset
279 options = []
165
7332323c8a6f arnica_slides: use prefix Webnail in options list
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 164
diff changeset
280 i = 0
189
5edba1f921b7 arnica: reduce code duplication, create URLs the correct way
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 186
diff changeset
281 for filename in filenames:
227
a16b7c703fd3 flag image_for_webnail mode refactored: the image becomes duplicated as webnail in the cache arena.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 226
diff changeset
282 url = cache.url(request, filename)
a16b7c703fd3 flag image_for_webnail mode refactored: the image becomes duplicated as webnail in the cache arena.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 226
diff changeset
283 prefix = 'Webnail:'
23
26d9d5f67365 arnica_slides: some more refactoring
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 22
diff changeset
284
190
45fcfc007160 arnica_slides: option_list bug fixed
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 189
diff changeset
285 options.append('<option%(selected)s value="%(name)s">%(prefix)s %(alias)s' % {
189
5edba1f921b7 arnica: reduce code duplication, create URLs the correct way
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 186
diff changeset
286 "selected": (url == this_image) and ' selected' or '',
5edba1f921b7 arnica: reduce code duplication, create URLs the correct way
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 186
diff changeset
287 "name": this_image,
5edba1f921b7 arnica: reduce code duplication, create URLs the correct way
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 186
diff changeset
288 "prefix": prefix,
5edba1f921b7 arnica: reduce code duplication, create URLs the correct way
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 186
diff changeset
289 "alias": original_images[i],
5edba1f921b7 arnica: reduce code duplication, create URLs the correct way
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 186
diff changeset
290 })
165
7332323c8a6f arnica_slides: use prefix Webnail in options list
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 164
diff changeset
291 i += 1
189
5edba1f921b7 arnica: reduce code duplication, create URLs the correct way
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 186
diff changeset
292 return ''.join(options)
23
26d9d5f67365 arnica_slides: some more refactoring
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 22
diff changeset
293
26d9d5f67365 arnica_slides: some more refactoring
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 22
diff changeset
294 class arnica_slides(ActionBase):
26d9d5f67365 arnica_slides: some more refactoring
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 22
diff changeset
295 """ arnica_slides page action
26d9d5f67365 arnica_slides: some more refactoring
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 22
diff changeset
296
26d9d5f67365 arnica_slides: some more refactoring
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 22
diff changeset
297 Note: the action name is the class name
26d9d5f67365 arnica_slides: some more refactoring
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 22
diff changeset
298 """
26d9d5f67365 arnica_slides: some more refactoring
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 22
diff changeset
299 def __init__(self, request, pagename):
26d9d5f67365 arnica_slides: some more refactoring
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 22
diff changeset
300 ActionBase.__init__(self, pagename, request)
26d9d5f67365 arnica_slides: some more refactoring
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 22
diff changeset
301 self.request = request
26d9d5f67365 arnica_slides: some more refactoring
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 22
diff changeset
302 self.pagename = pagename
26d9d5f67365 arnica_slides: some more refactoring
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 22
diff changeset
303 self.page = Page(request, pagename)
26d9d5f67365 arnica_slides: some more refactoring
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 22
diff changeset
304 self.method = 'POST'
26d9d5f67365 arnica_slides: some more refactoring
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 22
diff changeset
305 self.enctype = 'multipart/form-data'
26d9d5f67365 arnica_slides: some more refactoring
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 22
diff changeset
306
26d9d5f67365 arnica_slides: some more refactoring
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 22
diff changeset
307 def is_excluded(self):
26d9d5f67365 arnica_slides: some more refactoring
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 22
diff changeset
308 """ Return True if action is excluded """
26d9d5f67365 arnica_slides: some more refactoring
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 22
diff changeset
309 return self.actionname in self.cfg.actions_excluded
26d9d5f67365 arnica_slides: some more refactoring
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 22
diff changeset
310
26d9d5f67365 arnica_slides: some more refactoring
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 22
diff changeset
311 def is_allowed(self):
26d9d5f67365 arnica_slides: some more refactoring
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 22
diff changeset
312 """ Return True if read access is allowed """
26d9d5f67365 arnica_slides: some more refactoring
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 22
diff changeset
313 may = self.request.user.may
26d9d5f67365 arnica_slides: some more refactoring
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 22
diff changeset
314 return may.read(self.pagename)
0
d164d12d06b8 initial version of arnica (image gallery parser and slideshow action)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
315
d164d12d06b8 initial version of arnica (image gallery parser and slideshow action)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
316 def do_action(self):
d164d12d06b8 initial version of arnica (image gallery parser and slideshow action)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
317 """ Do the action and either return error msg or None, if there was no error. """
d164d12d06b8 initial version of arnica (image gallery parser and slideshow action)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
318 return None
d164d12d06b8 initial version of arnica (image gallery parser and slideshow action)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
319
12
39ca17464e9c arnica_slides: fixed definition of do_action_finish
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 11
diff changeset
320 def do_action_finish(self, success):
0
d164d12d06b8 initial version of arnica (image gallery parser and slideshow action)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
321 """ Do the action and either return error msg or None, if there was no error. """
d164d12d06b8 initial version of arnica (image gallery parser and slideshow action)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
322 return None
d164d12d06b8 initial version of arnica (image gallery parser and slideshow action)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
323
70
beea6a9e50c2 arnica_slides: slide_show refactored to a method
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 68
diff changeset
324 def slide_show(self, pagename):
181
b19e4e36a1f2 arnica: cosmetic fixes, improve docstrings, minor i18n bugfixes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 178
diff changeset
325 """ run the slide show """
70
beea6a9e50c2 arnica_slides: slide_show refactored to a method
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 68
diff changeset
326 _ = self.request.getText
beea6a9e50c2 arnica_slides: slide_show refactored to a method
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 68
diff changeset
327 request = self.request
beea6a9e50c2 arnica_slides: slide_show refactored to a method
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 68
diff changeset
328 if not request.user.may.read(pagename):
229
6cc67d4f27cb arnica_slides: refactored call of send_page
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 227
diff changeset
329 return _("You are not allowed to view this page!"), "error"
70
beea6a9e50c2 arnica_slides: slide_show refactored to a method
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 68
diff changeset
330
beea6a9e50c2 arnica_slides: slide_show refactored to a method
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 68
diff changeset
331 target = request.form.get('target', [''])[0]
beea6a9e50c2 arnica_slides: slide_show refactored to a method
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 68
diff changeset
332 images = request.form.get('images', [''])[0]
167
3311d9f639cf arnica_slides, text_x_arnica: use real image name in the option list
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 166
diff changeset
333 original_images = request.form.get('original_images', [''])[0]
178
d29abc5e4b4f PEP8 fixes
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 176
diff changeset
334
117
eb46d3641b93 arnica_slides: checks required parameters for slide_show
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 116
diff changeset
335 all_description = request.form.get('alias', [''])[0]
eb46d3641b93 arnica_slides: checks required parameters for slide_show
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 116
diff changeset
336 all_exif_date = request.form.get('exif_date', [''])[0]
eb46d3641b93 arnica_slides: checks required parameters for slide_show
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 116
diff changeset
337
eb46d3641b93 arnica_slides: checks required parameters for slide_show
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 116
diff changeset
338 if not (target and images and all_description and all_exif_date):
229
6cc67d4f27cb arnica_slides: refactored call of send_page
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 227
diff changeset
339 return _("Missing required parameters!"), "error"
70
beea6a9e50c2 arnica_slides: slide_show refactored to a method
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 68
diff changeset
340
beea6a9e50c2 arnica_slides: slide_show refactored to a method
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 68
diff changeset
341 images = unpackLine(images)
181
b19e4e36a1f2 arnica: cosmetic fixes, improve docstrings, minor i18n bugfixes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 178
diff changeset
342 images = images[1:]
178
d29abc5e4b4f PEP8 fixes
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 176
diff changeset
343
167
3311d9f639cf arnica_slides, text_x_arnica: use real image name in the option list
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 166
diff changeset
344 original_images = unpackLine(original_images)
181
b19e4e36a1f2 arnica: cosmetic fixes, improve docstrings, minor i18n bugfixes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 178
diff changeset
345 original_images = original_images[1:]
70
beea6a9e50c2 arnica_slides: slide_show refactored to a method
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 68
diff changeset
346
beea6a9e50c2 arnica_slides: slide_show refactored to a method
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 68
diff changeset
347 all_description = unpackLine(all_description)
181
b19e4e36a1f2 arnica: cosmetic fixes, improve docstrings, minor i18n bugfixes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 178
diff changeset
348 all_description = all_description[1:]
70
beea6a9e50c2 arnica_slides: slide_show refactored to a method
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 68
diff changeset
349
beea6a9e50c2 arnica_slides: slide_show refactored to a method
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 68
diff changeset
350 all_exif_date = unpackLine(all_exif_date)
181
b19e4e36a1f2 arnica: cosmetic fixes, improve docstrings, minor i18n bugfixes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 178
diff changeset
351 all_exif_date = all_exif_date[1:]
70
beea6a9e50c2 arnica_slides: slide_show refactored to a method
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 68
diff changeset
352
beea6a9e50c2 arnica_slides: slide_show refactored to a method
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 68
diff changeset
353 # XXX Check that all lists have same length
117
eb46d3641b93 arnica_slides: checks required parameters for slide_show
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 116
diff changeset
354 try:
eb46d3641b93 arnica_slides: checks required parameters for slide_show
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 116
diff changeset
355 idx = images.index(target)
eb46d3641b93 arnica_slides: checks required parameters for slide_show
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 116
diff changeset
356 except ValueError:
229
6cc67d4f27cb arnica_slides: refactored call of send_page
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 227
diff changeset
357 return _("Attachment '%(filename)s' does not exist!") % {'filename': target}, "error"
70
beea6a9e50c2 arnica_slides: slide_show refactored to a method
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 68
diff changeset
358
beea6a9e50c2 arnica_slides: slide_show refactored to a method
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 68
diff changeset
359 web = {}
beea6a9e50c2 arnica_slides: slide_show refactored to a method
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 68
diff changeset
360
227
a16b7c703fd3 flag image_for_webnail mode refactored: the image becomes duplicated as webnail in the cache arena.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 226
diff changeset
361 web['src'] = cache.url(request, target)
70
beea6a9e50c2 arnica_slides: slide_show refactored to a method
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 68
diff changeset
362 web['title'] = target
beea6a9e50c2 arnica_slides: slide_show refactored to a method
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 68
diff changeset
363
beea6a9e50c2 arnica_slides: slide_show refactored to a method
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 68
diff changeset
364 mimetype = "text/html"
beea6a9e50c2 arnica_slides: slide_show refactored to a method
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 68
diff changeset
365 request.emit_http_headers(["Content-Type: %s; charset=%s" % (mimetype, config.charset)])
beea6a9e50c2 arnica_slides: slide_show refactored to a method
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 68
diff changeset
366
beea6a9e50c2 arnica_slides: slide_show refactored to a method
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 68
diff changeset
367 request.theme.send_title(pagename,
beea6a9e50c2 arnica_slides: slide_show refactored to a method
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 68
diff changeset
368 pagename=pagename,
beea6a9e50c2 arnica_slides: slide_show refactored to a method
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 68
diff changeset
369 body_onload="arnica_preload();",
beea6a9e50c2 arnica_slides: slide_show refactored to a method
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 68
diff changeset
370 html_head=html_js(request, idx))
beea6a9e50c2 arnica_slides: slide_show refactored to a method
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 68
diff changeset
371
beea6a9e50c2 arnica_slides: slide_show refactored to a method
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 68
diff changeset
372 request.write(request.formatter.startContent("content"))
227
a16b7c703fd3 flag image_for_webnail mode refactored: the image becomes duplicated as webnail in the cache arena.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 226
diff changeset
373 html = html_slideform(request, pagename, all_description, all_exif_date, images, original_images, idx)
216
0779bac0e8f4 rnica_slides: use formatter.rawHTML to output html
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 215
diff changeset
374 request.write(request.formatter.rawHTML(html))
70
beea6a9e50c2 arnica_slides: slide_show refactored to a method
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 68
diff changeset
375 request.write(request.formatter.endContent())
beea6a9e50c2 arnica_slides: slide_show refactored to a method
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 68
diff changeset
376 request.write(request.theme.send_footer(pagename))
91
16d762c9c3e7 arnica_slides: fixed missing html closing
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 82
diff changeset
377 request.theme.send_closing_html()
229
6cc67d4f27cb arnica_slides: refactored call of send_page
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 227
diff changeset
378 return None, None
70
beea6a9e50c2 arnica_slides: slide_show refactored to a method
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 68
diff changeset
379
0
d164d12d06b8 initial version of arnica (image gallery parser and slideshow action)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
380 def render(self):
181
b19e4e36a1f2 arnica: cosmetic fixes, improve docstrings, minor i18n bugfixes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 178
diff changeset
381 """ executes the commands of the form data """
0
d164d12d06b8 initial version of arnica (image gallery parser and slideshow action)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
382 _ = self.request.getText
d164d12d06b8 initial version of arnica (image gallery parser and slideshow action)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
383 request = self.request
68
f0fed03fd6f7 fixed target_page for thumbnails and slide show
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 67
diff changeset
384 pagename = request.form.get('pagename', [self.pagename])[0]
0
d164d12d06b8 initial version of arnica (image gallery parser and slideshow action)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
385 command = request.form.get('do', ['none'])[0]
30
f28165322ad3 arnica_slides: reject access to unknown cache files
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 29
diff changeset
386 target = request.form.get('target', [''])[0]
41
edc8b8c5ccdd PEP8 whitespace fix
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 40
diff changeset
387
38
e6bd98eea9f5 arnica_slides: some comments added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 37
diff changeset
388 # View Slides
73
c827091b3427 unveil commands
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 72
diff changeset
389 if command == 'slide_show':
229
6cc67d4f27cb arnica_slides: refactored call of send_page
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 227
diff changeset
390 return self.slide_show(pagename)
18
72099349b4a8 arnica_action: moved view before check of delete rights
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 17
diff changeset
391
1
33d03349c532 small fixes for comments, separate import for Image
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 0
diff changeset
392 # only users which are allowed to delete should use this tool
116
4891dc042095 arnica_slides: fix wrong leading msg when called with macro Action.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 114
diff changeset
393 elif request.user.may.delete(pagename):
4891dc042095 arnica_slides: fix wrong leading msg when called with macro Action.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 114
diff changeset
394 # only POST continues
217
1c76b2acd1a5 arnica_slides: simplified and removed some useless comments
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 216
diff changeset
395 if request.request_method != 'POST':
229
6cc67d4f27cb arnica_slides: refactored call of send_page
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 227
diff changeset
396 return _('Missing parameters or GET method used'), "error"
116
4891dc042095 arnica_slides: fix wrong leading msg when called with macro Action.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 114
diff changeset
397
0
d164d12d06b8 initial version of arnica (image gallery parser and slideshow action)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
398 filename, ext = os.path.splitext(target)
217
1c76b2acd1a5 arnica_slides: simplified and removed some useless comments
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 216
diff changeset
399 img_type = "JPEG"
1c76b2acd1a5 arnica_slides: simplified and removed some useless comments
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 216
diff changeset
400 thumbfile = "tmp.thumbnail_%s.jpg" % filename
1c76b2acd1a5 arnica_slides: simplified and removed some useless comments
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 216
diff changeset
401 webnail = "tmp.webnail_%s.jpg" % filename
1c76b2acd1a5 arnica_slides: simplified and removed some useless comments
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 216
diff changeset
402
33
e8b445ed922d arnica_slides: use list instead of or
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 32
diff changeset
403 if ext in ('.gif', '.png'):
0
d164d12d06b8 initial version of arnica (image gallery parser and slideshow action)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
404 img_type = 'PNG'
215
63bb59fda932 arnica_slides: moving to bak file by AttachFile.move_file
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 214
diff changeset
405 thumbfile = "tmp.thumbnail_%s.png" % filename
63bb59fda932 arnica_slides: moving to bak file by AttachFile.move_file
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 214
diff changeset
406 webnail = "tmp.webnail_%s.png" % filename
224
bcd2ea17f130 PEP8 fix
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 219
diff changeset
407
185
7e23f320ce08 arnica: improve/reorganize some code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 181
diff changeset
408 if command in ('delete', 'rotate_left', 'rotate_right', ):
199
b82d3ce1764a action cache method used instead of similiar one from caching
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 190
diff changeset
409 cache.remove(self.request, webnail)
b82d3ce1764a action cache method used instead of similiar one from caching
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 190
diff changeset
410 cache.remove(self.request, thumbfile)
16
22e4dacd1d37 arnica_slides: viewing thumbnails and webnails from cache dir
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 13
diff changeset
411
185
7e23f320ce08 arnica: improve/reorganize some code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 181
diff changeset
412 infile = AttachFile.getFilename(request, pagename, target)
38
e6bd98eea9f5 arnica_slides: some comments added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 37
diff changeset
413
e6bd98eea9f5 arnica_slides: some comments added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 37
diff changeset
414 # removes attachment (moves to bak)
73
c827091b3427 unveil commands
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 72
diff changeset
415 if command == 'delete':
215
63bb59fda932 arnica_slides: moving to bak file by AttachFile.move_file
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 214
diff changeset
416 bakfile = "%s.bak" % target
63bb59fda932 arnica_slides: moving to bak file by AttachFile.move_file
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 214
diff changeset
417 try:
0
d164d12d06b8 initial version of arnica (image gallery parser and slideshow action)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
418 os.unlink("%(file)s.bak" % {"file": infile})
215
63bb59fda932 arnica_slides: moving to bak file by AttachFile.move_file
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 214
diff changeset
419 except:
63bb59fda932 arnica_slides: moving to bak file by AttachFile.move_file
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 214
diff changeset
420 pass
63bb59fda932 arnica_slides: moving to bak file by AttachFile.move_file
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 214
diff changeset
421 AttachFile.move_file(request, pagename, pagename, target, bakfile)
229
6cc67d4f27cb arnica_slides: refactored call of send_page
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 227
diff changeset
422 return None, None
111
2159a14c54ea arnica_slides.image_rotate: rotate only image, purge cache of thumbnail and webnail
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 110
diff changeset
423
73
c827091b3427 unveil commands
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 72
diff changeset
424 elif command == 'rotate_left':
111
2159a14c54ea arnica_slides.image_rotate: rotate only image, purge cache of thumbnail and webnail
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 110
diff changeset
425 image_rotate(infile, 90, img_type)
229
6cc67d4f27cb arnica_slides: refactored call of send_page
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 227
diff changeset
426 return _('%(target)s rotated left 90 degrees') % {'target': target}, "info"
0
d164d12d06b8 initial version of arnica (image gallery parser and slideshow action)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
427
73
c827091b3427 unveil commands
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 72
diff changeset
428 elif command == 'rotate_right':
111
2159a14c54ea arnica_slides.image_rotate: rotate only image, purge cache of thumbnail and webnail
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 110
diff changeset
429 image_rotate(infile, 270, img_type)
229
6cc67d4f27cb arnica_slides: refactored call of send_page
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 227
diff changeset
430 return _('%(target)s rotated right 90 degrees') % {'target': target}, "info"
17
cb6ad4cfdc5e PEP8 whitespace fix
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 16
diff changeset
431
0
d164d12d06b8 initial version of arnica (image gallery parser and slideshow action)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
432 else:
d164d12d06b8 initial version of arnica (image gallery parser and slideshow action)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
433 # fallback
229
6cc67d4f27cb arnica_slides: refactored call of send_page
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 227
diff changeset
434 return _('action not implemented: %s') % (command, ), "info"
0
d164d12d06b8 initial version of arnica (image gallery parser and slideshow action)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
435 else:
229
6cc67d4f27cb arnica_slides: refactored call of send_page
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 227
diff changeset
436 return _('Your are not allowed to change attachments on this page: %s') % (pagename, ), "error"
0
d164d12d06b8 initial version of arnica (image gallery parser and slideshow action)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
437
d164d12d06b8 initial version of arnica (image gallery parser and slideshow action)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
438
d164d12d06b8 initial version of arnica (image gallery parser and slideshow action)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
439 def execute(pagename, request):
29
af82335acd58 arnica_slides: requires also POST where delete rights are needed
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 28
diff changeset
440 """ Main dispatcher for the arnica_slides action. """
37
ad1d433589e4 moved test for PIL to a better place
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 36
diff changeset
441 _ = request.getText
229
6cc67d4f27cb arnica_slides: refactored call of send_page
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 227
diff changeset
442 msg = None
37
ad1d433589e4 moved test for PIL to a better place
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 36
diff changeset
443 if not Image:
181
b19e4e36a1f2 arnica: cosmetic fixes, improve docstrings, minor i18n bugfixes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 178
diff changeset
444 msg = _('The action %(action)s needs Python Imaging Library (PIL) installed') % {'action': action_name}
229
6cc67d4f27cb arnica_slides: refactored call of send_page
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 227
diff changeset
445 state = "error"
6cc67d4f27cb arnica_slides: refactored call of send_page
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 227
diff changeset
446 if not msg:
6cc67d4f27cb arnica_slides: refactored call of send_page
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 227
diff changeset
447 msg, state = arnica_slides(request, pagename).render()
6cc67d4f27cb arnica_slides: refactored call of send_page
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 227
diff changeset
448 if msg:
6cc67d4f27cb arnica_slides: refactored call of send_page
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 227
diff changeset
449 request.theme.add_msg(msg, state)
37
ad1d433589e4 moved test for PIL to a better place
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 36
diff changeset
450 Page(request, pagename).send_page()
229
6cc67d4f27cb arnica_slides: refactored call of send_page
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 227
diff changeset
451 return
37
ad1d433589e4 moved test for PIL to a better place
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 36
diff changeset
452