1
0
Fork 0

Client: add opengraph tags

This commit is contained in:
Chocobozzz 2016-11-04 17:37:44 +01:00
parent b58c69a1ed
commit 3ec343a41d
1 changed files with 22 additions and 0 deletions

View File

@ -2,6 +2,7 @@ import { Component, ElementRef, NgZone, OnDestroy, OnInit, ViewChild } from '@an
import { ActivatedRoute } from '@angular/router'; import { ActivatedRoute } from '@angular/router';
import { ModalDirective } from 'ng2-bootstrap/components/modal'; import { ModalDirective } from 'ng2-bootstrap/components/modal';
import { MetaService } from 'ng2-meta';
import { Video, VideoService } from '../shared'; import { Video, VideoService } from '../shared';
import { WebTorrentService } from './webtorrent.service'; import { WebTorrentService } from './webtorrent.service';
@ -33,6 +34,7 @@ export class VideoWatchComponent implements OnInit, OnDestroy {
private ngZone: NgZone, private ngZone: NgZone,
private route: ActivatedRoute, private route: ActivatedRoute,
private videoService: VideoService, private videoService: VideoService,
private metaService: MetaService,
private webTorrentService: WebTorrentService private webTorrentService: WebTorrentService
) {} ) {}
@ -42,6 +44,7 @@ export class VideoWatchComponent implements OnInit, OnDestroy {
this.videoService.getVideo(id).subscribe( this.videoService.getVideo(id).subscribe(
video => { video => {
this.video = video; this.video = video;
this.setOpenGraphTags();
this.loadVideo(); this.loadVideo();
}, },
error => alert(error.text) error => alert(error.text)
@ -104,6 +107,25 @@ export class VideoWatchComponent implements OnInit, OnDestroy {
console.error('The video load seems to be abnormally long.'); console.error('The video load seems to be abnormally long.');
} }
private setOpenGraphTags() {
this.metaService.setTag('og:type', 'video');
this.metaService.setTag('og:title', this.video.name);
this.metaService.setTag('name', this.video.name);
this.metaService.setTag('og:description', this.video.description);
this.metaService.setTag('description', this.video.description);
this.metaService.setTag('og:image', this.video.thumbnailPath);
this.metaService.setTag('og:duration', this.video.duration);
this.metaService.setTag('og:site_name', 'PeerTube');
this.metaService.setTag('og:url', window.location.href);
this.metaService.setTag('url', window.location.href);
}
private runInProgress(torrent: any) { private runInProgress(torrent: any) {
// Refresh each second // Refresh each second
this.torrentInfosInterval = setInterval(() => { this.torrentInfosInterval = setInterval(() => {