Bumped to version v0.0.14-alpha
[oweals/peertube.git] / server / controllers / client.ts
index 9a72fe8e085180b0e093ccf5b31f305e7014829f..bb02f5075e1a6af3b8bc5147988c2e2ea82b461f 100644 (file)
@@ -1,15 +1,9 @@
+import * as Bluebird from 'bluebird'
 import * as express from 'express'
 import { join } from 'path'
 import * as validator from 'validator'
-import * as Bluebird from 'bluebird'
-import {
-  CONFIG,
-  STATIC_PATHS,
-  STATIC_MAX_AGE,
-  OPENGRAPH_AND_OEMBED_COMMENT,
-  EMBED_SIZE
-} from '../initializers'
-import { root, readFileBufferPromise, escapeHTML } from '../helpers'
+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'
 
@@ -90,6 +84,16 @@ function addOpenGraphAndOEmbedTags (htmlStringPage: string, video: VideoModel) {
     }
   ]
 
+  const schemaTags = {
+    name: videoNameEscaped,
+    description: videoDescriptionEscaped,
+    duration: video.getActivityStreamDuration(),
+    thumbnailURL: previewUrl,
+    contentURL: videoUrl,
+    embedURL: embedUrl,
+    uploadDate: video.createdAt
+  }
+
   let tagsString = ''
   Object.keys(openGraphMetaTags).forEach(tagName => {
     const tagValue = openGraphMetaTags[tagName]
@@ -101,6 +105,16 @@ function addOpenGraphAndOEmbedTags (htmlStringPage: string, video: VideoModel) {
     tagsString += `<link rel="alternate" type="${oembedLinkTag.type}" href="${oembedLinkTag.href}" title="${oembedLinkTag.title}" />`
   }
 
+  tagsString += '<div itemprop="video" itemscope itemtype="http://schema.org/VideoObject">'
+  tagsString += '<h2>Video: <span itemprop="name">' + schemaTags.name + '</span></h2>'
+
+  Object.keys(schemaTags).forEach(tagName => {
+    const tagValue = schemaTags[tagName]
+    tagsString += `<meta itemprop="${tagName}" content="${tagValue}" />`
+  })
+
+  tagsString += '</div>'
+
   return htmlStringPage.replace(OPENGRAPH_AND_OEMBED_COMMENT, tagsString)
 }