Refactoring - change file name of Meta service & module
git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-services-library/trunk/ng-openaire-library/src/app@50684 d315682c-612b-4755-9ff5-7f18f6832af3
This commit is contained in:
parent
2cebe8c6b5
commit
5c641d6386
|
@ -9,7 +9,7 @@ import { RouterModule } from '@angular/router';
|
||||||
import { AppComponent } from './app.component';
|
import { AppComponent } from './app.component';
|
||||||
import {NavigationBarModule} from './sharedComponents/navigationBar.module';
|
import {NavigationBarModule} from './sharedComponents/navigationBar.module';
|
||||||
import { CookieLawModule } from './sharedComponents/cookie-law/cookie-law.module';
|
import { CookieLawModule } from './sharedComponents/cookie-law/cookie-law.module';
|
||||||
import {Meta} from '../angular2-meta';
|
import {Meta} from './sharedComponents/metaService';
|
||||||
// import { ErrorModule } from './error/error.module';
|
// import { ErrorModule } from './error/error.module';
|
||||||
import { ConfigurationService } from './utils/configuration/configuration.service';
|
import { ConfigurationService } from './utils/configuration/configuration.service';
|
||||||
import {MainSearchModule} from './searchPages/find/mainSearch.module';
|
import {MainSearchModule} from './searchPages/find/mainSearch.module';
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import {Component, ViewChild, Input} from '@angular/core';
|
import {Component, ViewChild, Input} from '@angular/core';
|
||||||
import {Location} from '@angular/common';
|
import {Location} from '@angular/common';
|
||||||
import {Observable} from 'rxjs/Observable';
|
import {Observable} from 'rxjs/Observable';
|
||||||
import { Meta} from '../../../angular2-meta';
|
import { Meta} from '../../sharedComponents/metaService';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'claims-admin',
|
selector: 'claims-admin',
|
||||||
|
|
|
@ -10,7 +10,7 @@ import {ModalLoading} from '../../utils/modal/loading.component';
|
||||||
import {Session} from '../../login/utils/helper.class';
|
import {Session} from '../../login/utils/helper.class';
|
||||||
|
|
||||||
import {RouterHelper} from '../../utils/routerHelper.class';
|
import {RouterHelper} from '../../utils/routerHelper.class';
|
||||||
import { Meta} from '../../../angular2-meta';
|
import { Meta} from '../../sharedComponents/metaService';
|
||||||
import {ClaimsDatatablePipe} from '../../utils/pipes/claimsDatatable.pipe';
|
import {ClaimsDatatablePipe} from '../../utils/pipes/claimsDatatable.pipe';
|
||||||
import { DataTableDirective } from 'angular-datatables';
|
import { DataTableDirective } from 'angular-datatables';
|
||||||
import{EnvProperties} from '../../utils/properties/env-properties';
|
import{EnvProperties} from '../../utils/properties/env-properties';
|
||||||
|
|
|
@ -8,7 +8,7 @@ import {SearchDatasetsService} from '../../services/searchDatasets.service';
|
||||||
import {SearchSoftwareService} from '../../services/searchSoftware.service';
|
import {SearchSoftwareService} from '../../services/searchSoftware.service';
|
||||||
import{EnvProperties} from '../../utils/properties/env-properties';
|
import{EnvProperties} from '../../utils/properties/env-properties';
|
||||||
|
|
||||||
import { Meta} from '../../../angular2-meta';
|
import { Meta} from '../../sharedComponents/metaService';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'directLinking',
|
selector: 'directLinking',
|
||||||
|
|
|
@ -5,7 +5,7 @@ import {EntitiesSearchService} from '../../utils/entitiesAutoComplete/entitySear
|
||||||
import {ClaimProject, ClaimResult} from '../claim-utils/claimEntities.class';
|
import {ClaimProject, ClaimResult} from '../claim-utils/claimEntities.class';
|
||||||
import {SearchPublicationsService} from '../../services/searchPublications.service';
|
import {SearchPublicationsService} from '../../services/searchPublications.service';
|
||||||
import {SearchDatasetsService} from '../../services/searchDatasets.service';
|
import {SearchDatasetsService} from '../../services/searchDatasets.service';
|
||||||
import { Meta} from '../../../angular2-meta';
|
import { Meta} from '../../sharedComponents/metaService';
|
||||||
import{EnvProperties} from '../../utils/properties/env-properties';
|
import{EnvProperties} from '../../utils/properties/env-properties';
|
||||||
|
|
||||||
declare var UIkit:any;
|
declare var UIkit:any;
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import {Component, Input} from '@angular/core';
|
import {Component, Input} from '@angular/core';
|
||||||
import {Observable} from 'rxjs/Observable';
|
import {Observable} from 'rxjs/Observable';
|
||||||
import { Meta} from '../../../angular2-meta';
|
import { Meta} from '../../sharedComponents/metaService';
|
||||||
|
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
|
|
|
@ -7,7 +7,7 @@ import { FetchDataproviders } from '../../utils/fetchEntitiesClasses/fetchDatapr
|
||||||
import { SearchDataprovidersService } from '../../services/searchDataproviders.service';
|
import { SearchDataprovidersService } from '../../services/searchDataproviders.service';
|
||||||
|
|
||||||
import {OrganizationService} from '../../services/organization.service';
|
import {OrganizationService} from '../../services/organization.service';
|
||||||
import { Meta} from '../../../angular2-meta';
|
import { Meta} from '../../sharedComponents/metaService';
|
||||||
|
|
||||||
import {RouterHelper} from '../../utils/routerHelper.class';
|
import {RouterHelper} from '../../utils/routerHelper.class';
|
||||||
import {PiwikService} from '../../utils/piwik/piwik.service';
|
import {PiwikService} from '../../utils/piwik/piwik.service';
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import {Component, Input} from '@angular/core';
|
import {Component, Input} from '@angular/core';
|
||||||
import {Observable} from 'rxjs/Observable';
|
import {Observable} from 'rxjs/Observable';
|
||||||
import { Router, ActivatedRoute} from '@angular/router';
|
import { Router, ActivatedRoute} from '@angular/router';
|
||||||
import { Meta} from '../../angular2-meta';
|
import { Meta} from '../sharedComponents/metaService';
|
||||||
import {PiwikService} from '../utils/piwik/piwik.service';
|
import {PiwikService} from '../utils/piwik/piwik.service';
|
||||||
import{EnvProperties} from '../utils/properties/env-properties';
|
import{EnvProperties} from '../utils/properties/env-properties';
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,7 @@ import { FetchDataproviders } from '../utils/fetchEntitiesClasses/fetchDataprovi
|
||||||
import { SearchDataprovidersService } from '../services/searchDataproviders.service';
|
import { SearchDataprovidersService } from '../services/searchDataproviders.service';
|
||||||
|
|
||||||
import {OrganizationService} from '../services/organization.service';
|
import {OrganizationService} from '../services/organization.service';
|
||||||
import { Meta} from '../../angular2-meta';
|
import { Meta} from '../sharedComponents/metaService';
|
||||||
|
|
||||||
import {RouterHelper} from '../utils/routerHelper.class';
|
import {RouterHelper} from '../utils/routerHelper.class';
|
||||||
import {PiwikService} from '../utils/piwik/piwik.service';
|
import {PiwikService} from '../utils/piwik/piwik.service';
|
||||||
|
|
|
@ -3,7 +3,7 @@ import { CommonModule } from '@angular/common';
|
||||||
import { FormsModule } from '@angular/forms';
|
import { FormsModule } from '@angular/forms';
|
||||||
|
|
||||||
import {ErrorPageComponent } from './errorPage.component';
|
import {ErrorPageComponent } from './errorPage.component';
|
||||||
import {MetaModule} from '../../meta.module';
|
import {MetaModule} from '../sharedComponents/metaService.module';
|
||||||
|
|
||||||
@NgModule({
|
@NgModule({
|
||||||
imports: [
|
imports: [
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import { Component, Input } from '@angular/core';
|
import { Component, Input } from '@angular/core';
|
||||||
import { Location } from '@angular/common';
|
import { Location } from '@angular/common';
|
||||||
import { Meta} from '../../angular2-meta';
|
import { Meta} from '../sharedComponents/metaService';
|
||||||
import {ActivatedRoute} from '@angular/router';
|
import {ActivatedRoute} from '@angular/router';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
|
|
|
@ -3,7 +3,7 @@ import {Observable} from 'rxjs/Observable';
|
||||||
import {DataProviderService} from './dataProvider.service';
|
import {DataProviderService} from './dataProvider.service';
|
||||||
import {DataProviderInfo} from '../../utils/entities/dataProviderInfo';
|
import {DataProviderInfo} from '../../utils/entities/dataProviderInfo';
|
||||||
import {ActivatedRoute, Router} from '@angular/router';
|
import {ActivatedRoute, Router} from '@angular/router';
|
||||||
import { Meta} from '../../../angular2-meta';
|
import { Meta} from '../../sharedComponents/metaService';
|
||||||
import { FetchPublications } from '../../utils/fetchEntitiesClasses/fetchPublications.class';
|
import { FetchPublications } from '../../utils/fetchEntitiesClasses/fetchPublications.class';
|
||||||
import { SearchPublicationsService } from '../../services/searchPublications.service';
|
import { SearchPublicationsService } from '../../services/searchPublications.service';
|
||||||
import { FetchDatasets } from '../../utils/fetchEntitiesClasses/fetchDatasets.class';
|
import { FetchDatasets } from '../../utils/fetchEntitiesClasses/fetchDatasets.class';
|
||||||
|
|
|
@ -4,7 +4,7 @@ import {DatasetService} from './dataset.service';
|
||||||
import {DatasetInfo} from '../../utils/entities/datasetInfo';
|
import {DatasetInfo} from '../../utils/entities/datasetInfo';
|
||||||
import {ActivatedRoute, Router} from '@angular/router';
|
import {ActivatedRoute, Router} from '@angular/router';
|
||||||
import {RouterHelper} from '../../utils/routerHelper.class';
|
import {RouterHelper} from '../../utils/routerHelper.class';
|
||||||
import { Meta} from '../../../angular2-meta';
|
import { Meta} from '../../sharedComponents/metaService';
|
||||||
import {PiwikService} from '../../utils/piwik/piwik.service';
|
import {PiwikService} from '../../utils/piwik/piwik.service';
|
||||||
import{EnvProperties} from '../../utils/properties/env-properties';
|
import{EnvProperties} from '../../utils/properties/env-properties';
|
||||||
|
|
||||||
|
|
|
@ -18,7 +18,7 @@ import { LandingModule } from '../landing-utils/landing.module';
|
||||||
import {FreeGuard} from'../../login/freeGuard.guard';
|
import {FreeGuard} from'../../login/freeGuard.guard';
|
||||||
import {IsRouteEnabled} from '../../error/isRouteEnabled.guard';
|
import {IsRouteEnabled} from '../../error/isRouteEnabled.guard';
|
||||||
|
|
||||||
import {MetaModule} from '../../../meta.module';
|
import {MetaModule} from '../../sharedComponents/metaService.module';
|
||||||
import { ConfigurationServiceModule } from '../../utils/configuration/configurationService.module';
|
import { ConfigurationServiceModule } from '../../utils/configuration/configurationService.module';
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,7 @@ import {Observable} from 'rxjs/Observable';
|
||||||
import {ActivatedRoute, Params, Router} from '@angular/router';
|
import {ActivatedRoute, Params, Router} from '@angular/router';
|
||||||
import {HtmlProjectReportService} from './htmlProjectReport.service';
|
import {HtmlProjectReportService} from './htmlProjectReport.service';
|
||||||
import {ProjectService} from '../project/project.service';
|
import {ProjectService} from '../project/project.service';
|
||||||
import { Meta} from '../../../angular2-meta';
|
import { Meta} from '../../sharedComponents/metaService';
|
||||||
import {PiwikService} from '../../utils/piwik/piwik.service';
|
import {PiwikService} from '../../utils/piwik/piwik.service';
|
||||||
import{EnvProperties} from '../../utils/properties/env-properties';
|
import{EnvProperties} from '../../utils/properties/env-properties';
|
||||||
|
|
||||||
|
|
|
@ -12,7 +12,7 @@ import {FetchDataproviders} from '../../utils/fetchEntitiesClasses/fetchDataprov
|
||||||
import {SearchPublicationsService} from '../../services/searchPublications.service';
|
import {SearchPublicationsService} from '../../services/searchPublications.service';
|
||||||
import {SearchDataprovidersService} from '../../services/searchDataproviders.service';
|
import {SearchDataprovidersService} from '../../services/searchDataproviders.service';
|
||||||
import {SearchProjectsService} from '../../services/searchProjects.service';
|
import {SearchProjectsService} from '../../services/searchProjects.service';
|
||||||
import { Meta} from '../../../angular2-meta';
|
import { Meta} from '../../sharedComponents/metaService';
|
||||||
import {ErrorCodes} from '../../utils/properties/openaireProperties';
|
import {ErrorCodes} from '../../utils/properties/openaireProperties';
|
||||||
import {SearchingProjectsTabComponent} from '../landing-utils/searchingProjectsInTab.component';
|
import {SearchingProjectsTabComponent} from '../landing-utils/searchingProjectsInTab.component';
|
||||||
import {RouterHelper} from '../../utils/routerHelper.class';
|
import {RouterHelper} from '../../utils/routerHelper.class';
|
||||||
|
|
|
@ -16,7 +16,7 @@ import {ModalLoading} from '../../utils/modal/loading.component';
|
||||||
|
|
||||||
import {ReportsService} from '../../services/reports.service';
|
import {ReportsService} from '../../services/reports.service';
|
||||||
import { ErrorCodes} from '../../utils/properties/openaireProperties';
|
import { ErrorCodes} from '../../utils/properties/openaireProperties';
|
||||||
import { Meta} from '../../../angular2-meta';
|
import { Meta} from '../../sharedComponents/metaService';
|
||||||
|
|
||||||
import {PiwikService} from '../../utils/piwik/piwik.service';
|
import {PiwikService} from '../../utils/piwik/piwik.service';
|
||||||
import{EnvProperties} from '../../utils/properties/env-properties';
|
import{EnvProperties} from '../../utils/properties/env-properties';
|
||||||
|
|
|
@ -7,7 +7,7 @@ import {RouterHelper} from '../../utils/routerHelper.class';
|
||||||
import {PiwikService} from '../../utils/piwik/piwik.service';
|
import {PiwikService} from '../../utils/piwik/piwik.service';
|
||||||
import{EnvProperties} from '../../utils/properties/env-properties';
|
import{EnvProperties} from '../../utils/properties/env-properties';
|
||||||
|
|
||||||
import { Meta} from '../../../angular2-meta';
|
import { Meta} from '../../sharedComponents/metaService';
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -18,7 +18,7 @@ import { ResultLandingModule } from '../landing-utils/resultLanding.module';
|
||||||
import { LandingModule } from '../landing-utils/landing.module';
|
import { LandingModule } from '../landing-utils/landing.module';
|
||||||
import {FreeGuard} from'../../login/freeGuard.guard';
|
import {FreeGuard} from'../../login/freeGuard.guard';
|
||||||
import {IsRouteEnabled} from '../../error/isRouteEnabled.guard';
|
import {IsRouteEnabled} from '../../error/isRouteEnabled.guard';
|
||||||
import {MetaModule} from '../../../meta.module';
|
import {MetaModule} from '../../sharedComponents/metaService.module';
|
||||||
import { ConfigurationServiceModule } from '../../utils/configuration/configurationService.module';
|
import { ConfigurationServiceModule } from '../../utils/configuration/configurationService.module';
|
||||||
@NgModule({
|
@NgModule({
|
||||||
imports: [
|
imports: [
|
||||||
|
|
|
@ -4,7 +4,7 @@ import {SoftwareService} from './software.service';
|
||||||
import {SoftwareInfo} from '../../utils/entities/softwareInfo';
|
import {SoftwareInfo} from '../../utils/entities/softwareInfo';
|
||||||
import {ActivatedRoute, Router} from '@angular/router';
|
import {ActivatedRoute, Router} from '@angular/router';
|
||||||
import {RouterHelper} from '../../utils/routerHelper.class';
|
import {RouterHelper} from '../../utils/routerHelper.class';
|
||||||
import { Meta} from '../../../angular2-meta';
|
import { Meta} from '../../sharedComponents/metaService';
|
||||||
import {PiwikService} from '../../utils/piwik/piwik.service';
|
import {PiwikService} from '../../utils/piwik/piwik.service';
|
||||||
import{EnvProperties} from '../../utils/properties/env-properties';
|
import{EnvProperties} from '../../utils/properties/env-properties';
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,7 @@ import {ActivatedRoute, Router} from '@angular/router';
|
||||||
// import {LoginService} from './login.service';
|
// import {LoginService} from './login.service';
|
||||||
import {User,Session} from './utils/helper.class';
|
import {User,Session} from './utils/helper.class';
|
||||||
import {RouterHelper} from '../utils/routerHelper.class';
|
import {RouterHelper} from '../utils/routerHelper.class';
|
||||||
import { Meta} from '../../angular2-meta';
|
import { Meta} from '../sharedComponents/metaService';
|
||||||
import{EnvProperties} from '../utils/properties/env-properties';
|
import{EnvProperties} from '../utils/properties/env-properties';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
|
|
|
@ -7,7 +7,7 @@ import { UserRoutingModule } from './user-routing.module';
|
||||||
import {PreviousRouteRecorder} from '../utils/piwik/previousRouteRecorder.guard';
|
import {PreviousRouteRecorder} from '../utils/piwik/previousRouteRecorder.guard';
|
||||||
import {FreeGuard} from './freeGuard.guard';
|
import {FreeGuard} from './freeGuard.guard';
|
||||||
import {LoginGuard} from './loginGuard.guard';
|
import {LoginGuard} from './loginGuard.guard';
|
||||||
import {MetaModule} from '../../meta.module';
|
import {MetaModule} from '../sharedComponents/metaService.module';
|
||||||
|
|
||||||
// import {LoginService} from './login.service';
|
// import {LoginService} from './login.service';
|
||||||
@NgModule({
|
@NgModule({
|
||||||
|
|
|
@ -3,7 +3,7 @@ import {Observable} from 'rxjs/Observable';
|
||||||
import {ActivatedRoute, Router} from '@angular/router';
|
import {ActivatedRoute, Router} from '@angular/router';
|
||||||
import {Location} from '@angular/common';
|
import {Location} from '@angular/common';
|
||||||
|
|
||||||
import { Meta, MetaDefinition} from '../../../angular2-meta';
|
import { Meta, MetaDefinition} from '../../sharedComponents/metaService';
|
||||||
|
|
||||||
import { FetchPublications } from '../../utils/fetchEntitiesClasses/fetchPublications.class';
|
import { FetchPublications } from '../../utils/fetchEntitiesClasses/fetchPublications.class';
|
||||||
import { FetchDataproviders } from '../../utils/fetchEntitiesClasses/fetchDataproviders.class';
|
import { FetchDataproviders } from '../../utils/fetchEntitiesClasses/fetchDataproviders.class';
|
||||||
|
|
|
@ -8,7 +8,7 @@ import {SearchFields, FieldDetails} from '../../utils/properties/searchFields';
|
||||||
import {SearchUtilsClass} from './searchUtils.class';
|
import {SearchUtilsClass} from './searchUtils.class';
|
||||||
import {ModalLoading} from '../../utils/modal/loading.component';
|
import {ModalLoading} from '../../utils/modal/loading.component';
|
||||||
import {StringUtils, Dates} from '../../utils/string-utils.class';
|
import {StringUtils, Dates} from '../../utils/string-utils.class';
|
||||||
import { Meta} from '../../../angular2-meta';
|
import { Meta} from '../../sharedComponents/metaService';
|
||||||
import {PiwikService} from '../../utils/piwik/piwik.service';
|
import {PiwikService} from '../../utils/piwik/piwik.service';
|
||||||
import{EnvProperties} from '../../utils/properties/env-properties';
|
import{EnvProperties} from '../../utils/properties/env-properties';
|
||||||
|
|
||||||
|
|
|
@ -9,7 +9,7 @@ import {SearchFields, FieldDetails} from '../../utils/properties/searchFields';
|
||||||
import {SearchUtilsClass} from './searchUtils.class';
|
import {SearchUtilsClass} from './searchUtils.class';
|
||||||
import {DOI, StringUtils} from '../../utils/string-utils.class';
|
import {DOI, StringUtils} from '../../utils/string-utils.class';
|
||||||
import {ModalLoading} from '../../utils/modal/loading.component';
|
import {ModalLoading} from '../../utils/modal/loading.component';
|
||||||
import { Meta} from '../../../angular2-meta';
|
import { Meta} from '../../sharedComponents/metaService';
|
||||||
import{SearchFilterComponent} from './searchFilter.component';
|
import{SearchFilterComponent} from './searchFilter.component';
|
||||||
import {SearchFilterModalComponent} from './searchFilterModal.component';
|
import {SearchFilterModalComponent} from './searchFilterModal.component';
|
||||||
import { ErrorCodes} from '../../utils/properties/openaireProperties';
|
import { ErrorCodes} from '../../utils/properties/openaireProperties';
|
||||||
|
|
|
@ -10,7 +10,7 @@ import {SearchFields, FieldDetails} from '../../utils/properties/searchFields';
|
||||||
import {SearchUtilsClass} from './searchUtils.class';
|
import {SearchUtilsClass} from './searchUtils.class';
|
||||||
import {DOI, StringUtils} from '../../utils/string-utils.class';
|
import {DOI, StringUtils} from '../../utils/string-utils.class';
|
||||||
import {ModalLoading} from '../../utils/modal/loading.component';
|
import {ModalLoading} from '../../utils/modal/loading.component';
|
||||||
import { Meta} from '../../../angular2-meta';
|
import { Meta} from '../../sharedComponents/metaService';
|
||||||
import{SearchFilterComponent} from './searchFilter.component';
|
import{SearchFilterComponent} from './searchFilter.component';
|
||||||
import {SearchFilterModalComponent} from './searchFilterModal.component';
|
import {SearchFilterModalComponent} from './searchFilterModal.component';
|
||||||
import { ErrorCodes} from '../../utils/properties/openaireProperties';
|
import { ErrorCodes} from '../../utils/properties/openaireProperties';
|
||||||
|
|
|
@ -0,0 +1,15 @@
|
||||||
|
import { NgModule} from '@angular/core';
|
||||||
|
import { CommonModule } from '@angular/common';
|
||||||
|
import { FormsModule } from '@angular/forms';
|
||||||
|
import { RouterModule } from '@angular/router';
|
||||||
|
import {Meta} from './metaService';
|
||||||
|
|
||||||
|
|
||||||
|
@NgModule({
|
||||||
|
imports: [
|
||||||
|
CommonModule
|
||||||
|
|
||||||
|
],
|
||||||
|
providers:[ Meta]
|
||||||
|
})
|
||||||
|
export class MetaModule {}
|
|
@ -0,0 +1,220 @@
|
||||||
|
/**
|
||||||
|
* @license
|
||||||
|
* Copyright Google Inc. All Rights Reserved.
|
||||||
|
*
|
||||||
|
* Use of this source code is governed by an MIT-style license that can be
|
||||||
|
* found in the LICENSE file at https://angular.io/license
|
||||||
|
*/
|
||||||
|
|
||||||
|
import {Injectable, Inject} from '@angular/core';
|
||||||
|
// es6-modules are used here
|
||||||
|
import { ɵgetDOM as getDOM} from '@angular/platform-browser';
|
||||||
|
import {DOCUMENT} from '@angular/platform-browser';
|
||||||
|
/**
|
||||||
|
* Represent meta element.
|
||||||
|
*
|
||||||
|
* ### Example
|
||||||
|
*
|
||||||
|
* ```ts
|
||||||
|
* { name: 'application-name', content: 'Name of my application' },
|
||||||
|
* { name: 'description', content: 'A description of the page', id: 'desc' }
|
||||||
|
* // ...
|
||||||
|
* // Twitter
|
||||||
|
* { name: 'twitter:title', content: 'Content Title' }
|
||||||
|
* // ...
|
||||||
|
* // Google+
|
||||||
|
* { itemprop: 'name', content: 'Content Title' },
|
||||||
|
* { itemprop: 'description', content: 'Content Title' }
|
||||||
|
* // ...
|
||||||
|
* // Facebook / Open Graph
|
||||||
|
* { property: 'fb:app_id', content: '123456789' },
|
||||||
|
* { property: 'og:title', content: 'Content Title' }
|
||||||
|
* ```
|
||||||
|
*
|
||||||
|
* @experimental
|
||||||
|
*/
|
||||||
|
export interface MetaDefinition {
|
||||||
|
charset?: string;
|
||||||
|
content?: string;
|
||||||
|
httpEquiv?: string;
|
||||||
|
id?: string;
|
||||||
|
itemprop?: string;
|
||||||
|
name?: string;
|
||||||
|
property?: string;
|
||||||
|
scheme?: string;
|
||||||
|
url?: string;
|
||||||
|
[prop: string]: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A service that can be used to get and add meta tags.
|
||||||
|
*
|
||||||
|
* @experimental
|
||||||
|
*/
|
||||||
|
@Injectable()
|
||||||
|
export class Meta {
|
||||||
|
private _dom: any = getDOM();
|
||||||
|
constructor( @Inject(DOCUMENT) private _document: any) { }
|
||||||
|
/**
|
||||||
|
* Sets the title of the page
|
||||||
|
*/
|
||||||
|
setTitle(title: string) {
|
||||||
|
this._document.title = title
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Adds a new meta tag to the dom.
|
||||||
|
*
|
||||||
|
* ### Example
|
||||||
|
*
|
||||||
|
* ```ts
|
||||||
|
* const name: MetaDefinition = {name: 'application-name', content: 'Name of my application'};
|
||||||
|
* const desc: MetaDefinition = {name: 'description', content: 'A description of the page'};
|
||||||
|
* const tags: HTMLMetaElement[] = this.meta.addTags([name, desc]);
|
||||||
|
* ```
|
||||||
|
*
|
||||||
|
* @param tags
|
||||||
|
* @returns {HTMLMetaElement[]}
|
||||||
|
*/
|
||||||
|
addTags(...tags: Array<MetaDefinition|MetaDefinition[]>): HTMLMetaElement[] {
|
||||||
|
const presentTags = this._flattenArray(tags);
|
||||||
|
if (presentTags.length === 0) return [];
|
||||||
|
return presentTags.map((tag: MetaDefinition) => this._addInternal(tag));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the meta tag by the given selector. Returns element or null
|
||||||
|
* if there's no such meta element.
|
||||||
|
*
|
||||||
|
* ### Example
|
||||||
|
*
|
||||||
|
* ```ts
|
||||||
|
* const meta: HTMLMetaElement = this.meta.getTag('name=description');
|
||||||
|
* const twitterMeta: HTMLMetaElement = this.meta.getTag('name="twitter:title"');
|
||||||
|
* const fbMeta: HTMLMetaElement = this.meta.getTag('property="fb:app_id"');
|
||||||
|
* ```
|
||||||
|
*
|
||||||
|
* @param selector
|
||||||
|
* @returns {HTMLMetaElement}
|
||||||
|
*/
|
||||||
|
// getTag(selector: string): HTMLMetaElement {
|
||||||
|
// if (!selector) return null;
|
||||||
|
// return this._dom.query(`meta[${selector}]`);
|
||||||
|
// }
|
||||||
|
getTag(attrSelector: string): HTMLMetaElement|null {
|
||||||
|
if (!attrSelector) return null;
|
||||||
|
return this._dom.querySelector(this._document, `meta[${attrSelector}]`);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Updates the meta tag with the given selector.
|
||||||
|
*
|
||||||
|
* * ### Example
|
||||||
|
*
|
||||||
|
* ```ts
|
||||||
|
* const meta: HTMLMetaElement = this.meta.updateTag('name=description', {name: 'description',
|
||||||
|
* content: 'New description'});
|
||||||
|
* console.log(meta.content); // 'New description'
|
||||||
|
* ```
|
||||||
|
*
|
||||||
|
* @param selector
|
||||||
|
* @param tag updated tag definition
|
||||||
|
* @returns {HTMLMetaElement}
|
||||||
|
*/
|
||||||
|
updateTag(selector: string, tag: MetaDefinition): HTMLMetaElement {
|
||||||
|
const meta: HTMLMetaElement = this.getTag(selector);
|
||||||
|
if (!meta) {
|
||||||
|
// create element if it doesn't exist
|
||||||
|
return this._addInternal(tag);
|
||||||
|
}
|
||||||
|
return this._prepareMetaElement(tag, meta);
|
||||||
|
}
|
||||||
|
|
||||||
|
updateMeta(name, content) {
|
||||||
|
const head = this._document.head;
|
||||||
|
let childNodesAsList = this._dom.childNodesAsList(head);
|
||||||
|
let metaEl = childNodesAsList.find(el => el['attribs'] ? el['attribs'].name == name : false);
|
||||||
|
if (metaEl) metaEl['attribs'].content = content;
|
||||||
|
}
|
||||||
|
updateProperty(property, content) {
|
||||||
|
const head = this._document.head;
|
||||||
|
let childNodesAsList = this._dom.childNodesAsList(head);
|
||||||
|
let metaEl = childNodesAsList.find(el => el['attribs'] ? el['attribs'].property == property : false);
|
||||||
|
if (metaEl) metaEl['attribs'].content = content;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Removes meta tag with the given selector from the dom.
|
||||||
|
*
|
||||||
|
* ### Example
|
||||||
|
*
|
||||||
|
* ```ts
|
||||||
|
* this.meta.removeTagBySelector('name=description');
|
||||||
|
* ```
|
||||||
|
*
|
||||||
|
* @param selector
|
||||||
|
*/
|
||||||
|
removeTagBySelector(selector: string): void {
|
||||||
|
const meta: HTMLMetaElement = this.getTag(selector);
|
||||||
|
this.removeTagElement(meta);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Removes given meta element from the dom.
|
||||||
|
*
|
||||||
|
* ### Example
|
||||||
|
* ```ts
|
||||||
|
* const elem: HTMLMetaElement = this.meta.getTag('name=description');
|
||||||
|
* this.meta.removeTagElement(elem);
|
||||||
|
* ```
|
||||||
|
*
|
||||||
|
* @param meta meta element
|
||||||
|
*/
|
||||||
|
removeTagElement(meta: HTMLMetaElement): void {
|
||||||
|
if (meta) {
|
||||||
|
this._removeMetaElement(meta);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private _addInternal(tag: MetaDefinition): HTMLMetaElement {
|
||||||
|
const meta: HTMLMetaElement = this._createMetaElement();
|
||||||
|
this._prepareMetaElement(tag, meta);
|
||||||
|
this._appendMetaElement(meta);
|
||||||
|
return meta;
|
||||||
|
}
|
||||||
|
|
||||||
|
private _createMetaElement(): HTMLMetaElement {
|
||||||
|
return this._dom.createElement('meta') as HTMLMetaElement;
|
||||||
|
}
|
||||||
|
|
||||||
|
private _prepareMetaElement(tag: MetaDefinition, el: HTMLMetaElement): HTMLMetaElement {
|
||||||
|
Object.keys(tag).forEach((prop: string) => this._dom.setAttribute(el, prop, tag[prop]));
|
||||||
|
return el;
|
||||||
|
}
|
||||||
|
|
||||||
|
// private _appendMetaElement(meta: HTMLMetaElement): void {
|
||||||
|
// const head = this._dom.getElementsByTagName(this._dom.defaultDoc(), 'head')[0];
|
||||||
|
// this._dom.appendChild(head, meta);
|
||||||
|
// }
|
||||||
|
private _appendMetaElement(meta: HTMLMetaElement): void {
|
||||||
|
const head = this._document.head;
|
||||||
|
this._dom.appendChild(head, meta);
|
||||||
|
}
|
||||||
|
private _removeMetaElement(meta: HTMLMetaElement): void {
|
||||||
|
const head = this._dom.parentElement(meta);
|
||||||
|
this._dom.removeChild(head, meta);
|
||||||
|
}
|
||||||
|
|
||||||
|
private _flattenArray(input: any[], out: any[] = []): any[] {
|
||||||
|
if (input) {
|
||||||
|
for (let i = 0; i < input.length; i++) {
|
||||||
|
const item: any = input[i];
|
||||||
|
if (Array.isArray(item)) {
|
||||||
|
this._flattenArray(item, out);
|
||||||
|
} else if (item) {
|
||||||
|
out.push(item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return out;
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,4 +1,4 @@
|
||||||
import {Meta} from '../../../angular2-meta';
|
import {Meta} from '../../sharedComponents/metaService';
|
||||||
|
|
||||||
export class OpenaireMetaTags{
|
export class OpenaireMetaTags{
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue