1
0
Fork 0
mirror of https://github.com/Chocobozzz/PeerTube.git synced 2025-10-04 02:09:37 +02:00

Inject plugin CSS in embed too

This commit is contained in:
Chocobozzz 2020-08-24 11:25:40 +02:00
parent 5505981154
commit cf649c2ed9
No known key found for this signature in database
GPG key ID: 583A612D890159BE
3 changed files with 61 additions and 11 deletions

View file

@ -171,6 +171,23 @@ export class ClientHtml {
return this.getAccountOrChannelHTMLPage(() => VideoChannelModel.loadByNameWithHostAndPopulateAccount(nameWithHost), req, res)
}
static async getEmbedHTML () {
const path = ClientHtml.getEmbedPath()
console.log('coucu')
console.log(path)
if (ClientHtml.htmlCache[path]) return ClientHtml.htmlCache[path]
const buffer = await readFile(path)
let html = buffer.toString()
html = await ClientHtml.addAsyncPluginCSS(html)
ClientHtml.htmlCache[path] = html
return html
}
private static async getAccountOrChannelHTMLPage (
loader: () => Bluebird<MAccountActor | MChannelActor>,
req: express.Request,
@ -252,6 +269,10 @@ export class ClientHtml {
return join(__dirname, '../../../client/dist/' + buildFileLocale(lang) + '/index.html')
}
private static getEmbedPath () {
return join(__dirname, '../../../client/dist/standalone/videos/embed.html')
}
private static addHtmlLang (htmlStringPage: string, paramLang: string) {
return htmlStringPage.replace('<html>', `<html lang="${paramLang}">`)
}