Back to index

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

Classes

class  TwikiDraw

Functions

def gedit_drawing
def attachment_drawing
def execute

Variables

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

Function Documentation

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

Definition at line 50 of file twikidraw.py.

00050 
00051 def attachment_drawing(self, url, text, **kw):
00052     # This is called for displaying a clickable drawing image by text_html formatter.
00053     # XXX text arg is unused!
00054     _ = self.request.getText
00055     pagename, drawing = AttachFile.absoluteName(url, self.page.page_name)
00056     containername = wikiutil.taintfilename(drawing)
00057 
00058     drawing_url = AttachFile.getAttachUrl(pagename, containername, self.request, do='modify')
00059     ci = AttachFile.ContainerItem(self.request, pagename, containername)
00060     if not ci.exists():
00061         title = _('Create new drawing "%(filename)s (opens in new window)"') % {'filename': self.text(containername)}
00062         img = self.icon('attachimg')  # TODO: we need a new "drawimg" in similar grey style and size
00063         css = 'nonexistent'
00064         return self.url(1, drawing_url, css=css, title=title) + img + self.url(0)
00065 
00066     title = _('Edit drawing %(filename)s (opens in new window)') % {'filename': self.text(containername)}
00067     kw['src'] = src = ci.member_url('drawing.png')
00068     kw['css'] = 'drawing'
00069 
00070     try:
00071         mapfile = ci.get('drawing.map')
00072         map = mapfile.read()
00073         mapfile.close()
00074         map = map.decode(config.charset)
00075     except (KeyError, IOError, OSError):
00076         map = u''
00077     if map:
00078         # we have a image map. inline it and add a map ref to the img tag
00079         # we have also to set a unique ID
00080         mapid = u'ImageMapOf%s%s' % (self.request.uid_generator(pagename), drawing)
00081         map = map.replace(u'%MAPNAME%', mapid)
00082         # add alt and title tags to areas
00083         map = re.sub(ur'href\s*=\s*"((?!%TWIKIDRAW%).+?)"', ur'href="\1" alt="\1" title="\1"', map)
00084         map = map.replace(u'%TWIKIDRAW%"', u'%s" alt="%s" title="%s"' % (
00085             wikiutil.escape(drawing_url, 1), title, title))
00086         # unxml, because 4.01 concrete will not validate />
00087         map = map.replace(u'/>', u'>')
00088         title = _('Clickable drawing: %(filename)s') % {'filename': self.text(containername)}
00089         if 'title' not in kw:
00090             kw['title'] = title
00091         if 'alt' not in kw:
00092             kw['alt'] = kw['title']
00093         kw['usemap'] = '#'+mapid
00094         return self.url(1, drawing_url) + map + self.image(**kw) + self.url(0)
00095     else:
00096         if 'title' not in kw:
00097             kw['title'] = title
00098         if 'alt' not in kw:
00099             kw['alt'] = kw['title']
00100         return self.url(1, drawing_url) + self.image(**kw) + self.url(0)
00101 

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

Definition at line 204 of file twikidraw.py.

00204 
00205 def execute(pagename, request):
00206     target = request.values.get('target')
00207     twd = TwikiDraw(request, pagename, target)
00208 
00209     do = request.values.get('do')
00210     if do == 'save':
00211         msg = twd.save()
00212     else:
00213         msg = twd.render()
00214     if msg:
00215         request.theme.add_msg(msg, 'error')
00216         do_show(pagename, request)
00217 
00218 

Here is the call graph for this function:

def MoinMoin.action.twikidraw.gedit_drawing (   self,
  url,
  text,
  kw 
)

Definition at line 28 of file twikidraw.py.

00028 
00029 def gedit_drawing(self, url, text, **kw):
00030     # This is called for displaying a drawing image by gui editor.
00031     _ = self.request.getText
00032     # TODO: this 'text' argument is kind of superfluous, replace by using alt=... kw arg
00033     # ToDo: make this clickable for the gui editor
00034     if 'alt' not in kw or not kw['alt']:
00035         kw['alt'] = text
00036     # we force the title here, needed later for html>wiki converter
00037     kw['title'] = "drawing:%s" % wikiutil.quoteWikinameURL(url)
00038     pagename, drawing = AttachFile.absoluteName(url, self.page.page_name)
00039     containername = wikiutil.taintfilename(drawing)
00040     drawing_url = AttachFile.getAttachUrl(pagename, containername, self.request)
00041     ci = AttachFile.ContainerItem(self.request, pagename, containername)
00042     if not ci.exists():
00043         title = _('Create new drawing "%(filename)s (opens in new window)"') % {'filename': self.text(containername)}
00044         img = self.icon('attachimg')  # TODO: we need a new "drawimg" in similar grey style and size
00045         css = 'nonexistent'
00046         return self.url(1, drawing_url, css=css, title=title) + img + self.url(0)
00047     kw['src'] = ci.member_url('drawing.png')
00048     return self.image(**kw)
00049 


Variable Documentation

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

Definition at line 25 of file twikidraw.py.

Definition at line 18 of file twikidraw.py.