mirror of
https://github.com/LCPQ/QUESTDB_website.git
synced 2024-12-26 14:23:42 +01:00
46 lines
1.2 KiB
JavaScript
46 lines
1.2 KiB
JavaScript
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){
|
|
var site_url = "/"+window.location.pathname.split('/')[1];
|
|
return site_url + `/data/publis/${DOI.replaceAll(".","/")}`
|
|
}
|
|
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))
|
|
}
|
|
}
|