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