diff --git a/frontend/site.py b/frontend/site.py index 81e52b2..9f97139 100644 --- a/frontend/site.py +++ b/frontend/site.py @@ -4,6 +4,7 @@ @author: wf ''' import os +from wikibot.smw import SMWClient class Site(object): ''' @@ -33,5 +34,9 @@ def configure(self,config:dict): self.wikiId=config['wikiId'] self.defaultPage=config['defaultPage'] self.template=config['template'] + if "templateFolder" in config: + self.templateFolder=config['templateFolder'] + else: + self.templateFolder=self.name \ No newline at end of file diff --git a/frontend/wikicms.py b/frontend/wikicms.py index d3f3fc2..ec78b9d 100644 --- a/frontend/wikicms.py +++ b/frontend/wikicms.py @@ -142,7 +142,14 @@ def getFrame(self,pageTitle): }} """ % pageTitle frame=None - frameResult=self.smwclient.query(askQuery) + frameResult={} + try: + frameResult=self.smwclient.query(askQuery) + except Exception as ex: + if "invalid characters" in str(ex): + pass + else: + raise ex if pageTitle in frameResult: frameRow=frameResult[pageTitle] frame=frameRow['frame'] @@ -152,7 +159,7 @@ def getFrame(self,pageTitle): pass return frame - def getContent(self,pagePath:str,dofilterEditSections=True): + def getPageContent(self,pagePath:str,dofilterEditSections=True): ''' get the content for the given pagePath Args: pagePath(str): the pagePath @@ -172,11 +179,18 @@ def getContent(self,pagePath:str,dofilterEditSections=True): if error is None: if self.wiki is None: raise Exception("getContent without wiki - you might want to call open first") - frame=self.getFrame(pageTitle) content=self.wiki.getHtml(pageTitle) if dofilterEditSections: content=self.filterEditSections(content) except Exception as e: error=self.errMsg(e) return pageTitle,content,error + + def getContent(self,pagePath:str,dofilterEditSections=True): + ''' + get the content for the given pagePath + ''' + pageTitle,content,error=self.getPageContent(pagePath, dofilterEditSections) + frame=self.getFrame(pageTitle) + return pageTitle,content,error \ No newline at end of file diff --git a/tests/test_frontend.py b/tests/test_frontend.py index ab87bda..4270d7a 100644 --- a/tests/test_frontend.py +++ b/tests/test_frontend.py @@ -50,6 +50,14 @@ def testProxy(self): self.assertEqual("200 OK",imageResponse.status) self.assertEqual(79499,len(imageResponse.data)) + + def testIssue14Templates(self): + ''' + test template handling + ''' + frontend=self.server.enableFrontend('wiki') + print (frontend.site) + def testIssue14(self): ''' test Allow to use templates specified in Wiki