示例#1
0
 def GetPreviousPage(self, argv):
     pattern = argv[0]
     currentPage = self.patternProcessor.Get(["PageNumber"])
     destinationPage = currentPage - 1
     destinationPageUrl = "index.html" if currentPage - 1 == 0 else "index" + str(currentPage - 1) + ".html"
     if destinationPage < 0 or self.patternProcessor.Get(["SingleEntry"]):
         return str()
     else:
         return pattern.format({"destinationPage": destinationPage, "destinationPageUrl": destinationPageUrl})
示例#2
0
 def GetNextPage(self, argv):
     pattern = argv[0]
     currentPage = self.patternProcessor.Get(["PageNumber"])
     pagesCount = len(self.patternProcessor.Get(["PagesList"]))
     destinationPage = currentPage + 1
     destinationPageUrl = "index" + str(destinationPage) + ".html"
     if destinationPage > pagesCount - 1 or self.patternProcessor.Get(["SingleEntry"]):
         return str()
     else:
         return pattern.format({"destinationPage": destinationPage, "destinationPageUrl": destinationPageUrl})
示例#3
0
    def GetPagesList(self, argv):
        try:
            listLenght = int(argv[0])
            pattern = argv[1]
            separator = argv[2]
            currentPage = self.patternProcessor.Get(["PageNumber"])
            pagesList = self.patternProcessor.Get(["PagesList"])
            
            if len(pagesList) == 1 or self.patternProcessor.Get(["SingleEntry"]):
                return str()

            output = str()
            for e in pagesList:
                if (not int(e["pageNumber"]) < int(currentPage) - listLenght) and (not int(e["pageNumber"]) > int(currentPage) + listLenght):
                    output += pattern.format(e) + separator

            return output[:-len(separator)]

        except Exception as e:
            return str(e)