Commit 90d0623e authored by Maxime Chaillet's avatar Maxime Chaillet

work in progress.

parent ef85b091
...@@ -172,15 +172,11 @@ DOIController.prototype.getDataForGoogleSearch = function (doi) { ...@@ -172,15 +172,11 @@ DOIController.prototype.getDataForGoogleSearch = function (doi) {
//dataType: 'text', // don't convert JSON to Javascript object //dataType: 'text', // don't convert JSON to Javascript object
success: function (data) { success: function (data) {
if (data) { if (data) {
// Here we add the 'description' field in the recieved object because 'name' and 'description' fields are required by google dataset search. googleMetadataObject = new GoogleMetadataObject(data);
if (data.name) { googleMetadataObject.setDescription();
if (!data.description) { googleMetadataObject.setLicense();
data.description = data.name;
} _this.view.addDOIMetadataToHead(JSON.stringify(googleMetadataObject.getMetadata()));
_this.view.addDOIMetadataToHead(JSON.stringify(data));
} else {
console.log("[GOOGLE SEARCH INDEXING] - The data required by Google is missing the 'name' field. This is required by Google for indexing.");
}
} else { } else {
console.log("[GOOGLE SEARCH INDEXING] - No metadata recieved from datacite."); console.log("[GOOGLE SEARCH INDEXING] - No metadata recieved from datacite.");
} }
......
/**
* This class corresponds to a Google metadata object
* @param {*} data
*/
function GoogleMetadataObject(data) {
this.data = data;
}
/**
* Get metadata
*/
GoogleMetadataObject.prototype.getMetadata = function () {
return this.data;
}
/**
* Set a license
*/
GoogleMetadataObject.prototype.setLicense = function () {
if (!this.data.license) {
this.data.license = "https://creativecommons.org/licenses/by/4.0"
}
}
/**
* Set a description.
*/
GoogleMetadataObject.prototype.setDescription = function () {
if (this.data.name) {
if (!this.data.description) {
this.data.description = this.data.name;
}
} else {
console.log("[GoogleMetadataObject] - The data required by Google is missing the 'name' field. This is required by Google for indexing.");
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment