diff options
author | Chocobozzz <me@florianbigard.com> | 2023-03-10 11:10:16 +0100 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2023-03-10 11:10:16 +0100 |
commit | 4265d90b0061399e23b816e3880ee1be47ead96f (patch) | |
tree | 79f62e4757b6397b707db481a73f59198357c896 /client/src/app/+videos | |
parent | c1b3f2e05d11dc8b452869582dcb1b926b306d79 (diff) | |
download | PeerTube-4265d90b0061399e23b816e3880ee1be47ead96f.tar.gz PeerTube-4265d90b0061399e23b816e3880ee1be47ead96f.tar.zst PeerTube-4265d90b0061399e23b816e3880ee1be47ead96f.zip |
Add ability for plugins to add metadata
Diffstat (limited to 'client/src/app/+videos')
-rw-r--r-- | client/src/app/+videos/+video-watch/shared/metadata/video-attributes.component.html | 7 | ||||
-rw-r--r-- | client/src/app/+videos/+video-watch/shared/metadata/video-attributes.component.ts | 32 |
2 files changed, 37 insertions, 2 deletions
diff --git a/client/src/app/+videos/+video-watch/shared/metadata/video-attributes.component.html b/client/src/app/+videos/+video-watch/shared/metadata/video-attributes.component.html index 52ad1999d..0aa707666 100644 --- a/client/src/app/+videos/+video-watch/shared/metadata/video-attributes.component.html +++ b/client/src/app/+videos/+video-watch/shared/metadata/video-attributes.component.html | |||
@@ -62,3 +62,10 @@ | |||
62 | <span i18n class="attribute-label">Duration</span> | 62 | <span i18n class="attribute-label">Duration</span> |
63 | <span class="attribute-value">{{ video.duration | myDurationFormatter }}</span> | 63 | <span class="attribute-value">{{ video.duration | myDurationFormatter }}</span> |
64 | </div> | 64 | </div> |
65 | |||
66 | <div class="attribute attribute-plugin" *ngFor="let metadata of pluginMetadata"> | ||
67 | <span class="attribute-label">{{ metadata.label }}</span> | ||
68 | |||
69 | <span *ngIf="metadata.value" class="attribute-value">{{ metadata.value }}</span> | ||
70 | <span *ngIf="metadata.safeHTML" class="attribute-value" [innerHTML]="metadata.safeHTML"></span> | ||
71 | </div> | ||
diff --git a/client/src/app/+videos/+video-watch/shared/metadata/video-attributes.component.ts b/client/src/app/+videos/+video-watch/shared/metadata/video-attributes.component.ts index b8f564c4c..ebfb42711 100644 --- a/client/src/app/+videos/+video-watch/shared/metadata/video-attributes.component.ts +++ b/client/src/app/+videos/+video-watch/shared/metadata/video-attributes.component.ts | |||
@@ -1,14 +1,35 @@ | |||
1 | import { Component, Input } from '@angular/core' | 1 | import { Component, Input, OnInit } from '@angular/core' |
2 | import { HooksService } from '@app/core' | ||
2 | import { VideoDetails } from '@app/shared/shared-main' | 3 | import { VideoDetails } from '@app/shared/shared-main' |
3 | 4 | ||
5 | type PluginMetadata = { | ||
6 | label: string | ||
7 | |||
8 | value?: string | ||
9 | safeHTML?: string | ||
10 | } | ||
11 | |||
4 | @Component({ | 12 | @Component({ |
5 | selector: 'my-video-attributes', | 13 | selector: 'my-video-attributes', |
6 | templateUrl: './video-attributes.component.html', | 14 | templateUrl: './video-attributes.component.html', |
7 | styleUrls: [ './video-attributes.component.scss' ] | 15 | styleUrls: [ './video-attributes.component.scss' ] |
8 | }) | 16 | }) |
9 | export class VideoAttributesComponent { | 17 | export class VideoAttributesComponent implements OnInit { |
10 | @Input() video: VideoDetails | 18 | @Input() video: VideoDetails |
11 | 19 | ||
20 | pluginMetadata: PluginMetadata[] = [] | ||
21 | |||
22 | constructor (private hooks: HooksService) { } | ||
23 | |||
24 | async ngOnInit () { | ||
25 | this.pluginMetadata = await this.hooks.wrapFunResult( | ||
26 | this.buildPluginMetadata.bind(this), | ||
27 | { video: this.video }, | ||
28 | 'video-watch', | ||
29 | 'filter:video-watch.video-plugin-metadata.result' | ||
30 | ) | ||
31 | } | ||
32 | |||
12 | getVideoHost () { | 33 | getVideoHost () { |
13 | return this.video.channel.host | 34 | return this.video.channel.host |
14 | } | 35 | } |
@@ -18,4 +39,11 @@ export class VideoAttributesComponent { | |||
18 | 39 | ||
19 | return this.video.tags | 40 | return this.video.tags |
20 | } | 41 | } |
42 | |||
43 | // Used for plugin hooks | ||
44 | private buildPluginMetadata (_options: { | ||
45 | video: VideoDetails | ||
46 | }): PluginMetadata[] { | ||
47 | return [] | ||
48 | } | ||
21 | } | 49 | } |