Skip to content

Commit

Permalink
Merge branch 'carlinmack-1855-rebase'
Browse files Browse the repository at this point in the history
  • Loading branch information
fnielsen committed May 6, 2024
2 parents f42a730 + 01e4c85 commit af0c18a
Show file tree
Hide file tree
Showing 8 changed files with 109 additions and 2 deletions.
9 changes: 8 additions & 1 deletion scholia/app/templates/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -106,11 +106,18 @@
$.getJSON(url, function (data) {
var item = data.entities["{{ q }}"];
if ('en' in item.labels) {
var title = item.labels.en.value
var title = item.labels.en.value;
var wdtitle = item.labels.en.value;
$("#h1").text(title);
$(".self").text(title);
$("title").text(title + " - Scholia");

var crossref_button = document.getElementById("check-crossref-button");
if (title && crossref_button) {
crossref_button.onclick = () => {get_dois_from_crossref(wdtitle)}
crossref_button.innerHTML = "Check Crossref"
}

{% if request.path.endswith("curation") or request.path.endswith("curation/") %}
$("#h1").text("Improve " + currentAspect + ": " + title);

Expand Down
9 changes: 9 additions & 0 deletions scholia/app/templates/check-crossref.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<h2 id="check-crossref">Check Crossref for new papers</h2>

<p>If you think that Wikidata is missing recent papers published on this topic, you can click the button below to check
the 20 most recent papers in Crossref. You will be redirected to the <a
href="/id-to-quickstatements">Identifier to Quickstatements</a> tool where you can see the presence of these in
Wikidata and have the opportunity to create these items in Wikidata using <a
href="https://www.wikidata.org/wiki/Help:QuickStatements">QuickStatements</a>.</p>

<button type="button" class="btn btn-primary mx-auto d-block" id="check-crossref-button">Loading...</button>
7 changes: 7 additions & 0 deletions scholia/app/templates/disease-curation.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{% extends "q_curation.html" %}

{% block curation_panels %}

{% include 'check-crossref.html' %}

{% endblock %}
7 changes: 7 additions & 0 deletions scholia/app/templates/gene-curation.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{% extends "q_curation.html" %}

{% block curation_panels %}

{% include 'check-crossref.html' %}

{% endblock %}
7 changes: 7 additions & 0 deletions scholia/app/templates/protein-curation.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{% extends "q_curation.html" %}

{% block curation_panels %}

{% include 'check-crossref.html' %}

{% endblock %}
68 changes: 68 additions & 0 deletions scholia/app/templates/q_curation.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,73 @@ <h1 id="h1">Improve...</h1>

{% block curation_panels %}{% endblock %}

<script>
function get_dois_from_crossref(query_string) {
const button = document.getElementById("check-crossref-button");
button.innerHTML = "Loading...";
button.classList.remove("d-block");
button.classList.add("d-none");
button.insertAdjacentHTML('beforebegin',
"<div id='check-crossref-loader' class='loader'><div></div><div></div><div></div></div>"
)
const currentDate = new Date().toISOString().split('T')[0];
const params = {
'query': query_string,
'select': 'DOI',
'filter': 'type:journal-article,until-issued-date:' + currentDate,
'rows': 20,
'sort': 'issued',
'order': 'desc',
};

// Create a URLSearchParams object to construct the query parameters
const searchParams = new URLSearchParams();

// Loop through the dictionary and add each key-value pair to the searchParams
for (const [key, value] of Object.entries(params)) {
searchParams.append(key, value);
}

// Construct the final URL by appending the search parameters
const url = `https://api.crossref.org/works/?${searchParams.toString()}`;
const error_message = "The API failed which could be due to a problem with your connection or with the upstream server. If the issue persists <a href='https://github.com/WDscholia/scholia/issues/new?assignees=&labels=bug&projects=&template=bug_report.md&title=''>submit a bug report on GitHub</a>"

fetch(url)
.then(response => response.json())
.then(data => {
if (data['status'] == 'ok') {
if (data["message"]["total-results"] > 0){
items = data.message?.items
if (items) {
dois = items.map(x => x.DOI).join(" ");
window.location.href = "/id-to-quickstatements?query=" + dois;
}
} else {
$('#check-crossref-loader').remove();
button.insertAdjacentHTML('afterend', `<div class="alert alert-secondary" role="alert">No results returned for ${data.message.query['status-terms']}</div>`);
button.innerHTML = "Check Crossref";
button.classList.remove("d-none");
button.classList.add("d-block");
}
} else {
console.error(`API status was ${data.status}`)
console.error(data)
$('#check-crossref-loader').remove();
button.insertAdjacentHTML('afterend', `<div class="alert alert-warning" role="alert">${error_message}</div>`);
button.innerHTML = "Check Crossref";
button.classList.remove("d-none");
button.classList.add("d-block");
}
})
.catch(error => {
console.error(error);
$('#check-crossref-loader').remove();
button.insertAdjacentHTML('afterend', `<div class="alert alert-warning" role="alert">${error_message}</div>`);
button.innerHTML = "Check Crossref";
button.classList.remove("d-none");
button.classList.add("d-block");
});
}
</script>

{% endblock %}
2 changes: 2 additions & 0 deletions scholia/app/templates/taxon-curation.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@

{% block curation_panels %}

{% include 'check-crossref.html' %}

<h2 id="missing-topic-tags-for-taxon-name">Missing topic tags for taxon name</h2>

<p>This table lists works which have this taxon's name in the title but that have not been annotated as having it as <i>main subject</i> (<a href="https://www.wikidata.org/entity/P921">P921</a>).<p/>
Expand Down
2 changes: 1 addition & 1 deletion scholia/doi.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ def get_author_name(author_dict):
get_author_name(author)
for author in entry.get("author", [])
],
# not full text url if the paper is closed source
# not full text URL if the paper is closed source
# "full_text_url":
# entry.get("resource", {}).get("primary", {}).get("URL"),
"date_P577": date,
Expand Down

0 comments on commit af0c18a

Please sign in to comment.