Project

General

Profile

« Previous | Next » 

Revision 56840

[Trunk | Library]: Fix and add when missing: schema2jsonld, canonincal url, meta tags, piwik call.

View differences:

displayClaims.component.ts
14 14
import {ClaimDBRecord} from "../claimHelper.class";
15 15
import {Dates} from "../../../utils/string-utils.class";
16 16
import {HelperService} from "../../../utils/helper/helper.service";
17
import {Meta, Title} from "@angular/platform-browser";
18
import {PiwikService} from "../../../utils/piwik/piwik.service";
17 19

  
18 20

  
19 21
@Component({
......
23 25

  
24 26
})
25 27
export class DisplayClaimsComponent {
28
  @Input() piwikSiteId = null;
29
  @Input() title: string = "";
30
  piwiksub:any;
31

  
26 32
  properties: EnvProperties;
27 33
  public searchTermStream = new Subject<string>();
28 34
  sub: any;
......
77 83
  public pageContents = null;
78 84

  
79 85
  constructor(private _claimService: ClaimsService, private route: ActivatedRoute, private _router: Router, private location: Location,
86
              private _meta: Meta, private _title: Title, private _piwikService:PiwikService,
80 87
              private seoService: SEOService, private indexInfoService:IndexInfoService,  private helper: HelperService) {
81 88
  }
82 89

  
......
85 92
      .subscribe((data: { envSpecific: EnvProperties }) => {
86 93
        this.properties = data.envSpecific;
87 94
        this.url = data.envSpecific.baseLink + this._router.url;
95

  
96
        var description = "Openaire, linking, claim, publication, research data, software, other research product, project, community";
97
        this.updateTitle(this.title);
98
        this.updateDescription(description);
99
        this.updateUrl(this.url);
100

  
101
        if(this.properties.enablePiwikTrack && (typeof document !== 'undefined')){
102
          this.piwiksub = this._piwikService.trackView(this.properties, this.title, this.piwikSiteId).subscribe();
103
        }
104

  
88 105
        this.helper.getPageHelpContents(this._router.url, this.properties, this.communityId).subscribe(contents => {
89 106
          this.pageContents = contents;
90 107
        });
......
92 109
          this.lastIndexDate = res;
93 110
        });
94 111
        this.sub = this.route.queryParams.subscribe(params => {
95
          this.seoService.createLinkForCanonicalURL(this.properties.baseLink + this._router.url, false);
112
          this.seoService.createLinkForCanonicalURL(this.url, false);
96 113

  
97 114
          if (this.myClaims) {
98 115
            this.fetchBy = "User";
......
132 149

  
133 150
  ngOnDestroy() {
134 151
    this.sub.unsubscribe();
152
    if(this.piwiksub){
153
      this.piwiksub.unsubscribe();
154
    }
135 155
    //this.searchTermStreamSub.unsubscribe();
136 156
  }
137 157

  
......
587 607
    }
588 608
    return totalPages;
589 609
  }
610

  
611
  private updateDescription(description:string) {
612
    this._meta.updateTag({content:description},"name='description'");
613
    this._meta.updateTag({content:description},"property='og:description'");
614
  }
615
  private updateTitle(title:string) {
616
    var _prefix ="";
617
    if(!this.communityId) {
618
      _prefix ="OpenAIRE | ";
619
    }
620
    var _title = _prefix + ((title.length> 50 ) ?title.substring(0,50):title);
621
    this._title.setTitle(_title);
622
    this._meta.updateTag({content:_title},"property='og:title'");
623
  }
624
  private updateUrl(url:string) {
625
    this._meta.updateTag({content:url},"property='og:url'");
626
  }
590 627
}

Also available in: Unified diff