X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server%2Flib%2Fclient-html.ts;h=926d6e93f40f67243cfac4918df5ce8f1b32f985;hb=13230c6815619829ca8916925c357fea60de7700;hp=85fced10ddb25dea956c89f8f6291ac4c4ffb107;hpb=6fad8e51c47b9d07bea99b777c1f55c10f6d576d;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server/lib/client-html.ts b/server/lib/client-html.ts index 85fced10d..926d6e93f 100644 --- a/server/lib/client-html.ts +++ b/server/lib/client-html.ts @@ -25,7 +25,7 @@ import { MAccountActor, MChannelActor } from '../types/models' type Tags = { ogType: string - twitterCard: string + twitterCard: 'player' | 'summary' | 'summary_large_image' schemaType: string list?: { @@ -171,6 +171,21 @@ export class ClientHtml { return this.getAccountOrChannelHTMLPage(() => VideoChannelModel.loadByNameWithHostAndPopulateAccount(nameWithHost), req, res) } + static async getEmbedHTML () { + const path = ClientHtml.getEmbedPath() + + 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, req: express.Request, @@ -252,6 +267,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('', ``) } @@ -348,6 +367,12 @@ export class ClientHtml { metaTags['twitter:image:height'] = tags.image.height } + if (tags.twitterCard === 'player') { + metaTags['twitter:player'] = tags.embed.url + metaTags['twitter:player:width'] = EMBED_SIZE.width + metaTags['twitter:player:height'] = EMBED_SIZE.height + } + return metaTags }