def _createWithThumbnailHtmlFragString(self, srcFile, model): (url, shortName, absPath, size, schemaDate) = self._getFileMetaData(srcFile) #@UnusedVariable size = model.size tnParams = ZThumbnailParams(size, size) (tn_name, tn_width, tn_height) = self._getImagingService().generateThumbnail(srcFile, tnParams) srcFile = encodeUri(srcFile) tn_name = encodeUri(tn_name) style = self._createCSSStyle(model) html = u'<a xmlns:z="urn:zoundry:xhtml:ext,2007,08" z:rel="tn" href="%s" title="%s"><img xmlns:z="urn:zoundry:xhtml:ext,2007,08" z:rel="tn" border="0" src="%s" width="%d" height="%d" style="%s" alt="%s"/></a>' % (srcFile, shortName, tn_name, tn_width, tn_height, style, shortName) #$NON-NLS-1$ return html
def _convertUri(self, uri): magicNum = len(IZDocumentSerializationConstants.RAVEN_BLOG_DOCUMENT_PATH_TOKEN) + 1 relativePath = uri[magicNum:] if relativePath: resolvedPath = resolveRelativePath(self.dataDir, relativePath) return encodeUri(resolvedPath) return None
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
def _convertUri(self, uri): magicNum = len(IZDocumentSerializationConstants. RAVEN_BLOG_DOCUMENT_PATH_TOKEN) + 1 relativePath = uri[magicNum:] if relativePath: resolvedPath = resolveRelativePath(self.dataDir, relativePath) return encodeUri(resolvedPath) return None
def createAffiliateLink(self, productUrl, sku, zoundryId): #@UnusedVariable zoundryId = getNoneString(zoundryId) if not zoundryId: zoundryId = u"zoundry-0" #$NON-NLS-1$ productUrl = encodeUri(productUrl) return u"http://www.kqzyfj.com/click-1670306-10388132?sid=%s&url=%s" % ( zoundryId, productUrl) #$NON-NLS-1$
def _createAmazonAssociateLink(self, productUrl, asin, assoicateId): asin = getNoneString(asin) if asin: return u"http://www.amazon.com/exec/obidos/ASIN/%s/ref=nosim/%s" % (asin, assoicateId) #$NON-NLS-1$ productUrl = getNoneString(productUrl) if not productUrl: return None productUrl = encodeUri(productUrl) return u"http://www.amazon.com/exec/obidos/redirect?tag=%s&path=%s" % (assoicateId, productUrl) #$NON-NLS-1$
def _createAmazonAssociateLink(self, productUrl, asin, assoicateId): asin = getNoneString(asin) if asin: return u"http://www.amazon.com/exec/obidos/ASIN/%s/ref=nosim/%s" % ( asin, assoicateId) #$NON-NLS-1$ productUrl = getNoneString(productUrl) if not productUrl: return None productUrl = encodeUri(productUrl) return u"http://www.amazon.com/exec/obidos/redirect?tag=%s&path=%s" % ( assoicateId, productUrl) #$NON-NLS-1$
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 )
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)
def setLinkAttributes(self, attrMap): #@UnusedVariable if not attrMap: return attrMapCopy = attrMap.copy() if attrMapCopy.has_key(u"href"): #$NON-NLS-1$ attrMap[u"href"] = encodeUri(attrMap[u"href"]) #$NON-NLS-1$ #$NON-NLS-2$ # # url encode and add proper file:// (if local file). # # FIXME (PJ) move this code to ZLinkModel. linkEle = self._getLinkElement() if linkEle: self._updateLink(linkEle, attrMapCopy) else: self._createLink(attrMapCopy) # run img visitor to set img runtime border = 0 self.mshtmlEditControl._getMshtmlControl()._runImgCleanupVisitor() self.mshtmlEditControl._getMshtmlControl()._fireContentModified()
def createAffiliateLink(self, productUrl, sku, zoundryId): #@UnusedVariable zoundryId = getNoneString(zoundryId) if not zoundryId: zoundryId = u"zoundry-0" #$NON-NLS-1$ productUrl = encodeUri(productUrl) return u"http://www.kqzyfj.com/click-1670306-10388132?sid=%s&url=%s" % (zoundryId, productUrl)#$NON-NLS-1$
def _createNoThumbnailHtmlFragString(self, srcFile): (url, shortName, absPath, size, schemaDate) = self._getFileMetaData(srcFile) #@UnusedVariable srcFile = encodeUri(srcFile) html = u'<img xmlns:z="urn:zoundry:xhtml:ext,2007,08" z:rel="tn" src="%s" alt="%s"/>' % (srcFile, shortName) #$NON-NLS-1$ return html