aboutsummaryrefslogtreecommitdiffhomepage
path: root/support/doc
diff options
context:
space:
mode:
Diffstat (limited to 'support/doc')
-rw-r--r--support/doc/plugins/guide.md89
-rw-r--r--support/doc/tools.md1
2 files changed, 90 insertions, 0 deletions
diff --git a/support/doc/plugins/guide.md b/support/doc/plugins/guide.md
index 41d70c372..2bd3fb6d2 100644
--- a/support/doc/plugins/guide.md
+++ b/support/doc/plugins/guide.md
@@ -21,6 +21,7 @@
21 - [Custom Modal](#custom-modal) 21 - [Custom Modal](#custom-modal)
22 - [Translate](#translate) 22 - [Translate](#translate)
23 - [Get public settings](#get-public-settings) 23 - [Get public settings](#get-public-settings)
24 - [Add custom fields to video form](#add-custom-fields-to-video-form)
24 - [Publishing](#publishing) 25 - [Publishing](#publishing)
25- [Write a plugin/theme](#write-a-plugintheme) 26- [Write a plugin/theme](#write-a-plugintheme)
26 - [Clone the quickstart repository](#clone-the-quickstart-repository) 27 - [Clone the quickstart repository](#clone-the-quickstart-repository)
@@ -29,6 +30,7 @@
29 - [Update package.json](#update-packagejson) 30 - [Update package.json](#update-packagejson)
30 - [Write code](#write-code) 31 - [Write code](#write-code)
31 - [Add translations](#add-translations) 32 - [Add translations](#add-translations)
33 - [Build your plugin](#build-your-plugin)
32 - [Test your plugin/theme](#test-your-plugintheme) 34 - [Test your plugin/theme](#test-your-plugintheme)
33 - [Publish](#publish) 35 - [Publish](#publish)
34- [Plugin & Theme hooks/helpers API](#plugin--theme-hookshelpers-api) 36- [Plugin & Theme hooks/helpers API](#plugin--theme-hookshelpers-api)
@@ -379,6 +381,68 @@ peertubeHelpers.getSettings()
379 }) 381 })
380``` 382```
381 383
384#### Add custom fields to video form
385
386To add custom fields in the video form (in *Plugin settings* tab):
387
388```js
389async function register ({ registerVideoField, peertubeHelpers }) {
390 const descriptionHTML = await peertubeHelpers.translate(descriptionSource)
391 const commonOptions = {
392 name: 'my-field-name,
393 label: 'My added field',
394 descriptionHTML: 'Optional description',
395 type: 'input-textarea',
396 default: ''
397 }
398
399 for (const type of [ 'upload', 'import-url', 'import-torrent', 'update' ]) {
400 registerVideoField(commonOptions, { type })
401 }
402}
403```
404
405PeerTube will send this field value in `body.pluginData['my-field-name']` and fetch it from `video.pluginData['my-field-name']`.
406
407So for example, if you want to store an additional metadata for videos, register the following hooks in **server**:
408
409```js
410async function register ({
411 registerHook,
412 storageManager
413}) {
414 const fieldName = 'my-field-name'
415
416 // Store data associated to this video
417 registerHook({
418 target: 'action:api.video.updated',
419 handler: ({ video, body }) => {
420 if (!body.pluginData) return
421
422 const value = body.pluginData[fieldName]
423 if (!value) return
424
425 storageManager.storeData(fieldName + '-' + video.id, value)
426 }
427 })
428
429 // Add your custom value to the video, so the client autofill your field using the previously stored value
430 registerHook({
431 target: 'filter:api.video.get.result',
432 handler: async (video) => {
433 if (!video) return video
434 if (!video.pluginData) video.pluginData = {}
435
436 const result = await storageManager.getData(fieldName + '-' + video.id)
437 video.pluginData[fieldName] = result
438
439 return video
440 }
441 })
442}
443
444```
445
382 446
383### Publishing 447### Publishing
384 448
@@ -498,6 +562,31 @@ Translation files are just objects, with the english sentence as the key and the
498} 562}
499``` 563```
500 564
565### Build your plugin
566
567If you added client scripts, you'll need to build them using webpack.
568
569Install webpack:
570
571```
572$ npm install
573```
574
575Add/update your files in the `clientFiles` array of `webpack.config.js`:
576
577```
578$ $EDITOR ./webpack.config.js
579```
580
581Build your client files:
582
583```
584$ npm run build
585```
586
587You built files are in the `dist/` directory. Check `package.json` to correctly point to them.
588
589
501### Test your plugin/theme 590### Test your plugin/theme
502 591
503You'll need to have a local PeerTube instance: 592You'll need to have a local PeerTube instance:
diff --git a/support/doc/tools.md b/support/doc/tools.md
index 1f1e52c36..04cf2b569 100644
--- a/support/doc/tools.md
+++ b/support/doc/tools.md
@@ -256,6 +256,7 @@ Or to transcode to a specific resolution:
256``` 256```
257$ sudo -u peertube NODE_CONFIG_DIR=/var/www/peertube/config NODE_ENV=production npm run create-transcoding-job -- -v [videoUUID] -r [resolution] 257$ sudo -u peertube NODE_CONFIG_DIR=/var/www/peertube/config NODE_ENV=production npm run create-transcoding-job -- -v [videoUUID] -r [resolution]
258``` 258```
259The resolution should be an integer (`1080`, `720`, `480`, etc.)
259 260
260To generate an HLS playlist for a video: 261To generate an HLS playlist for a video:
261 262