Attachment 'FormattedPage-1.0.py'
Download 1 # -*- coding: iso-8859-1 -*-
2 """
3 MoinMoin - FormattedPage macro Version 1.0, 21.06.2014
4
5 Returns HTML for a whole page formatted according to the processing
6 instructions of that page. It does not include the options of in-built
7 Include macro, but allows the formatted page to use footnotes, particularly
8 because these are used by the Ref macro. Also, it levels the heading
9 structure for the host page unaltered.
10
11 Syntax:
12 <<FormattedPage(pagename)>>
13
14 @copyright: 2014 Ian Riley <ian@riley.asia>
15
16 Developed with inspiration and code from MoinMoin - Include macro
17
18 @copyright: 2000-2004 Juergen Hermann <jh@web.de>,
19 2000-2001 Richard Jones <richard@bizarsoftware.com.au>
20
21 license: GNU GPL, see COPYING for details.
22 """
23
24 import StringIO
25 from MoinMoin.Page import Page
26 from MoinMoin import wikiutil
27
28 def execute(macro, args):
29 request = macro.request
30 page_name = macro.formatter.page.page_name
31
32 insert_name = ''
33 if args is not None:
34 insert_name = args
35
36 insert_name = wikiutil.AbsPageName(page_name, insert_name)
37 fmt = macro.formatter.__class__(request, is_included=False)
38 fmt._base_depth = 0
39 request._fmt_hd_counters = []
40 request._tocfm_collected_headings = []
41 request.pragma = {}
42
43 insert = Page(request, insert_name, formatter=fmt)
44
45 if (insert is None) or (not request.user.may.read(insert_name)):
46 return ''
47
48 strfile = StringIO.StringIO()
49 request.redirect(strfile)
50 try:
51 insert.send_page(content_only=True, count_hit=False)
52 result = strfile.getvalue()
53 finally:
54 request.redirect()
55 del strfile
56 del insert
57
58 return result
You are not allowed to attach a file to this page.