Example #1
0
    def _checkFilePathAttribute(self, node, attrName):
        fpath = node.getAttribute(attrName)
        uri = decodeUri(fpath)
#        print u"decodeUri: %s" % fpath.encode(u'iso-8859-1', u'replace') #$NON-NLS-1$ #$NON-NLS-2$ #$NON-NLS-3$
#        print u"         : %s" % uri.encode(u'iso-8859-1', u'replace') #$NON-NLS-1$ #$NON-NLS-2$ #$NON-NLS-3$
        if uri:
            node.setAttribute(attrName, uri )
Example #2
0
 def getLabel(self):
     if not self.linkIDO.getHost():
         return decodeUri(self.linkIDO.getUrl())
     if not self.getPath():
         return u"/" #$NON-NLS-1$
     else:
         return self.getPath()
Example #3
0
 def _convertUrl(self, url):
     decodedFilePath = decodeUri(url)
     relativePath = makeRelativePath(self.dataDir, decodedFilePath)
     if relativePath != decodedFilePath:
         return u"%s/%s" % (IZDocumentSerializationConstants.
                            RAVEN_BLOG_DOCUMENT_PATH_TOKEN, relativePath
                            )  #$NON-NLS-1$
Example #4
0
 def _checkFilePathAttribute(self, node, attrName):
     fpath = node.getAttribute(attrName)
     uri = decodeUri(fpath)
     #        print u"decodeUri: %s" % fpath.encode(u'iso-8859-1', u'replace') #$NON-NLS-1$ #$NON-NLS-2$ #$NON-NLS-3$
     #        print u"         : %s" % uri.encode(u'iso-8859-1', u'replace') #$NON-NLS-1$ #$NON-NLS-2$ #$NON-NLS-3$
     if uri:
         node.setAttribute(attrName, uri)
Example #5
0
 def createThumbnail(self, width, height, options = {}): #@UnusedVariable
     if not self.canCreateThumbnail() or (width < 10 and height < 10):
         return False
     imageEle = self._getImageElement()
     # get src. Assume local image. (TODO: support remote images.)
     srcFile = imageEle.getAttribute(u"src") #$NON-NLS-1$
     if not srcFile:
         return False
     try:
         tnService = getApplicationModel().getService(IZAppServiceIDs.IMAGING_SERVICE_ID)
         tnParams = ZThumbnailParams(width, height)
         (tn_name, tn_width, tn_height) = tnService.generateThumbnail( decodeUri(srcFile) , tnParams)
         # encode uri
         tn_name = encodeUri(tn_name)
         if imageEle.parentElement is not None and imageEle.parentElement.tagName == u"A": #$NON-NLS-1$
             # current image is already linked, so just update the src and width/height.
             self._setImageAttribute(imageEle, u"width", unicode(tn_width)) #$NON-NLS-1$
             self._setImageAttribute(imageEle, u"height", unicode(tn_height)) #$NON-NLS-1$
             imageEle.setAttribute(u"src", tn_name) #$NON-NLS-1$
         else:
             # generate html for the tn as well as a link to the large image
             # transfer the CSS from current image to the TN image
             self._setImageAttribute(imageEle, u"width", unicode(tn_width)) #$NON-NLS-1$
             self._setImageAttribute(imageEle, u"height", unicode(tn_height)) #$NON-NLS-1$
             css = self._getImageStyle(imageEle)
             if not css:
                 css = u"" #$NON-NLS-1$
             html = u"""<a href="%s"><img src="%s" width="%s" height="%s" style="%s"/></a>""" % (srcFile, tn_name, tn_width, tn_height, css)  #$NON-NLS-1$
             imageEle.outerHTML = html
         self._runCleanupAndFireModified()
     except:
         return False
Example #6
0
 def _checkFilePathAttribute(self, node, attrName):
     fpath = node.getAttribute(attrName)
     uri = getUriFromFilePath(fpath)
     # Hack alert: we don't want to modify any URIs that contain the 
     # special template directory token.
     if uri and not u"__RAVEN_TEMPLATE_DIR__" in uri: #$NON-NLS-1$
         # decode url if it is in unicode 'quoted' (e.g. %20 etc).
         uri = decodeUri(uri)
         # if needed, convert hostname to IDNA.
         uri = encodeIDNA(uri)
         # re-encode to Raven conention i.e. internally, store content as IDNA (hostname) with Unicode paths
         uri = encodeUri(uri)
         node.setAttribute(attrName, uri )
Example #7
0
 def _checkFilePathAttribute(self, node, attrName):
     fpath = node.getAttribute(attrName)
     uri = getUriFromFilePath(fpath)
     # Hack alert: we don't want to modify any URIs that contain the
     # special template directory token.
     if uri and not u"__RAVEN_TEMPLATE_DIR__" in uri:  #$NON-NLS-1$
         # decode url if it is in unicode 'quoted' (e.g. %20 etc).
         uri = decodeUri(uri)
         # if needed, convert hostname to IDNA.
         uri = encodeIDNA(uri)
         # re-encode to Raven conention i.e. internally, store content as IDNA (hostname) with Unicode paths
         uri = encodeUri(uri)
         node.setAttribute(attrName, uri)
Example #8
0
 def getImageAttributes(self):
     attrMap = None
     imageEle = self._getImageElement()
     if imageEle:
         attrMap = {}
         # get all, but css style attrs.
         attrNames = u"id,src,alt,title,className,width,height,align,border,margin".split(u",") #$NON-NLS-1$ #$NON-NLS-2$
         for attrName in attrNames:
             value = self._getImageAttribute(imageEle, attrName)
             if value and attrName == u"className": #$NON-NLS-1$
                 attrMap[u"class"] = value                 #$NON-NLS-1$
             elif value:
                 attrMap[attrName] = value
         # get css style.
         css = self._getImageStyle(imageEle)
         if css:
             attrMap[u"style"] = css #$NON-NLS-1$
         # FIXME (PJ) move this to zeditimagemodel
         if attrMap.has_key(u"src"): #$NON-NLS-1$
             attrMap[u"src"] = decodeUri(attrMap[u"src"]) #$NON-NLS-1$ #$NON-NLS-2$
     return attrMap
Example #9
0
 def getLinkAttributes(self):
     linkEle = self._getLinkElement()
     attrMap = None
     if linkEle:
         attrMap = {}
         attrNames = [u"className", u"href", u"target", u"rel", u"title"] #$NON-NLS-4$ #$NON-NLS-3$ #$NON-NLS-2$ #$NON-NLS-1$ #$NON-NLS-5$
         for attrName in attrNames:
             value = linkEle.getAttribute(attrName)
             if value:
                 # IE sometimes prefixes 'about:blank'.
                 if value.startswith(u"about:blank"): #$NON-NLS-1$
                     value = value[11:]
                 if attrName == u"className": #$NON-NLS-1$
                     attrName = u"class" #$NON-NLS-1$
                 attrMap[attrName] = value
         if linkEle.innerText:
             attrMap[u"text"] = linkEle.innerText  #$NON-NLS-1$
         if attrMap.has_key(u"href"): #$NON-NLS-1$
             attrMap[u"href"] = decodeUri(attrMap[u"href"]) #$NON-NLS-1$ #$NON-NLS-2$
             # if protocol is file://, then convert to a normal path.
             # FIXME (PJ) move this code to ZLinkModel.
     return attrMap
Example #10
0
 def getRowText(self, rowIndex, columnIndex):  #@UnusedVariable
     return decodeUri(self.links[rowIndex].getHref())
Example #11
0
 def getRowText(self, rowIndex, columnIndex): #@UnusedVariable
     return decodeUri(self.links[rowIndex].getHref())
Example #12
0
 def getRowText(self, rowIndex, columnIndex):  # @UnusedVariable
     return decodeUri(self.images[rowIndex].getSrc())
Example #13
0
 def getRowText(self, rowIndex, columnIndex): #@UnusedVariable
     return decodeUri(self.images[rowIndex].getSrc())
Example #14
0
 def _convertUrl(self, url):
     decodedFilePath = decodeUri(url)
     relativePath = makeRelativePath(self.dataDir, decodedFilePath)
     if relativePath != decodedFilePath:
         return u"%s/%s" % (IZDocumentSerializationConstants.RAVEN_BLOG_DOCUMENT_PATH_TOKEN, relativePath) #$NON-NLS-1$