*** sscop/data/plugin/macro/PageComment2.py	Sat Jan  6 17:07:40 2007
--- sscop/data/plugin/macro/PageCommentSF.py	Sun Jan  7 22:57:12 2007
***************
*** 1,6 ****
  # -*- coding: iso-8859-1 -*-
  """
!     PageComment2.py  Version 0.98.1  April 25, 2006
                                                                                                             
      This macro gives a form to post a new comment to the page and shows a list of the posted comments.
                                                                                                             
--- 1,6 ----
  # -*- coding: iso-8859-1 -*-
  """
!     PageComment2.py  Version 0.98.1sf  Jan. 6, 2007
                                                                                                             
      This macro gives a form to post a new comment to the page and shows a list of the posted comments.
                                                                                                             
***************
*** 55,64 ****
          - commentfirst: shows comment list before the input form.
              - commentfirst=0: default, the input form first
              - commentfirst=1: comment list first
!             
!         - articleview: shows comment list in an article view.
!             - articleview=0: default, list in table view
!             - articleview=1: list in article view
    
          - tablewidth: the width of the table format for PageComment2, default '' (none). 
              e.g., tablewidth=600, tablewidth=100%
--- 55,96 ----
          - commentfirst: shows comment list before the input form.
              - commentfirst=0: default, the input form first
              - commentfirst=1: comment list first
! 
!         - commentclass: specifies the class of the rows in the comment table
! 	    - commentclass=baz: means the class is "baz" for ordinary view and
! 	         "bazpreview" for preview (when markup=1); default is
! 	         determined by articleview parameter for backwards compat.
! 
!         - commentformat: specifies which fields of the comment are specified,
! 	    and in what order. Its value should be a string composed of the
!             following characters, which will cause the corresponding item
!             to be placed in the table of comments:
!               't': The text of the comment (cell has class commenttext)    
!               'a': The author of the comment (class  commentauthor)
!               'A': author in verbose "Posted by <author>" 
!                    (class commentauthorverbose)
!               'i': smiley (class commenticon)
!               'd': date/time (class commentdate)
!               'D': verbose date/time (class commentdate)
!               'x': link to delete the comment
!               ' ': bit o' horizontal whitespace
!               '{': break line, start a right-justified group of fields
!                    (class commentcontinuation) 
!               '}': Close group started by { - note this is mandatory 
!               'V': bit o' vertical whitespace, produced by a cell spanning the
!                    entire entry of style commentblankline. Probably only
!                    really works at the end of the format string. 
!             So note that the style for each cell is composed of the style
!             given by the commentclass, overridden by the style of 
!             the class listed for that field type. Note that the blank lines do
!             not have class commentclass.   
!  
!         - articleview: basically superseded by commentclass and commentformat
!             For backwards compatibility, sets their defaults: 
!             - articleview=0: (default) commentclass deflts to "commentclassic"
!                              commentformat deflts to "ia tdx"     
!             - articleview=1: commentclass deflts to "commentarticle"
!                              commentformat deflts to "t{AiDx}V"
    
          - tablewidth: the width of the table format for PageComment2, default '' (none). 
              e.g., tablewidth=600, tablewidth=100%
***************
*** 71,76 ****
--- 103,110 ----
              - nosmiley=0: default, shows smiley selection
              - nosmiley=1: no smiley selection
  
+         - prompt: what should go in the box at start (default 'Add your comment')
+         
          - notify: notifies to the subscribers of the page which includes the macro when a comment is added
              - notify=0: default, notification disabled
              - notify=1: notification enabled
***************
*** 85,90 ****
--- 119,130 ----
  
      Change Log
          
+ 	- Jan. 6, 2007 - Version 0.98sf
+             - Moved as nearly all of the style information to the stylesheet
+             - Implemented configurable styles and fields in the comment list
+             - added a prompt parameter for what's in the box to start
+             - changes by Glen Whitney gwhitneycom1 AT pobox OBFUSCATE DOT com
+  
          - April 17, 2006 - Version 0.98
              - fixed a bug on revision history
              - added a despam action
***************
*** 159,164 ****
--- 199,207 ----
      pagename = ''
      curpagename = ''
      cursubname = ''
+     fieldinterps = {}
+     colspan = u''
+     blankline = u''
      admin = ''
      macro = ''
      defaultacl = ''
***************
*** 180,186 ****
--- 223,232 ----
      countonly = 0
      section = ''
      articleview = 0
+     commentclass = ''
+     commentformat = ''
      notify = 0
+     prompt = u''
      encryptpass = 0
      markup = 0
      
***************
*** 251,257 ****
                  elif Params.maxlength and (len(comtext) > Params.maxlength):
                      message('Comment text is limited to %d characters. (%d characters now)' % (Params.maxlength, len(comtext)) )
                  
!                 elif not comtext.strip() or comtext == u'Add your comment':
                      message('Please fill the comment text')
                  
                  ## PREVIEW
--- 297,303 ----
                  elif Params.maxlength and (len(comtext) > Params.maxlength):
                      message('Comment text is limited to %d characters. (%d characters now)' % (Params.maxlength, len(comtext)) )
                  
!                 elif not comtext.strip() or comtext == Params.prompt:
                      message('Please fill the comment text')
                  
                  ## PREVIEW
***************
*** 304,310 ****
      html.append(u'<table border="0" class="pagecomment" %s>' % Params.tablewidth)
      
      if Globs.adminmsg:
!         html.append(u'<tr><td colspan="5" style="border-width: 0px;">')
          html.append(u'<font color="#aa0000">%s</font>' % Globs.adminmsg)
          html.append(u'</td></tr>')
  
--- 350,356 ----
      html.append(u'<table border="0" class="pagecomment" %s>' % Params.tablewidth)
      
      if Globs.adminmsg:
!         html.append(u'<tr><td %sstyle="border-width: 0px;">' % Globs.colspan)
          html.append(u'<font color="#aa0000">%s</font>' % Globs.adminmsg)
          html.append(u'</td></tr>')
  
***************
*** 316,333 ****
              html.append(commentpreview)
              
          html.append(commentlisthtml)
!         html.append(u'<tr><td colspan="5" class="commentblankline" style="border-width: 0px; height: 20px;"></td></tr>')
          html.append(commentformhtml)
      else:
          html.append(commentformhtml)
!         html.append(u'<tr><td colspan="5" class="commentblankline" style="border-width: 0px; height: 20px;"></td></tr>')
          if commentpreview:
              html.append(commentpreview)
  
          html.append(commentlisthtml)
  
      if Globs.debugmsg:
!         html.append(u'<tr><td colspan="5" style="border-width: 0px;">')
          html.append(u'<font color="#aa0000">%s</font>' % Globs.debugmsg)
          html.append(u'</td></tr>')
      
--- 362,379 ----
              html.append(commentpreview)
              
          html.append(commentlisthtml)
!         html.append(Globs.blankline)
          html.append(commentformhtml)
      else:
          html.append(commentformhtml)
!         html.append(Globs.blankline*2)
          if commentpreview:
              html.append(commentpreview)
  
          html.append(commentlisthtml)
  
      if Globs.debugmsg:
!         html.append(u'<tr><td %sstyle="border-width: 0px;">' % Globs.colspan)
          html.append(u'<font color="#aa0000">%s</font>' % Globs.debugmsg)
          html.append(u'</td></tr>')
      
***************
*** 345,351 ****
      html = []
      
      if not Params.commentonly:
!         html.append(u'<tr><td style="border-width: 1px; margin: 10px 0 10px 0;" colspan="5">')
          #html.append(u'<table class="commentform"><tr><td style="border-width: 1px;">')
          html.append(commentform(comauthor, comtext, compasswd, comicon, comrev, autopass, commarkup))
          #html.append(u'</td></tr></table>')
--- 391,397 ----
      html = []
      
      if not Params.commentonly:
!         html.append(u'<tr><td style="border-width: 1px; margin: 10px 0 10px 0;" %s>' % Globs.colspan)
          #html.append(u'<table class="commentform"><tr><td style="border-width: 1px;">')
          html.append(commentform(comauthor, comtext, compasswd, comicon, comrev, autopass, commarkup))
          #html.append(u'</td></tr></table>')
***************
*** 426,432 ****
          Params.articleview = int(params.get('articleview', 0))
      except ValueError:
          Params.articleview = 0
!         
      try:
          Params.smileylist = int(params.get('smileylist', 0))
      except ValueError:
--- 472,487 ----
          Params.articleview = int(params.get('articleview', 0))
      except ValueError:
          Params.articleview = 0
! 
!     defltclass = 'commentclassic'
!     defltformat = 'ia tdx'
!     if Params.articleview:
!         defltclass = 'commentarticle'
!         defltformat = 't{AiDx}V'
! 
!     Params.commentclass = params.get('commentclass', defltclass)
!     Params.commentformat = params.get('commentformat', defltformat) 
! 
      try:
          Params.smileylist = int(params.get('smileylist', 0))
      except ValueError:
***************
*** 452,457 ****
--- 507,514 ----
      except ValueError:
          Params.maxlength = 0
  
+     Params.prompt = params.get('prompt', u'Add your comment');
+ 
      try:
          Params.notify = int(params.get('notify', 0))
      except ValueError:
***************
*** 484,490 ****
      
      # ADD SMILEYS HERE TO BE USED:
      Globs.smileys = [':)', ':))', ':(', ';)', ':\\', '|)', 'X-(', 'B)']
!     
      if Params.markup:
          
          # ADD MACROS HERE TO ALLOW TO BE USED IN THE TEXT:
--- 541,575 ----
      
      # ADD SMILEYS HERE TO BE USED:
      Globs.smileys = [':)', ':))', ':(', ';)', ':\\', '|)', 'X-(', 'B)']
! 
!     totalcols = Params.commentformat.find('{')
!     if totalcols < 0: totalcols = len(Params.commentformat)
!     totalcols -= Params.commentformat.count('V',0,totalcols)
!     if totalcols > 1: Globs.colspan = u'colspan="%d" ' % totalcols
! 
!     # Now that we've computed all the derived values, stick a dummy start
!     # character onto the front and a dummy end character on the end
!     # to make the generation code more uniform:
!     Params.commentformat = 'S%sF' % Params.commentformat
! 
!     Globs.blankline = u'<tr><td %sclass="commentblankline"></td></tr>' % Globs.colspan
! 
!     Globs.fieldinterps = {
!         'S' : u'<tr class=%(commentclass)s>',
!         't' : u'<td class="commenttext">%(text)s</td>',
!     	'a' : u'<td class="commentauthor">%(author)s</td>',
!         'A' : u'<td class="commentauthorverbose">Posted by <b>%(author)s</b></td>',
!         'i' : u'<td class="commenticon">%(icon)s</td>',
!         'd' : u'<td class="commentdate" nowrap>%(date)s</td>',
! 	'D' : u'<td class="commentdate" nowrap>at %(date)s</td>',
!         'x' : u'<td>%(delform)s</td>',
! 	' ' : u'<td style="width: 10px;">&nbsp;</td>',
! 	'V' : u'</tr><tr><td %sclass="commentblankline"></td>' % Globs.colspan,
!         '{' : u'</tr><tr class="%%(commentclass)s"><td %s class="commentcontinuation" style="padding: 0px;"><table style="padding:0px; margin:0px; float:right;"><tr>' % Globs.colspan,
!         '}' : u'</tr></table></td>',
!         'F' : u'</tr>'
!     }
! 
      if Params.markup:
          
          # ADD MACROS HERE TO ALLOW TO BE USED IN THE TEXT:
***************
*** 592,600 ****
          initPass = tmppasswd
      
      if not tmptext:
!         tmptext = u'Add your comment'
          initText = tmptext
!     elif tmptext and tmptext == u'Add your comment':
          initText = tmptext
      
      previewbutton = ''
--- 677,685 ----
          initPass = tmppasswd
      
      if not tmptext:
!         tmptext = Params.prompt
          initText = tmptext
!     elif tmptext and tmptext == Params.prompt:
          initText = tmptext
      
      previewbutton = ''
***************
*** 768,793 ****
      #comtext = convertdelimeter(comtext)
      #comauthor = convertdelimeter(comauthor)
      
!     if Params.articleview:
!         cellstyle = u'border-width: 1px; border-bottom-width: 0px; border-color: #ff7777; background-color: #eeeeee; vertical-align: top; font-size: 9pt;'
!         htmlcomment = [
!             u'<tr><td colspan="5" class="commenttext" style="%(cellstyle)s">%(text)s</td></tr>',
!             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>',
!             u'<tr><td colspan="5" class="commentblankline" style="border-width: 0px; height: 20px;"></td></tr>',
!             ]
!             
!     else:
!         cellstyle = u'border-width: 0px; background-color: #ffeeee; border-top-width: 1px; vertical-align: top; font-size: 9pt;'
!         htmlcomment = [
!             u'<tr><td class="commenticon" style="%(cellstyle)s">%(icon)s</td>',
!             u'<td class="commentauthor" style="%(cellstyle)s">%(author)s</td>',
!             u'<td style="%(cellstyle)s width: 10px;">&nbsp;</td>',
!             u'<td class="commenttext" style="%(cellstyle)s">%(text)s</td>',
!             u'<td class="commentdate" style="%(cellstyle)s text-align: right; font-size: 8pt; " nowrap>%(date)s%(delform)s</td></tr>',
!             ]
!     
!     htmlcommentitem = u'\n'.join(htmlcomment) % {
!         'cellstyle': cellstyle,
          'icon': getsmiley(comicon),
          'author': converttext(comauthor),
          'text': converttext(comtext, commarkup),
--- 853,860 ----
      #comtext = convertdelimeter(comtext)
      #comauthor = convertdelimeter(comauthor)
      
!     htmlcommentitem = u'\n'.join([Globs.fieldinterps.get(x,u'') for x in Params.commentformat]) % {
!         'commentclass': Params.commentclass + 'preview',
          'icon': getsmiley(comicon),
          'author': converttext(comauthor),
          'text': converttext(comtext, commarkup),
***************
*** 810,833 ****
      html = []
      cur_index = 0
      
!     if Params.articleview:
!         cellstyle = u'border-width: 0px; background-color: #eeeeee; vertical-align: top; font-size: 9pt;'
!         htmlcomment = [
!             u'<tr><td colspan="5" class="commenttext" style="%(cellstyle)s">%(text)s</td></tr>',
!             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>',
!             u'<tr><td colspan="5" class="commentblankline" style="border-width: 0px; height: 20px;"></td></tr>',
!             ]
!             
!     else:
!         cellstyle = u'border-width: 0px; border-top-width: 1px; vertical-align: top; font-size: 9pt;'
!         htmlcomment = [
!             u'<tr><td class="commenticon" style="%(cellstyle)s">%(icon)s</td>',
!             u'<td class="commentauthor" style="%(cellstyle)s">%(author)s</td>',
!             u'<td style="%(cellstyle)s width: 10px;">&nbsp;</td>',
!             u'<td class="commenttext" style="%(cellstyle)s">%(text)s</td>',
!             u'<td class="commentdate" style="%(cellstyle)s text-align: right; font-size: 8pt; " nowrap>%(date)s%(delform)s</td></tr>',
!             ]
!     
      htmlcommentdel_admin = [
          u' <font style="font-size: 8pt;">',
          u'<a style="color: #aa0000;" href="javascript: requesttodeleteadmin%(formid)d(document.delform%(formid)d, \'%(key)s\');" title="%(msg)s">X</a>',
--- 877,883 ----
      html = []
      cur_index = 0
      
!     htmlcomment = [Globs.fieldinterps.get(x, u'') for x in Params.commentformat]
      htmlcommentdel_admin = [
          u' <font style="font-size: 8pt;">',
          u'<a style="color: #aa0000;" href="javascript: requesttodeleteadmin%(formid)d(document.delform%(formid)d, \'%(key)s\');" title="%(msg)s">X</a>',
***************
*** 855,861 ****
              }
                  
          htmlcommentitem = u'\n'.join(htmlcomment) % {
!             'cellstyle': cellstyle,
              'icon': getsmiley(item['icon']),
              'author': converttext(item['name']),
              'text': converttext(item['text'], item['markup']),
--- 905,911 ----
              }
                  
          htmlcommentitem = u'\n'.join(htmlcomment) % {
!             'commentclass': Params.commentclass,
              'icon': getsmiley(item['icon']),
              'author': converttext(item['name']),
              'text': converttext(item['text'], item['markup']),
