Attachment 'sf.patch'
Download 1 *** sscop/data/plugin/macro/PageComment2.py Sat Jan 6 17:07:40 2007
2 --- sscop/data/plugin/macro/PageCommentSF.py Sun Jan 7 22:57:12 2007
3 ***************
4 *** 1,6 ****
5 # -*- coding: iso-8859-1 -*-
6 """
7 ! PageComment2.py Version 0.98.1 April 25, 2006
8
9 This macro gives a form to post a new comment to the page and shows a list of the posted comments.
10
11 --- 1,6 ----
12 # -*- coding: iso-8859-1 -*-
13 """
14 ! PageComment2.py Version 0.98.1sf Jan. 6, 2007
15
16 This macro gives a form to post a new comment to the page and shows a list of the posted comments.
17
18 ***************
19 *** 55,64 ****
20 - commentfirst: shows comment list before the input form.
21 - commentfirst=0: default, the input form first
22 - commentfirst=1: comment list first
23 !
24 ! - articleview: shows comment list in an article view.
25 ! - articleview=0: default, list in table view
26 ! - articleview=1: list in article view
27
28 - tablewidth: the width of the table format for PageComment2, default '' (none).
29 e.g., tablewidth=600, tablewidth=100%
30 --- 55,96 ----
31 - commentfirst: shows comment list before the input form.
32 - commentfirst=0: default, the input form first
33 - commentfirst=1: comment list first
34 !
35 ! - commentclass: specifies the class of the rows in the comment table
36 ! - commentclass=baz: means the class is "baz" for ordinary view and
37 ! "bazpreview" for preview (when markup=1); default is
38 ! determined by articleview parameter for backwards compat.
39 !
40 ! - commentformat: specifies which fields of the comment are specified,
41 ! and in what order. Its value should be a string composed of the
42 ! following characters, which will cause the corresponding item
43 ! to be placed in the table of comments:
44 ! 't': The text of the comment (cell has class commenttext)
45 ! 'a': The author of the comment (class commentauthor)
46 ! 'A': author in verbose "Posted by <author>"
47 ! (class commentauthorverbose)
48 ! 'i': smiley (class commenticon)
49 ! 'd': date/time (class commentdate)
50 ! 'D': verbose date/time (class commentdate)
51 ! 'x': link to delete the comment
52 ! ' ': bit o' horizontal whitespace
53 ! '{': break line, start a right-justified group of fields
54 ! (class commentcontinuation)
55 ! '}': Close group started by { - note this is mandatory
56 ! 'V': bit o' vertical whitespace, produced by a cell spanning the
57 ! entire entry of style commentblankline. Probably only
58 ! really works at the end of the format string.
59 ! So note that the style for each cell is composed of the style
60 ! given by the commentclass, overridden by the style of
61 ! the class listed for that field type. Note that the blank lines do
62 ! not have class commentclass.
63 !
64 ! - articleview: basically superseded by commentclass and commentformat
65 ! For backwards compatibility, sets their defaults:
66 ! - articleview=0: (default) commentclass deflts to "commentclassic"
67 ! commentformat deflts to "ia tdx"
68 ! - articleview=1: commentclass deflts to "commentarticle"
69 ! commentformat deflts to "t{AiDx}V"
70
71 - tablewidth: the width of the table format for PageComment2, default '' (none).
72 e.g., tablewidth=600, tablewidth=100%
73 ***************
74 *** 71,76 ****
75 --- 103,110 ----
76 - nosmiley=0: default, shows smiley selection
77 - nosmiley=1: no smiley selection
78
79 + - prompt: what should go in the box at start (default 'Add your comment')
80 +
81 - notify: notifies to the subscribers of the page which includes the macro when a comment is added
82 - notify=0: default, notification disabled
83 - notify=1: notification enabled
84 ***************
85 *** 85,90 ****
86 --- 119,130 ----
87
88 Change Log
89
90 + - Jan. 6, 2007 - Version 0.98sf
91 + - Moved as nearly all of the style information to the stylesheet
92 + - Implemented configurable styles and fields in the comment list
93 + - added a prompt parameter for what's in the box to start
94 + - changes by Glen Whitney gwhitneycom1 AT pobox OBFUSCATE DOT com
95 +
96 - April 17, 2006 - Version 0.98
97 - fixed a bug on revision history
98 - added a despam action
99 ***************
100 *** 159,164 ****
101 --- 199,207 ----
102 pagename = ''
103 curpagename = ''
104 cursubname = ''
105 + fieldinterps = {}
106 + colspan = u''
107 + blankline = u''
108 admin = ''
109 macro = ''
110 defaultacl = ''
111 ***************
112 *** 180,186 ****
113 --- 223,232 ----
114 countonly = 0
115 section = ''
116 articleview = 0
117 + commentclass = ''
118 + commentformat = ''
119 notify = 0
120 + prompt = u''
121 encryptpass = 0
122 markup = 0
123
124 ***************
125 *** 251,257 ****
126 elif Params.maxlength and (len(comtext) > Params.maxlength):
127 message('Comment text is limited to %d characters. (%d characters now)' % (Params.maxlength, len(comtext)) )
128
129 ! elif not comtext.strip() or comtext == u'Add your comment':
130 message('Please fill the comment text')
131
132 ## PREVIEW
133 --- 297,303 ----
134 elif Params.maxlength and (len(comtext) > Params.maxlength):
135 message('Comment text is limited to %d characters. (%d characters now)' % (Params.maxlength, len(comtext)) )
136
137 ! elif not comtext.strip() or comtext == Params.prompt:
138 message('Please fill the comment text')
139
140 ## PREVIEW
141 ***************
142 *** 304,310 ****
143 html.append(u'<table border="0" class="pagecomment" %s>' % Params.tablewidth)
144
145 if Globs.adminmsg:
146 ! html.append(u'<tr><td colspan="5" style="border-width: 0px;">')
147 html.append(u'<font color="#aa0000">%s</font>' % Globs.adminmsg)
148 html.append(u'</td></tr>')
149
150 --- 350,356 ----
151 html.append(u'<table border="0" class="pagecomment" %s>' % Params.tablewidth)
152
153 if Globs.adminmsg:
154 ! html.append(u'<tr><td %sstyle="border-width: 0px;">' % Globs.colspan)
155 html.append(u'<font color="#aa0000">%s</font>' % Globs.adminmsg)
156 html.append(u'</td></tr>')
157
158 ***************
159 *** 316,333 ****
160 html.append(commentpreview)
161
162 html.append(commentlisthtml)
163 ! html.append(u'<tr><td colspan="5" class="commentblankline" style="border-width: 0px; height: 20px;"></td></tr>')
164 html.append(commentformhtml)
165 else:
166 html.append(commentformhtml)
167 ! html.append(u'<tr><td colspan="5" class="commentblankline" style="border-width: 0px; height: 20px;"></td></tr>')
168 if commentpreview:
169 html.append(commentpreview)
170
171 html.append(commentlisthtml)
172
173 if Globs.debugmsg:
174 ! html.append(u'<tr><td colspan="5" style="border-width: 0px;">')
175 html.append(u'<font color="#aa0000">%s</font>' % Globs.debugmsg)
176 html.append(u'</td></tr>')
177
178 --- 362,379 ----
179 html.append(commentpreview)
180
181 html.append(commentlisthtml)
182 ! html.append(Globs.blankline)
183 html.append(commentformhtml)
184 else:
185 html.append(commentformhtml)
186 ! html.append(Globs.blankline*2)
187 if commentpreview:
188 html.append(commentpreview)
189
190 html.append(commentlisthtml)
191
192 if Globs.debugmsg:
193 ! html.append(u'<tr><td %sstyle="border-width: 0px;">' % Globs.colspan)
194 html.append(u'<font color="#aa0000">%s</font>' % Globs.debugmsg)
195 html.append(u'</td></tr>')
196
197 ***************
198 *** 345,351 ****
199 html = []
200
201 if not Params.commentonly:
202 ! html.append(u'<tr><td style="border-width: 1px; margin: 10px 0 10px 0;" colspan="5">')
203 #html.append(u'<table class="commentform"><tr><td style="border-width: 1px;">')
204 html.append(commentform(comauthor, comtext, compasswd, comicon, comrev, autopass, commarkup))
205 #html.append(u'</td></tr></table>')
206 --- 391,397 ----
207 html = []
208
209 if not Params.commentonly:
210 ! html.append(u'<tr><td style="border-width: 1px; margin: 10px 0 10px 0;" %s>' % Globs.colspan)
211 #html.append(u'<table class="commentform"><tr><td style="border-width: 1px;">')
212 html.append(commentform(comauthor, comtext, compasswd, comicon, comrev, autopass, commarkup))
213 #html.append(u'</td></tr></table>')
214 ***************
215 *** 426,432 ****
216 Params.articleview = int(params.get('articleview', 0))
217 except ValueError:
218 Params.articleview = 0
219 !
220 try:
221 Params.smileylist = int(params.get('smileylist', 0))
222 except ValueError:
223 --- 472,487 ----
224 Params.articleview = int(params.get('articleview', 0))
225 except ValueError:
226 Params.articleview = 0
227 !
228 ! defltclass = 'commentclassic'
229 ! defltformat = 'ia tdx'
230 ! if Params.articleview:
231 ! defltclass = 'commentarticle'
232 ! defltformat = 't{AiDx}V'
233 !
234 ! Params.commentclass = params.get('commentclass', defltclass)
235 ! Params.commentformat = params.get('commentformat', defltformat)
236 !
237 try:
238 Params.smileylist = int(params.get('smileylist', 0))
239 except ValueError:
240 ***************
241 *** 452,457 ****
242 --- 507,514 ----
243 except ValueError:
244 Params.maxlength = 0
245
246 + Params.prompt = params.get('prompt', u'Add your comment');
247 +
248 try:
249 Params.notify = int(params.get('notify', 0))
250 except ValueError:
251 ***************
252 *** 484,490 ****
253
254 # ADD SMILEYS HERE TO BE USED:
255 Globs.smileys = [':)', ':))', ':(', ';)', ':\\', '|)', 'X-(', 'B)']
256 !
257 if Params.markup:
258
259 # ADD MACROS HERE TO ALLOW TO BE USED IN THE TEXT:
260 --- 541,575 ----
261
262 # ADD SMILEYS HERE TO BE USED:
263 Globs.smileys = [':)', ':))', ':(', ';)', ':\\', '|)', 'X-(', 'B)']
264 !
265 ! totalcols = Params.commentformat.find('{')
266 ! if totalcols < 0: totalcols = len(Params.commentformat)
267 ! totalcols -= Params.commentformat.count('V',0,totalcols)
268 ! if totalcols > 1: Globs.colspan = u'colspan="%d" ' % totalcols
269 !
270 ! # Now that we've computed all the derived values, stick a dummy start
271 ! # character onto the front and a dummy end character on the end
272 ! # to make the generation code more uniform:
273 ! Params.commentformat = 'S%sF' % Params.commentformat
274 !
275 ! Globs.blankline = u'<tr><td %sclass="commentblankline"></td></tr>' % Globs.colspan
276 !
277 ! Globs.fieldinterps = {
278 ! 'S' : u'<tr class=%(commentclass)s>',
279 ! 't' : u'<td class="commenttext">%(text)s</td>',
280 ! 'a' : u'<td class="commentauthor">%(author)s</td>',
281 ! 'A' : u'<td class="commentauthorverbose">Posted by <b>%(author)s</b></td>',
282 ! 'i' : u'<td class="commenticon">%(icon)s</td>',
283 ! 'd' : u'<td class="commentdate" nowrap>%(date)s</td>',
284 ! 'D' : u'<td class="commentdate" nowrap>at %(date)s</td>',
285 ! 'x' : u'<td>%(delform)s</td>',
286 ! ' ' : u'<td style="width: 10px;"> </td>',
287 ! 'V' : u'</tr><tr><td %sclass="commentblankline"></td>' % Globs.colspan,
288 ! '{' : u'</tr><tr class="%%(commentclass)s"><td %s class="commentcontinuation" style="padding: 0px;"><table style="padding:0px; margin:0px; float:right;"><tr>' % Globs.colspan,
289 ! '}' : u'</tr></table></td>',
290 ! 'F' : u'</tr>'
291 ! }
292 !
293 if Params.markup:
294
295 # ADD MACROS HERE TO ALLOW TO BE USED IN THE TEXT:
296 ***************
297 *** 592,600 ****
298 initPass = tmppasswd
299
300 if not tmptext:
301 ! tmptext = u'Add your comment'
302 initText = tmptext
303 ! elif tmptext and tmptext == u'Add your comment':
304 initText = tmptext
305
306 previewbutton = ''
307 --- 677,685 ----
308 initPass = tmppasswd
309
310 if not tmptext:
311 ! tmptext = Params.prompt
312 initText = tmptext
313 ! elif tmptext and tmptext == Params.prompt:
314 initText = tmptext
315
316 previewbutton = ''
317 ***************
318 *** 768,793 ****
319 #comtext = convertdelimeter(comtext)
320 #comauthor = convertdelimeter(comauthor)
321
322 ! if Params.articleview:
323 ! cellstyle = u'border-width: 1px; border-bottom-width: 0px; border-color: #ff7777; background-color: #eeeeee; vertical-align: top; font-size: 9pt;'
324 ! htmlcomment = [
325 ! u'<tr><td colspan="5" class="commenttext" style="%(cellstyle)s">%(text)s</td></tr>',
326 ! u'<tr><td colspan="5" class="commentauthor" style="border-color: #ff7777; border-width: 1px; border-top-width: 0px; text-align: right; font-size: 8pt; color: #999999;">Posted by <b>%(author)s</b> %(icon)s at %(date)s %(delform)s</td></tr>',
327 ! u'<tr><td colspan="5" class="commentblankline" style="border-width: 0px; height: 20px;"></td></tr>',
328 ! ]
329 !
330 ! else:
331 ! cellstyle = u'border-width: 0px; background-color: #ffeeee; border-top-width: 1px; vertical-align: top; font-size: 9pt;'
332 ! htmlcomment = [
333 ! u'<tr><td class="commenticon" style="%(cellstyle)s">%(icon)s</td>',
334 ! u'<td class="commentauthor" style="%(cellstyle)s">%(author)s</td>',
335 ! u'<td style="%(cellstyle)s width: 10px;"> </td>',
336 ! u'<td class="commenttext" style="%(cellstyle)s">%(text)s</td>',
337 ! u'<td class="commentdate" style="%(cellstyle)s text-align: right; font-size: 8pt; " nowrap>%(date)s%(delform)s</td></tr>',
338 ! ]
339 !
340 ! htmlcommentitem = u'\n'.join(htmlcomment) % {
341 ! 'cellstyle': cellstyle,
342 'icon': getsmiley(comicon),
343 'author': converttext(comauthor),
344 'text': converttext(comtext, commarkup),
345 --- 853,860 ----
346 #comtext = convertdelimeter(comtext)
347 #comauthor = convertdelimeter(comauthor)
348
349 ! htmlcommentitem = u'\n'.join([Globs.fieldinterps.get(x,u'') for x in Params.commentformat]) % {
350 ! 'commentclass': Params.commentclass + 'preview',
351 'icon': getsmiley(comicon),
352 'author': converttext(comauthor),
353 'text': converttext(comtext, commarkup),
354 ***************
355 *** 810,833 ****
356 html = []
357 cur_index = 0
358
359 ! if Params.articleview:
360 ! cellstyle = u'border-width: 0px; background-color: #eeeeee; vertical-align: top; font-size: 9pt;'
361 ! htmlcomment = [
362 ! u'<tr><td colspan="5" class="commenttext" style="%(cellstyle)s">%(text)s</td></tr>',
363 ! u'<tr><td colspan="5" class="commentauthor" style="text-align: right; border-width: 0px; font-size: 8pt; color: #999999;">Posted by <b>%(author)s</b> %(icon)s at %(date)s %(delform)s</td></tr>',
364 ! u'<tr><td colspan="5" class="commentblankline" style="border-width: 0px; height: 20px;"></td></tr>',
365 ! ]
366 !
367 ! else:
368 ! cellstyle = u'border-width: 0px; border-top-width: 1px; vertical-align: top; font-size: 9pt;'
369 ! htmlcomment = [
370 ! u'<tr><td class="commenticon" style="%(cellstyle)s">%(icon)s</td>',
371 ! u'<td class="commentauthor" style="%(cellstyle)s">%(author)s</td>',
372 ! u'<td style="%(cellstyle)s width: 10px;"> </td>',
373 ! u'<td class="commenttext" style="%(cellstyle)s">%(text)s</td>',
374 ! u'<td class="commentdate" style="%(cellstyle)s text-align: right; font-size: 8pt; " nowrap>%(date)s%(delform)s</td></tr>',
375 ! ]
376 !
377 htmlcommentdel_admin = [
378 u' <font style="font-size: 8pt;">',
379 u'<a style="color: #aa0000;" href="javascript: requesttodeleteadmin%(formid)d(document.delform%(formid)d, \'%(key)s\');" title="%(msg)s">X</a>',
380 --- 877,883 ----
381 html = []
382 cur_index = 0
383
384 ! htmlcomment = [Globs.fieldinterps.get(x, u'') for x in Params.commentformat]
385 htmlcommentdel_admin = [
386 u' <font style="font-size: 8pt;">',
387 u'<a style="color: #aa0000;" href="javascript: requesttodeleteadmin%(formid)d(document.delform%(formid)d, \'%(key)s\');" title="%(msg)s">X</a>',
388 ***************
389 *** 855,861 ****
390 }
391
392 htmlcommentitem = u'\n'.join(htmlcomment) % {
393 ! 'cellstyle': cellstyle,
394 'icon': getsmiley(item['icon']),
395 'author': converttext(item['name']),
396 'text': converttext(item['text'], item['markup']),
397 --- 905,911 ----
398 }
399
400 htmlcommentitem = u'\n'.join(htmlcomment) % {
401 ! 'commentclass': Params.commentclass,
402 'icon': getsmiley(item['icon']),
403 'author': converttext(item['name']),
404 'text': converttext(item['text'], item['markup']),
Attached Files
To refer to attachments on a page, use attachment:filename, as shown below in the list of files. Do NOT use the URL of the [get] link, since this is subject to change and can break easily.You are not allowed to attach a file to this page.