Initial release.
This commit is contained in:
parent
8635646b9d
commit
6d136a7da0
11
README.md
11
README.md
@ -1,3 +1,12 @@
|
||||
# PeerTube plugin livechat
|
||||
# PeerTube plugin livechat * ALPHA VERSION *
|
||||
|
||||
Work In Progress
|
||||
|
||||
Plugin that allows to integrated an iframe with an external webchat application.
|
||||
|
||||
This is under development. It is not functional yet.
|
||||
|
||||
For now, there is no documentation for how you can setup the webchat.
|
||||
It has to be setup by your own. For example with a XMPP Server and the ConverseJS Javascript.
|
||||
|
||||
Next step: document how you can setup the XMPP server.
|
||||
|
@ -0,0 +1,5 @@
|
||||
iframe.peertube-plugin-livechat {
|
||||
width: 100%;
|
||||
height: 300px;
|
||||
resize: vertical;
|
||||
}
|
@ -1,7 +0,0 @@
|
||||
function register ({ registerHook, peertubeHelpers }) {
|
||||
|
||||
}
|
||||
|
||||
export {
|
||||
register
|
||||
}
|
49
client/videowatch-client-plugin.js
Normal file
49
client/videowatch-client-plugin.js
Normal file
@ -0,0 +1,49 @@
|
||||
function register ({ registerHook, peertubeHelpers }) {
|
||||
registerHook({
|
||||
target: 'action:video-watch.player.loaded',
|
||||
handler: ({player, videojs, video}) => {
|
||||
peertubeHelpers.getSettings().then(s => {
|
||||
const liveOn = !!s['chat-all-lives']
|
||||
const nonLiveOn = !!s['chat-all-non-lives']
|
||||
const uuids = s['chat-videos-list'] ? s['chat-videos-list'].split('\n') : []
|
||||
const iframeUri = s['chat-uri'] || ''
|
||||
if ( iframeUri === '' ) {
|
||||
console.log('[peertube-plugin-livechat] no uri, can\'t add chat.')
|
||||
return
|
||||
}
|
||||
if (!uuids.length && !liveOn && !nonLiveOn) {
|
||||
console.log('[peertube-plugin-livechat] not activated.')
|
||||
return
|
||||
}
|
||||
|
||||
console.log('[peertube-plugin-livechat] Checking if this video should have a chat...')
|
||||
const uuid = video.uuid
|
||||
if (uuids.indexOf(uuid) >= 0) {
|
||||
console.log('[peertube-plugin-livechat] This video is in the list for chats.')
|
||||
} else if (video.isLive && liveOn) {
|
||||
console.log('[peertube-plugin-livechat] This video is live and we want all lives.')
|
||||
} else if (!video.isLive && nonLiveOn) {
|
||||
console.log('[peertube-plugin-livechat] This video is not live and we want all non-lives.')
|
||||
} else {
|
||||
console.log('[peertube-plugin-livechat] This video will not have a chat.')
|
||||
return
|
||||
}
|
||||
console.info('[peertube-plugin-livechat] Trying to load the chat for video ' + uuid + '.')
|
||||
const chatUrl = iframeUri.replace('{{VIDEO_UUID}}', uuid)
|
||||
if (!/^https?:\/\//.test(chatUrl)) {
|
||||
console.error('[peertube-plugin-livechat] The webchaturi must begin with https://')
|
||||
return
|
||||
}
|
||||
const parent = document.querySelector('.video-info')
|
||||
const iframe = document.createElement('iframe')
|
||||
iframe.setAttribute('src', chatUrl)
|
||||
iframe.setAttribute('class', 'peertube-plugin-livechat')
|
||||
parent.prepend(iframe)
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
export {
|
||||
register
|
||||
}
|
30
main.js
30
main.js
@ -7,7 +7,35 @@ async function register ({
|
||||
videoLicenceManager,
|
||||
videoLanguageManager
|
||||
}) {
|
||||
|
||||
registerSetting({
|
||||
name: 'chat-all-lives',
|
||||
label: 'Activate chat for all lives',
|
||||
type: 'input-checkbox',
|
||||
default: false,
|
||||
descriptionHTML: 'If checked, a chat will be added to all lives.'
|
||||
})
|
||||
registerSetting({
|
||||
name: 'chat-all-non-lives',
|
||||
label: 'Activate chat for all non-lives',
|
||||
type: 'input-checkbox',
|
||||
default: false,
|
||||
descriptionHTML: 'If checked, a chat will be added to all video that are not lives.'
|
||||
})
|
||||
registerSetting({
|
||||
name: 'chat-videos-list',
|
||||
label: 'Activate chat for specific videos',
|
||||
type: 'input-textarea',
|
||||
default: '',
|
||||
descriptionHTML: 'Videos UUIDs for which we want a chat. Can be non-live videos. One per line. Don\'t add private videos, the UUIDs will be send to frontend.'
|
||||
})
|
||||
registerSetting({
|
||||
name: 'chat-uri',
|
||||
label: 'Webchat url',
|
||||
type: 'input',
|
||||
default: '',
|
||||
descriptionHTML: 'The webchat url. An iframe will be created pointing to this url. The placeholder {{VIDEO_UUID}} will be replace by the video UUID if present. Example : https://my_domain/conversejs.html?room=video_{{VIDEO_UUID}}.'
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
async function unregister () {
|
||||
|
@ -6,9 +6,9 @@
|
||||
"bugs": "https://github.com/JohnXLivingston/peertube-plugin-livechat/issues",
|
||||
"clientScripts": [
|
||||
{
|
||||
"script": "dist/common-client-plugin.js",
|
||||
"script": "dist/videowatch-client-plugin.js",
|
||||
"scopes": [
|
||||
"common"
|
||||
"video-watch"
|
||||
]
|
||||
}
|
||||
],
|
||||
|
@ -3,7 +3,7 @@ const path = require("path")
|
||||
const EsmWebpackPlugin = require("@purtuga/esm-webpack-plugin")
|
||||
|
||||
const clientFiles = [
|
||||
'common-client-plugin.js'
|
||||
'videowatch-client-plugin.js'
|
||||
]
|
||||
|
||||
let config = clientFiles.map(f => ({
|
||||
|
Loading…
Reference in New Issue
Block a user