<> '''Have an action for exporting a page''' We had a conversation in chat. I suggested to have an action that would enable to download a page wihich contains only gettext ("#format gettext") as a PO file. We then tried to make this more general == discussion == . ''dreimark:'' I do have a !PackagePage patch written for attachments but it needs some further work to embed it to the action too see FeatureRequests/PackagesNeedsAddAttachmentAndMore ... I do believe that could be done with some parser code... I have done something similiar with pdf code in php some time ago ... with some of the frame parser code it could be rendered too but I would be prefer at first a very smart solution and to extend it later. Because the frame parser needs some fixes too. We will need a parser and an action macro (invisible for the menu). all content included by a parser could be downloaded as file by an action. -- ReimarBauer <> == first version == Here is a first implementation for exporting content for the 1.6 dev code. -- ReimarBauer <> '''Example''' {{{ { { {#!ExportFile = some wiki mark up = * A * B } } } { { {#!ExportFile file=example.txt #format plain AAEE BBAA CCAA DDDE FFAE BBCD } } } { { {#!ExportFile file=example.py #format python def format(self, formatter): self.pagename = formatter.page.page_name self.quoted_pagename = wikiutil.quoteWikinameURL(self.pagename) attachment_path = AttachFile.getAttachDir(self.request, self.pagename, create=1) } } } }}} {{attachment:ExportFile_1.png}} The results files are * [[attachment:exportfile.txt]] * [[attachment:example.txt]] * [[attachment:example.py]] We do need an action macro exportfile.py in the action directory and a parser text_x_exportfile.py in the parsers directory. A patch of wikutil makes sense because a dict of process instructions and getting the Parser instance would be needed in other routines too. {{attachment:wikiutil_20070104_patch.txt}} {{attachment:exportfile-1.6.0-1.py}} {{attachment:text_x_exportfile-1.6.0-3.py}} == comments wanted == If something like this could be implemented may be we could use it for all codings on the Markets. Because * We have then version control from the wiki. * Someone else could easier contribute. * We get easy a downloadable version -- ReimarBauer <> ThomasWaldmann proposed to add a ContentSaving Action too. wikiutil patch: * get_processING_instructionS() * can be optimized: * first check for line[0] == '#' * then check for line[1:] starting with pi (without #) * don't use "dict" as attribute name, this overloads dict() * if you iterate over lowercase stuff only, no need to lower() them again * break!? * maybe we rather want value = rest of line * and check if that all is done if #format ExportFile works too For this FeatureRequest and some other routines I would like to add these functions to wikiutil. -- ReimarBauer <> {{{#!python def getProcessingInstructions(text): """Creates dict of processing instructions""" lines = text.split('\n') kw = {} kw["processing_instructions"] = False for line in lines: if line.startswith('#'): for pi in ("format", "refresh", "redirect", "deprecated", "pragma", "form", "acl", "language"): if line[1:].lower().startswith(pi): kw[str(pi)] = ((line.split(pi))[1]).strip() kw["processing_instructions"] = True break return kw def getParser(request, text): """gets the parser used from text""" pi = getProcessingInstructions(text) pi_format = request.cfg.default_markup or "wiki" # check for XML content if text and text[:5] == '