#format python from MoinMoin.action import AttachFile from MoinMoin import wikiutil import os,string def execute(macro, text): if text: args = text.split(',') else: args = [] if len(args) < 3: return macro.formatter.sysmsg('Not enough arguments to embed macro') attname = wikiutil.taintfilename(macro.formatter.text(args[0])) current_pagename = macro.formatter.page.page_name src = AttachFile.getAttachUrl(current_pagename,attname,macro.request) # Check if attachment exists attachment_path = os.path.join(AttachFile.getAttachDir(current_pagename), attname) if not os.path.exists(attachment_path): import urllib linktext = macro.request.getText('Upload new attachment "%(filename)s"') return wikiutil.link_tag(macro.request, '%s?action=AttachFile&rename=%s' % (wikiutil.quoteWikiname(current_pagename), urllib.quote_plus(attname)), linktext % {'filename': attname}) width = wikiutil.escape(string.join(args[1],''), quote=1) height = wikiutil.escape(string.join(args[2],''), quote=1) return "" % (src, width, height)