00001
00002 """MoinMoin - IncludeWikiContent
00003
00004 A macro to include another wiki page content with the context set to the current
00005 page. This Inclusion is not recursive (included pages won't get their
00006 IncludeWikiContent macro evaluated).
00007
00008 Usage:
00009 Use this macro to include common elements of your wiki, such as standard
00010 subpages, headers etc...
00011
00012 Syntax:
00013 <<IncludeWikiContent(include page name)>>
00014
00015 """
00016
00017 from MoinMoin.Page import Page
00018 from MoinMoin import wikiutil
00019 from MoinMoin.parser.text_moin_wiki import Parser as WikiParser
00020
00021 import neo_cgi, neo_util, neo_cs
00022
00023
00024 Dependencies = ["namespace"]
00025
00026 def execute(macro, args):
00027 request = macro.request
00028 content = []
00029 page_name = macro.formatter.page.page_name
00030
00031
00032 include_page_name = ''
00033 if args is not None:
00034 include_page_name = args
00035
00036 include_page_name = wikiutil.AbsPageName(page_name, include_page_name)
00037
00038 include_page = Page(request, include_page_name)
00039
00040 if include_page is None:
00041 return ''
00042 if not request.user.may.read(include_page_name):
00043 return ''
00044
00045 cstemplate = include_page.getPageText()
00046
00047 pagename = macro.formatter.page.page_name
00048 kv_page = Page(request, pagename)
00049 kv_body = kv_page.get_body()
00050
00051 hdf = neo_util.HDF()
00052 for line in kv_body.split("\n"):
00053 if line.startswith("##"):
00054 line = line[2:].strip()
00055 parts = line.split("=", 1)
00056 if len(parts) == 2:
00057 hdf.setValue(parts[0].strip(), parts[1].strip())
00058
00059 hdf.setValue("Config.WhiteSpaceStrip ", "0")
00060
00061 cs = neo_cs.CS(hdf)
00062 cs.parseStr(cstemplate)
00063
00064 body = cs.render()
00065
00066 body = wikiutil.renderText(request, WikiParser, body)
00067 return body
00068