]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/commitdiff
Add plugin placeholder elements support
authorChocobozzz <me@florianbigard.com>
Mon, 12 Apr 2021 09:10:57 +0000 (11:10 +0200)
committerChocobozzz <me@florianbigard.com>
Mon, 12 Apr 2021 09:19:15 +0000 (11:19 +0200)
client/src/app/+videos/+video-watch/video-watch.component.html
client/src/app/core/core.module.ts
client/src/app/shared/shared-main/plugins/index.ts [new file with mode: 0644]
client/src/app/shared/shared-main/plugins/plugin-placeholder.component.ts [new file with mode: 0644]
client/src/app/shared/shared-main/shared-main.module.ts
shared/models/plugins/index.ts
shared/models/plugins/plugin-element-placeholder.type.ts [new file with mode: 0644]
support/doc/plugins/guide.md

index 99103c2c38decfa4271658c0a5f9bb9281721852..c1ba0a755b7323006dbe18ad069021b39c238b99 100644 (file)
@@ -16,6 +16,8 @@
       [playlist]="playlist" class="playlist"
       (videoFound)="onPlaylistVideoFound($event)"
     ></my-video-watch-playlist>
+
+    <my-plugin-placeholder pluginId="player-next"></my-plugin-placeholder>
   </div>
 
   <div class="row">
index 2392a234c1a3856c6397746744f4fe8082711c9b..3152a70037579da0929d665daa8f0c1ee3ef3170 100644 (file)
@@ -5,8 +5,7 @@ import { CommonModule } from '@angular/common'
 import { NgModule, Optional, SkipSelf } from '@angular/core'
 import { BrowserAnimationsModule } from '@angular/platform-browser/animations'
 import { PeerTubeSocket } from '@app/core/notification/peertube-socket.service'
-import { HooksService } from '@app/core/plugins/hooks.service'
-import { PluginService } from '@app/core/plugins/plugin.service'
+import { HooksService, PluginService } from '@app/core/plugins'
 import { AuthService } from './auth'
 import { ConfirmService } from './confirm'
 import { CheatSheetComponent } from './hotkeys'
@@ -15,7 +14,7 @@ import { throwIfAlreadyLoaded } from './module-import-guard'
 import { Notifier } from './notification'
 import { HtmlRendererService, LinkifierService, MarkdownService } from './renderer'
 import { RestExtractor, RestService } from './rest'
-import { LoginGuard, RedirectService, UserRightGuard, UnloggedGuard } from './routing'
+import { LoginGuard, RedirectService, UnloggedGuard, UserRightGuard } from './routing'
 import { CanDeactivateGuard } from './routing/can-deactivate-guard.service'
 import { ServerConfigResolver } from './routing/server-config-resolver.service'
 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 (file)
index 0000000..f36dab6
--- /dev/null
@@ -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 (file)
index 0000000..93ba9fb
--- /dev/null
@@ -0,0 +1,15 @@
+import { Component, Input } from '@angular/core'
+import { PluginElementPlaceholder } from '@shared/models'
+
+@Component({
+  selector: 'my-plugin-placeholder',
+  template: '<div [id]="getId()"></div>'
+})
+
+export class PluginPlaceholderComponent {
+  @Input() pluginId: PluginElementPlaceholder
+
+  getId () {
+    return 'plugin-placeholder-' + this.pluginId
+  }
+}
index 16d230f467cb4748540eb835903f5f55c2dbadc4..772198cb26e9d43ddac863095658187cb825202b 100644 (file)
@@ -33,6 +33,7 @@ import { DateToggleComponent } from './date'
 import { FeedComponent } from './feeds'
 import { LoaderComponent, SmallLoaderComponent } from './loaders'
 import { HelpComponent, ListOverflowComponent, SimpleSearchInputComponent, TopMenuDropdownComponent } from './misc'
+import { PluginPlaceholderComponent } from './plugins'
 import { UserHistoryService, UserNotificationsComponent, UserNotificationService, UserQuotaComponent } from './users'
 import { RedundancyService, VideoImportService, VideoOwnershipService, VideoService } from './video'
 import { VideoCaptionService } from './video-caption'
@@ -92,7 +93,9 @@ import { VideoChannelService } from './video-channel'
     SimpleSearchInputComponent,
 
     UserQuotaComponent,
-    UserNotificationsComponent
+    UserNotificationsComponent,
+
+    PluginPlaceholderComponent
   ],
 
   exports: [
@@ -144,7 +147,9 @@ import { VideoChannelService } from './video-channel'
     SimpleSearchInputComponent,
 
     UserQuotaComponent,
-    UserNotificationsComponent
+    UserNotificationsComponent,
+
+    PluginPlaceholderComponent
   ],
 
   providers: [
index 740083f0ee5dcfebd46b1c23aae6bd9e24d6d373..03b27f90751412b1e5ad114af91d5030348fc469 100644 (file)
@@ -7,6 +7,7 @@ export * from './peertube-plugin-index.model'
 export * from './peertube-plugin-latest-version.model'
 export * from './peertube-plugin.model'
 export * from './plugin-client-scope.type'
+export * from './plugin-element-placeholder.type'
 export * from './plugin-package-json.model'
 export * from './plugin-playlist-privacy-manager.model'
 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 (file)
index 0000000..129099c
--- /dev/null
@@ -0,0 +1 @@
+export type PluginElementPlaceholder = 'player-next'
index e30d95fc94434b249977760bdfea5dd200e7049e..81999bf32668e2734aee8f9f71631466f7c0be47 100644 (file)
@@ -15,7 +15,7 @@
     - [Add custom routes](#add-custom-routes)
     - [Add external auth methods](#add-external-auth-methods)
     - [Add new transcoding profiles](#add-new-transcoding-profiles)
-  - [Helpers](#helpers)
+    - [Server helpers](#server-helpers)
   - [Client API (themes & plugins)](#client-api-themes--plugins)
     - [Plugin static route](#plugin-static-route)
     - [Notifier](#notifier)
@@ -26,6 +26,7 @@
     - [Get server config](#get-server-config)
     - [Add custom fields to video form](#add-custom-fields-to-video-form)
     - [Register settings script](#register-settings-script)
+    - [HTML placeholder elements](#html-placeholder-elements)
   - [Publishing](#publishing)
 - [Write a plugin/theme](#write-a-plugintheme)
   - [Clone the quickstart repository](#clone-the-quickstart-repository)
@@ -424,7 +425,7 @@ async function register ({
 During live transcode input options are applied once for each target resolution.
 Plugins are responsible for detecting such situation and applying input options only once if necessary.
 
-### Helpers
+#### Server helpers
 
 PeerTube provides your plugin some helpers. For example:
 
@@ -628,6 +629,21 @@ async function register ({ registerSettingsScript }) {
 }
 ```
 
+#### HTML placeholder elements
+
+PeerTube provides some HTML id so plugins can easily insert their own element:
+
+```
+async function register (...) {
+  const elem = document.createElement('div')
+  elem.className = 'hello-world-h4'
+  elem.innerHTML = '<h4>Hello everybody! This is an element next to the player</h4>'
+
+  document.getElementById('plugin-placeholder-player-next').appendChild(elem)
+}
+```
+
+See the complete list on https://docs.joinpeertube.org/api-plugins
 
 ### Publishing