1 """
   2     MoinMoin - supplementation - presents a list of forum posts (comments) related to the current page, with a button allowing the user to submit a new comment. The idea is that to create a new discussion or thread, we will want to create a framing document first--which can have associated media attachments--and all comments will be stored as timestamp-labelled subpages. This is somewhat different from the standard "supplementation" feature, insofar as comments are stored and listed separately rather than on a single page. We have separated the commenting functions into two actions: (1) supplementation, which lists related comments, and (2) PostComment. There is also (3) a revised "include" macro that automatically includes authors' signatures.
   3 
   4     @copyright: 2005-2006, 2011 Bastian Blank, Florian Festi, Thomas Waldmann, Eric Thrift
   5     @license: GNU GPL, see COPYING for details.
   6 """
   7 from MoinMoin import wikiutil
   8 from MoinMoin.Page import Page
   9 import time
  10 from time import strftime
  11 from MoinMoin.wikiutil import quoteWikinameURL
  12 
  13 def _getParent(pagename):
  14     """ Return parent of pagename.
  15     """
  16     pos = pagename.rfind('/')
  17     if pos >= 0:
  18         return pagename[:pos]
  19     return None
  20     
  21 def execute(pagename, request):
  22 
  23     parent = _getParent(pagename)
  24 
  25     comment_page_name = "C"
  26     _ = request.getText
  27     thispage = Page(request, pagename)
  28     skipitems = int(request.values.get('skipitems', 0))
  29     items = int(request.values.get("items", 20))
  30     order = request.values.get('order', 'ascending')
  31     format = request.values.get('format', 'include')
  32 #    timestamp = time.strftime("D%Y%m%dT%H%M%S")
  33     timestamp = int(time.time()) ## This gives us seconds
  34     startitem = (skipitems + 1)
  35     nextitems = (skipitems + items)
  36     previousitems = (skipitems - items)
  37 #    count = request.page.getPageCount()
  38 #    count = len(request.rootpage.getPageList(filter=filter))
  39     if previousitems < 0:
  40         previousitems = 0
  41 
  42     if request.user.valid:
  43         username = request.user.name
  44     else:
  45         username = 'Anonymous'
  46 
  47 
  48     if pagename.rfind(comment_page_name) >= 0: # sub_page redirects to parent page
  49         query = {'action': 'supplementation'}
  50         url = Page(request, parent).url(request, query)
  51         request.http_redirect(url)
  52     #TODO: Just reference i18n variables
  53     pagecontent = _("""\
  54 = Forum: %s =
  55 <<Icon(moin-home.png)>> [[%s|Forum view|&action=supplementation,&format=include]] 
  56 <<Icon(moin-search.png)>> [[%s|Index view|&action=supplementation,&format=list]] 
  57 <<Icon(moin-up.png)>> [[%s|Back to content page]] <<BR>>
  58 
  59 <<IncludeComments(^%s.*/%s[0-9][^@]*@[^@]*,,,sort=%s,items=%s,skipitems=%s,editlink)>>
  60 
  61 [[%s/%s%s%s|Post a new comment|&action=localedit,class=buttonlink]] 
  62 
  63 
  64 """) % (pagename, pagename, pagename, pagename, pagename, comment_page_name, order, int(items), skipitems, pagename, comment_page_name, timestamp, username)
  65 
  66 
  67     if format == 'list':
  68             pagecontent = _("""\
  69 = Forum index: %s =
  70 <<Icon(moin-home.png)>> [[%s|Forum view|&action=supplementation,&format=include]] 
  71 <<Icon(moin-search.png)>> [[%s|Index view|&action=supplementation,&format=list]] 
  72 <<Icon(moin-up.png)>> [[%s|Back to content page]] 
  73 
  74 ----
  75 
  76 <<PageList(regex:^%s.*/%s[0-9][^@]*@[^@]*)>>
  77 
  78 [[%s/%s%s%s|Post a new comment|&action=localedit,class=buttonlink]]
  79 
  80 """) % (pagename, pagename, pagename, pagename, pagename, comment_page_name, pagename, comment_page_name, timestamp, username,)
  81 
  82 
  83     pagecontent = pagecontent % locals()
  84 
  85     pagecontent = pagecontent.replace('\n', '\r\n')
  86 
  87     from MoinMoin.parser.text_moin_wiki import Parser as WikiParser
  88 
  89     request.setContentLanguage(request.lang)
  90     request.theme.send_title(("%s/%s" % (pagename, _('Comments'))), page=thispage)
  91 
  92     parser = WikiParser(pagecontent, request)
  93     p = Page(request, pagename)
  94     request.formatter.setPage(p)
  95     parser.format(request.formatter)
  96 
  97     # Start content - IMPORTANT - without content div, there is no direction support!
  98     request.write(request.formatter.startContent("content"))
  99 
 100     request.write(request.formatter.endContent())
 101     request.theme.send_footer(thispage.page_name)
 102     request.theme.send_closing_html()

There are 0 attachment(s) stored for this page.

MoinMoinCustomizations/supplementation.py (last edited 2011-09-07 14:32:55 by MandalWebHome)