From 7e43cb5f18b6c78ef85a0b84478589238d1f2e7c Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Wed, 30 Jun 2021 16:44:42 +0200 Subject: [PATCH] Update hello world --- .../client/common-client-plugin.js | 20 ++++++++++ .../client/embed-client-plugin.js | 8 ++++ .../client/video-edit-client-plugin.js | 7 ++++ .../client/video-watch-client-plugin.js | 8 ++++ peertube-plugin-hello-world/main.js | 38 +++++++++---------- 5 files changed, 62 insertions(+), 19 deletions(-) diff --git a/peertube-plugin-hello-world/client/common-client-plugin.js b/peertube-plugin-hello-world/client/common-client-plugin.js index 4c86ca7..85edaaa 100644 --- a/peertube-plugin-hello-world/client/common-client-plugin.js +++ b/peertube-plugin-hello-world/client/common-client-plugin.js @@ -80,6 +80,26 @@ function register ({ registerHook, registerSettingsScript, peertubeHelpers }) { } }) + registerHook({ + target: 'filter:left-menu.links.create.result', + handler: (result) => { + return [ + { + key: 'in-my-stuff', + title: 'In my stuff', + links: [ + { + path: '/about', + icon: 'alert', + shortLabel: 'About', + label: 'About' + } + ] + } + ].concat(result) + } + }) + // Router hooks registerHook({ diff --git a/peertube-plugin-hello-world/client/embed-client-plugin.js b/peertube-plugin-hello-world/client/embed-client-plugin.js index b69a4d9..b759e7b 100644 --- a/peertube-plugin-hello-world/client/embed-client-plugin.js +++ b/peertube-plugin-hello-world/client/embed-client-plugin.js @@ -4,6 +4,14 @@ function register ({ registerHook, peertubeHelpers }) { handler: () => alert('video loaded') }) + registerHook({ + target: 'filter:internal.player.videojs.options.result', + handler: (options) => { + options.poster = 'https://joinpeertube.org/img/brand-with-v3.png' + return options + } + }) + console.log(peertubeHelpers.translate('toto')) } diff --git a/peertube-plugin-hello-world/client/video-edit-client-plugin.js b/peertube-plugin-hello-world/client/video-edit-client-plugin.js index 2cc1e10..22283bc 100644 --- a/peertube-plugin-hello-world/client/video-edit-client-plugin.js +++ b/peertube-plugin-hello-world/client/video-edit-client-plugin.js @@ -20,9 +20,16 @@ function register ({ registerHook, registerVideoField }) { } } + const commonOptions3 = { + name: 'hello-world-field-3', + label: 'Super field 3', + type: 'input-checkbox' + } + for (const type of [ 'upload', 'import-url', 'update' ]) { registerVideoField(commonOptions1, { type }) registerVideoField(commonOptions2, { type }) + registerVideoField(commonOptions3, { type }) } } diff --git a/peertube-plugin-hello-world/client/video-watch-client-plugin.js b/peertube-plugin-hello-world/client/video-watch-client-plugin.js index 9c1401e..49ad1af 100644 --- a/peertube-plugin-hello-world/client/video-watch-client-plugin.js +++ b/peertube-plugin-hello-world/client/video-watch-client-plugin.js @@ -63,6 +63,14 @@ function register ({ registerHook, peertubeHelpers }) { } }) + registerHook({ + target: 'filter:internal.player.videojs.options.result', + handler: (options) => { + options.poster = '' + return options + } + }) + peertubeHelpers.notifier.info('you are on the watch page', 'useless', 1000) } diff --git a/peertube-plugin-hello-world/main.js b/peertube-plugin-hello-world/main.js index 2909b44..a72e527 100644 --- a/peertube-plugin-hello-world/main.js +++ b/peertube-plugin-hello-world/main.js @@ -46,30 +46,30 @@ async function register ({ }) { - const fieldName = 'hello-world-field' + for (const fieldName of [ 'hello-world-field', 'hello-world-field-2', 'hello-world-field-3' ]) { + registerHook({ + target: 'action:api.video.updated', + handler: ({ video, body }) => { + if (!body.pluginData) return - registerHook({ - target: 'action:api.video.updated', - handler: ({ video, body }) => { - if (!body.pluginData) return + storageManager.storeData(fieldName + '-' + video.id, body.pluginData[fieldName]) + } + }) - storageManager.storeData(fieldName + '-' + video.id, body.pluginData[fieldName]) - } - }) + registerHook({ + target: 'filter:api.video.get.result', + handler: async (video) => { + if (!video) return video - registerHook({ - target: 'filter:api.video.get.result', - handler: async (video) => { - if (!video) return video + if (!video.pluginData) video.pluginData = {} - if (!video.pluginData) video.pluginData = {} + const result = await storageManager.getData(fieldName + '-' + video.id) + video.pluginData[fieldName] = result - const result = await storageManager.getData(fieldName + '-' + video.id) - video.pluginData[fieldName] = result - - return video - } - }) + return video + } + }) + } } registerSetting({