aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2021-04-12 11:10:57 +0200
committerChocobozzz <me@florianbigard.com>2021-04-12 11:19:15 +0200
commit62bc0352d9d465ce9d7c3e074b1b60bf99155e24 (patch)
tree7cfbf827b7b8c802ae79fb87e55c9d960120400f
parentc96e457bde8495cf9103bf819f887f341a528543 (diff)
downloadPeerTube-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.html2
-rw-r--r--client/src/app/core/core.module.ts5
-rw-r--r--client/src/app/shared/shared-main/plugins/index.ts1
-rw-r--r--client/src/app/shared/shared-main/plugins/plugin-placeholder.component.ts15
-rw-r--r--client/src/app/shared/shared-main/shared-main.module.ts9
-rw-r--r--shared/models/plugins/index.ts1
-rw-r--r--shared/models/plugins/plugin-element-placeholder.type.ts1
-rw-r--r--support/doc/plugins/guide.md20
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'
5import { NgModule, Optional, SkipSelf } from '@angular/core' 5import { NgModule, Optional, SkipSelf } from '@angular/core'
6import { BrowserAnimationsModule } from '@angular/platform-browser/animations' 6import { BrowserAnimationsModule } from '@angular/platform-browser/animations'
7import { PeerTubeSocket } from '@app/core/notification/peertube-socket.service' 7import { PeerTubeSocket } from '@app/core/notification/peertube-socket.service'
8import { HooksService } from '@app/core/plugins/hooks.service' 8import { HooksService, PluginService } from '@app/core/plugins'
9import { PluginService } from '@app/core/plugins/plugin.service'
10import { AuthService } from './auth' 9import { AuthService } from './auth'
11import { ConfirmService } from './confirm' 10import { ConfirmService } from './confirm'
12import { CheatSheetComponent } from './hotkeys' 11import { CheatSheetComponent } from './hotkeys'
@@ -15,7 +14,7 @@ import { throwIfAlreadyLoaded } from './module-import-guard'
15import { Notifier } from './notification' 14import { Notifier } from './notification'
16import { HtmlRendererService, LinkifierService, MarkdownService } from './renderer' 15import { HtmlRendererService, LinkifierService, MarkdownService } from './renderer'
17import { RestExtractor, RestService } from './rest' 16import { RestExtractor, RestService } from './rest'
18import { LoginGuard, RedirectService, UserRightGuard, UnloggedGuard } from './routing' 17import { LoginGuard, RedirectService, UnloggedGuard, UserRightGuard } from './routing'
19import { CanDeactivateGuard } from './routing/can-deactivate-guard.service' 18import { CanDeactivateGuard } from './routing/can-deactivate-guard.service'
20import { ServerConfigResolver } from './routing/server-config-resolver.service' 19import { ServerConfigResolver } from './routing/server-config-resolver.service'
21import { ScopedTokensService } from './scoped-tokens' 20import { 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 @@
1import { Component, Input } from '@angular/core'
2import { PluginElementPlaceholder } from '@shared/models'
3
4@Component({
5 selector: 'my-plugin-placeholder',
6 template: '<div [id]="getId()"></div>'
7})
8
9export 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'
33import { FeedComponent } from './feeds' 33import { FeedComponent } from './feeds'
34import { LoaderComponent, SmallLoaderComponent } from './loaders' 34import { LoaderComponent, SmallLoaderComponent } from './loaders'
35import { HelpComponent, ListOverflowComponent, SimpleSearchInputComponent, TopMenuDropdownComponent } from './misc' 35import { HelpComponent, ListOverflowComponent, SimpleSearchInputComponent, TopMenuDropdownComponent } from './misc'
36import { PluginPlaceholderComponent } from './plugins'
36import { UserHistoryService, UserNotificationsComponent, UserNotificationService, UserQuotaComponent } from './users' 37import { UserHistoryService, UserNotificationsComponent, UserNotificationService, UserQuotaComponent } from './users'
37import { RedundancyService, VideoImportService, VideoOwnershipService, VideoService } from './video' 38import { RedundancyService, VideoImportService, VideoOwnershipService, VideoService } from './video'
38import { VideoCaptionService } from './video-caption' 39import { 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'
7export * from './peertube-plugin-latest-version.model' 7export * from './peertube-plugin-latest-version.model'
8export * from './peertube-plugin.model' 8export * from './peertube-plugin.model'
9export * from './plugin-client-scope.type' 9export * from './plugin-client-scope.type'
10export * from './plugin-element-placeholder.type'
10export * from './plugin-package-json.model' 11export * from './plugin-package-json.model'
11export * from './plugin-playlist-privacy-manager.model' 12export * from './plugin-playlist-privacy-manager.model'
12export * from './plugin-settings-manager.model' 13export * 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 ({
424During live transcode input options are applied once for each target resolution. 425During live transcode input options are applied once for each target resolution.
425Plugins are responsible for detecting such situation and applying input options only once if necessary. 426Plugins are responsible for detecting such situation and applying input options only once if necessary.
426 427
427### Helpers 428#### Server helpers
428 429
429PeerTube provides your plugin some helpers. For example: 430PeerTube 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
634PeerTube provides some HTML id so plugins can easily insert their own element:
635
636```
637async 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
646See the complete list on https://docs.joinpeertube.org/api-plugins
631 647
632### Publishing 648### Publishing
633 649