def _populateWidgets(self):
     username = self._getSession().getAccountUsername()
     password = self._getSession().getAccountPassword()
     endpoint = self._getSession().getAccountAPIUrl()
     self.username.SetValue(getSafeString(username))
     self.password.SetValue(getSafeString(password))
     self.endpoint.SetValue(getSafeString(endpoint))
Beispiel #2
0
    def setPubMetaData(self, pubMetaData):
        # Updates the UI controls based on the data in pubMetaData
        self.draftCB.SetValue(pubMetaData.isPublishAsDraft())
        pubTime = pubMetaData.getPublishTime()
        if pubTime is not None:
            self.overridePubTimeCB.SetValue(True)
            self.dateCtrl.Enable(True)
            self.dateCtrl.setDateTime(pubTime)
        self.thumbnailsOnlyCB.SetValue(pubMetaData.isUploadTNsOnly())
        self.forceUploadCB.SetValue(pubMetaData.isForceReUploadImages())
        self.lightboxCB.SetValue(pubMetaData.isAddLightbox())
        self.poweredByZoundryCB.SetValue(pubMetaData.isAddPoweredBy())

        # WP custom data
        slug = getSafeString( getCustomWPMetaDataAttribute(pubMetaData, u"wp_slug") ) #$NON-NLS-1$
        self.wpPostSlugTextCtrl.SetValue(slug)
        # WP password
        s = getSafeString( getCustomWPMetaDataAttribute(pubMetaData, u"wp_password") ) #$NON-NLS-1$
        self.wpPasswordTextCtrl.SetValue(s)

        # WP pub status
        self.wpPublishStatusValue = ZPubMetaDataView.WP_PUBLISHED
        s = getSafeString( getCustomWPMetaDataAttribute(pubMetaData, u"post_status") ) #$NON-NLS-1$

        if s == u"pending":  #$NON-NLS-1$
            self.wpPublishStatusValue = ZPubMetaDataView.WP_PENDING
        elif s == u"private":  #$NON-NLS-1$
            self.wpPublishStatusValue = ZPubMetaDataView.WP_PRIVATE
        elif s == u"draft" or pubMetaData.isPublishAsDraft():  #$NON-NLS-1$
            self.wpPublishStatusValue = ZPubMetaDataView.WP_DRAFT

        self.wpPubStatusCombo.SetSelection(self.wpPublishStatusValue)
Beispiel #3
0
    def ping(self, pingUrl, id, url, title, blogName, excerpt):
        u"""ping(string, string, string, string, string, string) -> ZTrackbackPingResponse
        Pings the track back and returns ZTrackbackPingResponse""" #$NON-NLS-1$
        if getNoneString(pingUrl) is None:
            return ZTrackbackPingResponse(False, u"Trackback ping url is required.") #$NON-NLS-1$

        if getNoneString(id) is None:
            return ZTrackbackPingResponse(False, u"Trackback Originating Resource ID is required.") #$NON-NLS-1$

        if getNoneString(url) is None:
            return ZTrackbackPingResponse(False, u"Trackback post url is required.") #$NON-NLS-1$

        title = convertToUtf8( getSafeString(title) )
        blogName = convertToUtf8( getSafeString(blogName))
        excerpt = convertToUtf8( getSafeString(excerpt))

        postData = {
            u'id': id, #$NON-NLS-1$
            u'url': url, #$NON-NLS-1$
            u'title': title, #$NON-NLS-1$
            u'blog_name': blogName, #$NON-NLS-1$
            u'excerpt': excerpt #$NON-NLS-1$
        }

        htmlResult = self._sendHttpPostData(pingUrl, postData)
        resp = self._parseResponse(htmlResult)
        return resp
Beispiel #4
0
    def _populateAtomEntry(self, atomEntry, zserverBlogEntry):
        title = getSafeString( zserverBlogEntry.getTitle() )
        content = getSafeString( self._formatContentForPublishing( zserverBlogEntry ) )
        utcDateTime = zserverBlogEntry.getUtcDateTime()
        draft = zserverBlogEntry.isDraft()
        author = getNoneString( zserverBlogEntry.getAuthor() )
        if not author:
            author = self.getUsername()

        atomEntry.setTitle(title)
        atomEntry.setDate(utcDateTime)
        atomEntry.setContent(content)
        atomEntry.setDraft(draft)
        atomEntry.setAuthor(author)

        atomCatList = []
        # list of categories already added
        catNames = []
        for cat in zserverBlogEntry.getCategories():
            # map Zoundry cat id to atom category 'term' attribute.
            atomCat = ZAtomCategory(cat.getId(), cat.getName() )
            atomCatList.append( atomCat )
            name = cat.getName().lower()
            if name not in catNames:
                catNames.append(name)
        # Special case for Blogger. Blend zcategories + ztags into atom catories
        # FIXME (PJ) externalize this to a capability or param
        if zserverBlogEntry.getTagwords() and self.getApiUrl().startswith(u"http://www.blogger.com/feeds/default/blogs"): #$NON-NLS-1$
            for tagword in zserverBlogEntry.getTagwords():
                if tagword.lower() not in catNames:
                    catid = tagword
                    atomCat = ZAtomCategory(catid, tagword )
                    atomCatList.append( atomCat )

        atomEntry.setCategories(atomCatList)
Beispiel #5
0
 def getProxyConfig(self):
     enabled = False
     host = u""  #$NON-NLS-1$
     port = u""  #$NON-NLS-1$
     try:
         handle = _winreg.OpenKey(_winreg.HKEY_CURRENT_USER, u"Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings") #$NON-NLS-1$
         (enableStr, type) = _winreg.QueryValueEx(handle, u"ProxyEnable") #$NON-NLS-1$
         _winreg.CloseKey(handle)
         enableStr = getSafeString(enableStr)
         enabled = enableStr == u"1" #$NON-NLS-1$
     except:
         pass
             
     try:
         handle = _winreg.OpenKey(_winreg.HKEY_CURRENT_USER, u"Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings") #$NON-NLS-1$
         (hostsStr, type) = _winreg.QueryValueEx(handle, u"ProxyServer") #$NON-NLS-1$
         _winreg.CloseKey(handle)
         entries = getSafeString(hostsStr).split(u";") # eg http=127.0.0.1:8888; https=127.0.0.1:8888  #$NON-NLS-1$
         regHostportStr = None # host:port value, if available from registry.
         if len(entries) > 0:
             for entry in entries:
                 # entry = 'scheme=host:port
                 entry = entry.strip()
                 (scheme, regHostportStr) = entry.split(u"=") #$NON-NLS-1$
                 if scheme == u"http": #$NON-NLS-1$
                     break 
         if regHostportStr:
             hp = regHostportStr.strip().split(u":")  #$NON-NLS-1$
             if len(hp) > 0:
                 host = hp[0].strip()
             if len(hp) > 1:
                 port = hp[1].strip()
     except:
         pass 
     return ZOSProxyConfig(ZOSProxyConfig.TYPE_HTTP, enabled, host, port)
Beispiel #6
0
 def getRowText(self, rowIndex, columnIndex):
     if len(self.blogList) > 0 and rowIndex < len(self.blogList):
         blog = self.blogList[rowIndex]
         if columnIndex == 0:
             return getSafeString(blog.getName())
         elif columnIndex == 1:
             return getSafeString(blog.getUrl())
     return u"NA-r%d-c%d" % (rowIndex, columnIndex) #$NON-NLS-1$
Beispiel #7
0
    def _populateContentWidgets(self):
        if self.model.isInsertMode():
            self.rowsText.SetValue( str(self.model.getRows()) )
            self.colsText.SetValue( str(self.model.getCols()) )

        self.borderText.SetValue( getSafeString(self.model.getBorder()) )
        self.paddingText.SetValue( getSafeString(self.model.getPadding()) )
        self.spacingText.SetValue( getSafeString(self.model.getSpacing()) )
        self.widthText.SetValue( getSafeString( self.model.getWidth()) )
Beispiel #8
0
    def _populateNonHeaderWidgets(self):
        self.urlText.SetValue( getSafeString( self.model.getAttribute(u"href") ) ) #$NON-NLS-1$
        self.titleText.SetValue( getSafeString( self.model.getAttribute(u"title") ) ) #$NON-NLS-1$
        self.targetText.SetValue( getSafeString( self.model.getAttribute(u"target") ) ) #$NON-NLS-1$
        self.newWindowCB.SetValue( self.model.isOpenInNewWindow() )
        self.classText.SetValue( getSafeString( self.model.getAttribute(u"class") ) ) #$NON-NLS-1$
        self.relText.SetValue( getSafeString( self.model.getAttribute(u"rel") ) ) #$NON-NLS-1$

        if not self.model.isEditMode() and not self.urlText.GetValue():
            self.urlText.SetValue(u'http://') #$NON-NLS-1$
 def _getImageSizeFromElem(self):
     width = -1
     try:
         width = int( getSafeString( self.element.getAttribute(u"width")) )#$NON-NLS-1$
     except:
         pass
     height = -1
     try:
         height = int( getSafeString( self.element.getAttribute(u"height")) )#$NON-NLS-1$
     except:
         pass
     return (width, height)
Beispiel #10
0
 def apply(self):
     # also set changes to the global value
     (h, p) = self._getHostPortFromUI()
     proxy = ZHttpProxyConfiguration()
     proxy.setEnable( self.enableCB.GetValue() )
     proxy.setHost( h )
     port = 8080
     try:
         port  = int( p )
     except:
         pass
     proxy.setPort( port )
     proxy.setProxyAuthorization( getSafeString(self.usernameTxt.GetValue()), getSafeString(self.passwordTxt.GetValue()) )
     return ZApplicationPreferencesPrefPage.apply(self)
Beispiel #11
0
 def _getImageSizeFromElem(self):
     width = -1
     try:
         width = int(getSafeString(
             self.element.getAttribute(u"width")))  #$NON-NLS-1$
     except:
         pass
     height = -1
     try:
         height = int(getSafeString(
             self.element.getAttribute(u"height")))  #$NON-NLS-1$
     except:
         pass
     return (width, height)
Beispiel #12
0
    def _visitBodyDispatchElement(self, mshtmlBodyElement):  #@UnusedVariable
        self.mshtmlBodyElement = mshtmlBodyElement
        eleList = self.mshtmlBodyElement.getElementsByTagName(u"OBJECT") #$NON-NLS-1$
        for ele in eleList:
            if getNoneString(ele.classid) is not None: #$NON-NLS-1$
                # Class ID already defined. Skip!
                continue
            # 1. Lookup <embed> child element
            # 2. If child <embed> element is application/x-shockwave-flash, then remove OBJECT elem wrapper
            # The problem is, IE does not parse <embed> as an element. Instead, it is represented as OBJECT nodes' text.
            # Work around is to do load the content into ZDOm and select embed elem.

            content = getNoneString(ele.outerHTML)
            if not content:
                continue
            xhtmlDoc = loadXhtmlDocumentFromString(content)
            dom = xhtmlDoc.getDom()
            embed = dom.selectSingleNode(u"//xhtml:embed") #$NON-NLS-1$ #$NON-NLS-1$
            if not embed:
                continue
            if embed.getAttribute(u"type") == u"application/x-shockwave-flash": #$NON-NLS-1$ #$NON-NLS-2$
                embedNode = self.mshtmlDoc.createElement(u"embed") #$NON-NLS-1$
                ele.insertAdjacentElement(u"AfterEnd",embedNode) #$NON-NLS-1$
                embedEle = getDispElement(embedNode)
                for attrNode in embed.getAttributes():
                    embedEle.setAttribute( attrNode.nodeName, attrNode.getText() )
                ele.parentNode.removeChild(ele)
                classes = getSafeString(ele.getAttribute(u"className")).split(u" ") #$NON-NLS-1$ #$NON-NLS-2$
                if not u"_Z_RAVEN_OBJECT_WRAPPER_" in classes: #$NON-NLS-1$
                    classes.append(u"_Z_RAVEN_OBJECT_WRAPPER_") #$NON-NLS-1$
                embedEle.setAttribute(u"className", u" ".join(classes).strip() ) #$NON-NLS-2$ #$NON-NLS-1$
        return False
Beispiel #13
0
    def setInitDocument(self, document):
        u"""setInitDocument(IZBlogDocument) -> void
        Copies the document data to the model.""" #$NON-NLS-1$
        # Initialize the model data  with the given document
        title = getSafeString(document.getTitle())
        self.setTitle(title)

        self.setTagwords(u"") #$NON-NLS-1$
        # get tagwords based on default NS
        iZTagwordsObj = document.getTagwords(IZBlogPubTagwordNamespaces.DEFAULT_TAGWORDS_URI)
        if not iZTagwordsObj:
            # legacy, pre alpha build 132 support. check technorati ns. # FIXME (PJ) remove technorati tags NS for final release
            iZTagwordsObj = document.getTagwords(u"http://technorati.com/tag/") #$NON-NLS-1$
        if iZTagwordsObj:
            self.setTagwords( iZTagwordsObj.getValue() )

        # Use any existing pub meta data if it exists, else fall back to
        # blog info list data.
        pubMetaDataList = document.getPubMetaDataList()
        if pubMetaDataList is None or len(pubMetaDataList) == 0:
            pubMetaDataList = []
            # create pub meta data from blog info list.
            blogInfoList = document.getBlogInfoList()
            if blogInfoList is not None and len(blogInfoList) > 0:
                for blogInfo in blogInfoList:
                    pubMetaData = self._createPubMetaData(blogInfo)
                    pubMetaDataList.append(pubMetaData)

        if pubMetaDataList is not None:
            self.setPubMetaDataList(pubMetaDataList)
Beispiel #14
0
 def visitElement(self, element):
     if element.localName.lower() == u"embed": #$NON-NLS-1$
         classes = getSafeString(element.getAttribute(u"class")).split(u" ") #$NON-NLS-1$ #$NON-NLS-2$
         if not u"_Z_RAVEN_OBJECT_WRAPPER_" in classes: #$NON-NLS-1$
             return
         try:
             element.removeAttribute(u"class") #$NON-NLS-1$
             classes.remove( u"_Z_RAVEN_OBJECT_WRAPPER_" ) #$NON-NLS-1$
             objNode = element.ownerDocument.createElement(u"object") #$NON-NLS-1$
             objNode.setAttribute( u"width", element.getAttribute(u"width") ) #$NON-NLS-1$ #$NON-NLS-2$
             objNode.setAttribute( u"height", element.getAttribute(u"height") ) #$NON-NLS-1$ #$NON-NLS-2$
             paramNode = element.ownerDocument.createElement(u"param") #$NON-NLS-1$
             paramNode.setAttribute( u"name", u"movie" ) #$NON-NLS-1$ #$NON-NLS-2$
             paramNode.setAttribute( u"value", element.getAttribute(u"src") ) #$NON-NLS-1$ #$NON-NLS-2$
             objNode.appendChild(paramNode)
             paramNode = element.ownerDocument.createElement(u"param") #$NON-NLS-1$
             paramNode.setAttribute( u"name", u"wmode" ) #$NON-NLS-1$ #$NON-NLS-2$
             paramNode.setAttribute( u"value", element.getAttribute(u"wmode") ) #$NON-NLS-1$ #$NON-NLS-2$
             objNode.appendChild(paramNode)
             if classes:
                 objNode.setAttribute(u"class", u" ".join(classes).strip() ) #$NON-NLS-2$ #$NON-NLS-1$
             element.parentNode.replaceChild(objNode, element)
             objNode.appendChild(element)
         except:
             pass
Beispiel #15
0
    def setInitDocument(self, document):
        u"""setInitDocument(IZBlogDocument) -> void
        Copies the document data to the model.""" #$NON-NLS-1$
        # Initialize the model data  with the given document
        title = getSafeString(document.getTitle())
        self.setTitle(title)

        self.setTagwords(u"")  #$NON-NLS-1$
        # get tagwords based on default NS
        iZTagwordsObj = document.getTagwords(
            IZBlogPubTagwordNamespaces.DEFAULT_TAGWORDS_URI)
        if not iZTagwordsObj:
            # legacy, pre alpha build 132 support. check technorati ns. # FIXME (PJ) remove technorati tags NS for final release
            iZTagwordsObj = document.getTagwords(
                u"http://technorati.com/tag/")  #$NON-NLS-1$
        if iZTagwordsObj:
            self.setTagwords(iZTagwordsObj.getValue())

        # Use any existing pub meta data if it exists, else fall back to
        # blog info list data.
        pubMetaDataList = document.getPubMetaDataList()
        if pubMetaDataList is None or len(pubMetaDataList) == 0:
            pubMetaDataList = []
            # create pub meta data from blog info list.
            blogInfoList = document.getBlogInfoList()
            if blogInfoList is not None and len(blogInfoList) > 0:
                for blogInfo in blogInfoList:
                    pubMetaData = self._createPubMetaData(blogInfo)
                    pubMetaDataList.append(pubMetaData)

        if pubMetaDataList is not None:
            self.setPubMetaDataList(pubMetaDataList)
Beispiel #16
0
    def _applyListMarkup(self, listTag):
        handleLocallly = False
        tr = self.getSelectedTextRange()
        if tr:
            ele = tr.parentElement()
            if ele and tr.text == ele.innerText and ele.tagName != u"BODY": #$NON-NLS-1$
                pass 
            elif ele and ele.outerHTML == tr.htmlText:
                pass
            else:
                html = tr.htmlText.strip(u"\n\r\ ") #$NON-NLS-1$
                # handle locally if selection is a text fragment (i.e does not have <P> etc)
                handleLocallly = html and html[0] != u"<" #$NON-NLS-1$

        if handleLocallly: 
            # listTag = ou | ul on a text selection (instead of whole para)
            listTag = getSafeString(listTag).lower()
            if listTag not in (u"ol", u"ul"): #$NON-NLS-1$ #$NON-NLS-2$
                listTag = u"ul" #$NON-NLS-1$
            openTag = u"<%s><li>" % listTag #$NON-NLS-1$
            closeTag = u"</li></%s>" % listTag #$NON-NLS-1$
            self._wrapSelection(openTag, closeTag)
            
        elif listTag in (u"ol", u"ul"): #$NON-NLS-1$ #$NON-NLS-2$
            # Let IE handle it. IE will take care of handling multiple paras into a multline bullet
            if listTag == u"ol":             #$NON-NLS-1$
                ZMSHTMLControlBase.execCommand(self, u"InsertOrderedList", None) #$NON-NLS-1$
            else:
                ZMSHTMLControlBase.execCommand(self, u"InsertUnOrderedList", None) #$NON-NLS-1$
            # Assume exec command modifies the document.
            self._fireContentModified()            
Beispiel #17
0
 def _createLabelFromProperty(self, siteProp):
     label = getSafeString(siteProp.getDisplayName())
     if siteProp.getType() == u"checkbox": #$NON-NLS-1$
         label = u"" #$NON-NLS-1$
     else:
         label = label + u":" #$NON-NLS-1$
     return wx.StaticText(self, wx.ID_ANY, label)
Beispiel #18
0
    def _applyListMarkup(self, listTag):
        handleLocallly = False
        tr = self.getSelectedTextRange()
        if tr:
            ele = tr.parentElement()
            if ele and tr.text == ele.innerText and ele.tagName != u"BODY":  #$NON-NLS-1$
                pass
            elif ele and ele.outerHTML == tr.htmlText:
                pass
            else:
                html = tr.htmlText.strip(u"\n\r\ ")  #$NON-NLS-1$
                # handle locally if selection is a text fragment (i.e does not have <P> etc)
                handleLocallly = html and html[0] != u"<"  #$NON-NLS-1$

        if handleLocallly:
            # listTag = ou | ul on a text selection (instead of whole para)
            listTag = getSafeString(listTag).lower()
            if listTag not in (u"ol", u"ul"):  #$NON-NLS-1$ #$NON-NLS-2$
                listTag = u"ul"  #$NON-NLS-1$
            openTag = u"<%s><li>" % listTag  #$NON-NLS-1$
            closeTag = u"</li></%s>" % listTag  #$NON-NLS-1$
            self._wrapSelection(openTag, closeTag)

        elif listTag in (u"ol", u"ul"):  #$NON-NLS-1$ #$NON-NLS-2$
            # Let IE handle it. IE will take care of handling multiple paras into a multline bullet
            if listTag == u"ol":  #$NON-NLS-1$
                ZMSHTMLControlBase.execCommand(self, u"InsertOrderedList",
                                               None)  #$NON-NLS-1$
            else:
                ZMSHTMLControlBase.execCommand(self, u"InsertUnOrderedList",
                                               None)  #$NON-NLS-1$
            # Assume exec command modifies the document.
            self._fireContentModified()
Beispiel #19
0
    def getMisspelledWordData(self, spellCheckResult):
        u"""getMisspelledWordData(IZSpellCheckResult) -> (string, int, int)
        Returns tuple (misspelled_sentence, startPos, endPos) based on the current result.
        The misspelled_sentence includes the misspelled word and any surrounding words.
        startPos and endPos are the character position of the misspelled word within
        the misspelled_sentence.
        """ #$NON-NLS-1$
        sentence = u"" #$NON-NLS-1$
        startPos = 0
        endPos = 0
        if spellCheckResult:
            try:
                if spellCheckResult.getWordContext():
                    sentence = spellCheckResult.getWordContext()
                    (startPos, endPos) = spellCheckResult.getRangeInContext()
                else:
                    sentence = getSafeString( spellCheckResult.getWord() ).strip()
                    endPos = len(sentence)
            except:
                pass
        #
        return (sentence, startPos, endPos)
    # end getMisspelledWordData()

# end ZSpellCheckModel
Beispiel #20
0
 def _createPubMetaData(self, blogInfo):
     pubMetaData = createDefaultPubMetaData(blogInfo.getAccountId(),
                                            blogInfo.getBlogId())
     pubMetaData.setPublishAsDraft(blogInfo.getPublishInfo().isDraft())
     pubMetaData.setPublishTime(
         blogInfo.getPublishInfo().getPublishedTime())
     categories = blogInfo.getCategories()
     if categories is not None and len(categories) > 0:
         for category in categories:
             pubMetaData.addCategory(category)
     # WP custom attrs
     slug = getNoneString(
         getWPPublishedInfoAttribute(blogInfo.getPublishInfo(),
                                     u"wp_slug"))  #$NON-NLS-1$
     if slug:
         setCustomWPMetaDataAttribute(pubMetaData, u"wp_slug",
                                      slug)  #$NON-NLS-1$
     pw = getSafeString(
         getWPPublishedInfoAttribute(blogInfo.getPublishInfo(),
                                     u"wp_password"))  #$NON-NLS-1$
     setCustomWPMetaDataAttribute(pubMetaData, u"wp_password",
                                  pw)  #$NON-NLS-1$
     status = getNoneString(
         getWPPublishedInfoAttribute(blogInfo.getPublishInfo(),
                                     u"post_status"))  #$NON-NLS-1$
     if status:
         setCustomWPMetaDataAttribute(pubMetaData, u"post_status",
                                      status)  #$NON-NLS-1$
     return pubMetaData
Beispiel #21
0
    def getMisspelledWordData(self, spellCheckResult):
        u"""getMisspelledWordData(IZSpellCheckResult) -> (string, int, int)
        Returns tuple (misspelled_sentence, startPos, endPos) based on the current result.
        The misspelled_sentence includes the misspelled word and any surrounding words.
        startPos and endPos are the character position of the misspelled word within
        the misspelled_sentence.
        """ #$NON-NLS-1$
        sentence = u""  #$NON-NLS-1$
        startPos = 0
        endPos = 0
        if spellCheckResult:
            try:
                if spellCheckResult.getWordContext():
                    sentence = spellCheckResult.getWordContext()
                    (startPos, endPos) = spellCheckResult.getRangeInContext()
                else:
                    sentence = getSafeString(
                        spellCheckResult.getWord()).strip()
                    endPos = len(sentence)
            except:
                pass
        #
        return (sentence, startPos, endPos)

    # end getMisspelledWordData()


# end ZSpellCheckModel
    def _getAlbumName(self):
        if u"albumName" in self.properties: #$NON-NLS-1$
            return getSafeString(self.properties[u"albumName"]) #$NON-NLS-1$
        return None
    # end _getAlbumName()

# end ZLJFotoBilderStorageProvider
    def _populateServerEntry(self, zserverBlogEntry, zblog, zblogDocument,
                             zxhtmlDocument, zpubinfo):
        # Populate a ZServerBlogEntry given raven pubmeta data and post content.
        # Note: zpubinfo is valid only when updating existing post. It is None when posting new entry.
        pubmetadata = self._getPubMetaData(zblog, zblogDocument)
        title = zblogDocument.getTitle()
        content = self._transformContentForPublishing(zblog, zxhtmlDocument)

        zserverBlogEntry.setTitle(title)
        zserverBlogEntry.setContent(content)
        pubSchemaDT = pubmetadata.getPublishTime()

        # set pub time.
        if pubSchemaDT:
            # if user has specified a pub datetime, then use it.
            zserverBlogEntry.setUtcDateTime(
                pubSchemaDT.getDateTime())  # getDateTime
        elif zpubinfo:
            # if updating existing post, then use the previouslty published time
            publishedSchemaDt = zpubinfo.getPublishedTime()
            zserverBlogEntry.setUtcDateTime(publishedSchemaDt.getDateTime())
        else:
            # default to current time.
            nowDT = getCurrentUtcDateTime()
            zserverBlogEntry.setUtcDateTime(nowDT)

        zserverBlogEntry.setDraft(pubmetadata.isPublishAsDraft())
        for ravenCat in pubmetadata.getCategories():
            serverCatId = self._getServerId(ravenCat.getId())
            serverCat = ZServerBlogCategory(serverCatId, ravenCat.getName())
            self._copyAttrsFromRavenToServer(ravenCat, serverCat)
            zserverBlogEntry.addCategory(serverCat)

        # zblogDocument::getTagwordsList() -> list of ZTagwords (a ZTagwords is a list of words per site e.g. Technorati)
        listOfWords = getWordListFromZTagwords(zblogDocument.getTagwordsList())
        zserverBlogEntry.setTagwords(listOfWords)

        # custom meta data. (WP slug, password and post status
        slug = getCustomWPMetaDataAttribute(pubmetadata,
                                            u"wp_slug")  #$NON-NLS-1$
        if slug is not None:
            zserverBlogEntry.setAttribute(
                u"wp_slug", slug,
                IZBlogPubAttrNamespaces.WP_ATTR_NAMESPACE)  #$NON-NLS-1$
        status = getNoneString(
            getCustomWPMetaDataAttribute(pubmetadata,
                                         u"post_status"))  #$NON-NLS-1$
        if status:
            zserverBlogEntry.setAttribute(
                u"post_status", status,
                IZBlogPubAttrNamespaces.WP_ATTR_NAMESPACE)  #$NON-NLS-1$
        pw = getSafeString(
            getCustomWPMetaDataAttribute(pubmetadata,
                                         u"wp_password"))  #$NON-NLS-1$
        zserverBlogEntry.setAttribute(
            u"wp_password", pw,
            IZBlogPubAttrNamespaces.WP_ATTR_NAMESPACE)  #$NON-NLS-1$

        return zserverBlogEntry
Beispiel #24
0
 def createXhtmlDocument(self):
     u"""createXhtmlDocument() -> ZXhtmlDocument"""  #$NON-NLS-1$
     file = getSafeString(self.izBlogThisInformation.getFile())
     xhtmlDom = None
     if os.path.exists(file):
         try:
             xhtmlDom = loadXhtmlDocumentFromFile(file)
             return xhtmlDom
         except:
             pass
     # create new doc since file content was not found
     title = getSafeString(self.izBlogThisInformation.getTitle())
     htmlString = u"<html><head><title>%s</title></head><body></body></html>" % title  #$NON-NLS-1$
     xhtmlDoc = loadXhtmlDocumentFromString(htmlString)
     bodyNode = xhtmlDoc.getBody()
     self._createXhtmlContent(bodyNode)
     return xhtmlDoc
Beispiel #25
0
 def onPasswordChanged(self, event):
     if self.enableCB.GetValue():
         s = getSafeString(self.passwordTxt.GetValue())
         if s:
             s = crypt.encryptPlainText(s, PASSWORD_ENCRYPTION_KEY)
         self.session.setUserPreference(IZAppUserPrefsKeys.PROXY_PASSWORD, s)            
         self.onSessionChange()            
     event.Skip()
Beispiel #26
0
 def _getHostPortFromUI(self):        
     host = getSafeString( self.hostTxt.GetValue() )
     port = getSafeString( self.portTxt.GetValue() )
     if host.lower().startswith(u"http"): #$NON-NLS-1$
         (scheme, netloc, path, query, fragment) = urlsplit(host, u"http") #$NON-NLS-1$ @UnusedVariable
         desHostPort = netloc.split(u":") #$NON-NLS-1$
         h = desHostPort[0]
         p = u"80" #$NON-NLS-1$
         if len(desHostPort) == 2:
             p = desHostPort[1]
         if scheme == u"ssl" and p == u"80": #$NON-NLS-1$ #$NON-NLS-2$
             p = u"443" #$NON-NLS-1$
         if h:
             host = h
         if not port and p:
             port = p
     return (host, port)
Beispiel #27
0
 def createXhtmlDocument(self):
     u"""createXhtmlDocument() -> ZXhtmlDocument""" #$NON-NLS-1$
     file = getSafeString( self.izBlogThisInformation.getFile() )
     xhtmlDom = None
     if os.path.exists(file):
         try:
             xhtmlDom = loadXhtmlDocumentFromFile(file)
             return xhtmlDom
         except:
             pass
     # create new doc since file content was not found
     title = getSafeString( self.izBlogThisInformation.getTitle() )
     htmlString = u"<html><head><title>%s</title></head><body></body></html>" % title #$NON-NLS-1$
     xhtmlDoc = loadXhtmlDocumentFromString(htmlString)
     bodyNode = xhtmlDoc.getBody()
     self._createXhtmlContent(bodyNode)
     return xhtmlDoc
Beispiel #28
0
 def onDataChanged(self, event):
     if self.enableCB.GetValue():
         (h, p) = self._getHostPortFromUI()
         self.session.setUserPreference(IZAppUserPrefsKeys.PROXY_HOST, h)
         self.session.setUserPreference(IZAppUserPrefsKeys.PROXY_PORT, p)
         self.session.setUserPreference(IZAppUserPrefsKeys.PROXY_USERNAME, getSafeString(self.usernameTxt.GetValue()))
         self.onSessionChange()            
     event.Skip()
Beispiel #29
0
 def __init__(self, term, label = None, scheme = None):
     self.term = term
     self.label = label
     self.scheme = scheme
     name = getNoneString(label)
     if not name:
         name = getSafeString(term)
     ZServerBlogCategory.__init__(self, term, name)
Beispiel #30
0
 def _getHandlerClass(self, scheme):
     clazz = None
     scheme = getSafeString(scheme).lower()
     for (tmpScheme, tmpClazz) in self.handlerClases:  #@UnusedVariable
         if tmpScheme == scheme:
             clazz = tmpClazz
             break
     return clazz
Beispiel #31
0
 def _getHandlerClass(self, scheme):
     clazz = None
     scheme = getSafeString(scheme).lower()
     for (tmpScheme, tmpClazz) in self.handlerClases: #@UnusedVariable
         if tmpScheme == scheme:
             clazz = tmpClazz
             break
     return clazz
    def _populateContentWidgets(self):
        self._refreshCombos()

        text = getSafeString(self.findReplaceModel.getFindText())
        self.findwordCntrl.SetValue(text)
        if len(text) == 0:
            self.findwordCntrl.SetFocus()
        else:
            self.replacewordCntrl.SetFocus()
Beispiel #33
0
 def onTranslationUnfocus(self, event):
     value = self.translationText.GetValue()
     # if there is a selection, and the value has changed
     if self.selectedKey is not None and value != self.selectedValue:
         value = getSafeString(value).strip()
         self.model.setTranslationValue(self.selectedKey, value)
         self.listBox.refresh()
     self.translationText.Enable(False)
     event.Skip()
 def onAttached(self, task, numCompletedWorkUnits): #@UnusedVariable
     self.mutex.acquire()
     try:
         self.model.setCurrentWorkText(getSafeString(task.getLastLogMessage()))
         self.model.setCurrentWorkAmount(numCompletedWorkUnits)
         self.model.setRunning(task.isRunning())
     finally:
         self.mutex.release()
         fireRefreshEvent(self)
Beispiel #35
0
    def _doListSelection(self):
        selectionIdx = self.listBox.getSelection()[0]
        self.selectedKey = self.model.getKeys()[selectionIdx]
        defValue = self.model.getDefaultValue(self.selectedKey)
        transValue = self.model.getTranslationValue(self.selectedKey)
        self.selectedValue = getSafeString(transValue).strip()

        self.englishText.SetValue(defValue)
        self.translationText.SetValue(self.selectedValue)
Beispiel #36
0
 def __init__(self, id, name, url):
     name = getNoneString(name)
     id = getSafeString(id)
     if not name: #$NON-NLS-1$
         name = u"untitled blog" #$NON-NLS-1$
         if id != u"": #$NON-NLS-1$
             name = name + u" (" + id + u")" #$NON-NLS-2$ #$NON-NLS-1$
     ZNamedServerBase.__init__(self, id, name)
     self._setUrl(url)
 def onTranslationUnfocus(self, event):
     value = self.translationText.GetValue()
     # if there is a selection, and the value has changed
     if self.selectedKey is not None and value != self.selectedValue:
         value = getSafeString(value).strip()
         self.model.setTranslationValue(self.selectedKey, value)
         self.listBox.refresh()
     self.translationText.Enable(False)
     event.Skip()
 def onWorkDone(self, task, amount, text): #@UnusedVariable
     self.mutex.acquire()
     try:
         newWorkAmount = self.model.getCurrentWorkAmount() + amount
         self.model.setCurrentWorkAmount(newWorkAmount)
         self.model.setCurrentWorkText(getSafeString(text))
     finally:
         self.mutex.release()
         fireRefreshEvent(self)
Beispiel #39
0
    def _getAlbumName(self):
        if u"albumName" in self.properties:  #$NON-NLS-1$
            return getSafeString(self.properties[u"albumName"])  #$NON-NLS-1$
        return None

    # end _getAlbumName()


# end ZLJFotoBilderStorageProvider
    def _doListSelection(self):
        selectionIdx = self.listBox.getSelection()[0]
        self.selectedKey = self.model.getKeys()[selectionIdx]
        defValue = self.model.getDefaultValue(self.selectedKey)
        transValue = self.model.getTranslationValue(self.selectedKey)
        self.selectedValue = getSafeString(transValue).strip()

        self.englishText.SetValue(defValue)
        self.translationText.SetValue(self.selectedValue)
Beispiel #41
0
    def visitElement(self, element):
        elementStr = getSafeString(element.selectRaw(u"string(.)")) #$NON-NLS-1$
        elementStr = string.strip(elementStr)
        elementStr = self._trim(elementStr)
        if elementStr == self.trimmedCriteriaStr and self.isInBody:
            self.elements.append(element)

        if element.nodeName.lower() == u"body": #$NON-NLS-1$
            self.isInBody = True
Beispiel #42
0
    def _populateContentWidgets(self):
        self._refreshCombos()

        text = getSafeString(self.findReplaceModel.getFindText())
        self.findwordCntrl.SetValue(text)
        if len(text) == 0:
            self.findwordCntrl.SetFocus()
        else:
            self.replacewordCntrl.SetFocus()
Beispiel #43
0
 def onWorkDone(self, task, amount, text):  #@UnusedVariable
     self.mutex.acquire()
     try:
         newWorkAmount = self.model.getCurrentWorkAmount() + amount
         self.model.setCurrentWorkAmount(newWorkAmount)
         self.model.setCurrentWorkText(getSafeString(text))
     finally:
         self.mutex.release()
         fireRefreshEvent(self)
Beispiel #44
0
    def _internalPing(self, extendedPing, pingServerUrl, weblogName, weblogUrl, checkUrl = None, rssUrl = None):
        pingServerUrl = getNoneString(pingServerUrl)
        weblogName = getNoneString(weblogName)
        weblogUrl = getNoneString(weblogUrl)
        checkUrl = getSafeString(checkUrl).strip()
        rssUrl = getSafeString(rssUrl).strip()

        if pingServerUrl is None:
            return ZWeblogPingResponse(False, u"Weblog ping URL is required.") #$NON-NLS-1$

        if weblogName is None:
            return ZWeblogPingResponse(False, u"Weblog name or post title is required.") #$NON-NLS-1$

        if weblogUrl is None:
            return ZWeblogPingResponse(False, u"Weblog URL or post permanent link is required.") #$NON-NLS-1$

        if extendedPing and (checkUrl == u"" or rssUrl == u""): #$NON-NLS-1$ #$NON-NLS-2$
            return ZWeblogPingResponse(False, u"URL to RSS feed or Check URL parameter is required for ExtendedPings.") #$NON-NLS-1$

        success = False
        message = u"" #$NON-NLS-1$
        try:
            remoteServer = Server(pingServerUrl)
            result = None
            if extendedPing:
                result = remoteServer.weblogUpdate.extendedPing(weblogName, weblogUrl, checkUrl, rssUrl)
            else:
                result = remoteServer.weblogUpdates.ping(weblogName, weblogUrl)
            if result is not None and result.has_key(u"flerror"): #$NON-NLS-1$
                success = not result[u"flerror"] #$NON-NLS-1$
            if result is not None and result.has_key(u"message"): #$NON-NLS-1$
                message = result[u"message"] #$NON-NLS-1$
            elif not result or not result.has_key(u"message"): #$NON-NLS-1$
                message = u"Weblog ping response message not available after pinging %s" % pingServerUrl #$NON-NLS-1$
        except Fault, fault:
            fcode = u"" #$NON-NLS-1$
            if fault.faultCode:
                fcode = unicode(fault.faultCode)
            fstr = u"" #$NON-NLS-1$
            if fault.faultString:
                fstr = convertToUnicode(fault.faultString)
            success = False
            message = u"Weblog ping faulted when pinging %s (code: %s, reason: %s)" % (pingServerUrl, fcode, fstr) #$NON-NLS-1$
Beispiel #45
0
    def visitElement(self, element):
        elementStr = getSafeString(
            element.selectRaw(u"string(.)"))  #$NON-NLS-1$
        elementStr = string.strip(elementStr)
        elementStr = self._trim(elementStr)
        if elementStr == self.trimmedCriteriaStr and self.isInBody:
            self.elements.append(element)

        if element.nodeName.lower() == u"body":  #$NON-NLS-1$
            self.isInBody = True
Beispiel #46
0
 def onAttached(self, task, numCompletedWorkUnits):  #@UnusedVariable
     self.mutex.acquire()
     try:
         self.model.setCurrentWorkText(
             getSafeString(task.getLastLogMessage()))
         self.model.setCurrentWorkAmount(numCompletedWorkUnits)
         self.model.setRunning(task.isRunning())
     finally:
         self.mutex.release()
         fireRefreshEvent(self)
 def supportsFile(self, fileName): #@UnusedVariable
     ext = getSafeString( getFileExtension(fileName) ).lower()
     # for image upload, store must support image types or all types
     if ext and ext in self.imgExtensions and self.getCapabilities().supportsImageFiles():
         return True
     # for video upload, store must support video file types or all types
     if ext and ext in self.movExtensions and self.getCapabilities().supportsVideoFiles():
         return True        
     #default case - must support anytype
     return self.getCapabilities().supportsAnyFile()
Beispiel #48
0
 def _isEnabled(self, imageContext):
     en = ZBlogPostEditableImageActionBase._isEnabled(self, imageContext)
     if en:
         attrs = imageContext.getImageAttributes()
         style = None
         if attrs.has_key(u"border"):  #$NON-NLS-1$
             (width, style, zcssColor) = parseCssBorderProperty(
                 getSafeString(
                     attrs[u"border"]))  #$NON-NLS-1$ @UnusedVariable
         return style is None or style != self.borderStyle
     else:
         return False
Beispiel #49
0
 def supportsFile(self, fileName):  #@UnusedVariable
     ext = getSafeString(getFileExtension(fileName)).lower()
     # for image upload, store must support image types or all types
     if ext and ext in self.imgExtensions and self.getCapabilities(
     ).supportsImageFiles():
         return True
     # for video upload, store must support video file types or all types
     if ext and ext in self.movExtensions and self.getCapabilities(
     ).supportsVideoFiles():
         return True
     #default case - must support anytype
     return self.getCapabilities().supportsAnyFile()
Beispiel #50
0
    def _serializeTemplate(self, parentElem, template):
        rootFileNameElem = parentElem.ownerDocument.createElement(u"root", self.namespace) #$NON-NLS-1$
        parentElem.appendChild(rootFileNameElem)
        if template.getRootFileName():
            rootFileNameElem.setText(template.getRootFileName())

        nameElem = parentElem.ownerDocument.createElement(u"name", self.namespace) #$NON-NLS-1$
        parentElem.appendChild(nameElem)
        if template.getCreationTime():
            nameElem.setText(getSafeString(template.getName()))

        sourceElem = parentElem.ownerDocument.createElement(u"source", self.namespace) #$NON-NLS-1$
        parentElem.appendChild(sourceElem)
        if template.getCreationTime():
            sourceElem.setText(getSafeString(template.getSource()))

        allFileElem = parentElem.ownerDocument.createElement(u"allFile", self.namespace) #$NON-NLS-1$
        parentElem.appendChild(allFileElem)
        if template.getCreationTime():
            allFileElem.setText(getSafeString(template.getAllFileName()))

        bodyAndTitleFileElem = parentElem.ownerDocument.createElement(u"bodyAndTitleFile", self.namespace) #$NON-NLS-1$
        parentElem.appendChild(bodyAndTitleFileElem)
        if template.getCreationTime():
            bodyAndTitleFileElem.setText(getSafeString(template.getTitleAndBodyFileName()))

        bodyOnlyFileElem = parentElem.ownerDocument.createElement(u"bodyOnlyFile", self.namespace) #$NON-NLS-1$
        parentElem.appendChild(bodyOnlyFileElem)
        if template.getCreationTime():
            bodyOnlyFileElem.setText(getSafeString(template.getBodyOnlyFileName()))

        creationTimeElem = parentElem.ownerDocument.createElement(u"creationTime", self.namespace) #$NON-NLS-1$
        parentElem.appendChild(creationTimeElem)
        if template.getCreationTime():
            creationTimeElem.setText(unicode(template.getCreationTime()))

        lastModifiedTimeElem = parentElem.ownerDocument.createElement(u"lastModifiedTime", self.namespace) #$NON-NLS-1$
        parentElem.appendChild(lastModifiedTimeElem)
        if template.getLastModifiedTime():
            lastModifiedTimeElem.setText(unicode(template.getLastModifiedTime()))
Beispiel #51
0
 def getBlogPublisherMediaStoragesByAccount(self, accountId):
     # Returns list of stores for the given account that of type 'blog publisher'
     rval = []
     for store in self.mediaStoreService.getMediaStorages():
         if not self._isBlogPublisherTypeStore(store):
             continue
         # store is of type BLOGPUBLISHER_MEDIA_STORE_TYPE_ID
         props = store.getProperties()
         if props.has_key(u"account-id") and getSafeString(
                 props[u"account-id"]
         ) == accountId:  #$NON-NLS-1$ #$NON-NLS-2$
             rval.append(store)
     return rval
Beispiel #52
0
    def setPubMetaData(self, pubMetaData):
        # Updates the UI controls based on the data in pubMetaData
        self.draftCB.SetValue(pubMetaData.isPublishAsDraft())
        pubTime = pubMetaData.getPublishTime()
        if pubTime is not None:
            self.overridePubTimeCB.SetValue(True)
            self.dateCtrl.Enable(True)
            self.dateCtrl.setDateTime(pubTime)
        self.thumbnailsOnlyCB.SetValue(pubMetaData.isUploadTNsOnly())
        self.forceUploadCB.SetValue(pubMetaData.isForceReUploadImages())
        self.lightboxCB.SetValue(pubMetaData.isAddLightbox())
        self.poweredByZoundryCB.SetValue(pubMetaData.isAddPoweredBy())

        # WP custom data
        slug = getSafeString(
            getCustomWPMetaDataAttribute(pubMetaData,
                                         u"wp_slug"))  #$NON-NLS-1$
        self.wpPostSlugTextCtrl.SetValue(slug)
        # WP password
        s = getSafeString(
            getCustomWPMetaDataAttribute(pubMetaData,
                                         u"wp_password"))  #$NON-NLS-1$
        self.wpPasswordTextCtrl.SetValue(s)

        # WP pub status
        self.wpPublishStatusValue = ZPubMetaDataView.WP_PUBLISHED
        s = getSafeString(
            getCustomWPMetaDataAttribute(pubMetaData,
                                         u"post_status"))  #$NON-NLS-1$

        if s == u"pending":  #$NON-NLS-1$
            self.wpPublishStatusValue = ZPubMetaDataView.WP_PENDING
        elif s == u"private":  #$NON-NLS-1$
            self.wpPublishStatusValue = ZPubMetaDataView.WP_PRIVATE
        elif s == u"draft" or pubMetaData.isPublishAsDraft():  #$NON-NLS-1$
            self.wpPublishStatusValue = ZPubMetaDataView.WP_DRAFT

        self.wpPubStatusCombo.SetSelection(self.wpPublishStatusValue)
Beispiel #53
0
 def createBlogDocument(self):
     u"""createBlogDocument( -> IZBlogDocument"""  #$NON-NLS-1$
     xhtmlDoc = self.createXhtmlDocument()
     doc = ZBlogDocument()
     title = getNoneString(self.izBlogThisInformation.getTitle())
     if not title:
         title = getSafeString(xhtmlDoc.getTitle())
     doc.setTitle(title)
     content = ZXhtmlContent()
     content.setMode(u"xml")  #$NON-NLS-1$
     content.setType(u"application/xhtml+xml")  #$NON-NLS-1$
     content.setXhtmlDocument(xhtmlDoc)
     doc.setContent(content)
     return doc
Beispiel #54
0
    def _escape(self, s):
        s = getSafeString(s)
        s = s.replace(u"&apos;", u"'")  #$NON-NLS-1$ #$NON-NLS-2$
        s = s.replace(u"&amp;", u"&")  #$NON-NLS-1$ #$NON-NLS-2$
        s = s.replace(u"&quot;", u'\"')  #$NON-NLS-1$ #$NON-NLS-2$
        s = s.replace(u"&nbsp;", u" ")  #$NON-NLS-1$ #$NON-NLS-2$
        s = s.replace(u"&lt;", u"<")  #$NON-NLS-1$ #$NON-NLS-2$
        s = s.replace(u"&gt;", u">")  #$NON-NLS-1$ #$NON-NLS-2$
        return s

    # end escape


# end ZBlogThisHandler
Beispiel #55
0
 def _sendTrackbacks(self, trackbackUrlList):
     blog = self._getContext().getBlog()
     blogName = getNoneString(blog.getName())
     id = blog.getUrl()
     title = self._getContext().getTitle()
     if blogName is None:
         blogName = title
     # get the post entry url.
     postUrl = getNoneString(self._getContext().getUrl())
     if not postUrl:
         pass
         #log error and return
     if not id:
         id = postUrl
     # post summary
     excerpt = self._getContext().getXhtmlDocument().getSummary(500)
     pinger = ZTrackbackPinger()
     sentCount = 0
     for pingUrl in trackbackUrlList:
         if self.isCancelled():
             return
         s = u"Sending trackback to %s" % pingUrl  #$NON-NLS-1$
         self._getContext().logInfo(self, s)
         self._getContext().notifyProgress(self, s, 1, False)
         ok = False
         msg = u""  #$NON-NLS-1$
         try:
             response = pinger.ping(pingUrl, id, postUrl, title, blogName,
                                    excerpt)
             ok = response.isSuccessful()
             msg = getSafeString(response.getMessage())
         except Exception, e:
             ok = False
             msg = unicode(e)
         if ok:
             trackback = ZTrackback()
             trackback.setUrl(pingUrl)  #$NON-NLS-1$
             trackback.setSentDate(ZSchemaDateTime())
             pubInfo = self._getPubInfo()
             if pubInfo:
                 pubInfo.addTrackback(trackback)
             sentCount = sentCount + 1
             s = u"Trackback sent successfully: %s" % msg  #$NON-NLS-1$
             self._getContext().logInfo(self, s)
             self._getContext().notifyProgress(self, s, 0, False)
         else:
             s = u"Trackback failed: %s" % msg  #$NON-NLS-1$
             self._getContext().logError(self, s)
             self._getContext().notifyProgress(self, s, 0, False)