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.You are not allowed to attach a file to this page.