diff --git a/scholia/app/static/scholia.js b/scholia/app/static/scholia.js index 26220bd32..a066d2f41 100644 --- a/scholia/app/static/scholia.js +++ b/scholia/app/static/scholia.js @@ -672,4 +672,28 @@ function searchTerm(placeholder) { }); +} + +function quickStatement404DOI(doi, element) { + const c = require('citation-js') + + try { + let example = new c.Cite([doi]) + let output = example.format('quickstatements') + $( element ).append( output ); + output = encodeURI( + output.replaceAll('\t', '|') + .replaceAll('\n', '||')) + .replaceAll('/','%2F') + htmlOutput = "\n" + + " \n" + + "\n" + $( element ).after( htmlOutput ); + } catch (error) { + if (error.message.includes("status code 404")) { + $( element ).append( "DOI does not exist" ) + } else { + console.log(error) + } + } } \ No newline at end of file diff --git a/scholia/app/templates/404_doi.html b/scholia/app/templates/404_doi.html index 9981eadfb..f77bc9e49 100644 --- a/scholia/app/templates/404_doi.html +++ b/scholia/app/templates/404_doi.html @@ -1,31 +1,8 @@ {% extends "base.html" %} -{% block scripts %} -{{super()}} - - - +{% block in_ready %} + +{{ quick_statement( doi ,'qs') }} {% endblock %} diff --git a/scholia/app/templates/base.html b/scholia/app/templates/base.html index 1c837498d..0f05108b0 100644 --- a/scholia/app/templates/base.html +++ b/scholia/app/templates/base.html @@ -25,6 +25,11 @@ "#{{ panel }}-iframe", "{{ aspect }}_{{ panel }}.sparql"); {%- endmacro %} +{% macro quick_statement(doi, element) -%} +quickStatement404DOI( "{{ doi }}" ,"#{{ element }}") +{%- endmacro %} + + {% block head %} {{super()}} @@ -49,7 +54,7 @@ - +