NASA-PDS / ds-view

Data Set View application (pds.nasa.gov/ds-view)
Apache License 2.0
0 stars 0 forks source link

Add Datacite Content negotiation for schema.org metadata to dataset view #29

Open jordanpadams opened 1 year ago

jordanpadams commented 1 year ago

💡 Description

Add the following javascript to all dataset view pages:

$(document).ready(function() {
  var identifier = "https://doi.org/10.5284/1015681"; //for example 10.5284/1015681
  if (identifier === undefined) {
    return;
  }
  var doi = new URL(identifier);
  var url = "https://data.crosscite.org";
  url += '/application/vnd.schemaorg.ld+json/' + doi.pathname;

  $.ajax({
    url: url,
    dataType: 'text', // don't convert JSON to Javascript object
    success: function(data) {
      $('<script>')
         .attr('type', 'application/ld+json')
         .text(data)
         .appendTo('head');
    },
    error: function (error) {
      console.log(error.responseJSON);
    }
  });
});

https://gist.github.com/kjgarza/34ca6a866b4437bc1c07d84f208a01c4

Note: The JSP code will need to replace the DOI above with the DOI on the landing page (https://doi.org/10.5284/1015681). This should only be added to pages that have the actual DOIs (e.g. ignore for collections that point to parent DOI).

Most likely tightly coupled with https://github.com/NASA-PDS/pds-api/issues/45

jordanpadams commented 1 year ago

@c-suh not sure if this will work or not with the way our pages are displayed, but give it a shot...

jordanpadams commented 2 months ago

This is, unfortunately, not as easy as it looks based upon the original way we were getting this DOI information from the backend. Deferring until probably never.