]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/controllers/client.ts
Add context menu to player
[github/Chocobozzz/PeerTube.git] / server / controllers / client.ts
index 2fcca6f761227ffd4d8774eb19ec88c928aa2c1b..aff00fe6e7b4bbbe7ba211792ddc6a3caf910e59 100644 (file)
@@ -6,11 +6,12 @@ import { escapeHTML, readFileBufferPromise, root } from '../helpers/core-utils'
 import { CONFIG, EMBED_SIZE, OPENGRAPH_AND_OEMBED_COMMENT, STATIC_MAX_AGE, STATIC_PATHS } from '../initializers'
 import { asyncMiddleware } from '../middlewares'
 import { VideoModel } from '../models/video/video'
+import { VideoPrivacy } from '../../shared/models/videos'
 
 const clientsRouter = express.Router()
 
 const distPath = join(root(), 'client', 'dist')
-const assetsImagesPath = join(root(), 'client', 'dist', 'client', 'assets', 'images')
+const assetsImagesPath = join(root(), 'client', 'dist', 'assets', 'images')
 const embedPath = join(distPath, 'standalone', 'videos', 'embed.html')
 const indexPath = join(distPath, 'index.html')
 
@@ -77,8 +78,8 @@ function addOpenGraphAndOEmbedTags (htmlStringPage: string, video: VideoModel) {
     'description': videoDescriptionEscaped,
     'image': previewUrl,
 
-    'twitter:card': 'summary_large_image',
-    'twitter:site': '@Chocobozzz',
+    'twitter:card': CONFIG.SERVICES.TWITTER.WHITELISTED ? 'player' : 'summary_large_image',
+    'twitter:site': CONFIG.SERVICES.TWITTER.USERNAME,
     'twitter:title': videoNameEscaped,
     'twitter:description': videoDescriptionEscaped,
     'twitter:image': previewUrl,
@@ -100,11 +101,12 @@ function addOpenGraphAndOEmbedTags (htmlStringPage: string, video: VideoModel) {
     '@type': 'VideoObject',
     name: videoNameEscaped,
     description: videoDescriptionEscaped,
+    thumbnailUrl: previewUrl,
+    uploadDate: video.createdAt.toISOString(),
     duration: video.getActivityStreamDuration(),
-    thumbnailURL: previewUrl,
-    contentURL: videoUrl,
-    embedURL: embedUrl,
-    uploadDate: video.createdAt
+    contentUrl: videoUrl,
+    embedUrl: embedUrl,
+    interactionCount: video.views
   }
 
   let tagsString = ''
@@ -124,6 +126,9 @@ function addOpenGraphAndOEmbedTags (htmlStringPage: string, video: VideoModel) {
   // Schema.org
   tagsString += `<script type="application/ld+json">${JSON.stringify(schemaTags)}</script>`
 
+  // SEO
+  tagsString += `<link rel="canonical" href="${videoUrl}" />`
+
   return htmlStringPage.replace(OPENGRAPH_AND_OEMBED_COMMENT, tagsString)
 }
 
@@ -148,7 +153,7 @@ async function generateWatchHtmlPage (req: express.Request, res: express.Respons
   const html = file.toString()
 
   // Let Angular application handle errors
-  if (!video) return res.sendFile(indexPath)
+  if (!video || video.privacy === VideoPrivacy.PRIVATE) return res.sendFile(indexPath)
 
   const htmlStringPageWithTags = addOpenGraphAndOEmbedTags(html, video)
   res.set('Content-Type', 'text/html; charset=UTF-8').send(htmlStringPageWithTags)