2020-11-24 19:21:58 +01:00
|
|
|
class PubliData{
|
|
|
|
static async loadAsync(DOI){
|
|
|
|
const path = PubliData.GetPathForDOI(DOI)
|
|
|
|
var me = JSON.parse(await getTextFromFileUrlAsync(`${path}/metadata.json`))
|
|
|
|
Reflect.setPrototypeOf(me,PubliData.prototype)
|
|
|
|
return me
|
|
|
|
}
|
|
|
|
static async loadManyAsync(DOIs){
|
|
|
|
var data = []
|
|
|
|
for (const DOI of DOIs) {
|
|
|
|
if (DOI!=null) {
|
|
|
|
data.push(await PubliData.loadAsync(DOI))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return data
|
|
|
|
}
|
|
|
|
get Path(){
|
|
|
|
return PubliData.GetPathForDOI(this.DOI)
|
|
|
|
}
|
|
|
|
get PictureURL(){
|
|
|
|
return PubliData.GetPictureURLForDOI(this.DOI)
|
|
|
|
}
|
|
|
|
get AbstractURL(){
|
|
|
|
return PubliData.GetAbstractURLForDOI(this.DOI)
|
|
|
|
}
|
|
|
|
async getAbstractTextAsync(){
|
|
|
|
return await PubliData.getAbstractTexForDOIAsync(this.DOI)
|
|
|
|
}
|
|
|
|
|
|
|
|
static GetPathForDOI(DOI){
|
2020-11-25 02:00:59 +01:00
|
|
|
var site_url = "/"+window.location.pathname.split('/')[1];
|
2020-11-25 01:55:18 +01:00
|
|
|
return site_url + `/data/publis/${DOI.replaceAll(".","/")}`
|
2020-11-24 19:21:58 +01:00
|
|
|
}
|
|
|
|
static GetAbstractURLForDOI(DOI){
|
|
|
|
return `${PubliData.GetPathForDOI(DOI)}/abstract.html`
|
|
|
|
}
|
|
|
|
|
|
|
|
static GetPictureURLForDOI(DOI){
|
|
|
|
return `${PubliData.GetPathForDOI(DOI)}/picture.jpeg`
|
|
|
|
}
|
|
|
|
|
|
|
|
static async getAbstractTexForDOIAsync(DOI){
|
|
|
|
return await getTextFromFileUrlAsync(PubliData.GetAbstractURLForDOI(DOI))
|
|
|
|
}
|
2020-11-25 01:55:18 +01:00
|
|
|
}
|