annotate data/plugin/parser/text_x_arnica.py @ 188:a1a6a45edaf1

arnica: use StringIO file obj for cache.put(), remove unused code
author Thomas Waldmann <tw AT waldmann-edv DOT de>
date Thu, 17 Jul 2008 23:54:42 +0200
parents a2a5dedfeb1d
children 192f39a549e9
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 """
28
e71bbef3a837 PEP8 whitespace fix to satisfy test_sourcecode
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 26
diff changeset
3 MoinMoin - arnica parser
e71bbef3a837 PEP8 whitespace fix to satisfy test_sourcecode
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 26
diff changeset
4
0
d164d12d06b8 initial version of arnica (image gallery parser and slideshow action)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
5 This parser is used to visualize a couple of images as a thumbnail gallery.
149
62a6c964e63b fixed and added docstrings
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 144
diff changeset
6 Optionally, a description of an image can be added.
155
3d5773a1e24b text_x_arnica: output text by the formatter
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 153
diff changeset
7
149
62a6c964e63b fixed and added docstrings
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 144
diff changeset
8 By default the image name and its creation date is shown.
62a6c964e63b fixed and added docstrings
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 144
diff changeset
9 If you click on a thumbnail you get navigation tools shown to slide through your images.
0
d164d12d06b8 initial version of arnica (image gallery parser and slideshow action)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
10
149
62a6c964e63b fixed and added docstrings
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 144
diff changeset
11 Based on Gallery2 by ReimarBauer 2005-2008, ThomasWaldmann 2005, FlorianFesti 2006
28
e71bbef3a837 PEP8 whitespace fix to satisfy test_sourcecode
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 26
diff changeset
12
0
d164d12d06b8 initial version of arnica (image gallery parser and slideshow action)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
13 @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
14 @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
15 """
149
62a6c964e63b fixed and added docstrings
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 144
diff changeset
16
164
db98e843b83c text_x_arnica, arnica_slides: implemented sendcached from 1.8 repository
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 163
diff changeset
17 import os, re, StringIO
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 random import randint
149
62a6c964e63b fixed and added docstrings
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 144
diff changeset
19
89
83abc483373a text_x_arnica: internal _get_files routine added to select only valid image files
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 87
diff changeset
20 from MoinMoin import caching, config, wikiutil
166
9817520ac155 text_x_arnica, arnica_slides: refactored sendcached.* to cache.* methods
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 164
diff changeset
21 from MoinMoin.action import AttachFile, cache
64
ea6139631185 text_x_arnica: removed definition of _create_macro and usage from wikiutil.invoke_extension_function
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 63
diff changeset
22 from MoinMoin.filter import EXIF
40
c208aceb1ebd join and split exchanged on various places to packLine and unpackLine
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 37
diff changeset
23 from MoinMoin.packages import packLine
0
d164d12d06b8 initial version of arnica (image gallery parser and slideshow action)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
24 from MoinMoin.Page import Page
42
7bf792c8364b text_x_arnica: table is done by DataBrowserWidget
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 41
diff changeset
25 from MoinMoin.util.dataset import TupleDataset, Column
7bf792c8364b text_x_arnica: table is done by DataBrowserWidget
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 41
diff changeset
26 from MoinMoin.widget.browser import DataBrowserWidget
0
d164d12d06b8 initial version of arnica (image gallery parser and slideshow action)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
27
1
33d03349c532 small fixes for comments, separate import for Image
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 0
diff changeset
28 try:
33d03349c532 small fixes for comments, separate import for Image
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 0
diff changeset
29 import Image
33d03349c532 small fixes for comments, separate import for Image
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 0
diff changeset
30 except ImportError:
33d03349c532 small fixes for comments, separate import for Image
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 0
diff changeset
31 Image = None
17
cb6ad4cfdc5e PEP8 whitespace fix
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 15
diff changeset
32
37
ad1d433589e4 moved test for PIL to a better place
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 34
diff changeset
33 parser_name = __name__.split('.')[-1]
ad1d433589e4 moved test for PIL to a better place
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 34
diff changeset
34
164
db98e843b83c text_x_arnica, arnica_slides: implemented sendcached from 1.8 repository
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 163
diff changeset
35
121
f6ce62994858 text_x_arnica: initial setup for css.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 113
diff changeset
36 class _DataBrowserWidget(DataBrowserWidget):
f6ce62994858 text_x_arnica: initial setup for css.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 113
diff changeset
37 """ we have to remove the used form in format otherwise the needed form elements
181
b19e4e36a1f2 arnica: cosmetic fixes, improve docstrings, minor i18n bugfixes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 180
diff changeset
38 becomes a nested form and this raises lots of strict html4.01 errors.
b19e4e36a1f2 arnica: cosmetic fixes, improve docstrings, minor i18n bugfixes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 180
diff changeset
39 """
121
f6ce62994858 text_x_arnica: initial setup for css.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 113
diff changeset
40 def format(self):
f6ce62994858 text_x_arnica: initial setup for css.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 113
diff changeset
41 fmt = self.request.formatter
f6ce62994858 text_x_arnica: initial setup for css.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 113
diff changeset
42 result = []
f6ce62994858 text_x_arnica: initial setup for css.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 113
diff changeset
43 havefilters = False
f6ce62994858 text_x_arnica: initial setup for css.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 113
diff changeset
44 for col in self.data.columns:
f6ce62994858 text_x_arnica: initial setup for css.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 113
diff changeset
45 if col.autofilter:
f6ce62994858 text_x_arnica: initial setup for css.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 113
diff changeset
46 havefilters = True
f6ce62994858 text_x_arnica: initial setup for css.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 113
diff changeset
47 break
f6ce62994858 text_x_arnica: initial setup for css.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 113
diff changeset
48 if havefilters:
f6ce62994858 text_x_arnica: initial setup for css.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 113
diff changeset
49 result.append(fmt.rawHTML('<input type="submit" value="%s" %s>' % (self._filter, self._name('submit'))))
f6ce62994858 text_x_arnica: initial setup for css.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 113
diff changeset
50
f6ce62994858 text_x_arnica: initial setup for css.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 113
diff changeset
51 result.append(fmt.table(1, id='%stable' % self.data_id))
f6ce62994858 text_x_arnica: initial setup for css.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 113
diff changeset
52
f6ce62994858 text_x_arnica: initial setup for css.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 113
diff changeset
53 # add header line
f6ce62994858 text_x_arnica: initial setup for css.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 113
diff changeset
54 if self._show_header:
f6ce62994858 text_x_arnica: initial setup for css.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 113
diff changeset
55 result.append(fmt.table_row(1))
f6ce62994858 text_x_arnica: initial setup for css.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 113
diff changeset
56 for idx in range(len(self.data.columns)):
f6ce62994858 text_x_arnica: initial setup for css.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 113
diff changeset
57 col = self.data.columns[idx]
f6ce62994858 text_x_arnica: initial setup for css.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 113
diff changeset
58 if col.hidden:
f6ce62994858 text_x_arnica: initial setup for css.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 113
diff changeset
59 continue
f6ce62994858 text_x_arnica: initial setup for css.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 113
diff changeset
60 result.append(fmt.table_cell(1))
f6ce62994858 text_x_arnica: initial setup for css.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 113
diff changeset
61 result.append(fmt.strong(1))
f6ce62994858 text_x_arnica: initial setup for css.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 113
diff changeset
62 result.append(col.label or col.name)
f6ce62994858 text_x_arnica: initial setup for css.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 113
diff changeset
63 result.append(fmt.strong(0))
f6ce62994858 text_x_arnica: initial setup for css.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 113
diff changeset
64 if col.autofilter:
f6ce62994858 text_x_arnica: initial setup for css.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 113
diff changeset
65 result.append(fmt.linebreak(False))
181
b19e4e36a1f2 arnica: cosmetic fixes, improve docstrings, minor i18n bugfixes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 180
diff changeset
66 select = """<select %s onchange="dbw_update_search('%s');">%s</select>""" % (
121
f6ce62994858 text_x_arnica: initial setup for css.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 113
diff changeset
67 self._name('filter%d' % idx),
f6ce62994858 text_x_arnica: initial setup for css.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 113
diff changeset
68 self.data_id,
f6ce62994858 text_x_arnica: initial setup for css.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 113
diff changeset
69 self._filteroptions(idx))
f6ce62994858 text_x_arnica: initial setup for css.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 113
diff changeset
70 result.append(fmt.rawHTML(select))
f6ce62994858 text_x_arnica: initial setup for css.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 113
diff changeset
71 result.append(fmt.table_cell(0))
f6ce62994858 text_x_arnica: initial setup for css.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 113
diff changeset
72 result.append(fmt.table_row(0))
f6ce62994858 text_x_arnica: initial setup for css.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 113
diff changeset
73
f6ce62994858 text_x_arnica: initial setup for css.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 113
diff changeset
74 # add data
f6ce62994858 text_x_arnica: initial setup for css.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 113
diff changeset
75 self.data.reset()
f6ce62994858 text_x_arnica: initial setup for css.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 113
diff changeset
76 row = self.data.next()
f6ce62994858 text_x_arnica: initial setup for css.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 113
diff changeset
77 if row is not None:
f6ce62994858 text_x_arnica: initial setup for css.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 113
diff changeset
78 filters = [None] * len(row)
f6ce62994858 text_x_arnica: initial setup for css.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 113
diff changeset
79 if havefilters:
f6ce62994858 text_x_arnica: initial setup for css.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 113
diff changeset
80 for idx in range(len(row)):
f6ce62994858 text_x_arnica: initial setup for css.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 113
diff changeset
81 name = '%sfilter%d' % (self.data_id, idx)
f6ce62994858 text_x_arnica: initial setup for css.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 113
diff changeset
82 if name in self.request.form:
f6ce62994858 text_x_arnica: initial setup for css.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 113
diff changeset
83 filters[idx] = self.request.form[name][0]
f6ce62994858 text_x_arnica: initial setup for css.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 113
diff changeset
84 if filters[idx] == self._all:
f6ce62994858 text_x_arnica: initial setup for css.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 113
diff changeset
85 filters[idx] = None
f6ce62994858 text_x_arnica: initial setup for css.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 113
diff changeset
86 while row:
f6ce62994858 text_x_arnica: initial setup for css.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 113
diff changeset
87 hidden = False
f6ce62994858 text_x_arnica: initial setup for css.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 113
diff changeset
88 if havefilters:
f6ce62994858 text_x_arnica: initial setup for css.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 113
diff changeset
89 # check if row needs to be hidden due to filtering
f6ce62994858 text_x_arnica: initial setup for css.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 113
diff changeset
90 for idx in range(len(row)):
f6ce62994858 text_x_arnica: initial setup for css.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 113
diff changeset
91 if filters[idx]:
f6ce62994858 text_x_arnica: initial setup for css.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 113
diff changeset
92 if isinstance(row[idx], tuple):
f6ce62994858 text_x_arnica: initial setup for css.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 113
diff changeset
93 data = unicode(row[idx][1])
f6ce62994858 text_x_arnica: initial setup for css.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 113
diff changeset
94 else:
f6ce62994858 text_x_arnica: initial setup for css.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 113
diff changeset
95 data = unicode(row[idx])
f6ce62994858 text_x_arnica: initial setup for css.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 113
diff changeset
96 if data != '' and filters[idx] == self._notempty:
f6ce62994858 text_x_arnica: initial setup for css.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 113
diff changeset
97 continue
f6ce62994858 text_x_arnica: initial setup for css.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 113
diff changeset
98 if data == '' and filters[idx] == self._empty:
f6ce62994858 text_x_arnica: initial setup for css.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 113
diff changeset
99 continue
f6ce62994858 text_x_arnica: initial setup for css.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 113
diff changeset
100 if data != filters[idx]:
f6ce62994858 text_x_arnica: initial setup for css.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 113
diff changeset
101 hidden = True
f6ce62994858 text_x_arnica: initial setup for css.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 113
diff changeset
102 break
f6ce62994858 text_x_arnica: initial setup for css.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 113
diff changeset
103 if not hidden:
f6ce62994858 text_x_arnica: initial setup for css.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 113
diff changeset
104 result.append(fmt.table_row(1))
f6ce62994858 text_x_arnica: initial setup for css.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 113
diff changeset
105 for idx in range(len(row)):
f6ce62994858 text_x_arnica: initial setup for css.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 113
diff changeset
106 if self.data.columns[idx].hidden:
f6ce62994858 text_x_arnica: initial setup for css.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 113
diff changeset
107 continue
f6ce62994858 text_x_arnica: initial setup for css.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 113
diff changeset
108 if isinstance(row[idx], tuple):
f6ce62994858 text_x_arnica: initial setup for css.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 113
diff changeset
109 result.append(fmt.table_cell(1, abbr=unicode(row[idx][1])))
f6ce62994858 text_x_arnica: initial setup for css.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 113
diff changeset
110 result.append(unicode(row[idx][0]))
f6ce62994858 text_x_arnica: initial setup for css.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 113
diff changeset
111 else:
f6ce62994858 text_x_arnica: initial setup for css.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 113
diff changeset
112 result.append(fmt.table_cell(1))
f6ce62994858 text_x_arnica: initial setup for css.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 113
diff changeset
113 result.append(unicode(row[idx]))
f6ce62994858 text_x_arnica: initial setup for css.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 113
diff changeset
114 result.append(fmt.table_cell(0))
f6ce62994858 text_x_arnica: initial setup for css.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 113
diff changeset
115 result.append(fmt.table_row(0))
f6ce62994858 text_x_arnica: initial setup for css.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 113
diff changeset
116 row = self.data.next()
f6ce62994858 text_x_arnica: initial setup for css.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 113
diff changeset
117 result.append(fmt.table(0))
132
3ca3f4aadfca arnica_slides, text_x_arnica: removed off commented code lines
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 131
diff changeset
118
121
f6ce62994858 text_x_arnica: initial setup for css.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 113
diff changeset
119 return ''.join(result)
f6ce62994858 text_x_arnica: initial setup for css.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 113
diff changeset
120
181
b19e4e36a1f2 arnica: cosmetic fixes, improve docstrings, minor i18n bugfixes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 180
diff changeset
121
125
922ac221ea10 text_x_arnica: renamed macro_arnica into arnica_seetings
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 122
diff changeset
122 def arnica_settings(target_page=u'', columns=4, file_regex=u'.',
135
e0015917205d text_x_arnica: aligned some lines of arnica_settings
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 134
diff changeset
123 image_for_webnail=False,
e0015917205d text_x_arnica: aligned some lines of arnica_settings
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 134
diff changeset
124 show_text=True, show_date=True, show_tools=False,
e0015917205d text_x_arnica: aligned some lines of arnica_settings
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 134
diff changeset
125 sort_by_date=False, sort_by_name=True, sort_by_alias=False,
e0015917205d text_x_arnica: aligned some lines of arnica_settings
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 134
diff changeset
126 reverse_sort=False,
e0015917205d text_x_arnica: aligned some lines of arnica_settings
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 134
diff changeset
127 only_items=False, template_itemlist=False,
e0015917205d text_x_arnica: aligned some lines of arnica_settings
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 134
diff changeset
128 album=False, album_title=unicode, album_image=u'',
e0015917205d text_x_arnica: aligned some lines of arnica_settings
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 134
diff changeset
129 renew=False,
e0015917205d text_x_arnica: aligned some lines of arnica_settings
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 134
diff changeset
130 thumbnail_width=wikiutil.UnitArgument('128', float, ['px', ], defaultunit='px'),
e0015917205d text_x_arnica: aligned some lines of arnica_settings
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 134
diff changeset
131 webnail_width=wikiutil.UnitArgument('640', float, ['px', ], defaultunit='px')):
163
2676d2cbfaea text_x_arnica: comment fixed
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 162
diff changeset
132 """ dummy function to initialize all default parameters for arnica. The parameters are checked for wrong input.
181
b19e4e36a1f2 arnica: cosmetic fixes, improve docstrings, minor i18n bugfixes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 180
diff changeset
133
149
62a6c964e63b fixed and added docstrings
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 144
diff changeset
134 @param target_page: page to read attachments from. empty pagename is current page.
50
6122e5bb9332 text_x_arnica: moved description of keywords to macro_arnica
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 49
diff changeset
135 @param columns: number of columns for thumbnails
149
62a6c964e63b fixed and added docstrings
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 144
diff changeset
136 @param file_regex: regex for selecting images
50
6122e5bb9332 text_x_arnica: moved description of keywords to macro_arnica
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 49
diff changeset
137 @param image_for_webnail if set then the image is shown instead of the webnail
6122e5bb9332 text_x_arnica: moved description of keywords to macro_arnica
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 49
diff changeset
138 @param show_text: default shows description
181
b19e4e36a1f2 arnica: cosmetic fixes, improve docstrings, minor i18n bugfixes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 180
diff changeset
139 @param show_date: default shows date from exif header, if available
149
62a6c964e63b fixed and added docstrings
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 144
diff changeset
140 @param show_tools: default does not show the icon toolbar
181
b19e4e36a1f2 arnica: cosmetic fixes, improve docstrings, minor i18n bugfixes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 180
diff changeset
141 @param sort_by_name: default, sorts images by name
149
62a6c964e63b fixed and added docstrings
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 144
diff changeset
142 @param sort_by_date: if set, sorts images by the modification time
181
b19e4e36a1f2 arnica: cosmetic fixes, improve docstrings, minor i18n bugfixes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 180
diff changeset
143 @param sort_by_alias: if set, sorts images by the alias name, this also needs only_items enabled
b19e4e36a1f2 arnica: cosmetic fixes, improve docstrings, minor i18n bugfixes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 180
diff changeset
144 @param reverse_sort: if set, the file list is sorted in reverse order
b19e4e36a1f2 arnica: cosmetic fixes, improve docstrings, minor i18n bugfixes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 180
diff changeset
145 @param only_items: if set, only images which are described in listitem are shown, e.g.
50
6122e5bb9332 text_x_arnica: moved description of keywords to macro_arnica
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 49
diff changeset
146 * [[image1.jpg|alias]]
6122e5bb9332 text_x_arnica: moved description of keywords to macro_arnica
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 49
diff changeset
147 * [[image2.jpg|alias]]
149
62a6c964e63b fixed and added docstrings
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 144
diff changeset
148 @param template_itemlist: if set, an item list is shown which could be copied into the wiki page
62a6c964e63b fixed and added docstrings
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 144
diff changeset
149 @param album: if set, selects album mode, only thumbnail from first image is shown, related is album title and album_image
76
0d7bc75bc5a4 text_x_arnica: album_name renamed to album_title
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 75
diff changeset
150 @param album_title: default is pagename of the images for the album.
155
3d5773a1e24b text_x_arnica: output text by the formatter
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 153
diff changeset
151 @param album_image: image to show on album default is the first image
181
b19e4e36a1f2 arnica: cosmetic fixes, improve docstrings, minor i18n bugfixes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 180
diff changeset
152 @param renew: if set then all selected thumbnails_* and webnails_* are removed and will be recreated
b19e4e36a1f2 arnica: cosmetic fixes, improve docstrings, minor i18n bugfixes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 180
diff changeset
153 @param thumbnail_width: default width of thumbnail is 128px
112
8438a033d483 text_x_arnica.macro_arnica: uses the unitparser for thumbnail_width, webnail_width, text_width default unit is px
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 109
diff changeset
154 @param webnail_width: default width of webnail is 640px
50
6122e5bb9332 text_x_arnica: moved description of keywords to macro_arnica
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 49
diff changeset
155 """
112
8438a033d483 text_x_arnica.macro_arnica: uses the unitparser for thumbnail_width, webnail_width, text_width default unit is px
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 109
diff changeset
156 if thumbnail_width:
8438a033d483 text_x_arnica.macro_arnica: uses the unitparser for thumbnail_width, webnail_width, text_width default unit is px
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 109
diff changeset
157 if thumbnail_width[1] == 'px':
8438a033d483 text_x_arnica.macro_arnica: uses the unitparser for thumbnail_width, webnail_width, text_width default unit is px
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 109
diff changeset
158 thumbnail_width = '%dpx' % int(thumbnail_width[0])
8438a033d483 text_x_arnica.macro_arnica: uses the unitparser for thumbnail_width, webnail_width, text_width default unit is px
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 109
diff changeset
159 else:
8438a033d483 text_x_arnica.macro_arnica: uses the unitparser for thumbnail_width, webnail_width, text_width default unit is px
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 109
diff changeset
160 thumbnail_width = '%g%s' % thumbnail_width
8438a033d483 text_x_arnica.macro_arnica: uses the unitparser for thumbnail_width, webnail_width, text_width default unit is px
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 109
diff changeset
161 if webnail_width:
8438a033d483 text_x_arnica.macro_arnica: uses the unitparser for thumbnail_width, webnail_width, text_width default unit is px
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 109
diff changeset
162 if webnail_width[1] == 'px':
8438a033d483 text_x_arnica.macro_arnica: uses the unitparser for thumbnail_width, webnail_width, text_width default unit is px
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 109
diff changeset
163 webnail_width = '%dpx' % int(webnail_width[0])
8438a033d483 text_x_arnica.macro_arnica: uses the unitparser for thumbnail_width, webnail_width, text_width default unit is px
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 109
diff changeset
164 else:
8438a033d483 text_x_arnica.macro_arnica: uses the unitparser for thumbnail_width, webnail_width, text_width default unit is px
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 109
diff changeset
165 webnail_width = '%g%s' % webnail_width
61
6ab80d79e924 text_x_arnica.macro_arnica: much more simplified using locals()
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 60
diff changeset
166 return locals()
132
3ca3f4aadfca arnica_slides, text_x_arnica: removed off commented code lines
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 131
diff changeset
167
181
b19e4e36a1f2 arnica: cosmetic fixes, improve docstrings, minor i18n bugfixes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 180
diff changeset
168
28
e71bbef3a837 PEP8 whitespace fix to satisfy test_sourcecode
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 26
diff changeset
169 # ToDo may be move to wikiutil
8
b9eb24a6213a text_x_arnica: moved method get_exif_info to function
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 7
diff changeset
170 def get_exif_info(file_name):
28
e71bbef3a837 PEP8 whitespace fix to satisfy test_sourcecode
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 26
diff changeset
171 """ gets exif info from image file
181
b19e4e36a1f2 arnica: cosmetic fixes, improve docstrings, minor i18n bugfixes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 180
diff changeset
172
28
e71bbef3a837 PEP8 whitespace fix to satisfy test_sourcecode
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 26
diff changeset
173 @param: image file name
8
b9eb24a6213a text_x_arnica: moved method get_exif_info to function
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 7
diff changeset
174 """
b9eb24a6213a text_x_arnica: moved method get_exif_info to function
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 7
diff changeset
175 date = "--"
b9eb24a6213a text_x_arnica: moved method get_exif_info to function
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 7
diff changeset
176 if wikiutil.isPicture(file_name):
181
b19e4e36a1f2 arnica: cosmetic fixes, improve docstrings, minor i18n bugfixes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 180
diff changeset
177 # if there is no exif data available, tags is an empty dict
172
a2c26bbd9ed8 text_x_arnica: renamed some vars in get_exif_info
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 170
diff changeset
178 exif_file = open(file_name, 'rb')
a2c26bbd9ed8 text_x_arnica: renamed some vars in get_exif_info
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 170
diff changeset
179 tags = EXIF.process_file(exif_file, 'DateTimeOriginal')
a2c26bbd9ed8 text_x_arnica: renamed some vars in get_exif_info
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 170
diff changeset
180 exif_file.close()
161
8eee2fa838cf text_x_arnica: fixed EXIF date output
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 160
diff changeset
181 if 'EXIF DateTimeOriginal' in tags:
8
b9eb24a6213a text_x_arnica: moved method get_exif_info to function
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 7
diff changeset
182 date = str(tags['EXIF DateTimeOriginal'])
161
8eee2fa838cf text_x_arnica: fixed EXIF date output
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 160
diff changeset
183 date = date.replace(':', '-', 2)
98
edb3aa8208b2 text_x_arnica: removed some whitespaces, moved _get_files below macro_arnica
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 94
diff changeset
184 return date
1
33d03349c532 small fixes for comments, separate import for Image
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 0
diff changeset
185
181
b19e4e36a1f2 arnica: cosmetic fixes, improve docstrings, minor i18n bugfixes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 180
diff changeset
186
98
edb3aa8208b2 text_x_arnica: removed some whitespaces, moved _get_files below macro_arnica
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 94
diff changeset
187 def _get_files(request, pagename):
152
7438cd3fdfba text_x_arnica: removed internal duplicate of _get_files
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 149
diff changeset
188 # get files dependent on isPicture and ignores tmp. files
7438cd3fdfba text_x_arnica: removed internal duplicate of _get_files
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 149
diff changeset
189 # ToDo remove tmp. files check later
7438cd3fdfba text_x_arnica: removed internal duplicate of _get_files
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 149
diff changeset
190 files = AttachFile._get_files(request, pagename)
7438cd3fdfba text_x_arnica: removed internal duplicate of _get_files
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 149
diff changeset
191 files = [fn for fn in files if wikiutil.isPicture(fn) and not fn.startswith('tmp.')]
98
edb3aa8208b2 text_x_arnica: removed some whitespaces, moved _get_files below macro_arnica
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 94
diff changeset
192 return files
17
cb6ad4cfdc5e PEP8 whitespace fix
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 15
diff changeset
193
121
f6ce62994858 text_x_arnica: initial setup for css.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 113
diff changeset
194
0
d164d12d06b8 initial version of arnica (image gallery parser and slideshow action)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
195 class Parser:
3
c9ab05e6d499 text_x_arnica: fixed shadowing of Parser
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2
diff changeset
196 """ arnica parser """
0
d164d12d06b8 initial version of arnica (image gallery parser and slideshow action)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
197 extensions = '*.jpg'
d164d12d06b8 initial version of arnica (image gallery parser and slideshow action)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
198 def __init__(self, raw, request, **kw):
7
a067ae7020f6 text_x_arnica: fixed many pylint warnings, factored out get_exif_info from get_files
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 6
diff changeset
199 self.pagename = request.page.page_name
0
d164d12d06b8 initial version of arnica (image gallery parser and slideshow action)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
200 self.raw = raw
d164d12d06b8 initial version of arnica (image gallery parser and slideshow action)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
201 self.request = request
153
3abe0bd083b2 text_x_arnica: added formatter to self and replaced wikiutil.escape with formatter.text
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 152
diff changeset
202 self.formatter = request.formatter
7
a067ae7020f6 text_x_arnica: fixed many pylint warnings, factored out get_exif_info from get_files
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 6
diff changeset
203 self.form = None
0
d164d12d06b8 initial version of arnica (image gallery parser and slideshow action)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
204 self._ = request.getText
155
3d5773a1e24b text_x_arnica: output text by the formatter
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 153
diff changeset
205
49
83078930ae66 introduction of the argument parser
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 48
diff changeset
206 args = kw.get('format_args', '')
55
1eb0c987a260 text_x_arnica: if the parser was called with a not defined parameter, print an error and return.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 54
diff changeset
207 self.init_settings = False
57
7f56d8a670da text_x_arnica: some doc strings added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 56
diff changeset
208 # we use a macro definition to initialize the default init parameters
7f56d8a670da text_x_arnica: some doc strings added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 56
diff changeset
209 # if a user enters a wrong parameter the failure is shown by the exception
49
83078930ae66 introduction of the argument parser
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 48
diff changeset
210 try:
125
922ac221ea10 text_x_arnica: renamed macro_arnica into arnica_seetings
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 122
diff changeset
211 settings = wikiutil.invoke_extension_function(request, arnica_settings, args)
61
6ab80d79e924 text_x_arnica.macro_arnica: much more simplified using locals()
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 60
diff changeset
212 for key, value in settings.items():
64
ea6139631185 text_x_arnica: removed definition of _create_macro and usage from wikiutil.invoke_extension_function
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 63
diff changeset
213 setattr(self, key, value)
57
7f56d8a670da text_x_arnica: some doc strings added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 56
diff changeset
214 # saves the state of valid input
55
1eb0c987a260 text_x_arnica: if the parser was called with a not defined parameter, print an error and return.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 54
diff changeset
215 self.init_settings = True
49
83078930ae66 introduction of the argument parser
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 48
diff changeset
216 except ValueError, err:
55
1eb0c987a260 text_x_arnica: if the parser was called with a not defined parameter, print an error and return.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 54
diff changeset
217 msg = u"arnica: %s" % err.args[0]
149
62a6c964e63b fixed and added docstrings
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 144
diff changeset
218 # ToDo use formatter
153
3abe0bd083b2 text_x_arnica: added formatter to self and replaced wikiutil.escape with formatter.text
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 152
diff changeset
219 request.write(self.formatter.text(msg))
49
83078930ae66 introduction of the argument parser
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 48
diff changeset
220
0
d164d12d06b8 initial version of arnica (image gallery parser and slideshow action)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
221 self.inner_table_style = ' style="border-style:none; margin:10px;"'
d164d12d06b8 initial version of arnica (image gallery parser and slideshow action)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
222 self.td_style = ' align="center" style="padding:0; margin:2px 2px; border-style:none"'
173
f5cdee2715a3 text_x_arnica: various variables renamed
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 172
diff changeset
223 self.web_key = [] # array for webnail keys (medium_resolution_image)
f5cdee2715a3 text_x_arnica: various variables renamed
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 172
diff changeset
224 self.high_resolution_image = [] # array for images
f5cdee2715a3 text_x_arnica: various variables renamed
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 172
diff changeset
225 self.thumb_key = [] # array for thumbnail keys
7
a067ae7020f6 text_x_arnica: fixed many pylint warnings, factored out get_exif_info from get_files
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 6
diff changeset
226 self.exif_date = [] # array of exif date description
173
f5cdee2715a3 text_x_arnica: various variables renamed
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 172
diff changeset
227 self.imgtype = [] # array of imagetype of high_resolution_image image
7
a067ae7020f6 text_x_arnica: fixed many pylint warnings, factored out get_exif_info from get_files
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 6
diff changeset
228 self.description = [] # array of description
173
f5cdee2715a3 text_x_arnica: various variables renamed
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 172
diff changeset
229 self.webnail_image = [] # array of images for forms
17
cb6ad4cfdc5e PEP8 whitespace fix
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 15
diff changeset
230
126
02a3e2fba89f text_x_arnica: renamed html_show_tools_restricted to html_tools_restricted
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 125
diff changeset
231 def html_tools_restricted(self, this_target):
85
d705644861dc text_x_arnica: removed html definition for mode2, renamed mode1 methods
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 84
diff changeset
232 """ shows restricted tools
d705644861dc text_x_arnica: removed html definition for mode2, renamed mode1 methods
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 84
diff changeset
233 @param this_target: image
0
d164d12d06b8 initial version of arnica (image gallery parser and slideshow action)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
234 """
d164d12d06b8 initial version of arnica (image gallery parser and slideshow action)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
235 if not self.request.user.may.delete(self.pagename):
d164d12d06b8 initial version of arnica (image gallery parser and slideshow action)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
236 return ''
181
b19e4e36a1f2 arnica: cosmetic fixes, improve docstrings, minor i18n bugfixes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 180
diff changeset
237 return """
b19e4e36a1f2 arnica: cosmetic fixes, improve docstrings, minor i18n bugfixes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 180
diff changeset
238 <form action="%(url)s" method="POST" enctype="multipart/form-data">
b19e4e36a1f2 arnica: cosmetic fixes, improve docstrings, minor i18n bugfixes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 180
diff changeset
239 <div class="rotate-to-left">
b19e4e36a1f2 arnica: cosmetic fixes, improve docstrings, minor i18n bugfixes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 180
diff changeset
240 <input type="hidden" name="action" value="arnica_slides">
b19e4e36a1f2 arnica: cosmetic fixes, improve docstrings, minor i18n bugfixes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 180
diff changeset
241 <input type="hidden" name="do" value="rotate_left">
b19e4e36a1f2 arnica: cosmetic fixes, improve docstrings, minor i18n bugfixes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 180
diff changeset
242 <input type="hidden" name="target" value="%(this_target)s">
b19e4e36a1f2 arnica: cosmetic fixes, improve docstrings, minor i18n bugfixes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 180
diff changeset
243 <input type="image" value="submit" src="%(htdocs)s/arnica/img/arnica_rotate_to_left.png" title="rotate to left">
b19e4e36a1f2 arnica: cosmetic fixes, improve docstrings, minor i18n bugfixes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 180
diff changeset
244 </div>
b19e4e36a1f2 arnica: cosmetic fixes, improve docstrings, minor i18n bugfixes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 180
diff changeset
245 </form>
b19e4e36a1f2 arnica: cosmetic fixes, improve docstrings, minor i18n bugfixes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 180
diff changeset
246 <form action="%(url)s" method="POST" enctype="multipart/form-data">
b19e4e36a1f2 arnica: cosmetic fixes, improve docstrings, minor i18n bugfixes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 180
diff changeset
247 <div class="rotate-to-right">
b19e4e36a1f2 arnica: cosmetic fixes, improve docstrings, minor i18n bugfixes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 180
diff changeset
248 <input type="hidden" name="action" value="arnica_slides">
b19e4e36a1f2 arnica: cosmetic fixes, improve docstrings, minor i18n bugfixes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 180
diff changeset
249 <input type="hidden" name="do" value="rotate_right">
b19e4e36a1f2 arnica: cosmetic fixes, improve docstrings, minor i18n bugfixes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 180
diff changeset
250 <input type="hidden" name="target" value="%(this_target)s">
b19e4e36a1f2 arnica: cosmetic fixes, improve docstrings, minor i18n bugfixes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 180
diff changeset
251 <input type="image" value="submit" src="%(htdocs)s/arnica/img/arnica_rotate_to_right.png" title="rotate to right">
b19e4e36a1f2 arnica: cosmetic fixes, improve docstrings, minor i18n bugfixes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 180
diff changeset
252 </div>
b19e4e36a1f2 arnica: cosmetic fixes, improve docstrings, minor i18n bugfixes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 180
diff changeset
253 </form>
b19e4e36a1f2 arnica: cosmetic fixes, improve docstrings, minor i18n bugfixes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 180
diff changeset
254 <form action="%(url)s" method="POST" enctype="multipart/form-data">
b19e4e36a1f2 arnica: cosmetic fixes, improve docstrings, minor i18n bugfixes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 180
diff changeset
255 <div class="delete-image">
b19e4e36a1f2 arnica: cosmetic fixes, improve docstrings, minor i18n bugfixes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 180
diff changeset
256 <input type="hidden" name="action" value="arnica_slides">
b19e4e36a1f2 arnica: cosmetic fixes, improve docstrings, minor i18n bugfixes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 180
diff changeset
257 <input type="hidden" name="do" value="delete">
b19e4e36a1f2 arnica: cosmetic fixes, improve docstrings, minor i18n bugfixes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 180
diff changeset
258 <input type="hidden" name="target" value="%(this_target)s">
b19e4e36a1f2 arnica: cosmetic fixes, improve docstrings, minor i18n bugfixes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 180
diff changeset
259 <input type="image" value="submit" src="%(htdocs)s/arnica/img/arnica_remove_image.png" title="move to bak">
b19e4e36a1f2 arnica: cosmetic fixes, improve docstrings, minor i18n bugfixes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 180
diff changeset
260 </div>
b19e4e36a1f2 arnica: cosmetic fixes, improve docstrings, minor i18n bugfixes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 180
diff changeset
261 </form>
b19e4e36a1f2 arnica: cosmetic fixes, improve docstrings, minor i18n bugfixes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 180
diff changeset
262 """ % {
157
0116eb3e1099 text_x_arnica: replaced baseurl/pagename by Page.url
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 156
diff changeset
263 'url': Page(self.request, self.pagename).url(self.request),
0
d164d12d06b8 initial version of arnica (image gallery parser and slideshow action)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
264 'style': self.td_style,
d164d12d06b8 initial version of arnica (image gallery parser and slideshow action)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
265 'htdocs': self.request.cfg.url_prefix_static,
7
a067ae7020f6 text_x_arnica: fixed many pylint warnings, factored out get_exif_info from get_files
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 6
diff changeset
266 "pagename": wikiutil.quoteWikinameURL(self.pagename),
181
b19e4e36a1f2 arnica: cosmetic fixes, improve docstrings, minor i18n bugfixes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 180
diff changeset
267 "this_target": this_target,
b19e4e36a1f2 arnica: cosmetic fixes, improve docstrings, minor i18n bugfixes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 180
diff changeset
268 }
0
d164d12d06b8 initial version of arnica (image gallery parser and slideshow action)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
269
87
d60f41c17f42 text_x_arnica: renamed tools_html into html_tools
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 86
diff changeset
270 def html_tools(self, idx):
0
d164d12d06b8 initial version of arnica (image gallery parser and slideshow action)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
271 """ html code of thumbnails view with contol
181
b19e4e36a1f2 arnica: cosmetic fixes, improve docstrings, minor i18n bugfixes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 180
diff changeset
272
0
d164d12d06b8 initial version of arnica (image gallery parser and slideshow action)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
273 @param idx: index postion of corresponding data
d164d12d06b8 initial version of arnica (image gallery parser and slideshow action)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
274 """
173
f5cdee2715a3 text_x_arnica: various variables renamed
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 172
diff changeset
275 this_image = self.high_resolution_image[idx]
181
b19e4e36a1f2 arnica: cosmetic fixes, improve docstrings, minor i18n bugfixes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 180
diff changeset
276 text = """
b19e4e36a1f2 arnica: cosmetic fixes, improve docstrings, minor i18n bugfixes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 180
diff changeset
277 <form action="%(url)s" method="POST" enctype="multipart/form-data">
b19e4e36a1f2 arnica: cosmetic fixes, improve docstrings, minor i18n bugfixes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 180
diff changeset
278 <div class="get-image">
b19e4e36a1f2 arnica: cosmetic fixes, improve docstrings, minor i18n bugfixes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 180
diff changeset
279 <input type="hidden" name="action" value="AttachFile">
b19e4e36a1f2 arnica: cosmetic fixes, improve docstrings, minor i18n bugfixes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 180
diff changeset
280 <input type="hidden" name="do" value="get">
b19e4e36a1f2 arnica: cosmetic fixes, improve docstrings, minor i18n bugfixes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 180
diff changeset
281 <input type="hidden" name="target" value="%(this_target)s">
b19e4e36a1f2 arnica: cosmetic fixes, improve docstrings, minor i18n bugfixes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 180
diff changeset
282 <input type="image" value="submit" src="%(htdocs)s/arnica/img/arnica_full_image.png" title="load image">
b19e4e36a1f2 arnica: cosmetic fixes, improve docstrings, minor i18n bugfixes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 180
diff changeset
283 </div>
b19e4e36a1f2 arnica: cosmetic fixes, improve docstrings, minor i18n bugfixes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 180
diff changeset
284 </form>
b19e4e36a1f2 arnica: cosmetic fixes, improve docstrings, minor i18n bugfixes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 180
diff changeset
285 <form action="%(url)s" method="POST" enctype="multipart/form-data">
b19e4e36a1f2 arnica: cosmetic fixes, improve docstrings, minor i18n bugfixes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 180
diff changeset
286 <div class="slide-show">
b19e4e36a1f2 arnica: cosmetic fixes, improve docstrings, minor i18n bugfixes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 180
diff changeset
287 <input type="hidden" name="action" value="arnica_slides">
b19e4e36a1f2 arnica: cosmetic fixes, improve docstrings, minor i18n bugfixes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 180
diff changeset
288 <input type="hidden" name="do" value="slide_show">
b19e4e36a1f2 arnica: cosmetic fixes, improve docstrings, minor i18n bugfixes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 180
diff changeset
289 <input type="hidden" name="alias" value="%(description)s">
b19e4e36a1f2 arnica: cosmetic fixes, improve docstrings, minor i18n bugfixes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 180
diff changeset
290 <input type="hidden" name="target" value="%(target)s">
b19e4e36a1f2 arnica: cosmetic fixes, improve docstrings, minor i18n bugfixes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 180
diff changeset
291 <input type="hidden" name="pagename" value="%(pagename)s">
b19e4e36a1f2 arnica: cosmetic fixes, improve docstrings, minor i18n bugfixes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 180
diff changeset
292 <input type="hidden" name="images" value="%(images)s">
b19e4e36a1f2 arnica: cosmetic fixes, improve docstrings, minor i18n bugfixes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 180
diff changeset
293 <input type="hidden" name="original_images" value="%(original_images)s">
b19e4e36a1f2 arnica: cosmetic fixes, improve docstrings, minor i18n bugfixes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 180
diff changeset
294 <input type="hidden" name="exif_date" value="%(exif_date)s">
b19e4e36a1f2 arnica: cosmetic fixes, improve docstrings, minor i18n bugfixes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 180
diff changeset
295 <input type="hidden" name="image_for_webnail" value="%(image_for_webnail)s">
b19e4e36a1f2 arnica: cosmetic fixes, improve docstrings, minor i18n bugfixes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 180
diff changeset
296 <input type="image" value="submit" title="slide show" src="%(htdocs)s/arnica/img/arnica_load_slide_show.png">
b19e4e36a1f2 arnica: cosmetic fixes, improve docstrings, minor i18n bugfixes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 180
diff changeset
297 </div>
b19e4e36a1f2 arnica: cosmetic fixes, improve docstrings, minor i18n bugfixes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 180
diff changeset
298 </form>
b19e4e36a1f2 arnica: cosmetic fixes, improve docstrings, minor i18n bugfixes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 180
diff changeset
299 %(html_tools_restricted)s
b19e4e36a1f2 arnica: cosmetic fixes, improve docstrings, minor i18n bugfixes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 180
diff changeset
300 """ % {
157
0116eb3e1099 text_x_arnica: replaced baseurl/pagename by Page.url
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 156
diff changeset
301 "url": Page(self.request, self.pagename).url(self.request),
175
377e5f674c66 text_x_arnica: fixed wrong quoting of pagename
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 173
diff changeset
302 "pagename": 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
303 "htdocs": self.request.cfg.url_prefix_static,
d164d12d06b8 initial version of arnica (image gallery parser and slideshow action)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
304 "tablestyle": self.inner_table_style,
d164d12d06b8 initial version of arnica (image gallery parser and slideshow action)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
305 "style": self.td_style,
d164d12d06b8 initial version of arnica (image gallery parser and slideshow action)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
306 "thumbnail_width": self.thumbnail_width,
40
c208aceb1ebd join and split exchanged on various places to packLine and unpackLine
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 37
diff changeset
307 "description": packLine([self.description[idx]] + self.description),
104
8cfbd286d1c7 replaced ' with " in html code
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 103
diff changeset
308 "image_for_webnail": self.image_for_webnail,
40
c208aceb1ebd join and split exchanged on various places to packLine and unpackLine
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 37
diff changeset
309 "exif_date": packLine([self.exif_date[idx]] + self.exif_date),
173
f5cdee2715a3 text_x_arnica: various variables renamed
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 172
diff changeset
310 "target": self.webnail_image[idx],
f5cdee2715a3 text_x_arnica: various variables renamed
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 172
diff changeset
311 "original_images": packLine([self.high_resolution_image[idx]] + self.high_resolution_image),
f5cdee2715a3 text_x_arnica: various variables renamed
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 172
diff changeset
312 "images": packLine([self.webnail_image[idx]] + self.webnail_image),
f5cdee2715a3 text_x_arnica: various variables renamed
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 172
diff changeset
313 "original_images": packLine([self.high_resolution_image[idx]] + self.high_resolution_image),
f5cdee2715a3 text_x_arnica: various variables renamed
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 172
diff changeset
314 "this_target": self.high_resolution_image[idx],
f5cdee2715a3 text_x_arnica: various variables renamed
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 172
diff changeset
315 "thumbnail": "%s%s" % (AttachFile.getAttachUrl(self.pagename, '', self.request), self.thumb_key[idx]),
181
b19e4e36a1f2 arnica: cosmetic fixes, improve docstrings, minor i18n bugfixes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 180
diff changeset
316 "html_tools_restricted": self.html_tools_restricted(this_image),
b19e4e36a1f2 arnica: cosmetic fixes, improve docstrings, minor i18n bugfixes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 180
diff changeset
317 }
0
d164d12d06b8 initial version of arnica (image gallery parser and slideshow action)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
318 return text
d164d12d06b8 initial version of arnica (image gallery parser and slideshow action)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
319
85
d705644861dc text_x_arnica: removed html definition for mode2, renamed mode1 methods
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 84
diff changeset
320 def html_show_tools(self, idx):
d705644861dc text_x_arnica: removed html definition for mode2, renamed mode1 methods
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 84
diff changeset
321 """ shows toolbox """
94
68102c2191f9 text_x_arnica: small refactoring of html_* methods
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 93
diff changeset
322 text = ''
49
83078930ae66 introduction of the argument parser
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 48
diff changeset
323 if self.show_tools:
139
2aba556fe52d replaced "_" to "-" in css class names
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 137
diff changeset
324 text = '<div class="html-show-tools">%(tools)s</div>' % {
28
e71bbef3a837 PEP8 whitespace fix to satisfy test_sourcecode
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 26
diff changeset
325 "style": self.td_style,
87
d60f41c17f42 text_x_arnica: renamed tools_html into html_tools
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 86
diff changeset
326 "tools": self.html_tools(idx)}
0
d164d12d06b8 initial version of arnica (image gallery parser and slideshow action)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
327 return text
d164d12d06b8 initial version of arnica (image gallery parser and slideshow action)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
328
85
d705644861dc text_x_arnica: removed html definition for mode2, renamed mode1 methods
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 84
diff changeset
329 def html_show_date(self, idx):
d705644861dc text_x_arnica: removed html definition for mode2, renamed mode1 methods
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 84
diff changeset
330 """ shows date """
94
68102c2191f9 text_x_arnica: small refactoring of html_* methods
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 93
diff changeset
331 text = ''
49
83078930ae66 introduction of the argument parser
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 48
diff changeset
332 if self.show_date:
139
2aba556fe52d replaced "_" to "-" in css class names
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 137
diff changeset
333 text = '<div class="html-show-date">%(this_exif_date)s</div>' % {
161
8eee2fa838cf text_x_arnica: fixed EXIF date output
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 160
diff changeset
334 "this_exif_date": self.formatter.text(self.exif_date[idx])}
94
68102c2191f9 text_x_arnica: small refactoring of html_* methods
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 93
diff changeset
335 return text
0
d164d12d06b8 initial version of arnica (image gallery parser and slideshow action)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
336
85
d705644861dc text_x_arnica: removed html definition for mode2, renamed mode1 methods
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 84
diff changeset
337 def html_show_alias(self, idx):
0
d164d12d06b8 initial version of arnica (image gallery parser and slideshow action)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
338 """ view mode 1 alias text below image """
94
68102c2191f9 text_x_arnica: small refactoring of html_* methods
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 93
diff changeset
339 text = ''
49
83078930ae66 introduction of the argument parser
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 48
diff changeset
340 if self.show_text:
139
2aba556fe52d replaced "_" to "-" in css class names
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 137
diff changeset
341 text = '<div class="html-show-alias"> %(this_alias)s</div>' % {
94
68102c2191f9 text_x_arnica: small refactoring of html_* methods
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 93
diff changeset
342 "this_alias": self.to_wikitext(self.description[idx])}
68102c2191f9 text_x_arnica: small refactoring of html_* methods
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 93
diff changeset
343 return text
0
d164d12d06b8 initial version of arnica (image gallery parser and slideshow action)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
344
106
93ddff1a23ed text_x_arnica: renamed html_preview to html_arrange_thumbnails
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 105
diff changeset
345 def html_arrange_thumbnails(self, idx):
85
d705644861dc text_x_arnica: removed html definition for mode2, renamed mode1 methods
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 84
diff changeset
346 """ defines arrangement of thumbnail, text, date and tools """
63
9301ca6f1e33 text_x_arnica: fixed missing album title
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 61
diff changeset
347 title = ""
9301ca6f1e33 text_x_arnica: fixed missing album title
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 61
diff changeset
348 if self.album:
173
f5cdee2715a3 text_x_arnica: various variables renamed
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 172
diff changeset
349 title = '<div class="title">%(n)d images (%(album_title)s)</div>' % {"n": len(self.high_resolution_image),
102
b446b9826cf8 text_x_arnica: whitepaces removed, some linebreaks
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 100
diff changeset
350 "album_title": self.album_title or self.pagename}
181
b19e4e36a1f2 arnica: cosmetic fixes, improve docstrings, minor i18n bugfixes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 180
diff changeset
351 text = """
139
2aba556fe52d replaced "_" to "-" in css class names
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 137
diff changeset
352 <div class="arrange-thumbnails">
157
0116eb3e1099 text_x_arnica: replaced baseurl/pagename by Page.url
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 156
diff changeset
353 <form action="%(url)s" method="POST" enctype="multipart/form-data">
121
f6ce62994858 text_x_arnica: initial setup for css.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 113
diff changeset
354 <div class="image"> %(title)s
f6ce62994858 text_x_arnica: initial setup for css.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 113
diff changeset
355 <input type="hidden" name="action" value="arnica_slides">
f6ce62994858 text_x_arnica: initial setup for css.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 113
diff changeset
356 <input type="hidden" name="do" value="slide_show">
f6ce62994858 text_x_arnica: initial setup for css.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 113
diff changeset
357 <input type="hidden" name="alias" value="%(description)s">
f6ce62994858 text_x_arnica: initial setup for css.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 113
diff changeset
358 <input type="hidden" name="target" value="%(target)s">
f6ce62994858 text_x_arnica: initial setup for css.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 113
diff changeset
359 <input type="hidden" name="pagename" value="%(pagename)s">
f6ce62994858 text_x_arnica: initial setup for css.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 113
diff changeset
360 <input type="hidden" name="images" value="%(images)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
361 <input type="hidden" name="original_images" value="%(original_images)s">
121
f6ce62994858 text_x_arnica: initial setup for css.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 113
diff changeset
362 <input type="hidden" name="exif_date" value="%(exif_date)s">
f6ce62994858 text_x_arnica: initial setup for css.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 113
diff changeset
363 <input type="hidden" name="image_for_webnail" value="%(image_for_webnail)s">
f6ce62994858 text_x_arnica: initial setup for css.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 113
diff changeset
364 <input type="image" value="submit" title="slide show" src="%(thumbnail)s">
f6ce62994858 text_x_arnica: initial setup for css.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 113
diff changeset
365 </div>
f6ce62994858 text_x_arnica: initial setup for css.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 113
diff changeset
366 </form>
f6ce62994858 text_x_arnica: initial setup for css.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 113
diff changeset
367 %(alias_html)s
f6ce62994858 text_x_arnica: initial setup for css.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 113
diff changeset
368 %(date_html)s
f6ce62994858 text_x_arnica: initial setup for css.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 113
diff changeset
369 %(html_tools)s
181
b19e4e36a1f2 arnica: cosmetic fixes, improve docstrings, minor i18n bugfixes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 180
diff changeset
370 </div>
b19e4e36a1f2 arnica: cosmetic fixes, improve docstrings, minor i18n bugfixes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 180
diff changeset
371 """ % {
b19e4e36a1f2 arnica: cosmetic fixes, improve docstrings, minor i18n bugfixes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 180
diff changeset
372 "title": title,
b19e4e36a1f2 arnica: cosmetic fixes, improve docstrings, minor i18n bugfixes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 180
diff changeset
373 "tdstyle": self.td_style,
b19e4e36a1f2 arnica: cosmetic fixes, improve docstrings, minor i18n bugfixes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 180
diff changeset
374 "style": self.inner_table_style,
b19e4e36a1f2 arnica: cosmetic fixes, improve docstrings, minor i18n bugfixes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 180
diff changeset
375 "url": Page(self.request, self.pagename).url(self.request),
b19e4e36a1f2 arnica: cosmetic fixes, improve docstrings, minor i18n bugfixes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 180
diff changeset
376 "pagename": self.pagename,
b19e4e36a1f2 arnica: cosmetic fixes, improve docstrings, minor i18n bugfixes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 180
diff changeset
377 "description": packLine([self.description[idx]] + self.description),
b19e4e36a1f2 arnica: cosmetic fixes, improve docstrings, minor i18n bugfixes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 180
diff changeset
378 "exif_date": packLine([self.exif_date[idx]] + self.exif_date),
b19e4e36a1f2 arnica: cosmetic fixes, improve docstrings, minor i18n bugfixes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 180
diff changeset
379 "image_for_webnail": self.image_for_webnail,
b19e4e36a1f2 arnica: cosmetic fixes, improve docstrings, minor i18n bugfixes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 180
diff changeset
380 "target": self.webnail_image[idx],
b19e4e36a1f2 arnica: cosmetic fixes, improve docstrings, minor i18n bugfixes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 180
diff changeset
381 "original_images": packLine([self.high_resolution_image[idx]] + self.high_resolution_image),
b19e4e36a1f2 arnica: cosmetic fixes, improve docstrings, minor i18n bugfixes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 180
diff changeset
382 "images": packLine([self.webnail_image[idx]] + self.webnail_image),
b19e4e36a1f2 arnica: cosmetic fixes, improve docstrings, minor i18n bugfixes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 180
diff changeset
383 "thumbnail": cache.url(self.request, self.thumb_key[idx]),
b19e4e36a1f2 arnica: cosmetic fixes, improve docstrings, minor i18n bugfixes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 180
diff changeset
384 "thumbnail_width": self.thumbnail_width,
b19e4e36a1f2 arnica: cosmetic fixes, improve docstrings, minor i18n bugfixes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 180
diff changeset
385 "html_tools": self.html_show_tools(idx),
b19e4e36a1f2 arnica: cosmetic fixes, improve docstrings, minor i18n bugfixes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 180
diff changeset
386 "date_html": self.html_show_date(idx),
b19e4e36a1f2 arnica: cosmetic fixes, improve docstrings, minor i18n bugfixes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 180
diff changeset
387 "alias_html": self.html_show_alias(idx),
b19e4e36a1f2 arnica: cosmetic fixes, improve docstrings, minor i18n bugfixes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 180
diff changeset
388 }
0
d164d12d06b8 initial version of arnica (image gallery parser and slideshow action)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
389 return text
d164d12d06b8 initial version of arnica (image gallery parser and slideshow action)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
390
90
7e0445f8120e renamed get_files to define_thumb_webnails
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 89
diff changeset
391 def define_thumb_webnails(self, path, files, quotes):
7e0445f8120e renamed get_files to define_thumb_webnails
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 89
diff changeset
392 """ creates lists for thumbnails and webnails
0
d164d12d06b8 initial version of arnica (image gallery parser and slideshow action)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
393 @param path: path to attachment
d164d12d06b8 initial version of arnica (image gallery parser and slideshow action)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
394 @param files: file names of images
d164d12d06b8 initial version of arnica (image gallery parser and slideshow action)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
395 @param quotes: text alias for image file
d164d12d06b8 initial version of arnica (image gallery parser and slideshow action)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
396 """
d164d12d06b8 initial version of arnica (image gallery parser and slideshow action)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
397 ddict = {}
7
a067ae7020f6 text_x_arnica: fixed many pylint warnings, factored out get_exif_info from get_files
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 6
diff changeset
398 if len(quotes['image']) > 0:
0
d164d12d06b8 initial version of arnica (image gallery parser and slideshow action)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
399 i = 0
d164d12d06b8 initial version of arnica (image gallery parser and slideshow action)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
400 for txt in quotes['image']:
17
cb6ad4cfdc5e PEP8 whitespace fix
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 15
diff changeset
401 ddict[txt] = quotes['alias'][i]
cb6ad4cfdc5e PEP8 whitespace fix
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 15
diff changeset
402 i += 1
0
d164d12d06b8 initial version of arnica (image gallery parser and slideshow action)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
403 for attfile in files:
173
f5cdee2715a3 text_x_arnica: various variables renamed
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 172
diff changeset
404 # only files not thumb_key or webnails
89
83abc483373a text_x_arnica: internal _get_files routine added to select only valid image files
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 87
diff changeset
405 self.description.append(ddict.get(attfile, attfile))
173
f5cdee2715a3 text_x_arnica: various variables renamed
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 172
diff changeset
406 self.high_resolution_image.append(attfile)
89
83abc483373a text_x_arnica: internal _get_files routine added to select only valid image files
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 87
diff changeset
407 fname, ext = os.path.splitext(attfile)
178
d29abc5e4b4f PEP8 fixes
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 177
diff changeset
408 key = cache.key(self.request, itemname=self.pagename, attachname=attfile)
179
00e363a155c4 text_x_arnica: removed extension of the key
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 178
diff changeset
409 webnail = 'W' + key
00e363a155c4 text_x_arnica: removed extension of the key
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 178
diff changeset
410 thumbfile = 'T' + key
89
83abc483373a text_x_arnica: internal _get_files routine added to select only valid image files
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 87
diff changeset
411 if ext in ('.gif', '.png'):
83abc483373a text_x_arnica: internal _get_files routine added to select only valid image files
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 87
diff changeset
412 self.imgtype.append('PNG')
83abc483373a text_x_arnica: internal _get_files routine added to select only valid image files
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 87
diff changeset
413 else:
83abc483373a text_x_arnica: internal _get_files routine added to select only valid image files
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 87
diff changeset
414 self.imgtype.append("JPEG")
0
d164d12d06b8 initial version of arnica (image gallery parser and slideshow action)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
415
89
83abc483373a text_x_arnica: internal _get_files routine added to select only valid image files
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 87
diff changeset
416 att_file = os.path.join(path, attfile)
83abc483373a text_x_arnica: internal _get_files routine added to select only valid image files
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 87
diff changeset
417 if os.path.exists(att_file):
173
f5cdee2715a3 text_x_arnica: various variables renamed
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 172
diff changeset
418 self.web_key.append(webnail)
f5cdee2715a3 text_x_arnica: various variables renamed
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 172
diff changeset
419 self.thumb_key.append(thumbfile)
89
83abc483373a text_x_arnica: internal _get_files routine added to select only valid image files
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 87
diff changeset
420 date = get_exif_info(att_file)
153
3abe0bd083b2 text_x_arnica: added formatter to self and replaced wikiutil.escape with formatter.text
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 152
diff changeset
421 self.exif_date.append(self.formatter.text(date))
0
d164d12d06b8 initial version of arnica (image gallery parser and slideshow action)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
422
d164d12d06b8 initial version of arnica (image gallery parser and slideshow action)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
423 def to_wikitext(self, text):
181
b19e4e36a1f2 arnica: cosmetic fixes, improve docstrings, minor i18n bugfixes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 180
diff changeset
424 """ converts text to wiki name if it is written as WikiName or [[wikiname]]
b19e4e36a1f2 arnica: cosmetic fixes, improve docstrings, minor i18n bugfixes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 180
diff changeset
425
0
d164d12d06b8 initial version of arnica (image gallery parser and slideshow action)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
426 @param text: text to parse and render
d164d12d06b8 initial version of arnica (image gallery parser and slideshow action)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
427 """
d164d12d06b8 initial version of arnica (image gallery parser and slideshow action)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
428 text = ''.join(text)
3
c9ab05e6d499 text_x_arnica: fixed shadowing of Parser
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2
diff changeset
429 from MoinMoin.parser.text_moin_wiki import Parser as WikiParser
21
744416ee6590 text_x_arnica: iamge_for_webnail key added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 17
diff changeset
430 return wikiutil.renderText(self.request, WikiParser, text)
0
d164d12d06b8 initial version of arnica (image gallery parser and slideshow action)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
431
d164d12d06b8 initial version of arnica (image gallery parser and slideshow action)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
432 def get_quotes(self):
181
b19e4e36a1f2 arnica: cosmetic fixes, improve docstrings, minor i18n bugfixes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 180
diff changeset
433 """ gets the quotes from the item list """
b19e4e36a1f2 arnica: cosmetic fixes, improve docstrings, minor i18n bugfixes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 180
diff changeset
434 # ToDo make this more generic and use common libs of similar modules
0
d164d12d06b8 initial version of arnica (image gallery parser and slideshow action)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
435 quotes = self.raw.split('\n')
d164d12d06b8 initial version of arnica (image gallery parser and slideshow action)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
436 quotes = [quote.strip() for quote in quotes]
d164d12d06b8 initial version of arnica (image gallery parser and slideshow action)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
437 quotes = [quote[2:] for quote in quotes if quote.startswith('* ')]
d164d12d06b8 initial version of arnica (image gallery parser and slideshow action)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
438 image = []
d164d12d06b8 initial version of arnica (image gallery parser and slideshow action)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
439 text = []
d164d12d06b8 initial version of arnica (image gallery parser and slideshow action)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
440 for line in quotes:
93
64797a5fc3d9 text_x_arnica: check alias for [[ and ]]
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 92
diff changeset
441 if line.startswith('[[') and line.endswith(']]'):
64797a5fc3d9 text_x_arnica: check alias for [[ and ]]
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 92
diff changeset
442 img, alias = line[2:-2].split('|', 1)
64797a5fc3d9 text_x_arnica: check alias for [[ and ]]
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 92
diff changeset
443 alias = alias.strip()
153
3abe0bd083b2 text_x_arnica: added formatter to self and replaced wikiutil.escape with formatter.text
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 152
diff changeset
444 alias = self.formatter.text(alias)
93
64797a5fc3d9 text_x_arnica: check alias for [[ and ]]
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 92
diff changeset
445 text.append(alias)
64797a5fc3d9 text_x_arnica: check alias for [[ and ]]
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 92
diff changeset
446 image.append(img.strip())
0
d164d12d06b8 initial version of arnica (image gallery parser and slideshow action)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
447 return {
d164d12d06b8 initial version of arnica (image gallery parser and slideshow action)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
448 'alias': text,
d164d12d06b8 initial version of arnica (image gallery parser and slideshow action)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
449 'image': image,
d164d12d06b8 initial version of arnica (image gallery parser and slideshow action)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
450 }
d164d12d06b8 initial version of arnica (image gallery parser and slideshow action)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
451
4
ccc40ffe14fc text_x_arnica: factored out select_files from format
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 3
diff changeset
452 def select_files(self, formatter):
ccc40ffe14fc text_x_arnica: factored out select_files from format
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 3
diff changeset
453 """ select files """
28
e71bbef3a837 PEP8 whitespace fix to satisfy test_sourcecode
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 26
diff changeset
454 # we need to take the page_name from the formatter.page otherwise
9
6fb3b03afe2e text_x_arnica: added some comments
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 8
diff changeset
455 # include does not work
4
ccc40ffe14fc text_x_arnica: factored out select_files from format
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 3
diff changeset
456 self.pagename = formatter.page.page_name
128
eeee3b6cd853 text_x_arnica: checks target_page, exists, may.read
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 127
diff changeset
457 if self.target_page and Page(self.request, self.target_page).exists() and self.request.user.may.read(self.target_page):
4
ccc40ffe14fc text_x_arnica: factored out select_files from format
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 3
diff changeset
458 self.pagename = self.target_page
6
756cb845ddad removed var self.static_path
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5
diff changeset
459 path = AttachFile.getAttachDir(self.request, self.pagename, create=1)
7
a067ae7020f6 text_x_arnica: fixed many pylint warnings, factored out get_exif_info from get_files
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 6
diff changeset
460 image_dict = {}
4
ccc40ffe14fc text_x_arnica: factored out select_files from format
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 3
diff changeset
461 quotes = self.get_quotes()
49
83078930ae66 introduction of the argument parser
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 48
diff changeset
462 if self.only_items:
7
a067ae7020f6 text_x_arnica: fixed many pylint warnings, factored out get_exif_info from get_files
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 6
diff changeset
463 files = quotes['image']
102
b446b9826cf8 text_x_arnica: whitepaces removed, some linebreaks
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 100
diff changeset
464 all_files = [fn for fn in files if wikiutil.isPicture(fn) and
b446b9826cf8 text_x_arnica: whitepaces removed, some linebreaks
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 100
diff changeset
465 AttachFile.exists(self.request, self.pagename, fn)]
49
83078930ae66 introduction of the argument parser
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 48
diff changeset
466 if self.sort_by_alias:
4
ccc40ffe14fc text_x_arnica: factored out select_files from format
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 3
diff changeset
467 alias_text = quotes['alias']
ccc40ffe14fc text_x_arnica: factored out select_files from format
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 3
diff changeset
468 i = 0
ccc40ffe14fc text_x_arnica: factored out select_files from format
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 3
diff changeset
469 for attfile in all_files:
7
a067ae7020f6 text_x_arnica: fixed many pylint warnings, factored out get_exif_info from get_files
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 6
diff changeset
470 image_dict[alias_text[i]] = attfile
4
ccc40ffe14fc text_x_arnica: factored out select_files from format
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 3
diff changeset
471 i += 1
7
a067ae7020f6 text_x_arnica: fixed many pylint warnings, factored out get_exif_info from get_files
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 6
diff changeset
472 keys = image_dict.keys()
4
ccc40ffe14fc text_x_arnica: factored out select_files from format
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 3
diff changeset
473 keys.sort()
7
a067ae7020f6 text_x_arnica: fixed many pylint warnings, factored out get_exif_info from get_files
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 6
diff changeset
474 all_files = [image_dict[txt] for txt in keys]
4
ccc40ffe14fc text_x_arnica: factored out select_files from format
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 3
diff changeset
475 else:
89
83abc483373a text_x_arnica: internal _get_files routine added to select only valid image files
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 87
diff changeset
476 all_files = _get_files(self.request, self.pagename)
53
64c2bb702530 text_x_arnica: filer renamed into file_regex
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 52
diff changeset
477 if self.file_regex != u'.':
64c2bb702530 text_x_arnica: filer renamed into file_regex
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 52
diff changeset
478 all_files = [attfile for attfile in all_files if re.match(self.file_regex, attfile)]
149
62a6c964e63b fixed and added docstrings
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 144
diff changeset
479 # ToDo and not self.only_items
49
83078930ae66 introduction of the argument parser
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 48
diff changeset
480 if self.sort_by_name and self.only_items is False:
4
ccc40ffe14fc text_x_arnica: factored out select_files from format
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 3
diff changeset
481 all_files.sort()
49
83078930ae66 introduction of the argument parser
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 48
diff changeset
482 if self.sort_by_date:
4
ccc40ffe14fc text_x_arnica: factored out select_files from format
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 3
diff changeset
483 for attfile in all_files:
6
756cb845ddad removed var self.static_path
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5
diff changeset
484 infile = os.path.join(path, attfile)
162
c3e0ae8ba0a0 text_x_arnica: randint output formatted as hex value
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 161
diff changeset
485 ft_file = "%s%x" % (os.path.getmtime(infile), randint(0, 256))
17
cb6ad4cfdc5e PEP8 whitespace fix
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 15
diff changeset
486 image_dict[ft_file] = attfile
7
a067ae7020f6 text_x_arnica: fixed many pylint warnings, factored out get_exif_info from get_files
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 6
diff changeset
487 keys = image_dict.keys()
4
ccc40ffe14fc text_x_arnica: factored out select_files from format
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 3
diff changeset
488 keys.sort()
7
a067ae7020f6 text_x_arnica: fixed many pylint warnings, factored out get_exif_info from get_files
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 6
diff changeset
489 all_files = [image_dict[txt] for txt in keys]
a067ae7020f6 text_x_arnica: fixed many pylint warnings, factored out get_exif_info from get_files
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 6
diff changeset
490 image_dict.clear()
49
83078930ae66 introduction of the argument parser
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 48
diff changeset
491 if self.reverse_sort:
4
ccc40ffe14fc text_x_arnica: factored out select_files from format
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 3
diff changeset
492 all_files.reverse()
ccc40ffe14fc text_x_arnica: factored out select_files from format
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 3
diff changeset
493 if all_files:
90
7e0445f8120e renamed get_files to define_thumb_webnails
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 89
diff changeset
494 self.define_thumb_webnails(path, all_files, quotes)
4
ccc40ffe14fc text_x_arnica: factored out select_files from format
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 3
diff changeset
495 return all_files
17
cb6ad4cfdc5e PEP8 whitespace fix
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 15
diff changeset
496
173
f5cdee2715a3 text_x_arnica: various variables renamed
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 172
diff changeset
497 def create_thumbnail_and_webnail_image(self, image, webnail, thumbnail, image_type):
181
b19e4e36a1f2 arnica: cosmetic fixes, improve docstrings, minor i18n bugfixes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 180
diff changeset
498 """ creates thumbnails and webnails cache files for given image type
b19e4e36a1f2 arnica: cosmetic fixes, improve docstrings, minor i18n bugfixes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 180
diff changeset
499
5
413a64b78621 text_x_arnica: factored out create_thumbnail_and_webnail from format
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 4
diff changeset
500 @param image: filename of image
14
87d11a4031e3 text_x_arnica: thumbnails stored for each page in the cache dir
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 9
diff changeset
501 @param webnail: name of webnail file
87d11a4031e3 text_x_arnica: thumbnails stored for each page in the cache dir
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 9
diff changeset
502 @param thumbnail: name of thumbnail file
5
413a64b78621 text_x_arnica: factored out create_thumbnail_and_webnail from format
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 4
diff changeset
503 @param image_type: filetype of image
413a64b78621 text_x_arnica: factored out create_thumbnail_and_webnail from format
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 4
diff changeset
504 """
37
ad1d433589e4 moved test for PIL to a better place
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 34
diff changeset
505 _ = self.request.getText
ad1d433589e4 moved test for PIL to a better place
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 34
diff changeset
506 if not Image:
181
b19e4e36a1f2 arnica: cosmetic fixes, improve docstrings, minor i18n bugfixes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 180
diff changeset
507 msg = _('The parser %(parser)s needs python imaging library (PIL) installed') % {'parser': parser_name}
155
3d5773a1e24b text_x_arnica: output text by the formatter
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 153
diff changeset
508 self.request.write(self.formatter.text(msg))
37
ad1d433589e4 moved test for PIL to a better place
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 34
diff changeset
509 return
41
edc8b8c5ccdd PEP8 whitespace fix
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 40
diff changeset
510
6
756cb845ddad removed var self.static_path
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5
diff changeset
511 path = AttachFile.getAttachDir(self.request, self.pagename, create=1)
756cb845ddad removed var self.static_path
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5
diff changeset
512 imagef = os.path.join(path, image)
14
87d11a4031e3 text_x_arnica: thumbnails stored for each page in the cache dir
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 9
diff changeset
513
84
93125407c585 text_x_arnica.create_thumbnail_and_webnail: bug fix does not try to create thumbnails from empty or corrupted image data file
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 81
diff changeset
514 if os.path.getsize(imagef) == 0:
93125407c585 text_x_arnica.create_thumbnail_and_webnail: bug fix does not try to create thumbnails from empty or corrupted image data file
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 81
diff changeset
515 return
17
cb6ad4cfdc5e PEP8 whitespace fix
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 15
diff changeset
516
14
87d11a4031e3 text_x_arnica: thumbnails stored for each page in the cache dir
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 9
diff changeset
517 page = Page(self.request, self.pagename)
87d11a4031e3 text_x_arnica: thumbnails stored for each page in the cache dir
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 9
diff changeset
518
166
9817520ac155 text_x_arnica, arnica_slides: refactored sendcached.* to cache.* methods
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 164
diff changeset
519 cache_web = caching.CacheEntry(self.request, cache.cache_arena, webnail+'.data',
185
7e23f320ce08 arnica: improve/reorganize some code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 181
diff changeset
520 cache.cache_scope, do_locking=False)
166
9817520ac155 text_x_arnica, arnica_slides: refactored sendcached.* to cache.* methods
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 164
diff changeset
521 cache_thumb = caching.CacheEntry(self.request, cache.cache_arena, thumbnail+'.data',
185
7e23f320ce08 arnica: improve/reorganize some code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 181
diff changeset
522 cache.cache_scope, do_locking=False)
178
d29abc5e4b4f PEP8 fixes
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 177
diff changeset
523
49
83078930ae66 introduction of the argument parser
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 48
diff changeset
524 if self.renew:
14
87d11a4031e3 text_x_arnica: thumbnails stored for each page in the cache dir
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 9
diff changeset
525 cache_web.remove()
87d11a4031e3 text_x_arnica: thumbnails stored for each page in the cache dir
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 9
diff changeset
526 cache_thumb.remove()
87d11a4031e3 text_x_arnica: thumbnails stored for each page in the cache dir
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 9
diff changeset
527
87d11a4031e3 text_x_arnica: thumbnails stored for each page in the cache dir
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 9
diff changeset
528 if not cache_web.exists() or not cache_thumb.exists():
84
93125407c585 text_x_arnica.create_thumbnail_and_webnail: bug fix does not try to create thumbnails from empty or corrupted image data file
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 81
diff changeset
529 try:
93125407c585 text_x_arnica.create_thumbnail_and_webnail: bug fix does not try to create thumbnails from empty or corrupted image data file
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 81
diff changeset
530 im_obj = Image.open(imagef)
93125407c585 text_x_arnica.create_thumbnail_and_webnail: bug fix does not try to create thumbnails from empty or corrupted image data file
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 81
diff changeset
531 except IOError:
160
290d4eea1c0c text_x_arnica: added msg for IOError exception
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 159
diff changeset
532 msg = _("attachment: %(filename)s not exists") % {"filename": os.path.basename(imagef)}
290d4eea1c0c text_x_arnica: added msg for IOError exception
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 159
diff changeset
533 self.request.write(self.formatter.text(msg))
84
93125407c585 text_x_arnica.create_thumbnail_and_webnail: bug fix does not try to create thumbnails from empty or corrupted image data file
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 81
diff changeset
534 return
93125407c585 text_x_arnica.create_thumbnail_and_webnail: bug fix does not try to create thumbnails from empty or corrupted image data file
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 81
diff changeset
535
181
b19e4e36a1f2 arnica: cosmetic fixes, improve docstrings, minor i18n bugfixes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 180
diff changeset
536 # XXX later, a unit conversion method for using other units than 'px' is needed
14
87d11a4031e3 text_x_arnica: thumbnails stored for each page in the cache dir
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 9
diff changeset
537 if not cache_web.exists():
49
83078930ae66 introduction of the argument parser
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 48
diff changeset
538 if not self.image_for_webnail:
137
81f9d359f173 text_x_arnica: bug fix use type int for size of thumbnail and webnail
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 136
diff changeset
539 im_obj.thumbnail((int(self.webnail_width.strip('px')), int(self.webnail_width.strip('px'))), Image.ANTIALIAS)
188
a1a6a45edaf1 arnica: use StringIO file obj for cache.put(), remove unused code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 186
diff changeset
540 buf = StringIO.StringIO()
a1a6a45edaf1 arnica: use StringIO file obj for cache.put(), remove unused code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 186
diff changeset
541 im_obj.save(buf, image_type)
a1a6a45edaf1 arnica: use StringIO file obj for cache.put(), remove unused code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 186
diff changeset
542 buf.flush()
a1a6a45edaf1 arnica: use StringIO file obj for cache.put(), remove unused code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 186
diff changeset
543 buf.seek(0)
a1a6a45edaf1 arnica: use StringIO file obj for cache.put(), remove unused code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 186
diff changeset
544 cache.put(self.request, webnail, buf, filename=image)
a1a6a45edaf1 arnica: use StringIO file obj for cache.put(), remove unused code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 186
diff changeset
545 buf.close()
17
cb6ad4cfdc5e PEP8 whitespace fix
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 15
diff changeset
546
14
87d11a4031e3 text_x_arnica: thumbnails stored for each page in the cache dir
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 9
diff changeset
547 if not cache_thumb.exists():
137
81f9d359f173 text_x_arnica: bug fix use type int for size of thumbnail and webnail
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 136
diff changeset
548 im_obj.thumbnail((int(self.thumbnail_width.strip('px')), int(self.thumbnail_width.strip('px'))), Image.ANTIALIAS)
188
a1a6a45edaf1 arnica: use StringIO file obj for cache.put(), remove unused code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 186
diff changeset
549 buf = StringIO.StringIO()
a1a6a45edaf1 arnica: use StringIO file obj for cache.put(), remove unused code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 186
diff changeset
550 im_obj.save(buf, image_type)
a1a6a45edaf1 arnica: use StringIO file obj for cache.put(), remove unused code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 186
diff changeset
551 buf.flush()
a1a6a45edaf1 arnica: use StringIO file obj for cache.put(), remove unused code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 186
diff changeset
552 buf.seek(0)
a1a6a45edaf1 arnica: use StringIO file obj for cache.put(), remove unused code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 186
diff changeset
553 cache.put(self.request, thumbnail, buf, filename=image)
a1a6a45edaf1 arnica: use StringIO file obj for cache.put(), remove unused code
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 186
diff changeset
554 buf.close()
17
cb6ad4cfdc5e PEP8 whitespace fix
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 15
diff changeset
555
74
ad51b86d7bc1 introduce macro arnica which calls the arnica parser
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 73
diff changeset
556 def render(self, formatter):
ad51b86d7bc1 introduce macro arnica which calls the arnica parser
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 73
diff changeset
557 """ renders thumbnails """
49
83078930ae66 introduction of the argument parser
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 48
diff changeset
558
0
d164d12d06b8 initial version of arnica (image gallery parser and slideshow action)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
559 _ = self._
d164d12d06b8 initial version of arnica (image gallery parser and slideshow action)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
560
74
ad51b86d7bc1 introduce macro arnica which calls the arnica parser
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 73
diff changeset
561 # checks if initializing of all attributes in __init__ was done
55
1eb0c987a260 text_x_arnica: if the parser was called with a not defined parameter, print an error and return.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 54
diff changeset
562 if not self.init_settings:
1eb0c987a260 text_x_arnica: if the parser was called with a not defined parameter, print an error and return.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 54
diff changeset
563 return
1eb0c987a260 text_x_arnica: if the parser was called with a not defined parameter, print an error and return.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 54
diff changeset
564
128
eeee3b6cd853 text_x_arnica: checks target_page, exists, may.read
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 127
diff changeset
565 if self.target_page and (not Page(self.request, self.target_page).exists() or not self.request.user.may.read(self.target_page)):
155
3d5773a1e24b text_x_arnica: output text by the formatter
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 153
diff changeset
566 text = _("""Page '%(new_pagename)s' does not exist or you don't have enough rights.""") % {"pagename": self.target_page}
3d5773a1e24b text_x_arnica: output text by the formatter
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 153
diff changeset
567 self.request.write(self.formatter.text(text))
0
d164d12d06b8 initial version of arnica (image gallery parser and slideshow action)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
568 return
d164d12d06b8 initial version of arnica (image gallery parser and slideshow action)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
569
4
ccc40ffe14fc text_x_arnica: factored out select_files from format
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 3
diff changeset
570 if not self.select_files(formatter):
155
3d5773a1e24b text_x_arnica: output text by the formatter
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 153
diff changeset
571 text = _("No matching image file found!")
3d5773a1e24b text_x_arnica: output text by the formatter
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 153
diff changeset
572 self.request.write(self.formatter.text(text))
0
d164d12d06b8 initial version of arnica (image gallery parser and slideshow action)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
573 return
17
cb6ad4cfdc5e PEP8 whitespace fix
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 15
diff changeset
574
49
83078930ae66 introduction of the argument parser
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 48
diff changeset
575 if self.template_itemlist:
155
3d5773a1e24b text_x_arnica: output text by the formatter
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 153
diff changeset
576 self.request.write(self.formatter.div(1, css_class="text"))
181
b19e4e36a1f2 arnica: cosmetic fixes, improve docstrings, minor i18n bugfixes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 180
diff changeset
577 text = _("""\
b19e4e36a1f2 arnica: cosmetic fixes, improve docstrings, minor i18n bugfixes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 180
diff changeset
578 Copy the following listitems into the script.
b19e4e36a1f2 arnica: cosmetic fixes, improve docstrings, minor i18n bugfixes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 180
diff changeset
579 Replace alias with the label you want.
b19e4e36a1f2 arnica: cosmetic fixes, improve docstrings, minor i18n bugfixes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 180
diff changeset
580 Afterwards disable template_itemlist by setting it to False:""")
155
3d5773a1e24b text_x_arnica: output text by the formatter
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 153
diff changeset
581 self.request.write(self.formatter.text(text))
3d5773a1e24b text_x_arnica: output text by the formatter
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 153
diff changeset
582 self.request.write(self.formatter.div(1))
3d5773a1e24b text_x_arnica: output text by the formatter
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 153
diff changeset
583 self.request.write(self.formatter.preformatted(1))
173
f5cdee2715a3 text_x_arnica: various variables renamed
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 172
diff changeset
584 for image in self.high_resolution_image:
155
3d5773a1e24b text_x_arnica: output text by the formatter
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 153
diff changeset
585 text = ' * [[%(image)s|alias]]\n' % {
3d5773a1e24b text_x_arnica: output text by the formatter
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 153
diff changeset
586 'image': image,
3d5773a1e24b text_x_arnica: output text by the formatter
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 153
diff changeset
587 }
3d5773a1e24b text_x_arnica: output text by the formatter
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 153
diff changeset
588 self.request.write(self.formatter.text(text))
3d5773a1e24b text_x_arnica: output text by the formatter
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 153
diff changeset
589 self.request.write(self.formatter.preformatted(0))
3d5773a1e24b text_x_arnica: output text by the formatter
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 153
diff changeset
590 self.request.write(self.formatter.div(0))
3d5773a1e24b text_x_arnica: output text by the formatter
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 153
diff changeset
591 self.request.write(self.formatter.div(0))
173
f5cdee2715a3 text_x_arnica: various variables renamed
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 172
diff changeset
592 COLUMNS = min([self.columns, len(self.high_resolution_image)])
49
83078930ae66 introduction of the argument parser
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 48
diff changeset
593 if self.album:
42
7bf792c8364b text_x_arnica: table is done by DataBrowserWidget
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 41
diff changeset
594 COLUMNS = 1
7bf792c8364b text_x_arnica: table is done by DataBrowserWidget
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 41
diff changeset
595 data = TupleDataset()
7bf792c8364b text_x_arnica: table is done by DataBrowserWidget
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 41
diff changeset
596 data.columns = []
7bf792c8364b text_x_arnica: table is done by DataBrowserWidget
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 41
diff changeset
597 for dummy in range(COLUMNS):
7bf792c8364b text_x_arnica: table is done by DataBrowserWidget
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 41
diff changeset
598 data.columns.extend([Column('', label=(''))])
43
623ddf996af2 text_x_arnica: album after creating of all thumbnails and webnails
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 42
diff changeset
599 col_count = 1
623ddf996af2 text_x_arnica: album after creating of all thumbnails and webnails
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 42
diff changeset
600 result = []
173
f5cdee2715a3 text_x_arnica: various variables renamed
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 172
diff changeset
601 for image in self.high_resolution_image:
f5cdee2715a3 text_x_arnica: various variables renamed
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 172
diff changeset
602 i = self.high_resolution_image.index(image)
f5cdee2715a3 text_x_arnica: various variables renamed
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 172
diff changeset
603 self.create_thumbnail_and_webnail_image(image, self.web_key[i],
f5cdee2715a3 text_x_arnica: various variables renamed
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 172
diff changeset
604 self.thumb_key[i], self.imgtype[i])
49
83078930ae66 introduction of the argument parser
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 48
diff changeset
605 if not self.album:
173
f5cdee2715a3 text_x_arnica: various variables renamed
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 172
diff changeset
606 self.webnail_image = self.web_key
49
83078930ae66 introduction of the argument parser
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 48
diff changeset
607 if self.image_for_webnail:
173
f5cdee2715a3 text_x_arnica: various variables renamed
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 172
diff changeset
608 self.webnail_image = self.high_resolution_image
106
93ddff1a23ed text_x_arnica: renamed html_preview to html_arrange_thumbnails
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 105
diff changeset
609 text = self.html_arrange_thumbnails(i)
43
623ddf996af2 text_x_arnica: album after creating of all thumbnails and webnails
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 42
diff changeset
610 if col_count <= COLUMNS:
623ddf996af2 text_x_arnica: album after creating of all thumbnails and webnails
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 42
diff changeset
611 result.append(''.join(text))
60
d88a6a086d04 text_x_arnica.format: simplified if / else
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 59
diff changeset
612 if col_count == COLUMNS:
43
623ddf996af2 text_x_arnica: album after creating of all thumbnails and webnails
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 42
diff changeset
613 col_count = 0
623ddf996af2 text_x_arnica: album after creating of all thumbnails and webnails
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 42
diff changeset
614 data.addRow(tuple(result))
60
d88a6a086d04 text_x_arnica.format: simplified if / else
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 59
diff changeset
615 # resets the result list after the row is added
43
623ddf996af2 text_x_arnica: album after creating of all thumbnails and webnails
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 42
diff changeset
616 result = []
623ddf996af2 text_x_arnica: album after creating of all thumbnails and webnails
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 42
diff changeset
617 col_count += 1
49
83078930ae66 introduction of the argument parser
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 48
diff changeset
618 if result and not self.album:
47
4ff94f1065a4 text_x_arnica: if album is not in only items list show reason
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 46
diff changeset
619 for i in range(COLUMNS - col_count + 1):
4ff94f1065a4 text_x_arnica: if album is not in only items list show reason
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 46
diff changeset
620 result.append('')
49
83078930ae66 introduction of the argument parser
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 48
diff changeset
621 if self.album:
173
f5cdee2715a3 text_x_arnica: various variables renamed
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 172
diff changeset
622 album_image = self.album_image or self.high_resolution_image[0]
47
4ff94f1065a4 text_x_arnica: if album is not in only items list show reason
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 46
diff changeset
623 try:
173
f5cdee2715a3 text_x_arnica: various variables renamed
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 172
diff changeset
624 i = self.high_resolution_image.index(album_image)
f5cdee2715a3 text_x_arnica: various variables renamed
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 172
diff changeset
625 self.create_thumbnail_and_webnail_image(image, self.web_key[i], self.thumb_key[i], self.imgtype[i])
f5cdee2715a3 text_x_arnica: various variables renamed
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 172
diff changeset
626 self.webnail_image = self.web_key
49
83078930ae66 introduction of the argument parser
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 48
diff changeset
627 if self.image_for_webnail:
173
f5cdee2715a3 text_x_arnica: various variables renamed
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 172
diff changeset
628 self.webnail_image = self.high_resolution_image
106
93ddff1a23ed text_x_arnica: renamed html_preview to html_arrange_thumbnails
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 105
diff changeset
629 text = self.html_arrange_thumbnails(i)
47
4ff94f1065a4 text_x_arnica: if album is not in only items list show reason
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 46
diff changeset
630 except ValueError:
182
4fed0b16b6fb text_x_arnica: further cosmetic doc string fixes
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 181
diff changeset
631 text = self.formatter.text(_("""You can't use as album image:
4fed0b16b6fb text_x_arnica: further cosmetic doc string fixes
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 181
diff changeset
632 "%(album_image)s" because it does not exist or it is not listed
4fed0b16b6fb text_x_arnica: further cosmetic doc string fixes
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 181
diff changeset
633 in your item list!""") % {"album_image": album_image, })
178
d29abc5e4b4f PEP8 fixes
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 177
diff changeset
634
164
db98e843b83c text_x_arnica, arnica_slides: implemented sendcached from 1.8 repository
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 163
diff changeset
635 result.append(''.join(text))
42
7bf792c8364b text_x_arnica: table is done by DataBrowserWidget
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 41
diff changeset
636
60
d88a6a086d04 text_x_arnica.format: simplified if / else
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 59
diff changeset
637 # adds the last row if it is not filled up
42
7bf792c8364b text_x_arnica: table is done by DataBrowserWidget
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 41
diff changeset
638 if result:
7bf792c8364b text_x_arnica: table is done by DataBrowserWidget
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 41
diff changeset
639 data.addRow(tuple(result))
121
f6ce62994858 text_x_arnica: initial setup for css.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 113
diff changeset
640 browser = _DataBrowserWidget(self.request, show_header=False)
42
7bf792c8364b text_x_arnica: table is done by DataBrowserWidget
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 41
diff changeset
641 browser.setData(data)
127
6f578becaf71 text_x_arnica: removed GET exchange to POST because of internal _DataBrowserWidget.format()
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 126
diff changeset
642 return browser.format()
74
ad51b86d7bc1 introduce macro arnica which calls the arnica parser
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 73
diff changeset
643
ad51b86d7bc1 introduce macro arnica which calls the arnica parser
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 73
diff changeset
644 def format(self, formatter):
ad51b86d7bc1 introduce macro arnica which calls the arnica parser
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 73
diff changeset
645 """ parser output """
ad51b86d7bc1 introduce macro arnica which calls the arnica parser
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 73
diff changeset
646 # checks if initializing of all attributes in __init__ was done
94
68102c2191f9 text_x_arnica: small refactoring of html_* methods
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 93
diff changeset
647 if self.init_settings:
155
3d5773a1e24b text_x_arnica: output text by the formatter
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 153
diff changeset
648 self.request.write(self.formatter.div(1, css_class="arnica"))
94
68102c2191f9 text_x_arnica: small refactoring of html_* methods
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 93
diff changeset
649 self.request.write(self.render(formatter))
155
3d5773a1e24b text_x_arnica: output text by the formatter
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 153
diff changeset
650 self.request.write(self.formatter.div(0))
181
b19e4e36a1f2 arnica: cosmetic fixes, improve docstrings, minor i18n bugfixes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 180
diff changeset
651