Adding frontend peertubeHelpers.getBaseRouterRoute. (#4153)
* Adding frontend peertubeHelpers.getBaseRouterRoute. * Fix doctoc.
This commit is contained in:
parent
63da15eb18
commit
9777fe9eeb
|
@ -250,6 +250,11 @@ export class PluginService implements ClientHook {
|
||||||
return environment.apiUrl + `${pathPrefix}/${plugin.name}/${plugin.version}/static`
|
return environment.apiUrl + `${pathPrefix}/${plugin.name}/${plugin.version}/static`
|
||||||
},
|
},
|
||||||
|
|
||||||
|
getBaseRouterRoute: () => {
|
||||||
|
const pathPrefix = this.getPluginPathPrefix(pluginInfo.isTheme)
|
||||||
|
return environment.apiUrl + `${pathPrefix}/${plugin.name}/${plugin.version}/router`
|
||||||
|
},
|
||||||
|
|
||||||
getSettings: () => {
|
getSettings: () => {
|
||||||
const path = PluginService.BASE_PLUGIN_API_URL + '/' + npmName + '/public-settings'
|
const path = PluginService.BASE_PLUGIN_API_URL + '/' + npmName + '/public-settings'
|
||||||
|
|
||||||
|
|
|
@ -781,6 +781,8 @@ export class PeerTubeEmbed {
|
||||||
return {
|
return {
|
||||||
getBaseStaticRoute: unimplemented,
|
getBaseStaticRoute: unimplemented,
|
||||||
|
|
||||||
|
getBaseRouterRoute: unimplemented,
|
||||||
|
|
||||||
getSettings: unimplemented,
|
getSettings: unimplemented,
|
||||||
|
|
||||||
isLoggedIn: unimplemented,
|
isLoggedIn: unimplemented,
|
||||||
|
|
|
@ -19,6 +19,8 @@ export type RegisterClientOptions = {
|
||||||
export type RegisterClientHelpers = {
|
export type RegisterClientHelpers = {
|
||||||
getBaseStaticRoute: () => string
|
getBaseStaticRoute: () => string
|
||||||
|
|
||||||
|
getBaseRouterRoute: () => string
|
||||||
|
|
||||||
isLoggedIn: () => boolean
|
isLoggedIn: () => boolean
|
||||||
|
|
||||||
getAuthHeader: () => { 'Authorization': string } | undefined
|
getAuthHeader: () => { 'Authorization': string } | undefined
|
||||||
|
|
|
@ -21,6 +21,7 @@
|
||||||
- [Notifier](#notifier)
|
- [Notifier](#notifier)
|
||||||
- [Markdown Renderer](#markdown-renderer)
|
- [Markdown Renderer](#markdown-renderer)
|
||||||
- [Auth header](#auth-header)
|
- [Auth header](#auth-header)
|
||||||
|
- [Plugin router route](#plugin-router-route)
|
||||||
- [Custom Modal](#custom-modal)
|
- [Custom Modal](#custom-modal)
|
||||||
- [Translate](#translate)
|
- [Translate](#translate)
|
||||||
- [Get public settings](#get-public-settings)
|
- [Get public settings](#get-public-settings)
|
||||||
|
@ -561,6 +562,27 @@ function register (...) {
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
#### Plugin router route
|
||||||
|
|
||||||
|
**PeerTube >= 3.3**
|
||||||
|
|
||||||
|
To get your plugin router route, you can use `peertubeHelpers.getBaseRouterRoute()`:
|
||||||
|
|
||||||
|
```js
|
||||||
|
function register (...) {
|
||||||
|
registerHook({
|
||||||
|
target: 'action:video-watch.video.loaded',
|
||||||
|
handler: ({ video }) => {
|
||||||
|
fetch(peertubeHelpers.getBaseRouterRoute() + '/my/plugin/api', {
|
||||||
|
method: 'GET',
|
||||||
|
headers: peertubeHelpers.getAuthHeader()
|
||||||
|
}).then(res => res.json())
|
||||||
|
.then(data => console.log('Hi %s.', data))
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
#### Custom Modal
|
#### Custom Modal
|
||||||
|
|
||||||
To show a custom modal:
|
To show a custom modal:
|
||||||
|
|
Loading…
Reference in New Issue