예제 #1
0
    def export(self, package):
        """ 
        Export web site
        Cleans up the previous packages pages and performs the export
        """
        if not self.report:
            outputDir = self.filename
            if not outputDir.exists():
                outputDir.mkdir()

        # Import the Website Page class.  If the style has it's own page class
        # use that, else use the default one.
        if (self.stylesDir / "websitepage.py").exists():
            global WebsitePage
            module = imp.load_source("websitepage",
                                     self.stylesDir / "websitepage.py")
            WebsitePage = module.WebsitePage

        self.pages = [WebsitePage(self.prefix + "index", 0, package.root)]
        self.generatePages(package.root, 1)
        uniquifyNames(self.pages)

        prevPage = None
        thisPage = self.pages[0]
        if self.report:
            self.report = u'"%s","%s","%s","%s","%s","%s","%s","%s","%s","%s"\n' % (
                'File', 'Page Name', 'Level', 'Page File Name', 'Idevice Type',
                'Idevice Title', 'Resource File Name', 'Resource User Name',
                'Resource Path', 'Resource Checksum')
            self.appendPageReport(thisPage, package)

        for nextPage in self.pages[1:]:
            if self.report:
                self.appendPageReport(nextPage, package)
            else:
                thisPage.save(outputDir, prevPage, nextPage, self.pages)
            prevPage = thisPage
            thisPage = nextPage

        if not self.report:
            thisPage.save(outputDir, prevPage, None, self.pages)

            if self.prefix == "":
                self.copyFiles(package, outputDir)

            return outputDir

        else:
            self.filename.write_text(self.report, 'utf-8')
예제 #2
0
    def generatePages(self, node, depth):
        """
        Recursively generate pages and store in pages member variable
        for retrieving later
        """
        for child in node.children:
            # assure lower pagename, without whitespaces or alphanumeric characters:
            pageName = child.titleShort.lower().replace(" ", "_")
            pageName = re.sub(r"\W", "", pageName)
            if not pageName:
                pageName = "__"

            self.pages.append(WebsitePage(self.prefix + pageName, depth,
                                          child))
            self.generatePages(child, depth + 1)
예제 #3
0
    def exportZip(self, package):
        """ 
        Export web site
        Cleans up the previous packages pages and performs the export
        """

        outputDir = TempDirPath()

        # Import the Website Page class , if the secure mode is off.  If the style has it's own page class
        # use that, else use the default one.
        if self.styleSecureMode == "0":
            if (self.stylesDir / "websitepage.py").exists():
                global WebsitePage
                module = imp.load_source("websitepage",
                                         self.stylesDir / "websitepage.py")
                WebsitePage = module.WebsitePage

        self.pages = [WebsitePage("index", 0, package.root)]
        self.generatePages(package.root, 1)
        uniquifyNames(self.pages)

        prevPage = None
        thisPage = self.pages[0]

        for nextPage in self.pages[1:]:
            thisPage.save(outputDir, prevPage, nextPage, self.pages)
            prevPage = thisPage
            thisPage = nextPage

        thisPage.save(outputDir, prevPage, None, self.pages)
        self.copyFiles(package, outputDir)
        # Zip up the website package
        self.filename.safeSave(
            self.doZip, _('EXPORT FAILED!\nLast succesful export is %s.'),
            outputDir)
        # Clean up the temporary dir
        outputDir.rmtree()