Using getBaseStaticRoute for index.html urls.

This commit is contained in:
John Livingston 2021-05-18 18:17:13 +02:00
parent 2a8df1dc3c
commit d4b8c8b2e2
2 changed files with 7 additions and 8 deletions

View File

@ -5,9 +5,9 @@
<meta charset="utf-8"/> <meta charset="utf-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1.0"/> <meta name="viewport" content="width=device-width, initial-scale=1.0"/>
<meta name="description" content="Converse XMPP/Jabber Chat"/> <meta name="description" content="Converse XMPP/Jabber Chat"/>
<link type="text/css" rel="stylesheet" media="screen" href="{{BASE_STATIC_URL}}/conversejs/converse.min.css" /> <link type="text/css" rel="stylesheet" media="screen" href="{{BASE_STATIC_URL}}conversejs/converse.min.css" />
<script type="text/javaScript" src="{{BASE_STATIC_URL}}/conversejs/converse.min.js"></script> <script type="text/javaScript" src="{{BASE_STATIC_URL}}conversejs/converse.min.js"></script>
<script type="text/javascript" src="{{BASE_STATIC_URL}}/static/builtin.js"></script> <script type="text/javascript" src="{{BASE_STATIC_URL}}static/builtin.js"></script>
<style type="text/css"> <style type="text/css">
body.livechat-iframe #conversejs .chat-head { body.livechat-iframe #conversejs .chat-head {
display: none; display: none;
@ -20,7 +20,7 @@
<script type="text/javascript"> <script type="text/javascript">
initConverse({ initConverse({
jid: '{{JID}}', jid: '{{JID}}',
assetsPath : '{{BASE_STATIC_URL}}/conversejs/', assetsPath : '{{BASE_STATIC_URL}}conversejs/',
room: '{{ROOM}}', room: '{{ROOM}}',
boshServiceUrl: '{{BOSH_SERVICE_URL}}', boshServiceUrl: '{{BOSH_SERVICE_URL}}',
websocketServiceUrl: '{{WS_SERVICE_URL}}', websocketServiceUrl: '{{WS_SERVICE_URL}}',

View File

@ -1,6 +1,6 @@
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 { getBaseRouterRoute } from '../helpers' import { getBaseRouterRoute, getBaseStaticRoute } from '../helpers'
import { asyncMiddleware } from '../middlewares/async' import { asyncMiddleware } from '../middlewares/async'
import { getProsodyDomain } from '../prosody/config/domain' import { getProsodyDomain } from '../prosody/config/domain'
import * as path from 'path' import * as path from 'path'
@ -72,9 +72,8 @@ async function initWebchatRouter (options: RegisterServerOptions): Promise<Route
} }
let page = '' + (converseJSIndex as string) let page = '' + (converseJSIndex as string)
// FIXME: Peertube should provide the static folder path. For now: const baseStaticUrl = getBaseStaticRoute(options)
const staticRelative = '../../../static' page = page.replace(/{{BASE_STATIC_URL}}/g, baseStaticUrl)
page = page.replace(/{{BASE_STATIC_URL}}/g, staticRelative)
page = page.replace(/{{JID}}/g, server) page = page.replace(/{{JID}}/g, server)
room = room.replace(/{{VIDEO_UUID}}/g, video.uuid) room = room.replace(/{{VIDEO_UUID}}/g, video.uuid)
page = page.replace(/{{ROOM}}/g, room) page = page.replace(/{{ROOM}}/g, room)