ConverseJS: theme settings.
This commit is contained in:
parent
8a2b063489
commit
9b20042aad
@ -221,6 +221,12 @@ function register ({ registerHook, registerSettingsScript, peertubeHelpers }: Re
|
|||||||
case 'chat-ws-uri':
|
case 'chat-ws-uri':
|
||||||
case 'chat-type-help-builtin-converse':
|
case 'chat-type-help-builtin-converse':
|
||||||
return options.formValues['chat-type'] !== ('builtin-converse' as ChatType)
|
return options.formValues['chat-type'] !== ('builtin-converse' as ChatType)
|
||||||
|
case 'converse-advanced':
|
||||||
|
case 'converse-theme':
|
||||||
|
return !(
|
||||||
|
options.formValues['chat-type'] === ('builtin-converse' as ChatType) ||
|
||||||
|
options.formValues['chat-type'] === ('builtin-prosody' as ChatType)
|
||||||
|
)
|
||||||
case 'chat-uri':
|
case 'chat-uri':
|
||||||
case 'chat-type-help-external-uri':
|
case 'chat-type-help-external-uri':
|
||||||
return options.formValues['chat-type'] !== ('external-uri' as ChatType)
|
return options.formValues['chat-type'] !== ('external-uri' as ChatType)
|
||||||
|
@ -79,6 +79,7 @@ interface InitConverseParams {
|
|||||||
websocketServiceUrl: string
|
websocketServiceUrl: string
|
||||||
authenticationUrl: string
|
authenticationUrl: string
|
||||||
advancedControls: 'true' | 'false'
|
advancedControls: 'true' | 'false'
|
||||||
|
theme: string
|
||||||
}
|
}
|
||||||
window.initConverse = async function initConverse ({
|
window.initConverse = async function initConverse ({
|
||||||
jid,
|
jid,
|
||||||
@ -87,7 +88,8 @@ window.initConverse = async function initConverse ({
|
|||||||
boshServiceUrl,
|
boshServiceUrl,
|
||||||
websocketServiceUrl,
|
websocketServiceUrl,
|
||||||
authenticationUrl,
|
authenticationUrl,
|
||||||
advancedControls
|
advancedControls,
|
||||||
|
theme
|
||||||
}: InitConverseParams) {
|
}: InitConverseParams) {
|
||||||
const isInIframe = inIframe()
|
const isInIframe = inIframe()
|
||||||
|
|
||||||
@ -135,7 +137,7 @@ window.initConverse = async function initConverse ({
|
|||||||
emoji: true,
|
emoji: true,
|
||||||
toggle_occupants: true
|
toggle_occupants: true
|
||||||
},
|
},
|
||||||
theme: 'peertube',
|
theme: theme || 'peertube',
|
||||||
persistent_store: 'sessionStorage'
|
persistent_store: 'sessionStorage'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -20,7 +20,8 @@
|
|||||||
boshServiceUrl: '{{BOSH_SERVICE_URL}}',
|
boshServiceUrl: '{{BOSH_SERVICE_URL}}',
|
||||||
websocketServiceUrl: '{{WS_SERVICE_URL}}',
|
websocketServiceUrl: '{{WS_SERVICE_URL}}',
|
||||||
authenticationUrl: '{{AUTHENTICATION_URL}}',
|
authenticationUrl: '{{AUTHENTICATION_URL}}',
|
||||||
advancedControls: '{{ADVANCEDCONTROLS}}'
|
advancedControls: '{{ADVANCEDCONTROLS}}',
|
||||||
|
theme: '{{CONVERSEJS_THEME}}'
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
</body>
|
</body>
|
||||||
|
@ -45,3 +45,16 @@ You can add some custom styles that will be added to the iframe.
|
|||||||
For example a custom width:
|
For example a custom width:
|
||||||
|
|
||||||
```width:400px;```
|
```width:400px;```
|
||||||
|
|
||||||
|
### ConverseJS advanced settings
|
||||||
|
|
||||||
|
These settings are available if you are in mode «Prosody server controlled by Peertube»
|
||||||
|
or «Connect to an existing XMPP server with ConverseJS».
|
||||||
|
|
||||||
|
#### ConverseJS theme
|
||||||
|
|
||||||
|
You can choose which theme to use for ConverseJS:
|
||||||
|
|
||||||
|
- Peertube theme: this is a special theme, made especially for peertube's integration.
|
||||||
|
- Default ConverseJS theme: this is the default ConverseJS theme.
|
||||||
|
- ConverseJS concord theme: this is a theme provided by ConverseJS.
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
import type { Router, RequestHandler, Request, Response, NextFunction } from 'express'
|
import type { Router, RequestHandler, Request, Response, NextFunction } from 'express'
|
||||||
import type { ProxyOptions } from 'express-http-proxy'
|
import type { ProxyOptions } from 'express-http-proxy'
|
||||||
import type { ChatType, ProsodyListRoomsResult, ProsodyListRoomsResultRoom } from '../../../shared/lib/types'
|
import type {
|
||||||
|
ChatType, ProsodyListRoomsResult, ProsodyListRoomsResultRoom
|
||||||
|
} from '../../../shared/lib/types'
|
||||||
import { getBaseRouterRoute, getBaseStaticRoute, isUserAdmin } from '../helpers'
|
import { getBaseRouterRoute, getBaseStaticRoute, isUserAdmin } from '../helpers'
|
||||||
import { asyncMiddleware } from '../middlewares/async'
|
import { asyncMiddleware } from '../middlewares/async'
|
||||||
import { getProsodyDomain } from '../prosody/config/domain'
|
import { getProsodyDomain } from '../prosody/config/domain'
|
||||||
@ -39,7 +41,8 @@ async function initWebchatRouter (options: RegisterServerOptions): Promise<Route
|
|||||||
const settings = await settingsManager.getSettings([
|
const settings = await settingsManager.getSettings([
|
||||||
'chat-type', 'chat-room', 'chat-server',
|
'chat-type', 'chat-room', 'chat-server',
|
||||||
'chat-bosh-uri', 'chat-ws-uri',
|
'chat-bosh-uri', 'chat-ws-uri',
|
||||||
'prosody-room-type'
|
'prosody-room-type',
|
||||||
|
'converse-theme'
|
||||||
])
|
])
|
||||||
const chatType: ChatType = (settings['chat-type'] ?? 'disabled') as ChatType
|
const chatType: ChatType = (settings['chat-type'] ?? 'disabled') as ChatType
|
||||||
|
|
||||||
@ -49,6 +52,10 @@ async function initWebchatRouter (options: RegisterServerOptions): Promise<Route
|
|||||||
let wsUri: string
|
let wsUri: string
|
||||||
let authenticationUrl: string = ''
|
let authenticationUrl: string = ''
|
||||||
let advancedControls: boolean = false
|
let advancedControls: boolean = false
|
||||||
|
let converseJSTheme: string = settings['converse-theme'] as string
|
||||||
|
if (!/^\w+$/.test(converseJSTheme)) {
|
||||||
|
converseJSTheme = 'peertube'
|
||||||
|
}
|
||||||
if (chatType === 'builtin-prosody') {
|
if (chatType === 'builtin-prosody') {
|
||||||
const prosodyDomain = await getProsodyDomain(options)
|
const prosodyDomain = await getProsodyDomain(options)
|
||||||
jid = 'anon.' + prosodyDomain
|
jid = 'anon.' + prosodyDomain
|
||||||
@ -148,6 +155,7 @@ async function initWebchatRouter (options: RegisterServerOptions): Promise<Route
|
|||||||
page = page.replace(/{{WS_SERVICE_URL}}/g, wsUri)
|
page = page.replace(/{{WS_SERVICE_URL}}/g, wsUri)
|
||||||
page = page.replace(/{{AUTHENTICATION_URL}}/g, authenticationUrl)
|
page = page.replace(/{{AUTHENTICATION_URL}}/g, authenticationUrl)
|
||||||
page = page.replace(/{{ADVANCEDCONTROLS}}/g, advancedControls ? 'true' : 'false')
|
page = page.replace(/{{ADVANCEDCONTROLS}}/g, advancedControls ? 'true' : 'false')
|
||||||
|
page = page.replace(/{{CONVERSEJS_THEME}}/g, converseJSTheme)
|
||||||
|
|
||||||
res.status(200)
|
res.status(200)
|
||||||
res.type('html')
|
res.type('html')
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import { ensureProsodyRunning, ensureProsodyNotRunning } from './prosody/ctl'
|
import { ensureProsodyRunning, ensureProsodyNotRunning } from './prosody/ctl'
|
||||||
import type { ChatType } from '../../shared/lib/types'
|
import type { ChatType, ConverseJSTheme } from '../../shared/lib/types'
|
||||||
|
|
||||||
function initSettings (options: RegisterServerOptions): void {
|
function initSettings (options: RegisterServerOptions): void {
|
||||||
const { peertubeHelpers, registerSetting, settingsManager } = options
|
const { peertubeHelpers, registerSetting, settingsManager } = options
|
||||||
@ -269,6 +269,28 @@ Example: height:400px;`,
|
|||||||
private: false
|
private: false
|
||||||
})
|
})
|
||||||
|
|
||||||
|
// ********** ConverseJS advanced settings
|
||||||
|
registerSetting({
|
||||||
|
name: 'converse-advanced',
|
||||||
|
type: 'html',
|
||||||
|
private: true,
|
||||||
|
descriptionHTML: '<h3>ConverseJS advanced settings</h3>'
|
||||||
|
})
|
||||||
|
|
||||||
|
registerSetting({
|
||||||
|
name: 'converse-theme',
|
||||||
|
label: 'ConverseJS theme',
|
||||||
|
type: 'select',
|
||||||
|
default: 'peertube' as ConverseJSTheme,
|
||||||
|
private: true,
|
||||||
|
options: [
|
||||||
|
{ value: 'peertube', label: 'Peertube theme' },
|
||||||
|
{ value: 'default', label: 'Default ConverseJS theme' },
|
||||||
|
{ value: 'concord', label: 'ConverseJS concord theme' }
|
||||||
|
] as Array<{value: ConverseJSTheme, label: string}>,
|
||||||
|
descriptionHTML: 'Please choose the converseJS theme you want to use.'
|
||||||
|
})
|
||||||
|
|
||||||
// ********** Built-in Prosody advanced settings
|
// ********** Built-in Prosody advanced settings
|
||||||
registerSetting({
|
registerSetting({
|
||||||
name: 'prosody-advanced',
|
name: 'prosody-advanced',
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
type ChatType = 'disabled' | 'builtin-prosody' | 'builtin-converse' | 'external-uri'
|
type ChatType = 'disabled' | 'builtin-prosody' | 'builtin-converse' | 'external-uri'
|
||||||
|
type ConverseJSTheme = 'peertube' | 'default' | 'concord'
|
||||||
|
|
||||||
interface ProsodyListRoomsResultError {
|
interface ProsodyListRoomsResultError {
|
||||||
ok: false
|
ok: false
|
||||||
@ -28,6 +29,7 @@ type ProsodyListRoomsResult = ProsodyListRoomsResultError | ProsodyListRoomsResu
|
|||||||
|
|
||||||
export {
|
export {
|
||||||
ChatType,
|
ChatType,
|
||||||
|
ConverseJSTheme,
|
||||||
ProsodyListRoomsResult,
|
ProsodyListRoomsResult,
|
||||||
ProsodyListRoomsResultRoom
|
ProsodyListRoomsResultRoom
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user