From 4cb1095a775ceaf6226fff16a97b087ef22575af Mon Sep 17 00:00:00 2001 From: Wolfgang Fahl Date: Wed, 22 Mar 2023 16:14:51 +0100 Subject: [PATCH] fixes #36 --- ceurws/volumebrowser.py | 13 +++++++++++-- ceurws/wikidatasync.py | 17 ++++++++++++++++- 2 files changed, 27 insertions(+), 3 deletions(-) diff --git a/ceurws/volumebrowser.py b/ceurws/volumebrowser.py index 1355f43..ef7fca3 100644 --- a/ceurws/volumebrowser.py +++ b/ceurws/volumebrowser.py @@ -819,7 +819,7 @@ def __init__(self,version,args=None): self.addMenuLink(text='Volumes',icon='table-large',href="/volumes") self.addMenuLink(text='Wikidata Sync',icon='refresh-circle',href="/wikidatasync") self.addMenuLink(text='Settings',icon='cog',href="/settings") - self.addMenuLink(text='github',icon='github', href="https://github.com/WolfgangFahl/pyCEURmake/issues/16",target="_blank") + self.addMenuLink(text='github',icon='github', href="https://github.com/WolfgangFahl/pyCEURmake",target="_blank") self.addMenuLink(text='Documentation',icon='file-document',href="https://ceur-ws.bitplan.com/index.php/Volume_Browser",target="_blank") self.addMenuLink(text='Source',icon='file-code',href="https://github.com/WolfgangFahl/pyCEURmake/blob/main/ceurws/volumebrowser.py",target="_blank") self.addMenuLink(text='About',icon='information',href="/about") @@ -834,7 +834,6 @@ def __init__(self,version,args=None): self.wdSync=None @jp.app.get("/volumes.json") - @jp.app.get("/allvolumes.json") async def volumes(): """ direct fastapi return of volumes @@ -843,6 +842,16 @@ async def volumes(): self.wdSync=WikidataSync(debug=self.debug) volumeList=self.wdSync.vm.getList() return volumeList + + @jp.app.get("/papers.json") + async def papers(): + """ + direct fastapi return of volumes + """ + if self.wdSync is None: + self.wdSync=WikidataSync(debug=self.debug) + paperList=self.wdSync.pm.getList() + return paperList def setupPage(self,header=""): header=""" diff --git a/ceurws/wikidatasync.py b/ceurws/wikidatasync.py index 15b4069..6b015f6 100644 --- a/ceurws/wikidatasync.py +++ b/ceurws/wikidatasync.py @@ -5,6 +5,7 @@ ''' import datetime import os +import sys from dataclasses import dataclass from typing import Dict, List, Union from urllib.error import HTTPError @@ -13,7 +14,7 @@ from ceurws.utils.download import Download from lodstorage.lod import LOD -from ceurws.ceur_ws import Volume, VolumeManager, CEURWS +from ceurws.ceur_ws import Volume, VolumeManager, CEURWS, PaperManager from lodstorage.sparql import SPARQL from lodstorage.sql import SQLDB from lodstorage.query import QueryManager, EndpointManager @@ -34,6 +35,7 @@ def __init__(self, baseurl="https://www.wikidata.org", debug:bool=False): ''' self.debug = debug self.prepareVolumeManager() + self.preparePaperManager() self.prepareRDF() self.wdQuery = self.qm.queriesByName["Proceedings"] self.baseurl=baseurl @@ -62,6 +64,16 @@ def prepareRDF(self): qYamlFile = f"{path}/resources/queries/ceurws.yaml" if os.path.isfile(qYamlFile): self.qm = QueryManager(lang="sparql", queriesPath=qYamlFile) + + def preparePaperManager(self): + """ + prepare my paper Manager + """ + self.pm=PaperManager() + if self.pm.isCached(): + self.pm.fromStore(cacheFile=CEURWS.CACHE_FILE) + else: + print("PaperManager not cached you might want to run ceur-ws --recreate",file=sys.stderr) def prepareVolumeManager(self): ''' @@ -109,6 +121,9 @@ def getRecentlyAddedVolumeList(self)->list: return refreshVolumesByNumber,newVolumes def storeVolumes(self): + """ + store my volumes + """ self.vm.store() def getWikidataProceedingsRecord(self, volume):