annotate data/plugin/parser/text_x_arnica.py @ 157:0116eb3e1099

text_x_arnica: replaced baseurl/pagename by Page.url
author Reimar Bauer <rb.proj AT googlemail DOT com>
date Sat, 12 Jul 2008 14:42:22 +0200
parents a6ff4cf3dbc2
children cc31ed821e35
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
1
33d03349c532 small fixes for comments, separate import for Image
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 0
diff changeset
17 import os, re
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
156
a6ff4cf3dbc2 itext_x_arnica: removed sendcached dependency of 1.8
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 155
diff changeset
21 from MoinMoin.action import AttachFile
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
121
f6ce62994858 text_x_arnica: initial setup for css.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 113
diff changeset
35 class _DataBrowserWidget(DataBrowserWidget):
f6ce62994858 text_x_arnica: initial setup for css.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 113
diff changeset
36 """ we have to remove the used form in format otherwise the needed form elements
f6ce62994858 text_x_arnica: initial setup for css.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 113
diff changeset
37 becomes a nested form and this do raise lot's of strict html4.01 errors"""
f6ce62994858 text_x_arnica: initial setup for css.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 113
diff changeset
38 def format(self):
f6ce62994858 text_x_arnica: initial setup for css.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 113
diff changeset
39 fmt = self.request.formatter
f6ce62994858 text_x_arnica: initial setup for css.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 113
diff changeset
40
f6ce62994858 text_x_arnica: initial setup for css.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 113
diff changeset
41 result = []
f6ce62994858 text_x_arnica: initial setup for css.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 113
diff changeset
42
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
f6ce62994858 text_x_arnica: initial setup for css.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 113
diff changeset
65 if col.autofilter:
f6ce62994858 text_x_arnica: initial setup for css.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 113
diff changeset
66 result.append(fmt.linebreak(False))
f6ce62994858 text_x_arnica: initial setup for css.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 113
diff changeset
67 select = '<select %s onchange="dbw_update_search(\'%s\');">%s</select>' % (
f6ce62994858 text_x_arnica: initial setup for css.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 113
diff changeset
68 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
69 self.data_id,
f6ce62994858 text_x_arnica: initial setup for css.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 113
diff changeset
70 self._filteroptions(idx))
f6ce62994858 text_x_arnica: initial setup for css.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 113
diff changeset
71 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
72
f6ce62994858 text_x_arnica: initial setup for css.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 113
diff changeset
73 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
74 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
75
f6ce62994858 text_x_arnica: initial setup for css.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 113
diff changeset
76 # add data
f6ce62994858 text_x_arnica: initial setup for css.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 113
diff changeset
77 self.data.reset()
f6ce62994858 text_x_arnica: initial setup for css.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 113
diff changeset
78 row = self.data.next()
f6ce62994858 text_x_arnica: initial setup for css.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 113
diff changeset
79 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
80 filters = [None] * len(row)
f6ce62994858 text_x_arnica: initial setup for css.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 113
diff changeset
81
f6ce62994858 text_x_arnica: initial setup for css.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 113
diff changeset
82 if havefilters:
f6ce62994858 text_x_arnica: initial setup for css.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 113
diff changeset
83 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
84 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
85 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
86 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
87 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
88 filters[idx] = None
f6ce62994858 text_x_arnica: initial setup for css.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 113
diff changeset
89
f6ce62994858 text_x_arnica: initial setup for css.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 113
diff changeset
90 while row:
f6ce62994858 text_x_arnica: initial setup for css.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 113
diff changeset
91 hidden = False
f6ce62994858 text_x_arnica: initial setup for css.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 113
diff changeset
92
f6ce62994858 text_x_arnica: initial setup for css.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 113
diff changeset
93 if havefilters:
f6ce62994858 text_x_arnica: initial setup for css.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 113
diff changeset
94 # 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
95 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
96 if filters[idx]:
f6ce62994858 text_x_arnica: initial setup for css.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 113
diff changeset
97 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
98 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
99 else:
f6ce62994858 text_x_arnica: initial setup for css.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 113
diff changeset
100 data = unicode(row[idx])
f6ce62994858 text_x_arnica: initial setup for css.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 113
diff changeset
101 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
102 continue
f6ce62994858 text_x_arnica: initial setup for css.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 113
diff changeset
103 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
104 continue
f6ce62994858 text_x_arnica: initial setup for css.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 113
diff changeset
105 if data != filters[idx]:
f6ce62994858 text_x_arnica: initial setup for css.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 113
diff changeset
106 hidden = True
f6ce62994858 text_x_arnica: initial setup for css.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 113
diff changeset
107 break
f6ce62994858 text_x_arnica: initial setup for css.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 113
diff changeset
108
f6ce62994858 text_x_arnica: initial setup for css.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 113
diff changeset
109 if not hidden:
f6ce62994858 text_x_arnica: initial setup for css.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 113
diff changeset
110 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
111 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
112 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
113 continue
f6ce62994858 text_x_arnica: initial setup for css.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 113
diff changeset
114 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
115 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
116 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
117 else:
f6ce62994858 text_x_arnica: initial setup for css.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 113
diff changeset
118 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
119 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
120 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
121 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
122
f6ce62994858 text_x_arnica: initial setup for css.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 113
diff changeset
123 row = self.data.next()
f6ce62994858 text_x_arnica: initial setup for css.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 113
diff changeset
124
f6ce62994858 text_x_arnica: initial setup for css.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 113
diff changeset
125 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
126
121
f6ce62994858 text_x_arnica: initial setup for css.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 113
diff changeset
127 return ''.join(result)
f6ce62994858 text_x_arnica: initial setup for css.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 113
diff changeset
128
125
922ac221ea10 text_x_arnica: renamed macro_arnica into arnica_seetings
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 122
diff changeset
129 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
130 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
131 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
132 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
133 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
134 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
135 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
136 renew=False,
e0015917205d text_x_arnica: aligned some lines of arnica_settings
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 134
diff changeset
137 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
138 webnail_width=wikiutil.UnitArgument('640', float, ['px', ], defaultunit='px')):
149
62a6c964e63b fixed and added docstrings
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 144
diff changeset
139 """ dummy macro to initialize all default parameters for arnica. The parameters are checked for wrong input.
62a6c964e63b fixed and added docstrings
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 144
diff changeset
140 @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
141 @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
142 @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
143 @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
144 @param show_text: default shows description
6122e5bb9332 text_x_arnica: moved description of keywords to macro_arnica
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 49
diff changeset
145 @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
146 @param show_tools: default does not show the icon toolbar
50
6122e5bb9332 text_x_arnica: moved description of keywords to macro_arnica
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 49
diff changeset
147 @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
148 @param sort_by_date: if set, sorts images by the modification time
62a6c964e63b fixed and added docstrings
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 144
diff changeset
149 @param sort_by_alias: if set, sorts images by the alias name, this needs also only_items enabled
62a6c964e63b fixed and added docstrings
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 144
diff changeset
150 @param reverse_sort: if set, the file list is reverse sorted
50
6122e5bb9332 text_x_arnica: moved description of keywords to macro_arnica
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 49
diff changeset
151 @param only_items: if set only images which are described in listitem are shown, e.g.
6122e5bb9332 text_x_arnica: moved description of keywords to macro_arnica
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 49
diff changeset
152 * [[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
153 * [[image2.jpg|alias]]
149
62a6c964e63b fixed and added docstrings
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 144
diff changeset
154 @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
155 @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
156 @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
157 @param album_image: image to show on album default is the first image
50
6122e5bb9332 text_x_arnica: moved description of keywords to macro_arnica
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 49
diff changeset
158 @param renew: if set then all selected thumbnails_* and webnails_* are removed
6122e5bb9332 text_x_arnica: moved description of keywords to macro_arnica
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 49
diff changeset
159 and will be recreated
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
160 @param thumbnail_width: default width of thumbnails is 128px
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 @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
162 """
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
163 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
164 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
165 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
166 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
167 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
168
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
169 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
170 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
171 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
172 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
173 webnail_width = '%g%s' % 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
174
61
6ab80d79e924 text_x_arnica.macro_arnica: much more simplified using locals()
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 60
diff changeset
175 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
176
28
e71bbef3a837 PEP8 whitespace fix to satisfy test_sourcecode
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 26
diff changeset
177 # 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
178 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
179 """ gets exif info from image file
e71bbef3a837 PEP8 whitespace fix to satisfy test_sourcecode
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 26
diff changeset
180 @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
181 """
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 = "--"
b9eb24a6213a text_x_arnica: moved method get_exif_info to function
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 7
diff changeset
183 if wikiutil.isPicture(file_name):
155
3d5773a1e24b text_x_arnica: output text by the formatter
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 153
diff changeset
184 # XXX what happens if it is not a jpeg file
8
b9eb24a6213a text_x_arnica: moved method get_exif_info to function
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 7
diff changeset
185 id_file = open(file_name, 'rb')
b9eb24a6213a text_x_arnica: moved method get_exif_info to function
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 7
diff changeset
186 tags = EXIF.process_file(id_file, 'DateTimeOriginal')
b9eb24a6213a text_x_arnica: moved method get_exif_info to function
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 7
diff changeset
187 id_file.close()
149
62a6c964e63b fixed and added docstrings
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 144
diff changeset
188 # ToDo change to "in dict"
8
b9eb24a6213a text_x_arnica: moved method get_exif_info to function
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 7
diff changeset
189 if tags.has_key('EXIF DateTimeOriginal'):
b9eb24a6213a text_x_arnica: moved method get_exif_info to function
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 7
diff changeset
190 date = str(tags['EXIF DateTimeOriginal'])
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
191 date = self.formatter.text(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
192 return date
1
33d03349c532 small fixes for comments, separate import for Image
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 0
diff changeset
193
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
194 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
195 # 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
196 # ToDo remove tmp. files check later
155
3d5773a1e24b text_x_arnica: output text by the formatter
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 153
diff changeset
197
152
7438cd3fdfba text_x_arnica: removed internal duplicate of _get_files
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 149
diff changeset
198 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
199 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
200 return files
17
cb6ad4cfdc5e PEP8 whitespace fix
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 15
diff changeset
201
157
0116eb3e1099 text_x_arnica: replaced baseurl/pagename by Page.url
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 156
diff changeset
202 def getCacheUrl(url, filename):
121
f6ce62994858 text_x_arnica: initial setup for css.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 113
diff changeset
203 """ Get URL that points to cache of `filename` on page `pagename`. """
157
0116eb3e1099 text_x_arnica: replaced baseurl/pagename by Page.url
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 156
diff changeset
204 url_action = "%(url)s?action=arnica_slides&do=view&target=%(filename)s" % {'url': url,
0116eb3e1099 text_x_arnica: replaced baseurl/pagename by Page.url
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 156
diff changeset
205 'filename': filename}
0116eb3e1099 text_x_arnica: replaced baseurl/pagename by Page.url
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 156
diff changeset
206 return wikiutil.escape(url_action)
121
f6ce62994858 text_x_arnica: initial setup for css.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 113
diff changeset
207
0
d164d12d06b8 initial version of arnica (image gallery parser and slideshow action)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
208 class Parser:
3
c9ab05e6d499 text_x_arnica: fixed shadowing of Parser
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2
diff changeset
209 """ 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
210 extensions = '*.jpg'
d164d12d06b8 initial version of arnica (image gallery parser and slideshow action)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
211 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
212 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
213 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
214 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
215 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
216 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
217 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
218
49
83078930ae66 introduction of the argument parser
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 48
diff changeset
219 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
220 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
221 # 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
222 # 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
223 try:
125
922ac221ea10 text_x_arnica: renamed macro_arnica into arnica_seetings
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 122
diff changeset
224 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
225 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
226 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
227 # 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
228 self.init_settings = True
49
83078930ae66 introduction of the argument parser
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 48
diff changeset
229 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
230 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
231 # 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
232 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
233
0
d164d12d06b8 initial version of arnica (image gallery parser and slideshow action)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
234 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
235 self.td_style = ' align="center" style="padding:0; margin:2px 2px; border-style:none"'
17
cb6ad4cfdc5e PEP8 whitespace fix
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 15
diff changeset
236
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
237 self.web = [] # array for webnails
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
238 self.full = [] # array for images
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
239 self.thumb = [] # array for thumbnails
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
240 self.exif_date = [] # array of exif date description
28
e71bbef3a837 PEP8 whitespace fix to satisfy test_sourcecode
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 26
diff changeset
241 self.imgtype = [] # array of imagetype of full 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
242 self.description = [] # array of description
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
243 self.webimg = [] # array of images for forms
17
cb6ad4cfdc5e PEP8 whitespace fix
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 15
diff changeset
244
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
245 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
246 """ 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
247 @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
248 """
d164d12d06b8 initial version of arnica (image gallery parser and slideshow action)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
249 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
250 return ''
d164d12d06b8 initial version of arnica (image gallery parser and slideshow action)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
251
121
f6ce62994858 text_x_arnica: initial setup for css.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 113
diff changeset
252 return '''
157
0116eb3e1099 text_x_arnica: replaced baseurl/pagename by Page.url
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 156
diff changeset
253 <form action="%(url)s" method="POST" enctype="multipart/form-data">
139
2aba556fe52d replaced "_" to "-" in css class names
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 137
diff changeset
254 <div class="rotate-to-left">
121
f6ce62994858 text_x_arnica: initial setup for css.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 113
diff changeset
255 <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
256 <input type="hidden" name="do" value="rotate_left">
f6ce62994858 text_x_arnica: initial setup for css.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 113
diff changeset
257 <input type="hidden" name="target" value="%(this_target)s">
144
002df10706b5 renamed iamge paths to the new path
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 140
diff changeset
258 <input type="image" value="submit" src="%(htdocs)s/arnica/img/arnica_rotate_to_left.png" title="rotate to left">
121
f6ce62994858 text_x_arnica: initial setup for css.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 113
diff changeset
259 </div>
0
d164d12d06b8 initial version of arnica (image gallery parser and slideshow action)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
260 </form>
157
0116eb3e1099 text_x_arnica: replaced baseurl/pagename by Page.url
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 156
diff changeset
261 <form action="%(url)s" method="POST" enctype="multipart/form-data">
139
2aba556fe52d replaced "_" to "-" in css class names
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 137
diff changeset
262 <div class="rotate-to-right">
121
f6ce62994858 text_x_arnica: initial setup for css.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 113
diff changeset
263 <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
264 <input type="hidden" name="do" value="rotate_right">
f6ce62994858 text_x_arnica: initial setup for css.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 113
diff changeset
265 <input type="hidden" name="target" value="%(this_target)s">
144
002df10706b5 renamed iamge paths to the new path
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 140
diff changeset
266 <input type="image" value="submit" src="%(htdocs)s/arnica/img/arnica_rotate_to_right.png" title="rotate to right">
121
f6ce62994858 text_x_arnica: initial setup for css.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 113
diff changeset
267 </div>
0
d164d12d06b8 initial version of arnica (image gallery parser and slideshow action)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
268 </form>
157
0116eb3e1099 text_x_arnica: replaced baseurl/pagename by Page.url
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 156
diff changeset
269 <form action="%(url)s" method="POST" enctype="multipart/form-data">
139
2aba556fe52d replaced "_" to "-" in css class names
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 137
diff changeset
270 <div class="delete-image">
121
f6ce62994858 text_x_arnica: initial setup for css.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 113
diff changeset
271 <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
272 <input type="hidden" name="do" value="delete">
f6ce62994858 text_x_arnica: initial setup for css.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 113
diff changeset
273 <input type="hidden" name="target" value="%(this_target)s">
144
002df10706b5 renamed iamge paths to the new path
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 140
diff changeset
274 <input type="image" value="submit" src="%(htdocs)s/arnica/img/arnica_remove_image.png" title="move to bak">
121
f6ce62994858 text_x_arnica: initial setup for css.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 113
diff changeset
275 </div>
131
4ea7ff9f6ffb text_x_arnica: removed css class definition html_tools_restricted
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 130
diff changeset
276 </form>''' % {
157
0116eb3e1099 text_x_arnica: replaced baseurl/pagename by Page.url
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 156
diff changeset
277 '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
278 '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
279 '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
280 "pagename": wikiutil.quoteWikinameURL(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
281 "this_target": this_target}
d164d12d06b8 initial version of arnica (image gallery parser and slideshow action)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
282
87
d60f41c17f42 text_x_arnica: renamed tools_html into html_tools
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 86
diff changeset
283 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
284 """ html code of thumbnails view with contol
d164d12d06b8 initial version of arnica (image gallery parser and slideshow action)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
285 @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
286 """
d164d12d06b8 initial version of arnica (image gallery parser and slideshow action)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
287 this_image = self.full[idx]
121
f6ce62994858 text_x_arnica: initial setup for css.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 113
diff changeset
288 text = '''
157
0116eb3e1099 text_x_arnica: replaced baseurl/pagename by Page.url
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 156
diff changeset
289 <form action="%(url)s" method="POST" enctype="multipart/form-data">
139
2aba556fe52d replaced "_" to "-" in css class names
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 137
diff changeset
290 <div class="get-image">
121
f6ce62994858 text_x_arnica: initial setup for css.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 113
diff changeset
291 <input type="hidden" name="action" value="AttachFile">
f6ce62994858 text_x_arnica: initial setup for css.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 113
diff changeset
292 <input type="hidden" name="do" value="get">
f6ce62994858 text_x_arnica: initial setup for css.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 113
diff changeset
293 <input type="hidden" name="target" value="%(this_target)s">
144
002df10706b5 renamed iamge paths to the new path
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 140
diff changeset
294 <input type="image" value="submit" src="%(htdocs)s/arnica/img/arnica_full_image.png" title="load image">
121
f6ce62994858 text_x_arnica: initial setup for css.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 113
diff changeset
295 </div>
f6ce62994858 text_x_arnica: initial setup for css.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 113
diff changeset
296 </form>
157
0116eb3e1099 text_x_arnica: replaced baseurl/pagename by Page.url
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 156
diff changeset
297 <form action="%(url)s" method="POST" enctype="multipart/form-data">
139
2aba556fe52d replaced "_" to "-" in css class names
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 137
diff changeset
298 <div class="slide-show">
121
f6ce62994858 text_x_arnica: initial setup for css.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 113
diff changeset
299 <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
300 <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
301 <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
302 <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
303 <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
304 <input type="hidden" name="images" value="%(images)s">
f6ce62994858 text_x_arnica: initial setup for css.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 113
diff changeset
305 <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
306 <input type="hidden" name="image_for_webnail" value="%(image_for_webnail)s">
144
002df10706b5 renamed iamge paths to the new path
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 140
diff changeset
307 <input type="image" value="submit" title="slide show" src="%(htdocs)s/arnica/img/arnica_load_slide_show.png">
121
f6ce62994858 text_x_arnica: initial setup for css.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 113
diff changeset
308 </div>
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
309 </form> %(html_tools_restricted)s''' % {
157
0116eb3e1099 text_x_arnica: replaced baseurl/pagename by Page.url
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 156
diff changeset
310 "url": Page(self.request, self.pagename).url(self.request),
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
311 "pagename": wikiutil.quoteWikinameURL(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
312 "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
313 "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
314 "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
315 "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
316 "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
317 "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
318 "exif_date": packLine([self.exif_date[idx]] + self.exif_date),
34
864fba4e90f3 text_x_arnica: fixed VS mode in tools_html
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 32
diff changeset
319 "target": self.webimg[idx],
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
320 "images": packLine([self.webimg[idx]] + self.webimg),
0
d164d12d06b8 initial version of arnica (image gallery parser and slideshow action)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
321 "this_target": self.full[idx],
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
322 "thumbnail": "%s%s" % (AttachFile.getAttachUrl(self.pagename, '', self.request), self.thumb[idx]),
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
323 "html_tools_restricted": self.html_tools_restricted(this_image)
0
d164d12d06b8 initial version of arnica (image gallery parser and slideshow action)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
324 }
d164d12d06b8 initial version of arnica (image gallery parser and slideshow action)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
325 return text
d164d12d06b8 initial version of arnica (image gallery parser and slideshow action)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
326
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
327 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
328 """ shows toolbox """
94
68102c2191f9 text_x_arnica: small refactoring of html_* methods
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 93
diff changeset
329 text = ''
49
83078930ae66 introduction of the argument parser
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 48
diff changeset
330 if self.show_tools:
139
2aba556fe52d replaced "_" to "-" in css class names
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 137
diff changeset
331 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
332 "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
333 "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
334 return text
d164d12d06b8 initial version of arnica (image gallery parser and slideshow action)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
335
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
336 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
337 """ shows date """
94
68102c2191f9 text_x_arnica: small refactoring of html_* methods
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 93
diff changeset
338 text = ''
49
83078930ae66 introduction of the argument parser
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 48
diff changeset
339 if self.show_date:
139
2aba556fe52d replaced "_" to "-" in css class names
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 137
diff changeset
340 text = '<div class="html-show-date">%(this_exif_date)s</div>' % {
94
68102c2191f9 text_x_arnica: small refactoring of html_* methods
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 93
diff changeset
341 "this_exif_date": self.exif_date[idx]}
68102c2191f9 text_x_arnica: small refactoring of html_* methods
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 93
diff changeset
342 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
343
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
344 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
345 """ 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
346 text = ''
49
83078930ae66 introduction of the argument parser
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 48
diff changeset
347 if self.show_text:
139
2aba556fe52d replaced "_" to "-" in css class names
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 137
diff changeset
348 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
349 "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
350 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
351
106
93ddff1a23ed text_x_arnica: renamed html_preview to html_arrange_thumbnails
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 105
diff changeset
352 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
353 """ 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
354 title = ""
9301ca6f1e33 text_x_arnica: fixed missing album title
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 61
diff changeset
355 if self.album:
121
f6ce62994858 text_x_arnica: initial setup for css.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 113
diff changeset
356 title = '<div class="title">%(n)d images (%(album_title)s)</div>' % {"n": len(self.full),
102
b446b9826cf8 text_x_arnica: whitepaces removed, some linebreaks
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 100
diff changeset
357 "album_title": self.album_title or self.pagename}
121
f6ce62994858 text_x_arnica: initial setup for css.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 113
diff changeset
358 text = '''
139
2aba556fe52d replaced "_" to "-" in css class names
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 137
diff changeset
359 <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
360 <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
361 <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
362 <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
363 <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
364 <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
365 <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
366 <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
367 <input type="hidden" name="images" value="%(images)s">
f6ce62994858 text_x_arnica: initial setup for css.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 113
diff changeset
368 <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
369 <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
370 <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
371 </div>
f6ce62994858 text_x_arnica: initial setup for css.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 113
diff changeset
372 </form>
f6ce62994858 text_x_arnica: initial setup for css.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 113
diff changeset
373 %(alias_html)s
f6ce62994858 text_x_arnica: initial setup for css.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 113
diff changeset
374 %(date_html)s
f6ce62994858 text_x_arnica: initial setup for css.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 113
diff changeset
375 %(html_tools)s
f6ce62994858 text_x_arnica: initial setup for css.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 113
diff changeset
376 </div>'''% {
63
9301ca6f1e33 text_x_arnica: fixed missing album title
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 61
diff changeset
377 "title": title,
0
d164d12d06b8 initial version of arnica (image gallery parser and slideshow action)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
378 "tdstyle": 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
379 "style": self.inner_table_style,
157
0116eb3e1099 text_x_arnica: replaced baseurl/pagename by Page.url
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 156
diff changeset
380 "url": Page(self.request, self.pagename).url(self.request),
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
381 "pagename": wikiutil.quoteWikinameURL(self.pagename),
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
382 "description": packLine([self.description[idx]] + self.description),
c208aceb1ebd join and split exchanged on various places to packLine and unpackLine
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 37
diff changeset
383 "exif_date": packLine([self.exif_date[idx]] + self.exif_date),
21
744416ee6590 text_x_arnica: iamge_for_webnail key added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 17
diff changeset
384 "image_for_webnail": self.image_for_webnail,
32
03db81d282ce added for VS mode a list of images by a new image form element (target should be used only for the current image)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 28
diff changeset
385 "target": self.webimg[idx],
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
386 "images": packLine([self.webimg[idx]] + self.webimg),
157
0116eb3e1099 text_x_arnica: replaced baseurl/pagename by Page.url
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 156
diff changeset
387 "thumbnail": getCacheUrl(Page(self.request, self.pagename).url(self.request), self.thumb[idx]),
0
d164d12d06b8 initial version of arnica (image gallery parser and slideshow action)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
388 "thumbnail_width": self.thumbnail_width,
87
d60f41c17f42 text_x_arnica: renamed tools_html into html_tools
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 86
diff changeset
389 "html_tools": self.html_show_tools(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
390 "date_html": self.html_show_date(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
391 "alias_html": self.html_show_alias(idx)
0
d164d12d06b8 initial version of arnica (image gallery parser and slideshow action)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
392 }
d164d12d06b8 initial version of arnica (image gallery parser and slideshow action)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
393 return text
d164d12d06b8 initial version of arnica (image gallery parser and slideshow action)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
394
90
7e0445f8120e renamed get_files to define_thumb_webnails
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 89
diff changeset
395 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
396 """ 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
397 @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
398 @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
399 @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
400 """
d164d12d06b8 initial version of arnica (image gallery parser and slideshow action)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
401 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
402 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
403 i = 0
d164d12d06b8 initial version of arnica (image gallery parser and slideshow action)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
404 for txt in quotes['image']:
17
cb6ad4cfdc5e PEP8 whitespace fix
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 15
diff changeset
405 ddict[txt] = quotes['alias'][i]
cb6ad4cfdc5e PEP8 whitespace fix
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 15
diff changeset
406 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
407 for attfile in files:
d164d12d06b8 initial version of arnica (image gallery parser and slideshow action)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
408 # only files not thumb 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
409 self.description.append(ddict.get(attfile, 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
410 self.full.append(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
411 fname, ext = os.path.splitext(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
412 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
413 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
414 webnail = 'tmp.webnail_%s.png' % fname
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
415 thumbfile = 'tmp.thumbnail_%s.png' % fname
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 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
417 self.imgtype.append("JPEG")
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
418 webnail = 'tmp.webnail_%s.jpg' % fname
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
419 thumbfile = 'tmp.thumbnail_%s.jpg' % fname
0
d164d12d06b8 initial version of arnica (image gallery parser and slideshow action)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
420
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
421 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
422 if os.path.exists(att_file):
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
423 self.web.append(webnail)
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
424 self.thumb.append(thumbfile)
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
425 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
426 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
427
d164d12d06b8 initial version of arnica (image gallery parser and slideshow action)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
428 def to_wikitext(self, text):
d164d12d06b8 initial version of arnica (image gallery parser and slideshow action)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
429 """
d164d12d06b8 initial version of arnica (image gallery parser and slideshow action)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
430 converts text to wiki name if it is written as WikiName or [[wikiname]]
d164d12d06b8 initial version of arnica (image gallery parser and slideshow action)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
431 @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
432 """
d164d12d06b8 initial version of arnica (image gallery parser and slideshow action)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
433 text = ''.join(text)
3
c9ab05e6d499 text_x_arnica: fixed shadowing of Parser
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2
diff changeset
434 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
435 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
436
d164d12d06b8 initial version of arnica (image gallery parser and slideshow action)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
437 def get_quotes(self):
d164d12d06b8 initial version of arnica (image gallery parser and slideshow action)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
438 """ get's the qoutes from the itemlist """
149
62a6c964e63b fixed and added docstrings
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 144
diff changeset
439 # ToDo make this more generic and use common libs of similiar modules
0
d164d12d06b8 initial version of arnica (image gallery parser and slideshow action)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
440 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
441 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
442 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
443
d164d12d06b8 initial version of arnica (image gallery parser and slideshow action)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
444 image = []
d164d12d06b8 initial version of arnica (image gallery parser and slideshow action)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
445 text = []
d164d12d06b8 initial version of arnica (image gallery parser and slideshow action)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
446
d164d12d06b8 initial version of arnica (image gallery parser and slideshow action)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
447 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
448 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
449 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
450 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
451 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
452 text.append(alias)
64797a5fc3d9 text_x_arnica: check alias for [[ and ]]
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 92
diff changeset
453 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
454 return {
d164d12d06b8 initial version of arnica (image gallery parser and slideshow action)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
455 'alias': text,
d164d12d06b8 initial version of arnica (image gallery parser and slideshow action)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
456 'image': image,
d164d12d06b8 initial version of arnica (image gallery parser and slideshow action)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
457 }
d164d12d06b8 initial version of arnica (image gallery parser and slideshow action)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
458
4
ccc40ffe14fc text_x_arnica: factored out select_files from format
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 3
diff changeset
459 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
460 """ select files """
28
e71bbef3a837 PEP8 whitespace fix to satisfy test_sourcecode
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 26
diff changeset
461 # 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
462 # 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
463 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
464 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
465 self.pagename = self.target_page
6
756cb845ddad removed var self.static_path
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5
diff changeset
466 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
467 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
468 quotes = self.get_quotes()
49
83078930ae66 introduction of the argument parser
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 48
diff changeset
469 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
470 files = quotes['image']
102
b446b9826cf8 text_x_arnica: whitepaces removed, some linebreaks
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 100
diff changeset
471 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
472 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
473 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
474 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
475 i = 0
ccc40ffe14fc text_x_arnica: factored out select_files from format
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 3
diff changeset
476 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
477 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
478 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
479 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
480 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
481 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
482 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
483 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
484 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
485 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
486 # 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
487 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
488 all_files.sort()
49
83078930ae66 introduction of the argument parser
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 48
diff changeset
489 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
490 for attfile in all_files:
6
756cb845ddad removed var self.static_path
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5
diff changeset
491 infile = os.path.join(path, attfile)
155
3d5773a1e24b text_x_arnica: output text by the formatter
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 153
diff changeset
492 # ToDo take hex values
109
dba6f45c448e text_x_arnica: removed superfluous str() call
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 106
diff changeset
493 ft_file = "%s%s" % (os.path.getmtime(infile), randint(0, 65535))
17
cb6ad4cfdc5e PEP8 whitespace fix
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 15
diff changeset
494 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
495 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
496 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
497 all_files = [image_dict[txt] for txt in keys]
17
cb6ad4cfdc5e PEP8 whitespace fix
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 15
diff changeset
498
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
499 image_dict.clear()
17
cb6ad4cfdc5e PEP8 whitespace fix
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 15
diff changeset
500
49
83078930ae66 introduction of the argument parser
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 48
diff changeset
501 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
502 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
503 if all_files:
90
7e0445f8120e renamed get_files to define_thumb_webnails
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 89
diff changeset
504 self.define_thumb_webnails(path, all_files, quotes)
17
cb6ad4cfdc5e PEP8 whitespace fix
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 15
diff changeset
505
4
ccc40ffe14fc text_x_arnica: factored out select_files from format
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 3
diff changeset
506 return all_files
17
cb6ad4cfdc5e PEP8 whitespace fix
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 15
diff changeset
507
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
508 def create_thumbnail_and_webnail(self, image, webnail, thumbnail, image_type):
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
509 """creates thumbnails and webnails cache files for given image type
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
510 @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
511 @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
512 @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
513 @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
514 """
37
ad1d433589e4 moved test for PIL to a better place
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 34
diff changeset
515 _ = self.request.getText
ad1d433589e4 moved test for PIL to a better place
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 34
diff changeset
516 if not Image:
ad1d433589e4 moved test for PIL to a better place
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 34
diff changeset
517 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
518 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
519 return
41
edc8b8c5ccdd PEP8 whitespace fix
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 40
diff changeset
520
6
756cb845ddad removed var self.static_path
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 5
diff changeset
521 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
522 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
523
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
524 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
525 return
17
cb6ad4cfdc5e PEP8 whitespace fix
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 15
diff changeset
526
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
527 page = Page(self.request, self.pagename)
17
cb6ad4cfdc5e PEP8 whitespace fix
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 15
diff changeset
528 cache_web = caching.CacheEntry(self.request, page, webnail, scope='item', use_pickle=True)
cb6ad4cfdc5e PEP8 whitespace fix
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 15
diff changeset
529 cache_thumb = caching.CacheEntry(self.request, page, thumbnail, scope='item', use_pickle=True)
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
530
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
531 arena_dir = caching.get_arena_dir(self.request, page, 'item')
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
532 webf = os.path.join(arena_dir, webnail)
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
533 thumbf = os.path.join(arena_dir, thumbnail)
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
534
49
83078930ae66 introduction of the argument parser
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 48
diff changeset
535 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
536 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
537 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
538
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
539 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
540 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
541 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
542 except IOError:
149
62a6c964e63b fixed and added docstrings
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 144
diff changeset
543 # ToDo tell why
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
544 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
545
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
546 # XXX later on 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
547 if not cache_web.exists():
49
83078930ae66 introduction of the argument parser
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 48
diff changeset
548 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
549 im_obj.thumbnail((int(self.webnail_width.strip('px')), int(self.webnail_width.strip('px'))), Image.ANTIALIAS)
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
550 im_obj.save(webf, image_type)
17
cb6ad4cfdc5e PEP8 whitespace fix
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 15
diff changeset
551
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
552 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
553 im_obj.thumbnail((int(self.thumbnail_width.strip('px')), int(self.thumbnail_width.strip('px'))), Image.ANTIALIAS)
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
554 im_obj.save(thumbf, image_type)
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 # XXX remove from css template-itemlist
3d5773a1e24b text_x_arnica: output text by the formatter
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 153
diff changeset
577 self.request.write(self.formatter.div(1, css_class="text"))
3d5773a1e24b text_x_arnica: output text by the formatter
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 153
diff changeset
578 text = _("""
28
e71bbef3a837 PEP8 whitespace fix to satisfy test_sourcecode
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 26
diff changeset
579 Copy the following listitems into the script.
e71bbef3a837 PEP8 whitespace fix to satisfy test_sourcecode
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 26
diff changeset
580 Replace alias with the label you want.
155
3d5773a1e24b text_x_arnica: output text by the formatter
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 153
diff changeset
581 Afterwards disable template_itemlist by setting it to False:""")
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.text(text))
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.div(1))
3d5773a1e24b text_x_arnica: output text by the formatter
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 153
diff changeset
584 self.request.write(self.formatter.preformatted(1))
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
585 for image in self.full:
155
3d5773a1e24b text_x_arnica: output text by the formatter
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 153
diff changeset
586 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
587 'image': image,
3d5773a1e24b text_x_arnica: output text by the formatter
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 153
diff changeset
588 }
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.text(text))
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.preformatted(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))
3d5773a1e24b text_x_arnica: output text by the formatter
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 153
diff changeset
592 self.request.write(self.formatter.div(0))
0
d164d12d06b8 initial version of arnica (image gallery parser and slideshow action)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
593
49
83078930ae66 introduction of the argument parser
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 48
diff changeset
594 COLUMNS = min([self.columns, len(self.full)])
83078930ae66 introduction of the argument parser
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 48
diff changeset
595 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
596 COLUMNS = 1
0
d164d12d06b8 initial version of arnica (image gallery parser and slideshow action)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
597
42
7bf792c8364b text_x_arnica: table is done by DataBrowserWidget
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 41
diff changeset
598 data = TupleDataset()
7bf792c8364b text_x_arnica: table is done by DataBrowserWidget
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 41
diff changeset
599 data.columns = []
7bf792c8364b text_x_arnica: table is done by DataBrowserWidget
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 41
diff changeset
600
7bf792c8364b text_x_arnica: table is done by DataBrowserWidget
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 41
diff changeset
601 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
602 data.columns.extend([Column('', label=(''))])
7bf792c8364b text_x_arnica: table is done by DataBrowserWidget
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 41
diff changeset
603
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
604 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
605 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
606 for image in self.full:
623ddf996af2 text_x_arnica: album after creating of all thumbnails and webnails
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 42
diff changeset
607 i = self.full.index(image)
102
b446b9826cf8 text_x_arnica: whitepaces removed, some linebreaks
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 100
diff changeset
608 self.create_thumbnail_and_webnail(image, self.web[i],
b446b9826cf8 text_x_arnica: whitepaces removed, some linebreaks
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 100
diff changeset
609 self.thumb[i], self.imgtype[i])
49
83078930ae66 introduction of the argument parser
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 48
diff changeset
610 if not self.album:
60
d88a6a086d04 text_x_arnica.format: simplified if / else
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 59
diff changeset
611 self.webimg = self.web
49
83078930ae66 introduction of the argument parser
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 48
diff changeset
612 if self.image_for_webnail:
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 self.webimg = self.full
106
93ddff1a23ed text_x_arnica: renamed html_preview to html_arrange_thumbnails
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 105
diff changeset
614 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
615 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
616 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
617 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
618 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
619 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
620 # 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
621 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
622 col_count += 1
49
83078930ae66 introduction of the argument parser
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 48
diff changeset
623 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
624 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
625 result.append('')
49
83078930ae66 introduction of the argument parser
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 48
diff changeset
626 if self.album:
77
bddd103f5df1 text_x_arnica: front_image renamed to album_image
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 76
diff changeset
627 album_image = self.album_image or self.full[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
628 try:
77
bddd103f5df1 text_x_arnica: front_image renamed to album_image
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 76
diff changeset
629 i = self.full.index(album_image)
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 self.create_thumbnail_and_webnail(image, self.web[i], self.thumb[i], self.imgtype[i])
60
d88a6a086d04 text_x_arnica.format: simplified if / else
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 59
diff changeset
631 self.webimg = self.web
49
83078930ae66 introduction of the argument parser
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 48
diff changeset
632 if self.image_for_webnail:
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
633 self.webimg = self.full
106
93ddff1a23ed text_x_arnica: renamed html_preview to html_arrange_thumbnails
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 105
diff changeset
634 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
635 except ValueError:
149
62a6c964e63b fixed and added docstrings
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 144
diff changeset
636 # ToDo use """ """
155
3d5773a1e24b text_x_arnica: output text by the formatter
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 153
diff changeset
637 text = _("""You can't use as album image: \
3d5773a1e24b text_x_arnica: output text by the formatter
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 153
diff changeset
638 "%(album_image)s" because it does not exists or it is not listed \
3d5773a1e24b text_x_arnica: output text by the formatter
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 153
diff changeset
639 in your item list!""") % {"album_image": album_image, }
3d5773a1e24b text_x_arnica: output text by the formatter
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 153
diff changeset
640
3d5773a1e24b text_x_arnica: output text by the formatter
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 153
diff changeset
641 result.append(''.join(self.formatter.text(text)))
42
7bf792c8364b text_x_arnica: table is done by DataBrowserWidget
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 41
diff changeset
642
60
d88a6a086d04 text_x_arnica.format: simplified if / else
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 59
diff changeset
643 # 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
644 if result:
7bf792c8364b text_x_arnica: table is done by DataBrowserWidget
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 41
diff changeset
645 data.addRow(tuple(result))
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
646
121
f6ce62994858 text_x_arnica: initial setup for css.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 113
diff changeset
647 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
648 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
649 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
650
ad51b86d7bc1 introduce macro arnica which calls the arnica parser
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 73
diff changeset
651 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
652 """ parser output """
ad51b86d7bc1 introduce macro arnica which calls the arnica parser
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 73
diff changeset
653 # 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
654 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
655 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
656 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
657 self.request.write(self.formatter.div(0))