add metadata for SDGs and FOS pages

This commit is contained in:
Alex Martzios 2022-06-21 14:08:21 +03:00
parent fc317468c0
commit 429ad98246
8 changed files with 65 additions and 10 deletions

View File

@ -1,4 +1,4 @@
<!-- <schema2jsonld *ngIf="url" [URL]="url" [name]="pageTitle" type="other" [description]="description"></schema2jsonld> -->
<schema2jsonld *ngIf="url" [URL]="url" [name]="pageTitle" type="other" [description]="pageDescription"></schema2jsonld>
<div class="uk-container uk-container-large uk-section uk-section-small uk-padding-remove-bottom">
<div class="uk-padding-small uk-padding-remove-horizontal">
<breadcrumbs [breadcrumbs]="breadcrumbs"></breadcrumbs>

View File

@ -6,7 +6,8 @@ import {Breadcrumb} from "../openaireLibrary/utils/breadcrumbs/breadcrumbs.compo
import {EnvProperties} from "../openaireLibrary/utils/properties/env-properties";
import {properties} from "src/environments/environment";
import {FormBuilder, FormControl} from "@angular/forms";
import {ActivatedRoute} from "@angular/router";
import {ActivatedRoute, Router} from "@angular/router";
import {Meta, Title} from "@angular/platform-browser";
import {Location} from "@angular/common";
import {StringUtils} from "../openaireLibrary/utils/string-utils.class";
@ -16,6 +17,9 @@ import {StringUtils} from "../openaireLibrary/utils/string-utils.class";
styleUrls: ['fos.component.css']
})
export class FosComponent implements OnInit, OnDestroy {
public url: string = null;
public pageTitle: string = "OpenAIRE | Fields of Science";
public pageDescription: string = "We have integrated a Field-of-Science (FoS) taxonomy into our dataset to organize and discover research more effectively. Using the full capabilities of the OpenAIRE Research Graph (full-texts, citations, references, venues) we apply AI and bring forward any multidisciplinarity potential.";
public fos: any[] = [];
public fosOptions: string[] = [];
@ -38,9 +42,16 @@ export class FosComponent implements OnInit, OnDestroy {
private fb: FormBuilder,
private location: Location,
private route: ActivatedRoute,
private _router: Router,
private _meta: Meta,
private _title: Title
) {}
ngOnInit() {
this.url = this.properties.domain + this.properties.baseLink + this._router.url;
this.updateUrl(this.url);
this.updateTitle(this.pageTitle);
this.updateDescription(this.pageDescription);
this.keywordControl = this.fb.control('');
this.httpClient.get(properties.domain+'/assets/vocabulary/fos.json').subscribe(data => {
this.fos = data['fos'];
@ -139,5 +150,20 @@ export class FosComponent implements OnInit, OnDestroy {
public urlEncodeAndQuote(str: string): string {
return StringUtils.quote(StringUtils.URIEncode(str));
}
private updateUrl(url: string) {
this._meta.updateTag({content: url}, "property='og:url'");
}
private updateTitle(title: string) {
var _title = ((title.length > 50) ? title.substring(0, 50) : title);
this._title.setTitle(_title);
this._meta.updateTag({content: _title}, "property='og:title'");
}
private updateDescription(description: string) {
this._meta.updateTag({content: description}, "name='description'");
this._meta.updateTag({content: description}, "property='og:description'");
}
}

View File

@ -3,18 +3,19 @@ import {NgModule} from "@angular/core";
import {FormsModule} from "@angular/forms";
import {RouterModule} from "@angular/router";
import {PreviousRouteRecorder} from "../openaireLibrary/utils/piwik/previousRouteRecorder.guard";
import {IconsModule} from "../openaireLibrary/utils/icons/icons.module";
import {BreadcrumbsModule} from "../openaireLibrary/utils/breadcrumbs/breadcrumbs.module";
import {Schema2jsonldModule} from "../openaireLibrary/sharedComponents/schema2jsonld/schema2jsonld.module";
import {SearchInputModule} from "../openaireLibrary/sharedComponents/search-input/search-input.module";
import {FosRoutingModule} from './fos-routing.module';
import {FosComponent} from './fos.component';
import {IconsModule} from "../openaireLibrary/utils/icons/icons.module";
import {SearchInputModule} from "../openaireLibrary/sharedComponents/search-input/search-input.module";
@NgModule({
imports: [
CommonModule, FormsModule, RouterModule,
FosRoutingModule, BreadcrumbsModule, IconsModule,
SearchInputModule
SearchInputModule, Schema2jsonldModule
],
declarations: [
FosComponent

@ -1 +1 @@
Subproject commit fff6dffd8871615e2bccfcda9b6ff025e79f5d80
Subproject commit 0c4df8a34dd4f518353c5924238eca9d2cf0a91e

View File

@ -1,4 +1,4 @@
<!-- <schema2jsonld *ngIf="url" [URL]="url" [name]="pageTitle" type="other" [description]="description"></schema2jsonld> -->
<schema2jsonld *ngIf="url" [URL]="url" [name]="pageTitle" type="other" [description]="pageDescription"></schema2jsonld>
<div class="uk-container uk-container-large uk-section uk-section-small uk-padding-remove-bottom">
<div class="uk-padding-small uk-padding-remove-horizontal">
<breadcrumbs [breadcrumbs]="breadcrumbs"></breadcrumbs>

View File

@ -8,6 +8,8 @@ import {properties} from "src/environments/environment";
import {RefineFieldResultsService} from "../openaireLibrary/services/refineFieldResults.service";
import {OpenaireEntities} from "../openaireLibrary/utils/properties/searchFields";
import {StringUtils} from "../openaireLibrary/utils/string-utils.class";
import {Router} from '@angular/router';
import {Meta, Title} from "@angular/platform-browser";
@Component({
selector: 'sdg',
@ -15,6 +17,9 @@ import {StringUtils} from "../openaireLibrary/utils/string-utils.class";
styleUrls: ['sdg.component.css']
})
export class SdgComponent implements OnInit, OnDestroy {
public url: string = null;
public pageTitle: string = "OpenAIRE | Sustainable Development Goals";
public pageDescription: string = "Laying the foundation for new approaches and solutions. We have developed a classification scheme for UN Sustainable Development Goals, to view contributions of research towards complex challenges for humanity such as climate change, biodiversity loss, pollution and poverty reduction.";
private sdgs: any = [];
private sdgsResearchOutcomes: any = [];
@ -28,11 +33,18 @@ export class SdgComponent implements OnInit, OnDestroy {
subscriptions: Subscription[] = [];
constructor(
private httpClient: HttpClient, private refineFieldResultsService: RefineFieldResultsService
private httpClient: HttpClient, private refineFieldResultsService: RefineFieldResultsService,
private _router: Router,
private _meta: Meta,
private _title: Title
) {}
ngOnInit() {
this.loading = true;
this.url = this.properties.domain + this.properties.baseLink + this._router.url;
this.updateUrl(this.url);
this.updateTitle(this.pageTitle);
this.updateDescription(this.pageDescription);
this.httpClient.get(properties.domain+'/assets/vocabulary/sdg.json').subscribe(data => {
this.sdgs = data['sdg'];
});
@ -58,5 +70,20 @@ export class SdgComponent implements OnInit, OnDestroy {
public urlEncodeAndQuote(str: string): string {
return StringUtils.quote(StringUtils.URIEncode(str));
}
private updateUrl(url: string) {
this._meta.updateTag({content: url}, "property='og:url'");
}
private updateTitle(title: string) {
var _title = ((title.length > 50) ? title.substring(0, 50) : title);
this._title.setTitle(_title);
this._meta.updateTag({content: _title}, "property='og:title'");
}
private updateDescription(description: string) {
this._meta.updateTag({content: description}, "name='description'");
this._meta.updateTag({content: description}, "property='og:description'");
}
}

View File

@ -6,6 +6,7 @@ import {PreviousRouteRecorder} from "../openaireLibrary/utils/piwik/previousRout
import {BreadcrumbsModule} from "../openaireLibrary/utils/breadcrumbs/breadcrumbs.module";
import {RefineFieldResultsServiceModule} from "../openaireLibrary/services/refineFieldResultsService.module";
import {LoadingModule} from "../openaireLibrary/utils/loading/loading.module";
import {Schema2jsonldModule} from "../openaireLibrary/sharedComponents/schema2jsonld/schema2jsonld.module";
import {SdgRoutingModule} from './sdg-routing.module';
import {SdgComponent} from './sdg.component';
@ -14,7 +15,7 @@ import {SdgComponent} from './sdg.component';
imports: [
CommonModule, FormsModule, RouterModule,
SdgRoutingModule, BreadcrumbsModule, RefineFieldResultsServiceModule,
LoadingModule
LoadingModule, Schema2jsonldModule
],
declarations: [
SdgComponent

@ -1 +1 @@
Subproject commit 5940eee3a04ba2f8f46c5ffcb1a42824e9f89dbd
Subproject commit 4fca369b2e4f4f2c2689e0efc501d2c548dfeb68