Attachment 'IncludeUrlContentWiki-1.8.py'

Download

   1 """
   2         IncludeUrlContentWiki macro for MoinMoin 1.8
   3         
   4         Get the content from an URL, process it as wiki markup, and return those
   5         formatted results. 
   6         
   7         I personally use this in cases where I have a web server
   8         process to dynamically generate content that relies on wiki
   9         features like macros, smileys, table layout rules, etc.
  10         
  11         Usage: [[IncludeUrlContentWiki( http://foo.com/wikimarkup )]]
  12 
  13         Changes:
  14           11/19/08: Made the read text into unicode so that when the imported text contains a macro,
  15                     wikiutils doesn't freakout (in function invoke_extension_function).
  16         
  17         Originally written by:
  18         2005-03-31 Steve Poole, stevep@wrq.com 
  19         
  20         Updated by:
  21         2008-11-19 Dexter Arver, http://moinmo.in/counterpoke
  22 """
  23 
  24 import urllib
  25 from MoinMoin import wikiutil
  26 from MoinMoin.parser.text_moin_wiki import Parser as WikiParser
  27 
  28 def execute( macro, url ):
  29     request = macro.request
  30     try:
  31         text = urllib.urlopen( url ).read()
  32     except IOError:
  33         text = "{{{ IncludeUrl failed on " + url + " }}}"
  34     text = unicode(text)
  35     return wikiutil.renderText(request, WikiParser, 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.
  • [get | view] (2008-02-12 00:43:52, 1.1 KB) [[attachment:IncludeUrlContentWiki-1.6.py]]
  • [get | view] (2008-11-19 23:33:08, 1.2 KB) [[attachment:IncludeUrlContentWiki-1.8.py]]
  • [get | view] (2005-04-01 01:15:07, 1.1 KB) [[attachment:IncludeUrlContentWiki.py]]
 All files | Selected Files: delete move to page copy to page

You are not allowed to attach a file to this page.