aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--client/src/app/+videos/+video-watch/shared/metadata/video-attributes.component.html7
-rw-r--r--client/src/app/+videos/+video-watch/shared/metadata/video-attributes.component.ts32
-rw-r--r--client/src/app/core/plugins/hooks.service.ts9
-rw-r--r--shared/models/plugins/client/client-hook.model.ts2
4 files changed, 48 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 @@
1import { Component, Input } from '@angular/core' 1import { Component, Input, OnInit } from '@angular/core'
2import { HooksService } from '@app/core'
2import { VideoDetails } from '@app/shared/shared-main' 3import { VideoDetails } from '@app/shared/shared-main'
3 4
5type 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})
9export class VideoAttributesComponent { 17export 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}
diff --git a/client/src/app/core/plugins/hooks.service.ts b/client/src/app/core/plugins/hooks.service.ts
index 29db75d89..f325605e9 100644
--- a/client/src/app/core/plugins/hooks.service.ts
+++ b/client/src/app/core/plugins/hooks.service.ts
@@ -48,6 +48,15 @@ export class HooksService {
48 return this.pluginService.runHook(hookResultName, result, params) 48 return this.pluginService.runHook(hookResultName, result, params)
49 } 49 }
50 50
51 async wrapFunResult <P, R, H extends ClientFilterHookName>
52 (fun: RawFunction<P, R>, params: P, scope: PluginClientScope, hookResultName: H) {
53 await this.pluginService.ensurePluginsAreLoaded(scope)
54
55 const result = fun(params)
56
57 return this.pluginService.runHook(hookResultName, result, params)
58 }
59
51 runAction<T, U extends ClientActionHookName> (hookName: U, scope: PluginClientScope, params?: T) { 60 runAction<T, U extends ClientActionHookName> (hookName: U, scope: PluginClientScope, params?: T) {
52 // Use setTimeout to give priority to Angular change detector 61 // Use setTimeout to give priority to Angular change detector
53 setTimeout(() => { 62 setTimeout(() => {
diff --git a/shared/models/plugins/client/client-hook.model.ts b/shared/models/plugins/client/client-hook.model.ts
index ec1d2b5e5..bc3f5dd9f 100644
--- a/shared/models/plugins/client/client-hook.model.ts
+++ b/shared/models/plugins/client/client-hook.model.ts
@@ -87,6 +87,8 @@ export const clientFilterHookObject = {
87 'filter:share.video-playlist-url.build.params': true, 87 'filter:share.video-playlist-url.build.params': true,
88 'filter:share.video-playlist-url.build.result': true, 88 'filter:share.video-playlist-url.build.result': true,
89 89
90 'filter:video-watch.video-plugin-metadata.result': true,
91
90 // Filter videojs options built for PeerTube player 92 // Filter videojs options built for PeerTube player
91 'filter:internal.player.videojs.options.result': true, 93 'filter:internal.player.videojs.options.result': true,
92 94