diff --git a/peertube-plugin-hello-world/client/common-client-plugin.js b/peertube-plugin-hello-world/client/common-client-plugin.js index 5ceedad..a9aa82a 100644 --- a/peertube-plugin-hello-world/client/common-client-plugin.js +++ b/peertube-plugin-hello-world/client/common-client-plugin.js @@ -3,6 +3,75 @@ function register ({ registerHook, peertubeHelpers }) { target: 'action:application.init', handler: () => onApplicationInit(peertubeHelpers) }) + + // Videos list + + registerHook({ + target: 'filter:api.videos.list.trending.params', + handler: params => Object.assign({}, params, { sort: '-views' }) + }) + + registerHook({ + target: 'filter:api.videos.list.trending.result', + handler: result => addSymbolToVideoNameResult(result, '<3') + }) + + registerHook({ + target: 'filter:api.videos.list.local.params', + handler: params => Object.assign({}, params, { sort: '-views' }) + }) + + registerHook({ + target: 'filter:api.videos.list.local.result', + handler: result => addSymbolToVideoNameResult(result, ':)') + }) + + registerHook({ + target: 'filter:api.videos.list.recently-added.params', + handler: params => Object.assign({}, params, { filter: 'all-local' }) + }) + + registerHook({ + target: 'filter:api.videos.list.recently-added.result', + handler: result => addSymbolToVideoNameResult(result, 'o/') + }) + + registerHook({ + target: 'filter:api.videos.list.user-subscriptions.params', + handler: params => Object.assign({}, params, { sort: '-views' }) + }) + + registerHook({ + target: 'filter:api.videos.list.user-subscriptions.result', + handler: result => addSymbolToVideoNameResult(result, ':D') + }) + + // Search list + + registerHook({ + target: 'filter:api.search.videos.list.result', + handler: result => { + result.data.forEach(v => v.name += ' SEARCH') + + return { + total: result.total, + data: result.data + } + } + }) + + registerHook({ + target: 'filter:api.search.video-channels.list.result', + handler: result => { + result.data.forEach(v => v.displayName += ' :p') + + return { + total: result.total, + data: result.data + } + } + }) + } export { @@ -19,3 +88,12 @@ function onApplicationInit (peertubeHelpers) { topLeftBlock.style.backgroundImage = 'url(' + imageUrl + ')' } + +function addSymbolToVideoNameResult (result, symbol) { + result.data.forEach(v => v.name += ' ' + symbol) + + return { + data: result.data, + total: result.total + } +} 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 fef7ebb..739150c 100644 --- a/peertube-plugin-hello-world/client/video-watch-client-plugin.js +++ b/peertube-plugin-hello-world/client/video-watch-client-plugin.js @@ -3,6 +3,38 @@ function register ({ registerHook, peertubeHelpers }) { target: 'action:video-watch.init', handler: () => console.log('Hello video watch world') }) + + registerHook({ + target: 'action:video-watch.video.loaded', + handler: () => 'video loaded' + }) + + registerHook({ + target: 'filter:api.video-watch.video.get.result', + handler: video => { + video.name += ' \o/' + + return video + } + }) + + registerHook({ + target: 'filter:api.video-watch.video-threads.list.result', + handler: result => { + result.comments.forEach(c => c.text += ' THREAD') + + return result + } + }) + + registerHook({ + target: 'filter:api.video-watch.video-thread-replies.list.result', + handler: result => { + result.children.forEach(c => c.comment.text += ' REPLY DEEP 1') + + return result + } + }) } export { diff --git a/peertube-plugin-hello-world/package.json b/peertube-plugin-hello-world/package.json index cb89c09..6b6f315 100644 --- a/peertube-plugin-hello-world/package.json +++ b/peertube-plugin-hello-world/package.json @@ -1,6 +1,6 @@ { "name": "peertube-plugin-hello-world", - "version": "0.0.9", + "version": "0.0.10", "description": "Hello world PeerTube plugin example", "engine": { "peertube": ">=1.3.0"