Changeset 59

Show
Ignore:
Timestamp:
07/12/05 08:30:47 (3 years ago)
Author:
athomas
Message:
  • Brought AddCommentMacro up to date with trunk, closes #14. Unfortunately it has to use GET rather than POST, but it seems to work nonetheless.
Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • addcommentmacro/trunk/AddComment.py

    r41 r59  
    77from trac.wiki.model import WikiPage 
    88from trac.util import TracError 
     9from trac.web.chrome import add_link 
    910import re 
    1011 
     
    1718    authname = hdf.getValue("trac.authname", "anonymous") 
    1819    db = env.get_db_cnx() 
    19     perm = trac.perm.PermissionCache(db, authname) 
     20    perm = trac.perm.PermissionCache(env, authname) 
    2021    pagename = hdf.getValue("wiki.page_name", "WikiStart") 
    2122    page = WikiPage(env, pagename, None, db) 
     
    2627    cancomment = not readonlypage 
    2728    # Is this an "append-only" comment or are we an administrator? 
    28     if perm.has_permission(trac.perm.WIKI_ADMIN) or appendonly: 
     29    if perm.has_permission('WIKI_ADMIN') or appendonly: 
    2930        cancomment = True 
    3031 
     
    4748 
    4849    out = StringIO() 
    49     if wikipreview or not perm.has_permission(trac.perm.WIKI_MODIFY): 
     50    if wikipreview or not perm.has_permission('WIKI_MODIFY'): 
    5051        disabled = ' disabled="disabled"' 
    5152 
     
    5455        if preview: 
    5556            out.write("<div class='wikipage' id='preview'>\n") 
    56         out.write("<h4 id='commentpreview'>Comment by %s on %s</h4>\n<p>\n%s\n</p>\n" % (authname, time.strftime('%c', time.localtime()), wiki_to_html(comment, hdf, env, db))) 
     57        out.write("<h4 id='commentpreview'>Comment by %s on %s</h4>\n<p>\n%s\n</p>\n" % (authname, time.strftime('%c', time.localtime()), wiki_to_html(comment, env, None))) 
    5758        if preview: 
    5859            out.write("</div>\n") 
     
    7980            out.write("<div class='system-message'><strong>ERROR: [[AddComment]] macro call must be the only content on its line. Could not add comment.</strong></div>\n") 
    8081 
    81     out.write("<form action='%s#commentpreview' method='post'>\n" % env.href.wiki(pagename)) 
     82    out.write("<form action='%s#commentpreview' method='get'>\n" % env.href.wiki(pagename)) 
    8283    out.write("<fieldset>\n<legend>Add comment</legend>\n") 
    8384    out.write("<div class='field'>\n<textarea id='addcomment' name='addcomment' cols='80' rows='5'%s>" % disabled) 
     
    9293    out.write("<input type='submit' name='previewaddcomment' value='Preview comment'%s/>\n" % disabled) 
    9394    out.write("<input type='submit' name='canceladdcomment' value='Cancel'%s/>\n</div>\n" % disabled) 
     95    out.write('<script type="text/javascript" src="%sjs/wikitoolbar.js"></script>' % hdf['htdocs_location']) 
    9496    out.write("<script type='text/javascript'>\naddWikiFormattingToolbar(document.getElementById('addcomment'));\n</script>\n") 
    9597    out.write("</fieldset>\n</form>\n")