Attachment 'patch-backto-section.diff'
Download 1 # HG changeset patch
2 # User Paul Boddie <paul@boddie.org.uk>
3 # Date 1301168961 -3600
4 # Node ID eab32df358f6a10b5e1aa36d4e89927f56d857ca
5 # Parent 3931b6a8b535c151d17b8969fe8da64c6e88ecdd
6 Added support for returning to a particular section of a page, where the section
7 is provided by an included page, when cancelling or saving an edit on that
8 included page initiated from the "parent" or "including" page.
9
10 diff -r 3931b6a8b535 -r eab32df358f6 MoinMoin/PageEditor.py
11 --- a/MoinMoin/PageEditor.py Sat Mar 12 23:48:11 2011 +0100
12 +++ b/MoinMoin/PageEditor.py Sat Mar 26 20:49:21 2011 +0100
13 @@ -354,6 +354,9 @@
14 backto = request.values.get('backto')
15 if backto:
16 request.write(unicode(html.INPUT(type="hidden", name="backto", value=backto)))
17 + section = request.values.get('section')
18 + if section:
19 + request.write(unicode(html.INPUT(type="hidden", name="section", value=section)))
20
21 # button bar
22 button_spellcheck = '<input class="button" type="submit" name="button_spellcheck" value="%s" onClick="flgChange = false;">' % _('Check Spelling')
23 @@ -529,7 +532,12 @@
24 backto = request.values.get('backto')
25 if backto:
26 pg = Page(request, backto)
27 - request.http_redirect(pg.url(request))
28 + section = request.values.get('section')
29 + if section:
30 + url = pg.url(request, anchor=section)
31 + else:
32 + url = pg.url(request)
33 + request.http_redirect(url)
34 else:
35 request.theme.add_msg(_('Edit was cancelled.'), "error")
36 self.send_page()
37 diff -r 3931b6a8b535 -r eab32df358f6 MoinMoin/action/edit.py
38 --- a/MoinMoin/action/edit.py Sat Mar 12 23:48:11 2011 +0100
39 +++ b/MoinMoin/action/edit.py Sat Mar 26 20:49:21 2011 +0100
40 @@ -177,6 +177,17 @@
41 # msg contains a unicode string
42 savemsg = unicode(msg)
43
44 + backto = request.values.get('backto')
45 + if backto:
46 + pg = Page(request, backto)
47 + section = request.values.get('section')
48 + if section:
49 + url = pg.url(request, anchor=section)
50 + else:
51 + url = pg.url(request)
52 + request.http_redirect(url)
53 + return
54 +
55 # Send new page after save or after unsuccessful conflict merge.
56 request.reset()
57 pg = Page(request, pagename)
58 diff -r 3931b6a8b535 -r eab32df358f6 MoinMoin/macro/Include.py
59 --- a/MoinMoin/macro/Include.py Sat Mar 12 23:48:11 2011 +0100
60 +++ b/MoinMoin/macro/Include.py Sat Mar 26 20:49:21 2011 +0100
61 @@ -202,7 +202,7 @@
62 this_page._macroInclude_pagelist.get(inc_name, 0) + 1
63
64 # output a container for the included page
65 - result.append(macro.formatter.div(1, css_class="included-page"))
66 + result.append(macro.formatter.div(1, id=inc_name, css_class="included-page"))
67
68 # output the included page
69 strfile = StringIO.StringIO()
70 @@ -227,7 +227,7 @@
71 result.extend([
72 macro.formatter.div(1, css_class="include-link"),
73 inc_page.link_to(request, '[%s]' % (inc_name, ), css_class="include-page-link"),
74 - inc_page.link_to(request, '[%s]' % (_('edit'), ), css_class="include-edit-link", querystr={'action': 'edit', 'backto': request._Include_backto}),
75 + inc_page.link_to(request, '[%s]' % (_('edit'), ), css_class="include-edit-link", querystr={'action': 'edit', 'backto': request._Include_backto, "section": wikiutil.anchor_name_from_text(inc_name)}),
76 macro.formatter.div(0),
77 ])
78 # XXX page.link_to is wrong now, it escapes the edit_icon html as it escapes normal text
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.