Skip to content

Commit

Permalink
fixes #36
Browse files Browse the repository at this point in the history
  • Loading branch information
WolfgangFahl committed Mar 22, 2023
1 parent 0a85e11 commit 4cb1095
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 3 deletions.
13 changes: 11 additions & 2 deletions ceurws/volumebrowser.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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
Expand All @@ -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="""<link rel="stylesheet" href="/static/css/md_style_indigo.css">
Expand Down
17 changes: 16 additions & 1 deletion ceurws/wikidatasync.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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):
'''
Expand Down Expand Up @@ -109,6 +121,9 @@ def getRecentlyAddedVolumeList(self)->list:
return refreshVolumesByNumber,newVolumes

def storeVolumes(self):
"""
store my volumes
"""
self.vm.store()

def getWikidataProceedingsRecord(self, volume):
Expand Down

0 comments on commit 4cb1095

Please sign in to comment.