Back to index

moin  1.9.0~rc2
Classes | Functions | Variables
MoinMoin.action.anywikidraw Namespace Reference

Classes

class  AnyWikiDraw

Functions

def attachment_drawing
def execute

Variables

tuple logging = log.getLogger(__name__)
tuple action_name = __name__.split('.')

Function Documentation

def MoinMoin.action.anywikidraw.attachment_drawing (   self,
  url,
  text,
  kw 
)

Definition at line 30 of file anywikidraw.py.

00030 
00031 def attachment_drawing(self, url, text, **kw):
00032     # This is called for displaying a clickable drawing image by text_html formatter.
00033     # XXX text arg is unused!
00034     _ = self.request.getText
00035     pagename, drawing = AttachFile.absoluteName(url, self.page.page_name)
00036     containername = wikiutil.taintfilename(drawing)
00037 
00038     drawing_url = AttachFile.getAttachUrl(pagename, containername, self.request, do='modify')
00039     ci = AttachFile.ContainerItem(self.request, pagename, containername)
00040     if not ci.exists():
00041         title = _('Create new drawing "%(filename)s (opens in new window)"') % {'filename': self.text(containername)}
00042         img = self.icon('attachimg')  # TODO: we need a new "drawimg" in similar grey style and size
00043         css = 'nonexistent'
00044         return self.url(1, drawing_url, css=css, title=title) + img + self.url(0)
00045 
00046     title = _('Edit drawing %(filename)s (opens in new window)') % {'filename': self.text(containername)}
00047     kw['src'] = src = ci.member_url('drawing.png')
00048     kw['css'] = 'drawing'
00049 
00050     try:
00051         mapfile = ci.get('drawing.map')
00052         map = mapfile.read()
00053         mapfile.close()
00054         map = map.decode(config.charset)
00055     except (KeyError, IOError, OSError):
00056         map = u''
00057     if map:
00058         # ToDo mapid must become uniq
00059         # we have a image map. inline it and add a map ref to the img tag
00060         # we have also to set a unique ID
00061         mapid = u'ImageMapOf%s%s' % (self.request.uid_generator(pagename), drawing)
00062 
00063         map = map.replace(u'id="%s.svg"' % drawing, '')
00064         map = map.replace(u'name="%s.svg"' % drawing, u'name="%s"' % mapid)
00065         # unxml, because 4.01 concrete will not validate />
00066         map = map.replace(u'/>', u'>')
00067         title = _('Clickable drawing: %(filename)s') % {'filename': self.text(containername)}
00068         if 'title' not in kw:
00069             kw['title'] = title
00070         if 'alt' not in kw:
00071             kw['alt'] = kw['title']
00072         kw['usemap'] = '#'+mapid
00073         return self.url(1, drawing_url) + map + self.image(**kw) + self.url(0)
00074     else:
00075         if 'title' not in kw:
00076             kw['title'] = title
00077         if 'alt' not in kw:
00078             kw['alt'] = kw['title']
00079         return self.url(1, drawing_url) + self.image(**kw) + self.url(0)
00080 

def MoinMoin.action.anywikidraw.execute (   pagename,
  request 
)

Definition at line 193 of file anywikidraw.py.

00193 
00194 def execute(pagename, request):
00195     target = request.values.get('target')
00196     awd = AnyWikiDraw(request, pagename, target)
00197 
00198     do = request.values.get('do')
00199     if do == 'save':
00200         msg = awd.save()
00201     else:
00202         msg = awd.render()
00203     if msg:
00204         request.theme.add_msg(msg, 'error')
00205         do_show(pagename, request)
00206 

Here is the call graph for this function:


Variable Documentation

tuple MoinMoin.action.anywikidraw.action_name = __name__.split('.')

Definition at line 24 of file anywikidraw.py.

Definition at line 18 of file anywikidraw.py.