예제 #1
0
    def updateDynamic(self):
               
        text = readFile(self.getFullName())
        
        if text.find("<maker_dynamic") == -1:
            # no dynamics
            return

        
        if self.core.getFilesByExtension(".dynamic") != []:
        
#            print "project dynamics"
#            for x in self.core.filterFilesByLanguage(self.core.getFilesByExtension(".dynamic")):
#                print x
#            
            
            for i in self.core.filterFilesByLanguage(self.core.getFilesByExtension(".dynamic")):
                # self.output("replacing dynamic: %s" % str(i))
                # TO DO 
                # make this faster
                dynamicContent = readFile(self.core.getPathParts()+i+".dynamic")
                newtext = text.replace(str("<maker_dynamic:" + i + " />").encode(self.core.encoding), dynamicContent) 
                text = newtext
                # ---
            
            writeFile(self.getFullName(), newtext)
예제 #2
0
    def save(self, event=None):

        text = self.fileController.getTextFromEditor()
        if text == "Encoding Error":
            return
        writeFile(
            os.path.join(self.core.getPathParts(),
                         self.getName() + self.type), text)

        self.setSaved()

        self.curr = self.core.getCurrentFile()

        filesUsingThisDynamic = self.core.findContentFilesContainingThisDynamic(
            self.getName())

        if filesUsingThisDynamic != []:

            fileList = ""

            for x in filesUsingThisDynamic:
                self.core.addToFtpQueue(x + ".content")
                fileList = fileList + x + ".content\n"
                self.core.justInitFile(x, ".content")
                self.core.currentFile.makeWebSite()
                #print "Curr ", self.curr.getName()

            self.core.setCurrentFile(self.curr)
예제 #3
0
    def updateDynamic(self):

        text = readFile(self.getFullName())

        if text.find("<maker_dynamic") == -1:
            # no dynamics
            return

        if self.core.getFilesByExtension(".dynamic") != []:

            #            print "project dynamics"
            #            for x in self.core.filterFilesByLanguage(self.core.getFilesByExtension(".dynamic")):
            #                print x
            #

            for i in self.core.filterFilesByLanguage(
                    self.core.getFilesByExtension(".dynamic")):
                # self.output("replacing dynamic: %s" % str(i))
                # TO DO
                # make this faster
                dynamicContent = readFile(self.core.getPathParts() + i +
                                          ".dynamic")
                newtext = text.replace(
                    str("<maker_dynamic:" + i + " />").encode(
                        self.core.encoding), dynamicContent)
                text = newtext
                # ---

            writeFile(self.getFullName(), newtext)
예제 #4
0
 def save(self, event=None):
     
     text = self.fileController.getTextFromEditor()
     if not text:
         return
     writeFile(os.path.join(self.core.getPathParts(), self.getName() + self.type), text)
             
     self.setSaved()
     
     self.curr = self.core.getCurrentFile()
     
     filesUsingThisDynamic = self.core.findContentFilesContainingThisDynamic(self.getName())
         
     if filesUsingThisDynamic != []:
         
         fileList = ""
         
         
         for x in filesUsingThisDynamic:
             self.core.addToFtpQueue(x + ".content")                
             fileList = fileList + x + ".content\n"
             self.core.justInitFile(x,".content")
             self.core.currentFile.makeWebSite()
             #print "Curr ", self.curr.getName()
             
         self.core.setCurrentFile(self.curr)
예제 #5
0
 def firstWrite(self):
     """ is a new file of this kind is created this method is called 
         writing the template to the file
     """
     writeFile(os.path.join(self.core.getPathParts(), 
                            self.getName() + self.type), 
                            self.getNewFileTemplate())
예제 #6
0
    def printViaBrowser(self):
        """
        Is sending the contents of the current file to a webbrowser for printing
        
        This printing method works for most text files 
        It is overridden in some derived classes
        """
        printHeader = """
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="expires" content="0" />
<title></title>
</head>
<body onLoad="javascript:window.print();">
<pre>"""
        
        source = readFile(os.path.join(self.core.getPathParts(), self.getName() + 
                                       self.getType()))
        
        
        aSource = source.replace("<", "&lt;")
        bSource = aSource.replace(">", "&gt;")
        
        
        theContent = printHeader + bSource
        theContent += "</pre></html>" 
        
        writeFile(os.path.join(self.core.getProjectPath(), "makerPrintOut.html"), theContent)
        
        webbrowser.open("file:///" + os.path.join(self.core.getProjectPath(), "makerPrintOut.html"))
예제 #7
0
    def createRSSFeed(self, HTMLFile):
        """
        Creates an RSS 2.0 Feed from a given HTML File.
        The feed is saved under the same filename but with the extension .rss.
        It also extends the existing HTML file with a list of anchors.
        """

        content = readFile(HTMLFile)

        headlines = re.compile('<h1>(.*?)</h1>',
                               re.DOTALL | re.IGNORECASE).findall(content)

        # make sure to remove doubles from the list
        uniqueSet = Set(headlines)
        headlines = list(uniqueSet)

        for i in headlines:
            #
            # this might need some explanation
            #
            # * the anchor is attached BEFORE the h1 so we do not get in trouble
            # with exising anchors inside the h1 tag
            #
            # the style of the a tag is set to display none so it does not
            # interfere with existing styles and settings
            #
            this = "<h1>%s</h1>" % str(i)
            that = "<a name='" + i.replace(" ",
                                           "_") + "'> </a>\n<h1>" + i + "</h1>"
            new = content.replace(this, that)

            content = new

        # replace RSS link placeholder
        new = content.replace("!RSS!",
                              self.name.encode(self.core.encoding) + ".rss")
        content = new

        # write the updated HTML to File
        writeFile(HTMLFile, content)

        # create RSS Feed
        location = (self.core.getPageLocationsBySource(self.name + ".htm"))[0]

        rss = ""

        for i in headlines:
            link = urlparse.urljoin(self.core.getProjectURL(), location)
            link = link.encode(self.core.encoding) + "#" + i.replace(" ", "_")
            rss += "<item>"
            rss += "<title>%s</title>" % str(i)
            rss += "<link>%s</link>" % str(link)
            rss += "</item>\n"

        _head = readFile(os.path.join(self.core.getPathParts(), 'rss.head'))
        _foot = readFile(os.path.join(self.core.getPathParts(), 'rss.foot'))

        fName = os.path.join(self.core.getPathParts(), self.name + '.rss')
        writeFile(fName, _head + rss + _foot)
예제 #8
0
 def firstWrite(self):
     """ is a new file of this kind is created this method is called 
         writing the template to the file
     """
     writeFile(
         os.path.join(self.core.getPathParts(),
                      self.getName() + self.type),
         self.getNewFileTemplate())
예제 #9
0
 def save(self, event=None):
     
     text = self.fileController.getTextFromEditor()
     if not text:
         return
     writeFile(os.path.join(self.core.getPathParts(), self.getName() + self.type), text)
     self.setSaved()
     self.core.makeAll()
예제 #10
0
    def createRSSFeed(self, HTMLFile):
        """
        Creates an RSS 2.0 Feed from a given HTML File.
        The feed is saved under the same filename but with the extension .rss.
        It also extends the existing HTML file with a list of anchors.
        """

        content = readFile(HTMLFile)
        
        headlines  = re.compile('<h1>(.*?)</h1>', 
                                re.DOTALL |  re.IGNORECASE).findall(content)
        
        # make sure to remove doubles from the list        
        uniqueSet = Set(headlines)
        headlines = list(uniqueSet)
        
        for i in headlines:
            #
            # this might need some explanation
            #
            # * the anchor is attached BEFORE the h1 so we do not get in trouble
            # with exising anchors inside the h1 tag
            #
            # the style of the a tag is set to display none so it does not 
            # interfere with existing styles and settings
            #
            this = "<h1>%s</h1>" % str(i)
            that = "<a name='" + i.replace(" ", "_") + "'> </a>\n<h1>" + i + "</h1>"
            new = content.replace(this, that)

            content = new
            
        
        # replace RSS link placeholder        
        new = content.replace("!RSS!", self.name.encode(self.core.encoding)+".rss")
        content = new
        
        # write the updated HTML to File        
        writeFile(HTMLFile, content)

        # create RSS Feed
        location  = (self.core.getPageLocationsBySource(self.name+".htm"))[0]
        
        rss = ""
        
        for i in headlines:
            link = urlparse.urljoin(self.core.getProjectURL(), location)
            link = link.encode(self.core.encoding) + "#" + i.replace(" ", "_")
            rss +=  "<item>"
            rss += "<title>%s</title>" % str(i)
            rss += "<link>%s</link>" % str(link)
            rss += "</item>\n"
        
        _head = readFile(os.path.join(self.core.getPathParts(),'rss.head'))
        _foot = readFile(os.path.join(self.core.getPathParts(),'rss.foot'))

        fName  = os.path.join(self.core.getPathParts(),self.name+'.rss')
        writeFile(fName, _head + rss + _foot)
예제 #11
0
 def preview(self, theContent):
     
     filePath = self.core.getPathParts() + "tmp.htm" 
     writeFile(filePath, theContent)
             
     try:
         webbrowser.open('file://' + filePath, autoraise=0)    
     except: 
         print "unable to open ", urlToOpen
예제 #12
0
 def saveAsTemplate(self):
     
     # check if valid 
     text = self.fileController.getTextFromEditor()
     if text == "Encoding Error":
         return
     
     writeFile(os.path.join(self.core.getProjectPath(),"templates", self.getLanguage() + self.type), text)
     self.setSaved()
예제 #13
0
    def preview(self, theContent):

        filePath = self.core.getPathParts() + "tmp.htm"
        writeFile(filePath, theContent)

        try:
            webbrowser.open('file://' + filePath, autoraise=0)
        except:
            print "unable to open ", urlToOpen
예제 #14
0
 def save(self, event=None):
     
     text = self.fileController.getTextFromEditor()
     if not text:
         return
     writeFile(os.path.join(self.core.getPathParts(), self.getName() + self.type), text)
     self.setSaved()
     # this class is also used for the rss head 
     if self.getName() != "rss": 
         self.core.addToFtpQueue(self.getName() + ".content")
예제 #15
0
    def save(self, event=None):

        text = self.fileController.getTextFromEditor()
        if text == "Encoding Error":
            return
        writeFile(
            os.path.join(self.core.getPathParts(),
                         self.getName() + self.type), text)
        self.setSaved()
        self.core.makeAll()
예제 #16
0
 def save(self, event=None):
     text = self.fileController.getTextFromEditor()
     
     if text == "Encoding Error":
         return
     
     writeFile(os.path.join(self.core.getPathParts(), self.getName() + self.type), text)
     self.setSaved()
     
     self.core.addToFtpQueue(self.getFileName())
예제 #17
0
 def save(self, event=None):
     
     text = self.fileController.getTextFromEditor()
     if not text:
         return
     writeFile(os.path.join(self.core.getPathParts(), self.getName() + self.type), text)
     self.setSaved()
 
               
     self.makeWebSite(preview = True)
     self.core.addToFtpQueue(self.getFileName())
예제 #18
0
    def saveAsTemplate(self):

        # check if valid
        text = self.fileController.getTextFromEditor()
        if text == "Encoding Error":
            return

        writeFile(
            os.path.join(self.core.getProjectPath(), "templates",
                         self.getLanguage() + self.type), text)
        self.setSaved()
예제 #19
0
 def save(self, event=None):
     
     text = self.fileController.getTextFromEditor()
     if text == "Encoding Error":
         return
     writeFile(os.path.join(self.core.getPathParts(), self.getName() + self.type), text)
     self.setSaved()
     
     if self.getName() != "rss":
         
         self.core.makeAll()
예제 #20
0
    def preview(self, theContent):
        """Invokes MakeWebsite."""
        the_content = readFile(self.getEditModeName())

        writeFile(self.getEditModeName(), theContent)

        self.makeWebSite(preview=True)

        urlToOpen = 'file://' + self.core.getPathParts() + self.getRealName()
        webbrowser.open(urlToOpen, autoraise=1)
        writeFile(self.getEditModeName(), the_content)
예제 #21
0
    def preview(self, theContent):
        """Invokes MakeWebsite."""
        the_content = readFile(self.getEditModeName())

        writeFile(self.getEditModeName(), theContent)
                
        self.makeWebSite(preview = True)

        urlToOpen = 'file://'+self.core.getPathParts()+self.getRealName()
        webbrowser.open(urlToOpen, autoraise=1)
        writeFile(self.getEditModeName(), the_content)
예제 #22
0
    def save(self, event=None):

        text = self.fileController.getTextFromEditor()
        if text == "Encoding Error":
            return
        writeFile(
            os.path.join(self.core.getPathParts(),
                         self.getName() + self.type), text)
        self.setSaved()

        self.makeWebSite(preview=True)
        self.core.addToFtpQueue(self.getFileName())
예제 #23
0
    def save(self, event=None):

        text = self.fileController.getTextFromEditor()
        if text == "Encoding Error":
            return
        writeFile(
            os.path.join(self.core.getPathParts(),
                         self.getName() + self.type), text)
        self.setSaved()
        # this class is also used for the rss head
        if self.getName() != "rss":
            self.core.addToFtpQueue(self.getName() + ".content")
예제 #24
0
    def setProjectDirNT(self, showOnlyWarnings=False):
        """
        from revision 387 
        we are moving the path file to the application directory due to problems on Vista
        
        """
        fPath = os.path.join(self.getApplicationPath(), "makerPath")
        if os.path.isfile(fPath):

            path = readFile(fPath, asLines=True, lineRange=[0])

            if os.path.isdir(path) and path.endswith(Constants.PROJECTBASE):
                self.projectDir = path
            else:
                m = "No maker projects OR invalid path to projects: "
                m += path
                self.controller.errorMessage(m)
                os.remove(fPath)
                self.setProjectDirNT(showOnlyWarnings=True)
        else:
            m = "Please select a directory to store your projects!\n"
            m += "You can also select an existing 'makerProjects' folder."

            if not showOnlyWarnings:
                self.controller.infoMessage(m)

            p = self.controller.dirDialog()

            if p:
                self.projectDir = os.path.join(p, Constants.PROJECTBASE)
                if p.endswith(Constants.PROJECTBASE):
                    self.projectDir = p

                writeFile(fPath, self.projectDir)
                if not os.path.isdir(self.projectDir):
                    self.createProjectDir()
            else:
                m = "You need to select a project folder "
                m += "to run the maker !\n"
                m += "Would you like to try again ?"
                if self.controller.askYesOrNo(m) == "Yes":
                    self.setProjectDirNT(showOnlyWarnings=True)
                else:
                    sys.exit(0)
예제 #25
0
    def makeWebSite(self, preview=False):
        """
        Build website from parts - invoked by preview
        rss creation has been removed !        
        Calls self.updateDynamic().
        """

        pathParts = self.core.getPathParts()
        lang = self.getLanguage()

        writeFile(self.core.getPathParts() + self.getRealName(), ' ')

        name0 = pathParts + self.name + '.head'
        name1 = pathParts + lang + '.body'
        name2 = pathParts + lang + '.nav'
        name3 = pathParts + self.name + self.type
        name4 = pathParts + lang + '.foot'

        sourceMarkers = [
            'head', 'top of page', 'navigation', 'content', 'foot'
        ]

        theList = [name0, name1, name2, name3, name4]
        for aFile, sMarker in zip(theList, sourceMarkers):
            out = readFile(aFile)
            out += "\n\n\n<!-- end of part: %s -->\n\n" % sMarker
            writeFile(self.getFullName(), out, append=True)

        #print "make_this_website: %s.htm  Done..." % self.getName()
        self.updateDynamic()

        text = readFile(self.getFullName())

        for marker in self.core.markers:
            #print str(self.core.getDataForMakerMarker(marker)), marker

            this = marker.encode(self.core.encoding)
            that = self.core.getDataForMakerMarker(marker).encode(
                self.core.encoding)
            something = text.replace(this, that)
            text = something

        # do markdown
        markD = re.compile('<markdown>(.*?)</markdown>',
                           re.DOTALL | re.IGNORECASE).findall(text)
        for md in markD:
            #ITB 25/10/2011 add support for tables and footnotes in markdown
            mdHTML = (markdown2.markdown(md.decode("latin-1"),
                                         extras=["wiki-tables", "footnotes"
                                                 ])).encode("latin-1")

            text = text.replace('<markdown>' + md + '</markdown>', mdHTML)

        writeFile(self.getFullName(), text)

        self.createRSSFeed(self.getFullName())

        if not preview:
            self.core.addToFtpQueue(self.getFileName())
예제 #26
0
    def printViaBrowser(self):
        """
        Is sending the contents of the current file to a webbrowser for printing
        
        This printing method works for most text files 
        It is overridden in some derived classes
        """
        printHeader = """
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="expires" content="0" />
<title></title>
</head>
<body onLoad="javascript:window.print();">
<pre>"""

        source = readFile(
            os.path.join(self.core.getPathParts(),
                         self.getName() + self.getType()))

        aSource = source.replace("<", "&lt;")
        bSource = aSource.replace(">", "&gt;")

        theContent = printHeader + bSource
        theContent += "</pre></html>"

        writeFile(
            os.path.join(self.core.getProjectPath(), "makerPrintOut.html"),
            theContent)

        webbrowser.open(
            "file:///" +
            os.path.join(self.core.getProjectPath(), "makerPrintOut.html"))
예제 #27
0
    def makeWebSite(self , preview = False):
        """
        Build website from parts - invoked by preview
        rss creation has been removed !        
        Calls self.updateDynamic().
        """
        
        pathParts = self.core.getPathParts()
        lang = self.getLanguage()
        
        writeFile(self.core.getPathParts()+self.getRealName(), ' ')
                
        name0 = pathParts + self.name + '.head'
        name1 = pathParts + lang + '.body'
        name2 = pathParts + lang + '.nav'
        name3 = pathParts + self.name+self.type
        name4 = pathParts + lang + '.foot'
            
        sourceMarkers = ['head', 'top of page', 'navigation', 'content', 'foot']
            
        theList = [name0, name1, name2, name3, name4]      
        for aFile, sMarker in zip(theList, sourceMarkers):
            out  = readFile(aFile)
            out += "\n\n\n<!-- end of part: %s -->\n\n" % sMarker
            writeFile(self.getFullName(), out, append=True)
        
        #print "make_this_website: %s.htm  Done..." % self.getName()
        self.updateDynamic()
        
        text = readFile(self.getFullName())
        
        for marker in self.core.markers:
            #print str(self.core.getDataForMakerMarker(marker)), marker

            this = marker.encode(self.core.encoding)
            that = self.core.getDataForMakerMarker(marker).encode(self.core.encoding)
            something = text.replace(this, that)
            text = something
        
        # do markdown
        markD = re.compile('<markdown>(.*?)</markdown>', re.DOTALL | re.IGNORECASE).findall(text)
        for md in markD:
            #ITB 25/10/2011 add support for tables and footnotes in markdown
            mdHTML = (markdown2.markdown(md.decode("latin-1"), extras=["wiki-tables","footnotes"])).encode("latin-1")
            
            text = text.replace('<markdown>' + md + '</markdown>', mdHTML)
            print text
                    
        writeFile(self.getFullName(), text)
        
        self.createRSSFeed(self.getFullName())
        
        if not preview:
            self.core.addToFtpQueue(self.getFileName())
    def createFile(self, name, lang):

        # just making sure
        if not name.endswith("_"):
            name += "_"
              
        if not self.content:
            content = makerFileTemplates.getTemplate(self.type)
        
        if self.type == ".content":
            
            
        
            # TO DO: convert to use os.path.join()
            pathToHead = self.project.getPathParts()+"../templates/"+ lang +".head" 
            head = readFile(pathToHead)
                
                   
            pathToNewHead = self.project.getPathParts() + name + lang +".head"
                    
                    
            writeFile(pathToNewHead, head)
        
                    # TO DO: convert to use os.path.join()
            nameInTable = name + lang + ".htm"
                                        
                    
            self.project.addToDistributionTable(nameInTable, 
                                        self.project.getDefaultRemoteFolder(self.type), 
                                        "lines", 
                                        nameInTable)
            newFile = self.project.getPathParts() + name + lang + self.type
            writeFile(newFile, content)
        
                
        elif self.type==".dynamic":
        
            # TO DO: convert to use os.path.join()
                                        
            newFile = self.project.getPathParts() + name + lang + self.type
                            
            writeFile(newFile, content)
    
        
        group = self.projectController.findTreeItemByText(self.type)
        if not group:
            group = self.projectController.treeViewAddFolder(self.type)
                
        newItem = self.projectController.treeViewAppendItem(group, name + lang, type=None)
        self.projectController.selectTreeItemAndLoad(newItem)
예제 #29
0
 def preview(self, theContent):
     
     """
     Preview for .css files is using either an already opened .content file or
     one from inside the project to show changes to the stylesheet in the browser
     
     """
     
     current_version = readFile(self.getFullName())
            
     writeFile(self.getFullName(), theContent)
     
     openFiles = self.core.projectManager.openFiles
     
     contentFiles = []
     
     # get open .content files
     for instance in openFiles:
         if instance.getType() == ".content":
             contentFiles.append(instance.getFullName())
     
     # if no open files get all of them
     if contentFiles == []:
         contentFiles = self.core.getFilesByExtension(".content")
         # ok there are .content files in the project
         if contentFiles == []:
             writeFile(self.getFullName(), current_version)
             return
         else:
             # use right extensions
             correctExtensions = []
             for f in contentFiles:
                 correctExtensions.append(os.path.join(self.core.getPathParts(), f + ".htm"))
             
             contentFiles = correctExtensions
     
     tool = makerCSSTools.CSSTools()
     
     for file in contentFiles:
         if self.getRealName() in tool.listUsedStyleSheetsForFilename(file):
           
             urlToOpen = 'file://'+ file
             webbrowser.open(urlToOpen, autoraise=0)    
             writeFile(self.getFullName(), current_version)
             return
예제 #30
0
    def preview(self, theContent):
        """
        Preview for .css files is using either an already opened .content file or
        one from inside the project to show changes to the stylesheet in the browser
        
        """

        current_version = readFile(self.getFullName())

        writeFile(self.getFullName(), theContent)

        openFiles = self.core.projectManager.openFiles

        contentFiles = []

        # get open .content files
        for instance in openFiles:
            if instance.getType() == ".content":
                contentFiles.append(instance.getFullName())

        # if no open files get all of them
        if contentFiles == []:
            contentFiles = self.core.getFilesByExtension(".content")
            # ok there are .content files in the project
            if contentFiles == []:
                writeFile(self.getFullName(), current_version)
                return
            else:
                # use right extensions
                correctExtensions = []
                for f in contentFiles:
                    correctExtensions.append(
                        os.path.join(self.core.getPathParts(), f + ".htm"))

                contentFiles = correctExtensions

        tool = makerCSSTools.CSSTools()

        for file in contentFiles:
            if self.getRealName() in tool.listUsedStyleSheetsForFilename(file):

                urlToOpen = 'file://' + file
                webbrowser.open(urlToOpen, autoraise=0)
                writeFile(self.getFullName(), current_version)
                return
예제 #31
0
    def updateFileBase(self):
        """
        Works on the finished HTML file and searches the distribution 
        table and current file for ftp_sources. In a second step the 
        file references are completed with the absolute path of the file.
        """
        
        text = readFile(self.getFullName())
        
        sourceList = []
        
        class XmlReader(ContentHandler):
            def __init__(XmlReader, scrwid=79, *args):
                ContentHandler.__init__(XmlReader, *args)
                
            def startElement(XmlReader, name, attrs):
                XmlReader.start_name = name
                        
                if XmlReader.start_name == "rule":
                    sourceList.append(attrs.get("ftp_source"))

            def endElement(XmlReader, name):
                pass
                
            def characters(XmlReader, chars):                        
                pass
                
        parse(self.core.getDistributionTableFilename(), XmlReader())
              
        for i in sourceList:
            try:
                print text.index(i.encode(self.core.encoding))
            except:
                print 'Unable to print text.index(i) for: %s' % str(i)
            
            if text.find(i.encode(self.core.encoding))==-1:
                print "DEBUG: cannot find ",i," in file..."
            else:
                #print "replacing ",i
                
                loc = self.core.getPageLocationsBySource(i)
                location = urlparse.urljoin(self.core.url,loc[0])
                #print location,i
                
                this = '"'+i.encode(self.core.encoding)+'"'
                that = '"'+location.encode(self.core.encoding)+'"'
                newtext = text.replace(this, that)
                text = newtext
        
        bar = text
        imagelist = self.core.getImageFiles()
        
        for image in imagelist:
            image = image.encode(self.core.encoding)
                    
            #print " inside Update Filebase: image is:",image
                    
            if bar.find('"'+image+'"')==-1:
                pass
                #print "image is not referenced in file"
            else:
                #print "inside Update Filebase: replacing : ", image
                this = '"'+image+'"'
                that = '"'+urlparse.urljoin(self.core.getProjectURL(),
                                            self.core.getRemoteGfxFolder())
                that += image+'"'
                that = str(that).encode(self.core.encoding)
                new = bar.replace(this, that)
                bar = new        
                text = new
        
        writeFile(self.core.getPathParts()+self.name+".htm", text)
예제 #32
0
    def rename(self):
        
        oldFilename = self.fileModel.getFileName()
        oldRealName = self.fileModel.getRealName()
        newName = self.controller.getNewName()
    
        nName = os.path.join(self.fileModel.core.getPathParts(),
                             newName + self.fileModel.getType())
        
        fName = os.path.join(self.fileModel.core.getPathParts(), oldFilename)
               
        
        if self.fileModel.getType() == ".content":
            #print fName
            os.rename(fName, nName)
            os.rename(os.path.join(self.fileModel.core.getPathParts(),
                                       self.fileModel.getName()+".head"),
                          os.path.join(self.fileModel.core.getPathParts(),
                                       newName+".head")) 
            
            # remove old htm file
            fileName = self.fileModel.getFullName()
            
            if os.path.isfile(fileName):
                os.remove(fileName)


        elif self.fileModel.getType() == ".dynamic":
                #print fName
                os.rename(fName, nName)
            
        else:
                #print fName
            os.rename(fName, nName)
           
            
        self.fileModel.setName(newName)

        distContent = readFile(self.fileModel.core.getDistributionTableFilename())
         

        if self.fileModel.getType() == ".content":
                newDist = distContent.replace(oldRealName, newName+".htm")
        
        else:
        
            newDist = distContent.replace(oldFilename, newName + self.fileModel.getType())
            
        writeFile(self.fileModel.core.getDistributionTableFilename(), newDist)
            
        if self.fileModel.getType() == ".content":
            
            quotes = ["'",'"']
            
            for q in quotes:
            
                this = q + oldRealName + q
                that = q + newName+".htm" + q                
                self.fileModel.core.replaceStringInAllItems(this, that)
                
        else:
            quotes = ["'",'"']
            
            for q in quotes:
            
                this = q + oldFilename + q
                that = q + newName + self.fileModel.getType() + q
                # Brinick: why is this done twice?
                # Gerald once for single , once for double quotes
                self.fileModel.core.replaceStringInAllItems(this, that)
        
        # update in ftp queue
        self.fileModel.core.renameItemInFtpQueue(oldFilename, newName + self.fileModel.getType())
예제 #33
0
    def updateFileBase(self):
        """
        Works on the finished HTML file and searches the distribution 
        table and current file for ftp_sources. In a second step the 
        file references are completed with the absolute path of the file.
        """

        text = readFile(self.getFullName())

        sourceList = []

        class XmlReader(ContentHandler):
            def __init__(XmlReader, scrwid=79, *args):
                ContentHandler.__init__(XmlReader, *args)

            def startElement(XmlReader, name, attrs):
                XmlReader.start_name = name

                if XmlReader.start_name == "rule":
                    sourceList.append(attrs.get("ftp_source"))

            def endElement(XmlReader, name):
                pass

            def characters(XmlReader, chars):
                pass

        parse(self.core.getDistributionTableFilename(), XmlReader())

        for i in sourceList:
            try:
                print text.index(i.encode(self.core.encoding))
            except:
                print 'Unable to print text.index(i) for: %s' % str(i)

            if text.find(i.encode(self.core.encoding)) == -1:
                print "DEBUG: cannot find ", i, " in file..."
            else:

                loc = self.core.getPageLocationsBySource(i)
                location = urlparse.urljoin(self.core.url, loc[0])

                toReplace = [['"', '"'], ["'", "'"], ['"', '?'], ["'", "?"]]

                for quotes in toReplace:

                    this = quotes[0] + i.encode(self.core.encoding) + quotes[1]
                    that = quotes[0] + location.encode(
                        self.core.encoding) + quotes[1]
                    newtext = text.replace(this, that)
                    text = newtext

        bar = text
        imagelist = self.core.getImageFiles()

        for image in imagelist:
            image = image.encode(self.core.encoding)

            #print " inside Update Filebase: image is:",image

            if bar.find('"' + image + '"') == -1:
                pass
                #print "image is not referenced in file"
            else:
                #print "inside Update Filebase: replacing : ", image
                this = '"' + image + '"'
                that = '"' + urlparse.urljoin(self.core.getProjectURL(),
                                              self.core.getRemoteGfxFolder())
                that += image + '"'
                that = str(that).encode(self.core.encoding)
                new = bar.replace(this, that)
                bar = new
                text = new

        writeFile(self.core.getPathParts() + self.name + ".htm", text)
예제 #34
0
 def save(self, event=None):
     text = self.fileController.getTextFromEditor()
     if text == "Encoding Error":
         return
     writeFile(self.getFullName(), text)
     self.setSaved()
예제 #35
0
    def rename(self):

        oldFilename = self.fileModel.getFileName()
        oldRealName = self.fileModel.getRealName()
        newName = self.controller.getNewName()

        nName = os.path.join(self.fileModel.core.getPathParts(),
                             newName + self.fileModel.getType())

        fName = os.path.join(self.fileModel.core.getPathParts(), oldFilename)

        if self.fileModel.getType() == ".content":
            #print fName
            os.rename(fName, nName)
            os.rename(
                os.path.join(self.fileModel.core.getPathParts(),
                             self.fileModel.getName() + ".head"),
                os.path.join(self.fileModel.core.getPathParts(),
                             newName + ".head"))

            # remove old htm file
            fileName = self.fileModel.getFullName()

            if os.path.isfile(fileName):
                os.remove(fileName)

        elif self.fileModel.getType() == ".dynamic":
            #print fName
            os.rename(fName, nName)

        else:
            #print fName
            os.rename(fName, nName)

        self.fileModel.setName(newName)

        distContent = readFile(
            self.fileModel.core.getDistributionTableFilename())

        if self.fileModel.getType() == ".content":
            newDist = distContent.replace(oldRealName, newName + ".htm")

        else:

            newDist = distContent.replace(oldFilename,
                                          newName + self.fileModel.getType())

        writeFile(self.fileModel.core.getDistributionTableFilename(), newDist)

        if self.fileModel.getType() == ".content":

            quotes = ["'", '"']

            for q in quotes:

                this = q + oldRealName + q
                that = q + newName + ".htm" + q
                self.fileModel.core.replaceStringInAllItems(this, that)

        else:
            quotes = ["'", '"']

            for q in quotes:

                this = q + oldFilename + q
                that = q + newName + self.fileModel.getType() + q
                # Brinick: why is this done twice?
                # Gerald once for single , once for double quotes
                self.fileModel.core.replaceStringInAllItems(this, that)

        # update in ftp queue
        self.fileModel.core.renameItemInFtpQueue(
            oldFilename, newName + self.fileModel.getType())
예제 #36
0
 def save(self, event=None):
     text = self.fileController.getTextFromEditor()
     if text == "Encoding Error":
         return
     writeFile(self.getFullName(), text)
     self.setSaved()
예제 #37
0
def buildView(systemDir, viewPath):
    
    
    writeFile(os.path.join(viewPath,"yourTemplates.html"), scaffold(systemDir, defaultTemplate()))
    
    return os.path.join(viewPath,"yourTemplates.html")
예제 #38
0
 def saveAsTemplate(self):
     writeFile(os.path.join(self.core.getProjectPath(),"templates", self.getLanguage() + self.type), self.fileController.getTextFromEditor())
     self.setSaved()
예제 #39
0
 def save(self, event=None):
     text = self.fileController.getTextFromEditor()
     if not text:
         return
     writeFile(self.getFullName(), text)
     self.setSaved()