10
0
mirror of https://github.com/LCPQ/QUESTDB_website.git synced 2024-12-26 14:23:42 +01:00

Improvements for publications

This commit is contained in:
Mickaël Véril 2021-02-17 16:39:54 +01:00 committed by Anthony Scemama
parent d1af83bbf9
commit 14ae7312fc
3 changed files with 48 additions and 11 deletions

View File

@ -44,16 +44,24 @@ draft: false
if (sodois.has(null)) { if (sodois.has(null)) {
sodois.delete(null) sodois.delete(null)
} }
for (const [setName,dois] of sets) {
if (dois.length>0) {
const doi=dois[0]
if (sodois.has(doi)) {
sodois.delete(doi)
}
}
}
odois=Array.from(sodois) odois=Array.from(sodois)
const uoopublis = await PubliData.loadManyAsync(odois) const uoopublis = await PubliData.loadManyAsync(odois)
const opublis = uoopublis.sort((puba, pubb) => pubUtils.getIssuedDate(puba) - pubUtils.getIssuedDate(pubb)) const opublis = uoopublis.sort((puba, pubb) => pubUtils.parseDate(pubUtils.bestDate(puba).dateInfo) - pubUtils.parseDate(pubUtils.bestDate(pubb).dateInfo))
for (const publi of opublis) { for (const publi of opublis) {
const art = await createPubliUI(publi, true, !myDB.others.includes(publi.DOI)) const art = await createPubliUI(publi, true, !myDB.others.includes(publi.DOI))
$(art).appendTo("#publis_other") $(art).appendTo("#publis_other")
} }
const rdois = myDB.reviews const rdois = myDB.reviews
const uorpublis = await PubliData.loadManyAsync(rdois) const uorpublis = await PubliData.loadManyAsync(rdois)
const rpublis = uorpublis.sort((puba, pubb) => pubUtils.getIssuedDate(puba) - pubUtils.getIssuedDate(pubb)) const rpublis = uorpublis.sort((puba, pubb) => pubUtils.parseDate(pubUtils.bestDate(puba).dateInfo) - pubUtils.parseDate(pubUtils.bestDate(pubb).dateInfo))
for (const publi of rpublis) { for (const publi of rpublis) {
art = await createPubliUI(publi, true, true) art = await createPubliUI(publi, true, true)
$(art).appendTo("#publis_review") $(art).appendTo("#publis_review")

View File

@ -1,4 +1,8 @@
async function createPubliUI(publi,toolTips=false,abstract=false) { async function createPubliUI(publi,toolTips=false,abstract=false) {
var DayAndMothsFormat ={
minimumIntegerDigits: 2,
useGrouping: false
}
const art = $("<article/>").addClass("publi") const art = $("<article/>").addClass("publi")
art.className = "publi" art.className = "publi"
$("<a/>", { $("<a/>", {
@ -13,9 +17,11 @@ async function createPubliUI(publi,toolTips=false,abstract=false) {
var notifycontent = $("<div/>").addClass("author-info") var notifycontent = $("<div/>").addClass("author-info")
$("<h1/>").text(String.raw`${author.given} ${author.family}`).appendTo(notifycontent) $("<h1/>").text(String.raw`${author.given} ${author.family}`).appendTo(notifycontent)
ulaff = $("<ul/>").addClass("affiliation-list").appendTo(notifycontent) ulaff = $("<ul/>").addClass("affiliation-list").appendTo(notifycontent)
if (author.affiliation) {
for (const a of author.affiliation) { for (const a of author.affiliation) {
$("<li/>").text(a.name).appendTo(ulaff) $("<li/>").text(a.name).appendTo(ulaff)
} }
}
if (author["authenticated-orcid"]) { if (author["authenticated-orcid"]) {
const html = String.raw`<div class="orcid-id"><a href="https://orcid.org" target="_blank"><img alt="ORCID logo" src="https://orcid.org/sites/default/files/images/orcid_16x16.png" width="16" height="16"/></a> <a href="${author.ORCID}" target="_blank">${author.ORCID} </a></div>` const html = String.raw`<div class="orcid-id"><a href="https://orcid.org" target="_blank"><img alt="ORCID logo" src="https://orcid.org/sites/default/files/images/orcid_16x16.png" width="16" height="16"/></a> <a href="${author.ORCID}" target="_blank">${author.ORCID} </a></div>`
notifycontent.append(html) notifycontent.append(html)
@ -44,7 +50,8 @@ async function createPubliUI(publi,toolTips=false,abstract=false) {
else { else {
$("<span/>").text(publi["container-title"][0]).appendTo(journaldiv) $("<span/>").text(publi["container-title"][0]).appendTo(journaldiv)
} }
var date = pubUtils.getIssuedDate(publi) var publiDate = pubUtils.bestDate(publi)
var date = pubUtils.parseDate(publiDate.dateInfo)
journaldiv.append(" ") journaldiv.append(" ")
$("<span/>").text(date.getFullYear().toString()).appendTo(journaldiv) $("<span/>").text(date.getFullYear().toString()).appendTo(journaldiv)
journaldiv.append(" ") journaldiv.append(" ")
@ -58,8 +65,9 @@ async function createPubliUI(publi,toolTips=false,abstract=false) {
href: publi.URL, href: publi.URL,
target: "_blank" target: "_blank"
}).text(String.raw`DOI: ${publi.DOI}`).appendTo(art) }).text(String.raw`DOI: ${publi.DOI}`).appendTo(art)
$("<p/>").append("Published on ").append($("<time/>", {
datetime: JSON.stringify(date) $("<p/>").append(`${publiDate.type== "created" ? "First p" : "P"}ublished on `).append($("<time/>", {
datetime: date.toISOString().substring(0, 10)
}).text(date.toLocaleDateString("en-us", { }).text(date.toLocaleDateString("en-us", {
day: "numeric", day: "numeric",
month: "short", month: "short",

View File

@ -1,6 +1,27 @@
class pubUtils{ class pubUtils {
static getIssuedDate(publi) { static parseDate(date) {
const parts=publi.issued["date-parts"][0] if (date["date-time"]) {
return new Date(Date.UTC(parts[0], parts[1] - 1, parts[2])) return Date.parse(date["date-time"])
}
if (date.timestamp) {
return Date(date.timestamp)
}
const parts=date["date-parts"][0]
const [year, month, day] = date['date-parts'][0]
if (day) {
return new Date(Date.UTC(year, month - 1, day))
} else if (month) {
return new Date(Date.UTC(year, month - 1))
} else {
return new Date(Date.UTC(year))
}
}
static bestDate(publi) {
if (publi.issued != null) {
return {type:"issued", dateInfo:publi.issued}
}
else {
return {type:"created", dateInfo:publi.created}
}
} }
} }