Attachment 'wikiaction.patch'

Download

   1 --- wikiaction-1.5b2.py	2005-10-23 21:50:50.000000000 +0900
   2 +++ wikiaction.py	2005-11-24 09:47:28.196742300 +0900
   3 @@ -563,10 +563,6 @@
   4          from MoinMoin.PageEditor import PageEditor
   5          pg = PageEditor(request, pagename)
   6  
   7 -    # Edit was canceled
   8 -    if request.form.has_key('button_cancel'):
   9 -        pg.sendCancel(savetext, rev)
  10 -        return
  11  
  12      # is invoked without savetext start editing
  13      if savetext is None:
  14 @@ -577,11 +573,39 @@
  15      if lasteditor == 'gui':
  16          from MoinMoin.converter.text_html_text_x_moin import convert
  17          savetext = convert(request, pagename, savetext) # XXX error handling
  18 +    
  19 +    # section editing
  20 +    startline = int(request.form.get('startline', ['0'])[0])
  21 +    endline = int(request.form.get('endline', ['0'])[0])
  22 +        
  23 +    if startline or endline:
  24 +        issectionedit = 1
  25 +        
  26 +        if not startline:
  27 +            startline = 1
  28 +        
  29 +        if not endline:
  30 +            endline = -1    
  31 +
  32 +    else:
  33 +        issectionedit = 0
  34 +
  35 +    if issectionedit:
  36 +        savetext = pg.normalizeText(savetext, stripspaces=rstrip)
  37 +        sectiontext = savetext
  38 +        savetext = mergesection(pg.get_raw_body(), savetext, startline, endline)
  39 +
  40 +
  41 +    # Edit was canceled
  42 +    if request.form.has_key('button_cancel'):
  43 +        pg.sendCancel(savetext, rev)
  44 +        return
  45  
  46      # IMPORTANT: normalize text from the form. This should be done in
  47      # one place before we manipulate the text.
  48 -    savetext = pg.normalizeText(savetext, stripspaces=rstrip)
  49 -
  50 +    if not issectionedit:
  51 +        savetext = pg.normalizeText(savetext, stripspaces=rstrip)
  52 +    
  53      # Add category
  54  
  55      # TODO: this code does not work with extended links, and is doing
  56 @@ -630,11 +654,17 @@
  57      if (request.form.has_key('button_preview') or
  58          request.form.has_key('button_spellcheck') or
  59          request.form.has_key('button_newwords')):
  60 -        pg.sendEditor(preview=savetext, comment=comment)
  61 +        if issectionedit:
  62 +            pg.sendEditor(preview=sectiontext, comment=comment, pagetext=savetext)
  63 +        else:
  64 +            pg.sendEditor(preview=savetext, comment=comment)
  65      
  66      # Preview with mode switch
  67      elif request.form.has_key('button_switch'):
  68 -        pg.sendEditor(preview=savetext, comment=comment, staytop=1)
  69 +        if issectionedit:
  70 +            pg.sendEditor(preview=sectiontext, comment=comment, staytop=1, pagetext=savetext)
  71 +        else:
  72 +            pg.sendEditor(preview=savetext, comment=comment, staytop=1)
  73      
  74      # Save new text
  75      else:
  76 @@ -655,7 +685,10 @@
  77                                             querystr='action=diff&rev=%d' % rev)
  78                      }
  79                  # We don't send preview when we do merge conflict
  80 -                pg.sendEditor(msg=conflict_msg, comment=comment)
  81 +                if issectionedit:
  82 +                    conflict_msg = u'%s %s' % (conflict_msg, _('Section editing is canceled.'))
  83 +                
  84 +                pg.sendEditor(msg=conflict_msg, comment=comment, issectionedit=0)
  85                  return
  86              else:
  87                  savemsg = conflict_msg
  88 @@ -949,6 +982,15 @@
  89          
  90      return handler
  91  
  92 -    
  93 - 
  94  
  95 +def mergesection(pagetext, newsectiontext, startline, endline):
  96 +    
  97 +    pagetext = pagetext.split('\n')
  98 +    
  99 +    prevtext = u'%s\n' % u'\n'.join(pagetext[:startline-1])
 100 +    if endline == -1:
 101 +        nexttext = ''
 102 +    else:
 103 +        nexttext = u'\n%s' % u'\n'.join(pagetext[endline:])
 104 +    
 105 +    return u'%s%s%s' % (prevtext, newsectiontext, nexttext)
 106 

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.
  • [get | view] (2005-11-23 19:38:55, 0.5 KB) [[attachment:Include.patch]]
  • [get | view] (2005-11-24 11:57:17, 5.3 KB) [[attachment:PageEditor.patch]]
  • [get | view] (2005-11-24 11:57:23, 5.0 KB) [[attachment:PageGraphicalEditor.patch]]
  • [get | view] (2007-02-13 21:59:15, 19.1 KB) [[attachment:SectionEditing-1.5.4.patch]]
  • [get | view] (2007-04-18 19:03:14, 19.3 KB) [[attachment:SectionEditing-1.5.7.patch]]
  • [get | view] (2008-09-19 06:53:44, 21.3 KB) [[attachment:SectionEditing-1.7.1.patch]]
  • [get | view] (2005-11-23 19:38:14, 0.3 KB) [[attachment:multiconfig.patch]]
  • [get | view] (2005-11-29 10:18:42, 14.2 KB) [[attachment:patch-1.35.txt]]
  • [get | view] (2007-02-07 09:47:30, 55.0 KB) [[attachment:patch-1.5.6.zip]]
  • [get | view] (2005-11-29 10:18:29, 20.2 KB) [[attachment:patch-1.5b2.txt]]
  • [get | view] (2006-03-06 03:43:16, 19.7 KB) [[attachment:patch-sectioin-editing-1.5r1.txt]]
  • [get | view] (2010-01-20 00:32:20, 21.3 KB) [[attachment:section-edit-1.9-v1.1.patch]]
  • [get | view] (2010-01-22 14:57:16, 21.3 KB) [[attachment:section-edit-1.9-v1.2.patch]]
  • [get | view] (2010-10-11 19:06:34, 21.7 KB) [[attachment:section-edit-1.9-v1.4.patch]]
  • [get | view] (2010-01-15 20:38:36, 21.3 KB) [[attachment:section-edit-1.9.patch]]
  • [get | view] (2007-07-15 10:21:53, 57.1 KB) [[attachment:sectionedit_opera.png]]
  • [get | view] (2005-11-24 11:57:05, 5.2 KB) [[attachment:text_html.patch]]
  • [get | view] (2005-11-24 11:57:11, 3.6 KB) [[attachment:wikiaction.patch]]
 All files | Selected Files: delete move to page copy to page

You are not allowed to attach a file to this page.