diff options
-rw-r--r-- | .github/CONTRIBUTING.md | 7 | ||||
-rw-r--r-- | client/src/app/core/plugins/plugin.service.ts | 3 | ||||
-rw-r--r-- | client/src/types/client-script.model.ts | 7 | ||||
-rw-r--r-- | client/src/types/register-client-option.model.ts | 9 | ||||
-rw-r--r-- | support/doc/plugins/guide.md | 5 |
5 files changed, 29 insertions, 2 deletions
diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md index 1672ebfa9..6fc80b6aa 100644 --- a/.github/CONTRIBUTING.md +++ b/.github/CONTRIBUTING.md | |||
@@ -7,8 +7,9 @@ Interested in contributing? Awesome! | |||
7 | * [Translate](#translate) | 7 | * [Translate](#translate) |
8 | * [Give your feedback](#give-your-feedback) | 8 | * [Give your feedback](#give-your-feedback) |
9 | * [Write documentation](#write-documentation) | 9 | * [Write documentation](#write-documentation) |
10 | * [Develop](#develop) | ||
11 | * [Improve the website](#improve-the-website) | 10 | * [Improve the website](#improve-the-website) |
11 | * [Develop](#develop) | ||
12 | * [Write a plugin or a theme](#plugins--themes) | ||
12 | 13 | ||
13 | ## Translate | 14 | ## Translate |
14 | 15 | ||
@@ -199,3 +200,7 @@ $ npm run mocha -- --exit --require ts-node/register/type-check --bail server/te | |||
199 | 200 | ||
200 | Instance configurations are in `config/test-{1,2,3,4,5,6}.yaml`. | 201 | Instance configurations are in `config/test-{1,2,3,4,5,6}.yaml`. |
201 | Note that only instance 2 has transcoding enabled. | 202 | Note that only instance 2 has transcoding enabled. |
203 | |||
204 | ## Plugins & Themes | ||
205 | |||
206 | See the dedicated documentation: https://docs.joinpeertube.org/#/contribute-plugins | ||
diff --git a/client/src/app/core/plugins/plugin.service.ts b/client/src/app/core/plugins/plugin.service.ts index e4a73de81..1294edd7d 100644 --- a/client/src/app/core/plugins/plugin.service.ts +++ b/client/src/app/core/plugins/plugin.service.ts | |||
@@ -3,6 +3,7 @@ import { Router } from '@angular/router' | |||
3 | import { ServerConfigPlugin } from '@shared/models' | 3 | import { ServerConfigPlugin } from '@shared/models' |
4 | import { ServerService } from '@app/core/server/server.service' | 4 | import { ServerService } from '@app/core/server/server.service' |
5 | import { ClientScript } from '@shared/models/plugins/plugin-package-json.model' | 5 | import { ClientScript } from '@shared/models/plugins/plugin-package-json.model' |
6 | import { ClientScript as ClientScriptModule } from '../../../types/client-script.model' | ||
6 | import { environment } from '../../../environments/environment' | 7 | import { environment } from '../../../environments/environment' |
7 | import { ReplaySubject } from 'rxjs' | 8 | import { ReplaySubject } from 'rxjs' |
8 | import { first, shareReplay } from 'rxjs/operators' | 9 | import { first, shareReplay } from 'rxjs/operators' |
@@ -186,7 +187,7 @@ export class PluginService implements ClientHook { | |||
186 | console.log('Loading script %s of plugin %s.', clientScript.script, plugin.name) | 187 | console.log('Loading script %s of plugin %s.', clientScript.script, plugin.name) |
187 | 188 | ||
188 | return import(/* webpackIgnore: true */ clientScript.script) | 189 | return import(/* webpackIgnore: true */ clientScript.script) |
189 | .then(script => script.register({ registerHook, peertubeHelpers })) | 190 | .then((script: ClientScriptModule) => script.register({ registerHook, peertubeHelpers })) |
190 | .then(() => this.sortHooksByPriority()) | 191 | .then(() => this.sortHooksByPriority()) |
191 | } | 192 | } |
192 | 193 | ||
diff --git a/client/src/types/client-script.model.ts b/client/src/types/client-script.model.ts new file mode 100644 index 000000000..6197fcac9 --- /dev/null +++ b/client/src/types/client-script.model.ts | |||
@@ -0,0 +1,7 @@ | |||
1 | import { RegisterClientOptions } from './register-client-option.model' | ||
2 | |||
3 | export interface ClientScript { | ||
4 | register: (options: RegisterClientOptions) => Promise<any> | ||
5 | |||
6 | unregister: () => Promise<any> | ||
7 | } | ||
diff --git a/client/src/types/register-client-option.model.ts b/client/src/types/register-client-option.model.ts new file mode 100644 index 000000000..42d689403 --- /dev/null +++ b/client/src/types/register-client-option.model.ts | |||
@@ -0,0 +1,9 @@ | |||
1 | import { RegisterClientHookOptions } from '@shared/models/plugins/register-client-hook.model' | ||
2 | |||
3 | export type RegisterClientOptions = { | ||
4 | registerHook: (options: RegisterClientHookOptions) => void | ||
5 | |||
6 | peertubeHelpers: { | ||
7 | getBaseStaticRoute: () => string | ||
8 | } | ||
9 | } | ||
diff --git a/support/doc/plugins/guide.md b/support/doc/plugins/guide.md index 0b2d337eb..8f8884d00 100644 --- a/support/doc/plugins/guide.md +++ b/support/doc/plugins/guide.md | |||
@@ -262,6 +262,11 @@ Every time you want to publish another version of your plugin/theme, just update | |||
262 | and republish it on NPM. Remember that the PeerTube index will take into account your new plugin/theme version after ~24 hours. | 262 | and republish it on NPM. Remember that the PeerTube index will take into account your new plugin/theme version after ~24 hours. |
263 | 263 | ||
264 | 264 | ||
265 | ## Plugin & Theme hooks/helpers API | ||
266 | |||
267 | See the dedicated documentation: https://docs.joinpeertube.org/#/api-plugins | ||
268 | |||
269 | |||
265 | ## Tips | 270 | ## Tips |
266 | 271 | ||
267 | ### Compatibility with PeerTube | 272 | ### Compatibility with PeerTube |