diff options
author | Chocobozzz <me@florianbigard.com> | 2021-04-12 11:10:57 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2021-04-12 11:19:15 +0200 |
commit | 62bc0352d9d465ce9d7c3e074b1b60bf99155e24 (patch) | |
tree | 7cfbf827b7b8c802ae79fb87e55c9d960120400f | |
parent | c96e457bde8495cf9103bf819f887f341a528543 (diff) | |
download | PeerTube-62bc0352d9d465ce9d7c3e074b1b60bf99155e24.tar.gz PeerTube-62bc0352d9d465ce9d7c3e074b1b60bf99155e24.tar.zst PeerTube-62bc0352d9d465ce9d7c3e074b1b60bf99155e24.zip |
Add plugin placeholder elements support
-rw-r--r-- | client/src/app/+videos/+video-watch/video-watch.component.html | 2 | ||||
-rw-r--r-- | client/src/app/core/core.module.ts | 5 | ||||
-rw-r--r-- | client/src/app/shared/shared-main/plugins/index.ts | 1 | ||||
-rw-r--r-- | client/src/app/shared/shared-main/plugins/plugin-placeholder.component.ts | 15 | ||||
-rw-r--r-- | client/src/app/shared/shared-main/shared-main.module.ts | 9 | ||||
-rw-r--r-- | shared/models/plugins/index.ts | 1 | ||||
-rw-r--r-- | shared/models/plugins/plugin-element-placeholder.type.ts | 1 | ||||
-rw-r--r-- | support/doc/plugins/guide.md | 20 |
8 files changed, 47 insertions, 7 deletions
diff --git a/client/src/app/+videos/+video-watch/video-watch.component.html b/client/src/app/+videos/+video-watch/video-watch.component.html index 99103c2c3..c1ba0a755 100644 --- a/client/src/app/+videos/+video-watch/video-watch.component.html +++ b/client/src/app/+videos/+video-watch/video-watch.component.html | |||
@@ -16,6 +16,8 @@ | |||
16 | [playlist]="playlist" class="playlist" | 16 | [playlist]="playlist" class="playlist" |
17 | (videoFound)="onPlaylistVideoFound($event)" | 17 | (videoFound)="onPlaylistVideoFound($event)" |
18 | ></my-video-watch-playlist> | 18 | ></my-video-watch-playlist> |
19 | |||
20 | <my-plugin-placeholder pluginId="player-next"></my-plugin-placeholder> | ||
19 | </div> | 21 | </div> |
20 | 22 | ||
21 | <div class="row"> | 23 | <div class="row"> |
diff --git a/client/src/app/core/core.module.ts b/client/src/app/core/core.module.ts index 2392a234c..3152a7003 100644 --- a/client/src/app/core/core.module.ts +++ b/client/src/app/core/core.module.ts | |||
@@ -5,8 +5,7 @@ import { CommonModule } from '@angular/common' | |||
5 | import { NgModule, Optional, SkipSelf } from '@angular/core' | 5 | import { NgModule, Optional, SkipSelf } from '@angular/core' |
6 | import { BrowserAnimationsModule } from '@angular/platform-browser/animations' | 6 | import { BrowserAnimationsModule } from '@angular/platform-browser/animations' |
7 | import { PeerTubeSocket } from '@app/core/notification/peertube-socket.service' | 7 | import { PeerTubeSocket } from '@app/core/notification/peertube-socket.service' |
8 | import { HooksService } from '@app/core/plugins/hooks.service' | 8 | import { HooksService, PluginService } from '@app/core/plugins' |
9 | import { PluginService } from '@app/core/plugins/plugin.service' | ||
10 | import { AuthService } from './auth' | 9 | import { AuthService } from './auth' |
11 | import { ConfirmService } from './confirm' | 10 | import { ConfirmService } from './confirm' |
12 | import { CheatSheetComponent } from './hotkeys' | 11 | import { CheatSheetComponent } from './hotkeys' |
@@ -15,7 +14,7 @@ import { throwIfAlreadyLoaded } from './module-import-guard' | |||
15 | import { Notifier } from './notification' | 14 | import { Notifier } from './notification' |
16 | import { HtmlRendererService, LinkifierService, MarkdownService } from './renderer' | 15 | import { HtmlRendererService, LinkifierService, MarkdownService } from './renderer' |
17 | import { RestExtractor, RestService } from './rest' | 16 | import { RestExtractor, RestService } from './rest' |
18 | import { LoginGuard, RedirectService, UserRightGuard, UnloggedGuard } from './routing' | 17 | import { LoginGuard, RedirectService, UnloggedGuard, UserRightGuard } from './routing' |
19 | import { CanDeactivateGuard } from './routing/can-deactivate-guard.service' | 18 | import { CanDeactivateGuard } from './routing/can-deactivate-guard.service' |
20 | import { ServerConfigResolver } from './routing/server-config-resolver.service' | 19 | import { ServerConfigResolver } from './routing/server-config-resolver.service' |
21 | import { ScopedTokensService } from './scoped-tokens' | 20 | import { ScopedTokensService } from './scoped-tokens' |
diff --git a/client/src/app/shared/shared-main/plugins/index.ts b/client/src/app/shared/shared-main/plugins/index.ts new file mode 100644 index 000000000..f36dab624 --- /dev/null +++ b/client/src/app/shared/shared-main/plugins/index.ts | |||
@@ -0,0 +1 @@ | |||
export * from './plugin-placeholder.component' | |||
diff --git a/client/src/app/shared/shared-main/plugins/plugin-placeholder.component.ts b/client/src/app/shared/shared-main/plugins/plugin-placeholder.component.ts new file mode 100644 index 000000000..93ba9fb9b --- /dev/null +++ b/client/src/app/shared/shared-main/plugins/plugin-placeholder.component.ts | |||
@@ -0,0 +1,15 @@ | |||
1 | import { Component, Input } from '@angular/core' | ||
2 | import { PluginElementPlaceholder } from '@shared/models' | ||
3 | |||
4 | @Component({ | ||
5 | selector: 'my-plugin-placeholder', | ||
6 | template: '<div [id]="getId()"></div>' | ||
7 | }) | ||
8 | |||
9 | export class PluginPlaceholderComponent { | ||
10 | @Input() pluginId: PluginElementPlaceholder | ||
11 | |||
12 | getId () { | ||
13 | return 'plugin-placeholder-' + this.pluginId | ||
14 | } | ||
15 | } | ||
diff --git a/client/src/app/shared/shared-main/shared-main.module.ts b/client/src/app/shared/shared-main/shared-main.module.ts index 16d230f46..772198cb2 100644 --- a/client/src/app/shared/shared-main/shared-main.module.ts +++ b/client/src/app/shared/shared-main/shared-main.module.ts | |||
@@ -33,6 +33,7 @@ import { DateToggleComponent } from './date' | |||
33 | import { FeedComponent } from './feeds' | 33 | import { FeedComponent } from './feeds' |
34 | import { LoaderComponent, SmallLoaderComponent } from './loaders' | 34 | import { LoaderComponent, SmallLoaderComponent } from './loaders' |
35 | import { HelpComponent, ListOverflowComponent, SimpleSearchInputComponent, TopMenuDropdownComponent } from './misc' | 35 | import { HelpComponent, ListOverflowComponent, SimpleSearchInputComponent, TopMenuDropdownComponent } from './misc' |
36 | import { PluginPlaceholderComponent } from './plugins' | ||
36 | import { UserHistoryService, UserNotificationsComponent, UserNotificationService, UserQuotaComponent } from './users' | 37 | import { UserHistoryService, UserNotificationsComponent, UserNotificationService, UserQuotaComponent } from './users' |
37 | import { RedundancyService, VideoImportService, VideoOwnershipService, VideoService } from './video' | 38 | import { RedundancyService, VideoImportService, VideoOwnershipService, VideoService } from './video' |
38 | import { VideoCaptionService } from './video-caption' | 39 | import { VideoCaptionService } from './video-caption' |
@@ -92,7 +93,9 @@ import { VideoChannelService } from './video-channel' | |||
92 | SimpleSearchInputComponent, | 93 | SimpleSearchInputComponent, |
93 | 94 | ||
94 | UserQuotaComponent, | 95 | UserQuotaComponent, |
95 | UserNotificationsComponent | 96 | UserNotificationsComponent, |
97 | |||
98 | PluginPlaceholderComponent | ||
96 | ], | 99 | ], |
97 | 100 | ||
98 | exports: [ | 101 | exports: [ |
@@ -144,7 +147,9 @@ import { VideoChannelService } from './video-channel' | |||
144 | SimpleSearchInputComponent, | 147 | SimpleSearchInputComponent, |
145 | 148 | ||
146 | UserQuotaComponent, | 149 | UserQuotaComponent, |
147 | UserNotificationsComponent | 150 | UserNotificationsComponent, |
151 | |||
152 | PluginPlaceholderComponent | ||
148 | ], | 153 | ], |
149 | 154 | ||
150 | providers: [ | 155 | providers: [ |
diff --git a/shared/models/plugins/index.ts b/shared/models/plugins/index.ts index 740083f0e..03b27f907 100644 --- a/shared/models/plugins/index.ts +++ b/shared/models/plugins/index.ts | |||
@@ -7,6 +7,7 @@ export * from './peertube-plugin-index.model' | |||
7 | export * from './peertube-plugin-latest-version.model' | 7 | export * from './peertube-plugin-latest-version.model' |
8 | export * from './peertube-plugin.model' | 8 | export * from './peertube-plugin.model' |
9 | export * from './plugin-client-scope.type' | 9 | export * from './plugin-client-scope.type' |
10 | export * from './plugin-element-placeholder.type' | ||
10 | export * from './plugin-package-json.model' | 11 | export * from './plugin-package-json.model' |
11 | export * from './plugin-playlist-privacy-manager.model' | 12 | export * from './plugin-playlist-privacy-manager.model' |
12 | export * from './plugin-settings-manager.model' | 13 | export * from './plugin-settings-manager.model' |
diff --git a/shared/models/plugins/plugin-element-placeholder.type.ts b/shared/models/plugins/plugin-element-placeholder.type.ts new file mode 100644 index 000000000..129099c62 --- /dev/null +++ b/shared/models/plugins/plugin-element-placeholder.type.ts | |||
@@ -0,0 +1 @@ | |||
export type PluginElementPlaceholder = 'player-next' | |||
diff --git a/support/doc/plugins/guide.md b/support/doc/plugins/guide.md index e30d95fc9..81999bf32 100644 --- a/support/doc/plugins/guide.md +++ b/support/doc/plugins/guide.md | |||
@@ -15,7 +15,7 @@ | |||
15 | - [Add custom routes](#add-custom-routes) | 15 | - [Add custom routes](#add-custom-routes) |
16 | - [Add external auth methods](#add-external-auth-methods) | 16 | - [Add external auth methods](#add-external-auth-methods) |
17 | - [Add new transcoding profiles](#add-new-transcoding-profiles) | 17 | - [Add new transcoding profiles](#add-new-transcoding-profiles) |
18 | - [Helpers](#helpers) | 18 | - [Server helpers](#server-helpers) |
19 | - [Client API (themes & plugins)](#client-api-themes--plugins) | 19 | - [Client API (themes & plugins)](#client-api-themes--plugins) |
20 | - [Plugin static route](#plugin-static-route) | 20 | - [Plugin static route](#plugin-static-route) |
21 | - [Notifier](#notifier) | 21 | - [Notifier](#notifier) |
@@ -26,6 +26,7 @@ | |||
26 | - [Get server config](#get-server-config) | 26 | - [Get server config](#get-server-config) |
27 | - [Add custom fields to video form](#add-custom-fields-to-video-form) | 27 | - [Add custom fields to video form](#add-custom-fields-to-video-form) |
28 | - [Register settings script](#register-settings-script) | 28 | - [Register settings script](#register-settings-script) |
29 | - [HTML placeholder elements](#html-placeholder-elements) | ||
29 | - [Publishing](#publishing) | 30 | - [Publishing](#publishing) |
30 | - [Write a plugin/theme](#write-a-plugintheme) | 31 | - [Write a plugin/theme](#write-a-plugintheme) |
31 | - [Clone the quickstart repository](#clone-the-quickstart-repository) | 32 | - [Clone the quickstart repository](#clone-the-quickstart-repository) |
@@ -424,7 +425,7 @@ async function register ({ | |||
424 | During live transcode input options are applied once for each target resolution. | 425 | During live transcode input options are applied once for each target resolution. |
425 | Plugins are responsible for detecting such situation and applying input options only once if necessary. | 426 | Plugins are responsible for detecting such situation and applying input options only once if necessary. |
426 | 427 | ||
427 | ### Helpers | 428 | #### Server helpers |
428 | 429 | ||
429 | PeerTube provides your plugin some helpers. For example: | 430 | PeerTube provides your plugin some helpers. For example: |
430 | 431 | ||
@@ -628,6 +629,21 @@ async function register ({ registerSettingsScript }) { | |||
628 | } | 629 | } |
629 | ``` | 630 | ``` |
630 | 631 | ||
632 | #### HTML placeholder elements | ||
633 | |||
634 | PeerTube provides some HTML id so plugins can easily insert their own element: | ||
635 | |||
636 | ``` | ||
637 | async function register (...) { | ||
638 | const elem = document.createElement('div') | ||
639 | elem.className = 'hello-world-h4' | ||
640 | elem.innerHTML = '<h4>Hello everybody! This is an element next to the player</h4>' | ||
641 | |||
642 | document.getElementById('plugin-placeholder-player-next').appendChild(elem) | ||
643 | } | ||
644 | ``` | ||
645 | |||
646 | See the complete list on https://docs.joinpeertube.org/api-plugins | ||
631 | 647 | ||
632 | ### Publishing | 648 | ### Publishing |
633 | 649 | ||