diff options
author | Chocobozzz <me@florianbigard.com> | 2022-01-10 11:38:58 +0100 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2022-01-10 11:38:58 +0100 |
commit | 3c33d71474786ce39049b000fc6bc20404d19002 (patch) | |
tree | 7791ae6015740231001d694dfbb4439b974ea2b6 /support/doc/plugins | |
parent | 5097cbda4aad10cc60d3dc485dc9e9c3b1eddb17 (diff) | |
download | PeerTube-3c33d71474786ce39049b000fc6bc20404d19002.tar.gz PeerTube-3c33d71474786ce39049b000fc6bc20404d19002.tar.zst PeerTube-3c33d71474786ce39049b000fc6bc20404d19002.zip |
Add "Create client page" plugin doc
Diffstat (limited to 'support/doc/plugins')
-rw-r--r-- | support/doc/plugins/guide.md | 60 |
1 files changed, 36 insertions, 24 deletions
diff --git a/support/doc/plugins/guide.md b/support/doc/plugins/guide.md index 5c1f6a2af..52e3b6052 100644 --- a/support/doc/plugins/guide.md +++ b/support/doc/plugins/guide.md | |||
@@ -16,11 +16,10 @@ | |||
16 | - [Add new transcoding profiles](#add-new-transcoding-profiles) | 16 | - [Add new transcoding profiles](#add-new-transcoding-profiles) |
17 | - [Server helpers](#server-helpers) | 17 | - [Server helpers](#server-helpers) |
18 | - [Client API (themes & plugins)](#client-api-themes--plugins) | 18 | - [Client API (themes & plugins)](#client-api-themes--plugins) |
19 | - [Plugin static route](#plugin-static-route) | 19 | - [Get plugin static and router routes](#get-plugin-static-and-router-routes) |
20 | - [Notifier](#notifier) | 20 | - [Notifier](#notifier) |
21 | - [Markdown Renderer](#markdown-renderer) | 21 | - [Markdown Renderer](#markdown-renderer) |
22 | - [Auth header](#auth-header) | 22 | - [Auth header](#auth-header) |
23 | - [Plugin router route](#plugin-router-route) | ||
24 | - [Custom Modal](#custom-modal) | 23 | - [Custom Modal](#custom-modal) |
25 | - [Translate](#translate) | 24 | - [Translate](#translate) |
26 | - [Get public settings](#get-public-settings) | 25 | - [Get public settings](#get-public-settings) |
@@ -30,6 +29,7 @@ | |||
30 | - [Plugin selector on HTML elements](#plugin-selector-on-html-elements) | 29 | - [Plugin selector on HTML elements](#plugin-selector-on-html-elements) |
31 | - [HTML placeholder elements](#html-placeholder-elements) | 30 | - [HTML placeholder elements](#html-placeholder-elements) |
32 | - [Add/remove left menu links](#addremove-left-menu-links) | 31 | - [Add/remove left menu links](#addremove-left-menu-links) |
32 | - [Create client page](#create-client-page) | ||
33 | - [Publishing](#publishing) | 33 | - [Publishing](#publishing) |
34 | - [Write a plugin/theme](#write-a-plugintheme) | 34 | - [Write a plugin/theme](#write-a-plugintheme) |
35 | - [Clone the quickstart repository](#clone-the-quickstart-repository) | 35 | - [Clone the quickstart repository](#clone-the-quickstart-repository) |
@@ -531,7 +531,7 @@ See the [plugin API reference](https://docs.joinpeertube.org/api-plugins) to see | |||
531 | 531 | ||
532 | ### Client API (themes & plugins) | 532 | ### Client API (themes & plugins) |
533 | 533 | ||
534 | #### Plugin static route | 534 | #### Get plugin static and router routes |
535 | 535 | ||
536 | To get your plugin static route: | 536 | To get your plugin static route: |
537 | 537 | ||
@@ -542,6 +542,24 @@ function register (...) { | |||
542 | } | 542 | } |
543 | ``` | 543 | ``` |
544 | 544 | ||
545 | And to get your plugin router route, use `peertubeHelpers.getBaseRouterRoute()`: | ||
546 | |||
547 | ```js | ||
548 | function register (...) { | ||
549 | registerHook({ | ||
550 | target: 'action:video-watch.video.loaded', | ||
551 | handler: ({ video }) => { | ||
552 | fetch(peertubeHelpers.getBaseRouterRoute() + '/my/plugin/api', { | ||
553 | method: 'GET', | ||
554 | headers: peertubeHelpers.getAuthHeader() | ||
555 | }).then(res => res.json()) | ||
556 | .then(data => console.log('Hi %s.', data)) | ||
557 | } | ||
558 | }) | ||
559 | } | ||
560 | ``` | ||
561 | |||
562 | |||
545 | #### Notifier | 563 | #### Notifier |
546 | 564 | ||
547 | To notify the user with the PeerTube ToastModule: | 565 | To notify the user with the PeerTube ToastModule: |
@@ -594,27 +612,6 @@ function register (...) { | |||
594 | } | 612 | } |
595 | ``` | 613 | ``` |
596 | 614 | ||
597 | #### Plugin router route | ||
598 | |||
599 | **PeerTube >= 3.3** | ||
600 | |||
601 | To get your plugin router route, you can use `peertubeHelpers.getBaseRouterRoute()`: | ||
602 | |||
603 | ```js | ||
604 | function register (...) { | ||
605 | registerHook({ | ||
606 | target: 'action:video-watch.video.loaded', | ||
607 | handler: ({ video }) => { | ||
608 | fetch(peertubeHelpers.getBaseRouterRoute() + '/my/plugin/api', { | ||
609 | method: 'GET', | ||
610 | headers: peertubeHelpers.getAuthHeader() | ||
611 | }).then(res => res.json()) | ||
612 | .then(data => console.log('Hi %s.', data)) | ||
613 | } | ||
614 | }) | ||
615 | } | ||
616 | ``` | ||
617 | |||
618 | #### Custom Modal | 615 | #### Custom Modal |
619 | 616 | ||
620 | To show a custom modal: | 617 | To show a custom modal: |
@@ -806,6 +803,21 @@ See the complete list on https://docs.joinpeertube.org/api-plugins | |||
806 | 803 | ||
807 | Left menu links can be filtered (add/remove a section or add/remove links) using the `filter:left-menu.links.create.result` client hook. | 804 | Left menu links can be filtered (add/remove a section or add/remove links) using the `filter:left-menu.links.create.result` client hook. |
808 | 805 | ||
806 | #### Create client page | ||
807 | |||
808 | To create a client page, register a new client route: | ||
809 | |||
810 | ```js | ||
811 | function register ({ registerClientRoute }) { | ||
812 | registerClientRoute({ | ||
813 | route: 'my-super/route', | ||
814 | onMount: ({ rootEl }) => { | ||
815 | rootEl.innerHTML = 'hello' | ||
816 | } | ||
817 | }) | ||
818 | } | ||
819 | ``` | ||
820 | |||
809 | 821 | ||
810 | ### Publishing | 822 | ### Publishing |
811 | 823 | ||