]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/lib/client-html.ts
Translated using Weblate (Hebrew)
[github/Chocobozzz/PeerTube.git] / server / lib / client-html.ts
index 85fced10ddb25dea956c89f8f6291ac4c4ffb107..926d6e93f40f67243cfac4918df5ce8f1b32f985 100644 (file)
@@ -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<MAccountActor | MChannelActor>,
     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('<html>', `<html lang="${paramLang}">`)
   }
@@ -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
   }