Add other hooks to hello world plugin
This commit is contained in:
parent
76bd650ad0
commit
47a4d19252
12
peertube-plugin-hello-world/client/embed-client-plugin.js
Normal file
12
peertube-plugin-hello-world/client/embed-client-plugin.js
Normal file
@ -0,0 +1,12 @@
|
||||
function register ({ registerHook, peertubeHelpers }) {
|
||||
registerHook({
|
||||
target: 'action:embed.player.loaded',
|
||||
handler: () => alert('video loaded')
|
||||
})
|
||||
|
||||
console.log(peertubeHelpers.translate('toto'))
|
||||
}
|
||||
|
||||
export {
|
||||
register
|
||||
}
|
@ -0,0 +1,20 @@
|
||||
function register ({ registerVideoField }) {
|
||||
console.log('loading video edit stuff')
|
||||
|
||||
{
|
||||
const commonOptions = {
|
||||
name: 'hello-world-field',
|
||||
label: 'Super field',
|
||||
type: 'input',
|
||||
default: 'hello'
|
||||
}
|
||||
|
||||
for (const type of [ 'upload', 'import-url', 'update' ]) {
|
||||
registerVideoField(commonOptions, { type })
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export {
|
||||
register
|
||||
}
|
@ -45,6 +45,33 @@ async function register ({
|
||||
}
|
||||
})
|
||||
|
||||
{
|
||||
const fieldName = 'hello-world-field'
|
||||
|
||||
registerHook({
|
||||
target: 'action:api.video.updated',
|
||||
handler: ({ video, body }) => {
|
||||
if (!body.pluginData) return
|
||||
|
||||
storageManager.storeData(fieldName + '-' + video.id, body.pluginData[fieldName])
|
||||
}
|
||||
})
|
||||
|
||||
registerHook({
|
||||
target: 'filter:api.video.get.result',
|
||||
handler: async (video) => {
|
||||
if (!video) return video
|
||||
|
||||
if (!video.pluginData) video.pluginData = {}
|
||||
|
||||
const result = await storageManager.getData(fieldName + '-' + video.id)
|
||||
video.pluginData[fieldName] = result
|
||||
|
||||
return video
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
registerSetting({
|
||||
name: 'admin-name',
|
||||
label: 'Admin name',
|
||||
|
@ -36,6 +36,14 @@
|
||||
{
|
||||
"script": "client/login-client-plugin.js",
|
||||
"scopes": [ "login" ]
|
||||
},
|
||||
{
|
||||
"script": "client/embed-client-plugin.js",
|
||||
"scopes": [ "embed" ]
|
||||
},
|
||||
{
|
||||
"script": "client/video-edit-client-plugin.js",
|
||||
"scopes": [ "video-edit" ]
|
||||
}
|
||||
],
|
||||
"translations": {
|
||||
|
Loading…
x
Reference in New Issue
Block a user