From d97a4d6f6974995a33bfbb7e949b1d88ab91b3b2 Mon Sep 17 00:00:00 2001 From: "argiro.kokogiannaki" Date: Wed, 28 Apr 2021 15:54:30 +0000 Subject: [PATCH] [Library | Trunk] Search pages: updating canonical url with filters update title with filter values git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-services-library/trunk/ng-openaire-library/src/app@60976 d315682c-612b-4755-9ff5-7f18f6832af3 --- .../result/resultLanding.component.ts | 1 + .../advancedSearchForm.component.ts | 1 - .../searchUtils/datasourcesHelper.class.ts | 8 +- .../searchUtils/newSearchPage.component.html | 4 +- .../searchUtils/newSearchPage.component.ts | 81 +++++++++---------- 5 files changed, 47 insertions(+), 48 deletions(-) diff --git a/landingPages/result/resultLanding.component.ts b/landingPages/result/resultLanding.component.ts index 13394fc3..bb329f0f 100644 --- a/landingPages/result/resultLanding.component.ts +++ b/landingPages/result/resultLanding.component.ts @@ -362,6 +362,7 @@ export class ResultLandingComponent { this.canonicalUrl = this.properties.domain+ properties.baseLink + ( pid ? (this.linkToLandingPage.split("?")[0] + "?pid=" + encodeURIComponent(pid.id)): (this.linkToLandingPage + this.resultLandingInfo.relcanId)); this.seoService.createLinkForCanonicalURL(this.canonicalUrl); + this.updateUrl(this.canonicalUrl); if ((this.type == "publication") && (this.properties.environment == "beta" || this.properties.environment == "development") && (typeof document !== 'undefined')) { this.getOpenCitations(); } diff --git a/searchPages/searchUtils/advancedSearchForm.component.ts b/searchPages/searchUtils/advancedSearchForm.component.ts index 86666ce6..7e2684b1 100644 --- a/searchPages/searchUtils/advancedSearchForm.component.ts +++ b/searchPages/searchUtils/advancedSearchForm.component.ts @@ -24,7 +24,6 @@ export class AdvancedSearchFormComponent { @Input() advancedSearchLinkParameters; @Input() simpleView:boolean = false; @Input() formPlaceholderText = "Type Keywords..."; - @Input() pageTitle; @Output() queryChange = new EventEmitter(); @Input()resultTypes; @Input() quickFilter:{filter: Filter, selected:boolean, filterId:string, value:string}; diff --git a/searchPages/searchUtils/datasourcesHelper.class.ts b/searchPages/searchUtils/datasourcesHelper.class.ts index 9d2ced46..fe16fd41 100644 --- a/searchPages/searchUtils/datasourcesHelper.class.ts +++ b/searchPages/searchUtils/datasourcesHelper.class.ts @@ -32,13 +32,13 @@ export class DatasourcesHelperClass { } public static getDescription(type: "all" | "registries" | "journals" | "compatible" | "deposit") { if (type == "registries") { - return ["Discover research Entity Registries.","For each entity are available description and the research projects managed. Categorized by type and OpenAIRE compatibility level."]; + return ["Entity Registries","Discover research Entity Registries.","For each entity are available description and the research projects managed. Categorized by type and OpenAIRE compatibility level."]; } else if (type == "journals") { - return ["Discover research Journals. ","For each entity are available description, subjects, related content providers, publications and research outcomes per year and type."]; + return ["Research journals","Discover research Journals. ","For each entity are available description, subjects, related content providers, publications and research outcomes per year and type."]; } else if (type == "compatible") { - return ["Discover publication, data, software, istitutional and thematic repositories.","Available repository research outcomes per year and type."]; + return ["research repositories", "Discover publication, data, software, istitutional and thematic repositories.","Available repository research outcomes per year and type."]; } else { - return ["Discover worldwide research content providers and correlated research.","Statistics data about produced research outocomes per year available."]; + return ["Content providers","Discover worldwide research content providers and correlated research.","Statistics data about produced research outocomes per year available."]; } } public static getQueryPrefix(type: "all" | "registries" | "journals" | "compatible" | "deposit"): string { diff --git a/searchPages/searchUtils/newSearchPage.component.html b/searchPages/searchUtils/newSearchPage.component.html index b3c6a731..d6bbab11 100644 --- a/searchPages/searchUtils/newSearchPage.component.html +++ b/searchPages/searchUtils/newSearchPage.component.html @@ -177,7 +177,7 @@ [advancedSearchLink]="advancedSearchLink" [advancedSearchLinkParameters] ="this.routerHelper.createQueryParams(this.parameterNames, this.parameterValues)" - [pageTitle]=pageTitle [simpleView]="simpleView" [formPlaceholderText]="formPlaceholderText" + [simpleView]="simpleView" [formPlaceholderText]="formPlaceholderText" [resultTypes]="resultTypes" [quickFilter]="quickFilter" [entitiesSelection]="entitiesSelection" [showSwitchSearchLink]="showSwitchSearchLink" [customFilter]="customFilter" > @@ -190,7 +190,7 @@ - diff --git a/searchPages/searchUtils/newSearchPage.component.ts b/searchPages/searchUtils/newSearchPage.component.ts index 9d68d844..8203ee83 100644 --- a/searchPages/searchUtils/newSearchPage.component.ts +++ b/searchPages/searchUtils/newSearchPage.component.ts @@ -36,6 +36,7 @@ export class NewSearchPageComponent { @Input() piwikSiteId = null; @Input() hasPrefix: boolean = true; @Input() pageTitle = ""; + pageTitleWithFilters = ""; @Input() results = []; @Input() type; @Input() entityType; @@ -154,26 +155,20 @@ export class NewSearchPageComponent { HelperFunctions.scrollToId("searchForm"); } this.customFilterEnabled = params['cf'] && params['cf'] == "true"; - }); - if (!this.includeOnlyResultsAndFilter) { if(this.basicMetaDescription.length == 0 ){ if (this.entityType == "result") { - this.basicMetaDescription = ["Discover" + (this.properties.adminToolsCommunity == 'openaire'?"over 100 million of":"")+" research outcomes ", "categorized by research type, year range, funder, languages, community and content providers."]; + this.basicMetaDescription = ["Research outcomes","Discover" + (this.properties.adminToolsCommunity == 'openaire'?" over 100 million of":"")+" research outcomes ", "categorized by research type, year range, funder, languages, community and content providers."]; } else if (this.entityType == "project") { - this.basicMetaDescription = ["Discover research projects and correlated research categorized by Funder and active year. ", "Statistics data about produced research outcomes per year available."]; + this.basicMetaDescription = ["Research projects", "Discover research projects and correlated research categorized by Funder and active year. ", "Statistics data about produced research outcomes per year available."]; } else if (this.entityType == "organization") { - this.basicMetaDescription = ["Discover worldwide research organizations from over 100 countries and correlated research. ", "Funding, content providers, research pubblications and research data available."]; + this.basicMetaDescription = ["Research organization","Discover worldwide research organizations from over 100 countries and correlated research. ", "Funding, content providers, research pubblications and research data available."]; }else{ this.basicMetaDescription.push(this.pageTitle) } } - this.metaDescription = this.basicMetaDescription.join(" "); - this.updateTitle(this.pageTitle); - this.updateDescription(); - } - + this.updateMeta(this.pageTitle); + }); this.searchUtils.baseUrl = "/" + this.searchUtils.baseUrl; - this.seoService.createLinkForCanonicalURL(this.properties.domain + this.properties.baseLink + this.router.url, false); this.breadcrumbs.push({name: 'home', route: '/'}); if(this.simpleView) { this.breadcrumbs.push( {name: "Search", route: null}); @@ -211,52 +206,55 @@ export class NewSearchPageComponent { }); } - updateDescription() { - // this.metaDescription2 = ""; - /*if(this.resultTypes){ - let array = []; - for(let type of this.resultTypeOptions){ - if(this.resultTypes[type.id]== true){ - array.push(type.name); + updateMeta(title:string) { + let filterArray = []; + let filtervalues = []; + let filterURL = ""; + if(this.resultTypes && this.resultTypes.countSelectedValues> 0){ + filterURL += ((filterURL.length == 0) ? '?' : '&') + this.resultTypes.filterId + "="; + let filterName = this.resultTypes.title+" "; + for(let value of this.resultTypes.values){ + if(value.selected) { + filterArray.push(filterName + '"' + value.name + '"'); + filtervalues.push(value.name); + filterURL += ((filterName.length == 0) ? ',' : '') + StringUtils.URIEncode('"' + value.id+ '"' ); + filterName = ""; } } - if(array.length == 0){ - this.metaDescription += "research outcomes "; - }else{ - this.metaDescription += array.join(", ") + " "; - } - }else{ - this.metaDescription = this.pageTitle + " "; - }*/ - let filterArray = []; + } for(let filter of this.filters){ if(filter.countSelectedValues> 0){ + filterURL += ((filterURL.length == 0) ? '?' : '&') + filter.filterId + "="; + let filterName = filter.title+" "; for(let value of filter.values){ if(value.selected) { - filterArray.push(value.name); + filterArray.push(filterName + '"' + value.name + '"'); + filtervalues.push(value.name); + filterURL += ((filterName.length == 0) ? ',' : '') + StringUtils.URIEncode('"' + value.id + '"' ); + filterName = ""; + } } } } - for(let field of this.selectedFields){ - if((field.type == "entity" || field.type == "refine") && field.valueLabel.length > 0 && filterArray.indexOf(field.valueLabel)==-1){ - filterArray.push(field.valueLabel) - }else if(!(field.type == "entity" || field.type == "refine") && field.value.length > 0 && filterArray.indexOf(field.value)==-1) { - filterArray.push(field.value); - } - } - this.metaDescription= (filterArray.length > 0?( this.basicMetaDescription[0] + " Filtered by: " + filterArray.join(", ") + " ") - :this.basicMetaDescription.join(" ")); + let nonCanonicalizedPage = (filterArray.length > 0 && filterArray.length<3); + this.metaDescription= (nonCanonicalizedPage?( (this.basicMetaDescription[0] + " filtered by: " + filterArray.join(" and ") + ". ") + (this.basicMetaDescription.length > 1 ?this.basicMetaDescription[1]:"")) + :((this.basicMetaDescription.length > 2 ?this.basicMetaDescription[1] + this.basicMetaDescription[2]:this.basicMetaDescription[0]))); this._meta.updateTag({content: this.metaDescription}, "name='description'"); this._meta.updateTag({content: this.metaDescription}, "property='og:description'"); + this.updateTitle(title, (nonCanonicalizedPage ? filtervalues.join(" | ") + " | ": "")); + this.url = this.properties.domain + this.properties.baseLink + this.router.url.split('?')[0] + (nonCanonicalizedPage ? filterURL : ""); + this.seoService.createLinkForCanonicalURL(this.url, true); } - updateTitle(title: string) { - var _prefix = ""; + updateTitle(title: string, filters:string) { + let _prefix = ""; if (this.hasPrefix) { _prefix = "OpenAIRE | "; } - var _title = _prefix + ((title.length > 50) ? title.substring(0, 50) : title); + let _title = _prefix + filters + title; + // _title = ((_title.length > 50) ? _title.substring(0, 50) : _title); + this.pageTitleWithFilters = _title; this._title.setTitle(_title); this._meta.updateTag({content: _title}, "property='og:title'"); } @@ -457,7 +455,7 @@ export class NewSearchPageComponent { } this.filterFilterValues(this.filters); if(!this.includeOnlyResultsAndFilter) { - this.updateDescription(); + this.updateMeta(this.pageTitle); } return filters; } @@ -1535,6 +1533,7 @@ public static createRangeFilterQuery(rangeField,selectedFromValue, selectedToVal this.checkSelectedFilters(this.filters); this.countSelectedFilters(this.filters); + this.updateMeta(this.pageTitle) return this.filters; }