diff --git a/landingPages/dataProvider/dataProvider.component.ts b/landingPages/dataProvider/dataProvider.component.ts index f2ee50da..ab0f0c66 100644 --- a/landingPages/dataProvider/dataProvider.component.ts +++ b/landingPages/dataProvider/dataProvider.component.ts @@ -129,7 +129,6 @@ export class DataProviderComponent { .subscribe((data: { envSpecific: EnvProperties }) => { this.properties = data.envSpecific; this.updateUrl(data.envSpecific.baseLink+this._router.url); - this.seoService.createLinkForCanonicalURL(this.properties.baseLink+this._router.url); }); this.sub = this.route.queryParams.subscribe(data => { @@ -174,7 +173,7 @@ export class DataProviderComponent { this.subInfo = this._dataproviderService.getDataproviderInfo(this.datasourceId, this.properties).subscribe( data => { this.dataProviderInfo = data; - + this.seoService.createLinkForCanonicalURL(this.properties.baseLink+this._router.url); this.getDataProviderAggregationStatus(this.dataProviderInfo.originalId); this.initTabs(); @@ -196,6 +195,7 @@ export class DataProviderComponent { this.handleError("Error getting content provider for id: "+this.datasourceId, err); this.errorMessage = 'No dataProvider found'; this.showLoading = false; + this.seoService.createLinkForCanonicalURL(this.properties.baseLink + this.properties.searchLinkToDataProviders); } ); } diff --git a/landingPages/dataset/dataset.component.ts b/landingPages/dataset/dataset.component.ts index 0a5ed44d..418d497c 100644 --- a/landingPages/dataset/dataset.component.ts +++ b/landingPages/dataset/dataset.component.ts @@ -76,7 +76,6 @@ export class DatasetComponent { .subscribe((data: { envSpecific: EnvProperties }) => { this.properties = data.envSpecific; this.updateUrl(data.envSpecific.baseLink+this._router.url); - this.seoService.createLinkForCanonicalURL(this.properties.baseLink+this._router.url); }); this.sub = this.route.queryParams.subscribe(params => { @@ -129,6 +128,7 @@ export class DatasetComponent { this.infoSub = this._datasetService.getDatasetInfo(id, this. properties).subscribe( data => { this.datasetInfo = data; + this.seoService.createLinkForCanonicalURL(this.properties.baseLink + this.properties.searchLinkToDataset + this.datasetInfo.record["result"]["header"]["dri:objIdentifier"]); /* if(this.datasetInfo.title.name != undefined && this.datasetInfo.title.name!= ''){ this.updateTitle(this.datasetInfo.title.name); @@ -159,7 +159,7 @@ export class DatasetComponent { err => { //console.log(err) this.handleError("Error getting research data for id: "+this.datasetId, err); - + this.seoService.createLinkForCanonicalURL(this.properties.baseLink + this.properties.searchLinkToDatasets); this.errorMessage = 'No research data found'; this.showLoading = false; } diff --git a/landingPages/organization/organization.component.ts b/landingPages/organization/organization.component.ts index d50dc553..4235b1f9 100644 --- a/landingPages/organization/organization.component.ts +++ b/landingPages/organization/organization.component.ts @@ -126,7 +126,6 @@ export class OrganizationComponent { .subscribe((data: { envSpecific: EnvProperties }) => { this.properties = data.envSpecific; this.updateUrl(data.envSpecific.baseLink+this._router.url); - this.seoService.createLinkForCanonicalURL(this.properties.baseLink+this._router.url); }); this.sub = this.route.queryParams.subscribe(params => { this.organizationInfo=null; @@ -203,7 +202,8 @@ export class OrganizationComponent { this.errorMessage = 'No organization found'; } else { this.organizationInfo = data; - this.updateTitle(this.organizationInfo.title.name); + this.seoService.createLinkForCanonicalURL(this.properties.baseLink+this._router.url); + this.updateTitle(this.organizationInfo.title.name); this.updateDescription("Organization, country, "+this.organizationInfo.title.name +((this.organizationInfo.title.name && this.organizationInfo.title.name != this.organizationInfo.name)?(", "+this.organizationInfo.name):"") ); if(this.properties.enablePiwikTrack && (typeof document !== 'undefined')){ this.piwiksub = this._piwikService.trackView(this.properties, this.organizationInfo.title.name, this.piwikSiteId).subscribe(); @@ -235,7 +235,7 @@ export class OrganizationComponent { err => { //console.log(err) this.handleError("Error getting organization for id: "+this.organizationId, err); - + this.seoService.createLinkForCanonicalURL(this.properties.baseLink + this.properties.searchLinkToOrganizations); this.errorMessage = 'No organization found'; this.showLoading = false; } diff --git a/landingPages/orp/orp.component.ts b/landingPages/orp/orp.component.ts index 51f77d8a..1f4fa1e3 100644 --- a/landingPages/orp/orp.component.ts +++ b/landingPages/orp/orp.component.ts @@ -76,7 +76,6 @@ export class OrpComponent { .subscribe((data: { envSpecific: EnvProperties }) => { this.properties = data.envSpecific; this.updateUrl(data.envSpecific.baseLink+this._router.url); - this.seoService.createLinkForCanonicalURL(this.properties.baseLink+this._router.url); }); this.sub = this.route.queryParams.subscribe(params => { @@ -125,6 +124,7 @@ export class OrpComponent { this.infoSub = this._orpService.getOrpInfo(id, this. properties).subscribe( data => { this.orpInfo = data; + this.seoService.createLinkForCanonicalURL(this.properties.baseLink + this.properties.searchLinkToOrp + this.orpInfo.record["result"]["header"]["dri:objIdentifier"]); if(this.orpInfo.title){ this.updateTitle(this.orpInfo.title); this.updateDescription((this.orpInfo.description?(this.orpInfo.description):(","+this.orpInfo.title))); @@ -149,7 +149,7 @@ export class OrpComponent { err => { //console.log(err) this.handleError("Error getting other research product for id: "+this.orpId, err); - + this.seoService.createLinkForCanonicalURL(this.properties.baseLink + this.properties.searchLinkToOrps); this.errorMessage = 'No research product found'; this.showLoading = false; } diff --git a/landingPages/project/project.component.ts b/landingPages/project/project.component.ts index 77e580f9..e3f2834c 100644 --- a/landingPages/project/project.component.ts +++ b/landingPages/project/project.component.ts @@ -136,7 +136,6 @@ properties:EnvProperties; this.updateTitle(title); this.updateDescription(description); - this.seoService.createLinkForCanonicalURL(this.properties.baseLink+this._router.url); this.projectId = params['projectId']; var grantId = params['grantId']; var funder = params['funder']; @@ -318,7 +317,7 @@ actionsAfterLoadId(){ err => { //console.log(err); this.handleError("Error getting project for id: "+this.projectId, err); - + this.seoService.createLinkForCanonicalURL(this.properties.baseLink + this.properties.searchLinkToProjects); this.errorMessage = 'No project found'; this.showLoading = false; } @@ -343,7 +342,7 @@ actionsAfterLoadId(){ err => { //console.log(err); this.handleError("Error getting project for grant id: "+grantId+" and funder: "+funder, err); - + this.seoService.createLinkForCanonicalURL(this.properties.baseLink + this.properties.searchLinkToProjects); this.errorMessage = 'No project found'; this.showLoading = false; } @@ -354,6 +353,7 @@ actionsAfterGettingProjectInfo(){ if(this.projectName == undefined || this.projectName == '') { this.projectName = this.projectInfo.title; } + this.seoService.createLinkForCanonicalURL(this.properties.baseLink+this._router.url); this.updateTitle(this.projectName); this.updateDescription("project, "+this.projectName+ ","+this.projectInfo.funder+","+this.projectInfo.acronym); if(this.properties.enablePiwikTrack && (typeof document !== 'undefined')){ diff --git a/landingPages/publication/publication.component.ts b/landingPages/publication/publication.component.ts index ffca4f16..011960ec 100644 --- a/landingPages/publication/publication.component.ts +++ b/landingPages/publication/publication.component.ts @@ -94,7 +94,6 @@ export class PublicationComponent { this.publicationInfo = null; this.updateTitle("Publication"); this.updateDescription(""); - this.seoService.createLinkForCanonicalURL(this.properties.baseLink+this._router.url); this.articleId = data['articleId']; this.metricsClicked = false; @@ -152,7 +151,7 @@ export class PublicationComponent { this.infoSub = this._publicationService.getPublicationInfo(this.articleId, this.properties).subscribe( data => { this.publicationInfo = data; - + this.seoService.createLinkForCanonicalURL(this.properties.baseLink + this.properties.searchLinkToPublication + this.publicationInfo.record["result"]["header"]["dri:objIdentifier"]); if((this.properties.environment == "beta" || this.properties.environment == "development") && (typeof document !== 'undefined')) { this.getOpenCitations(this.articleId); } @@ -219,6 +218,7 @@ export class PublicationComponent { this.errorMessage = 'No publication found'; this.showLoading = false; + this.seoService.createLinkForCanonicalURL(this.properties.baseLink + this.properties.searchLinkToPublications); } ); } diff --git a/landingPages/software/software.component.ts b/landingPages/software/software.component.ts index 62a0682c..06b040bd 100644 --- a/landingPages/software/software.component.ts +++ b/landingPages/software/software.component.ts @@ -71,7 +71,6 @@ export class SoftwareComponent { .subscribe((data: { envSpecific: EnvProperties }) => { this.properties = data.envSpecific; this.updateUrl(data.envSpecific.baseLink+this._router.url); - this.seoService.createLinkForCanonicalURL(this.properties.baseLink+this._router.url); }); this.sub = this.route.queryParams.subscribe(params => { @@ -124,6 +123,7 @@ export class SoftwareComponent { this.infoSub = this._softwareService.getSoftwareInfo(id, this.properties).subscribe( data => { this.softwareInfo = data; + this.seoService.createLinkForCanonicalURL(this.properties.baseLink + this.properties.searchLinkToSoftwareLanding + this.softwareInfo.record["result"]["header"]["dri:objIdentifier"]); /*if(this.softwareInfo.title.name != undefined && this.softwareInfo.title.name!= ''){ this.updateTitle(this.softwareInfo.title.name); this.updateDescription("Software, search, repositories, open access,"+this.softwareInfo.title.name); @@ -152,7 +152,7 @@ export class SoftwareComponent { err => { //console.log(err) this.handleError("Error getting software for id: "+this.softwareId, err); - + this.seoService.createLinkForCanonicalURL(this.properties.baseLink + this.properties.searchLinkToSoftware); this.errorMessage = 'No software found'; this.showLoading = false; } diff --git a/sharedComponents/SEO/SEO.service.ts b/sharedComponents/SEO/SEO.service.ts index e0811bb5..4e38c75b 100644 --- a/sharedComponents/SEO/SEO.service.ts +++ b/sharedComponents/SEO/SEO.service.ts @@ -11,10 +11,8 @@ export class SEOService { createLinkForCanonicalURL(url:string, addParameters:boolean=true) { if(this.doc && (typeof this.doc.getElementById === "function" || typeof this.doc.createElement === "function") ){ - if(addParameters || !this.doc.URL || this.doc.URL.indexOf("?") == -1){ - url = this.doc.URL; - }else{ - url = this.doc.URL.substring(0,this.doc.URL.indexOf("?")); + if(!addParameters && url && url.indexOf("?") != -1){ + url = url.substring(0,url.indexOf("?")); } if (typeof this.doc.getElementById === "function") { let currentLink: HTMLLinkElement = this.doc.getElementById("relcan"); diff --git a/utils/entities/organizationInfo.ts b/utils/entities/organizationInfo.ts index 74583872..1e72f53c 100644 --- a/utils/entities/organizationInfo.ts +++ b/utils/entities/organizationInfo.ts @@ -3,6 +3,7 @@ export class OrganizationInfo { name: string; country: string; + projects: Map