resultLanding: update jsonld to include isPartOf url with FOS/SDG search pages

This commit is contained in:
argirok 2022-06-22 16:13:28 +03:00
parent 18b403bec0
commit d12138bc2a
5 changed files with 20 additions and 6 deletions

View File

@ -113,8 +113,10 @@
<div [attr.style]="'margin-top: '+(graph_height? 'calc(40px + 20px - '+graph_height+'px)': '40px')"> <div [attr.style]="'margin-top: '+(graph_height? 'calc(40px + 20px - '+graph_height+'px)': '40px')">
<!-- schema.org--> <!-- schema.org-->
<schema2jsonld *ngIf="resultLandingInfo.record" [data]=resultLandingInfo.record <schema2jsonld *ngIf="resultLandingInfo.record" [data]=resultLandingInfo.record
[URL]="canonicalUrl"></schema2jsonld> [URL]="canonicalUrl"
<!-- Actions for mobile viewport --> [searchActionRoute]="properties.searchLinkToResults"></schema2jsonld>
<!-- Actions for mobile viewport -->
<div class="uk-flex uk-flex-right uk-margin-medium-bottom uk-hidden@s"> <div class="uk-flex uk-flex-right uk-margin-medium-bottom uk-hidden@s">
<!-- Share --> <!-- Share -->
<div class="uk-margin-small-right"> <div class="uk-margin-small-right">

View File

@ -18,6 +18,7 @@ export class Dataset extends JsonldDocument {
issn:String[]; issn:String[];
headline:String[]; headline:String[];
alternativeHeadline:String[]; alternativeHeadline:String[];
isPartOf;
} }
export interface Identifier { export interface Identifier {

View File

@ -59,7 +59,7 @@ export class Schema2jsonldComponent implements OnInit, OnChanges {
} else if (this.type == 'search') { } else if (this.type == 'search') {
this.json = this.documentParser.createSearchPage(this.name, this.URL, this.logoURL, this.searchAction, this.description, this.searchActionRoute); this.json = this.documentParser.createSearchPage(this.name, this.URL, this.logoURL, this.searchAction, this.description, this.searchActionRoute);
} else if (this.type == 'result') { } else if (this.type == 'result') {
docOvject = this.documentParser.convertResult(this.data, this.URL); docOvject = this.documentParser.convertResult(this.data, this.URL, this.searchActionRoute);
this.json = this.documentSerializer.serializeDataset(docOvject); this.json = this.documentSerializer.serializeDataset(docOvject);
} else { } else {
this.json = this.documentParser.createSimplePage(this.name, this.URL, this.description); this.json = this.documentParser.createSimplePage(this.name, this.URL, this.description);

View File

@ -88,7 +88,9 @@ export class JsonldDocumentSerializerService {
else if (doc.keyword && doc.keyword.length > 1) { else if (doc.keyword && doc.keyword.length > 1) {
buffer["keywords"] = _.join(doc.keyword, ", "); buffer["keywords"] = _.join(doc.keyword, ", ");
} }
if(doc.isPartOf && doc.isPartOf.length > 0){
buffer["isPartOf"] = doc.isPartOf;
}
if (doc.citation && doc.citation.length == 1) { if (doc.citation && doc.citation.length == 1) {
buffer["citation"] = this.buildCitation(doc.citation[0]); buffer["citation"] = this.buildCitation(doc.citation[0]);
} }

View File

@ -92,7 +92,7 @@ export class OpenAireJsonldConverterService {
} }
return buffer; return buffer;
} }
convertResult(result: any, URL): Dataset { convertResult(result: any, URL, searchActionRoute = null): Dataset {
const doc = new Dataset(); const doc = new Dataset();
doc.title = this.getTitle(result); doc.title = this.getTitle(result);
@ -111,6 +111,15 @@ export class OpenAireJsonldConverterService {
doc.citation = this.getCitation(result); doc.citation = this.getCitation(result);
doc.license = this.getLicense(result); doc.license = this.getLicense(result);
doc.keyword = this.getKeyword(result); doc.keyword = this.getKeyword(result);
doc.isPartOf = [];
let fosSubjects = this.getKeyword(result,"FOS");
let sdgSubjects = this.getKeyword(result,"SDG");
for(let fos of fosSubjects?fosSubjects:[]){
doc.isPartOf.push(URL.split('/search/')[0]+ searchActionRoute + "?fos=" + encodeURIComponent('"'+fos+'"'));
}
for(let sdg of sdgSubjects?sdgSubjects:[] ){
doc.isPartOf.push(URL.split('/search/')[0]+ searchActionRoute + "?sdg=" + encodeURIComponent('"'+sdg+'"'));
}
return doc; return doc;
} }