diff options
author | Chocobozzz <me@florianbigard.com> | 2018-01-24 09:21:45 +0100 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2018-01-24 09:21:45 +0100 |
commit | c7b1b92b118b0db21d542169bbe2ea9a33fd8943 (patch) | |
tree | aa9558e69ef907de338e0d8fa832c9cc6ce20f81 | |
parent | d0e848b77e187fc1dc6267a81469357a38cc3b01 (diff) | |
download | PeerTube-c7b1b92b118b0db21d542169bbe2ea9a33fd8943.tar.gz PeerTube-c7b1b92b118b0db21d542169bbe2ea9a33fd8943.tar.zst PeerTube-c7b1b92b118b0db21d542169bbe2ea9a33fd8943.zip |
Use json for schema.org instead of tags
-rwxr-xr-x | scripts/release.sh | 2 | ||||
-rw-r--r-- | server/controllers/client.ts | 16 |
2 files changed, 8 insertions, 10 deletions
diff --git a/scripts/release.sh b/scripts/release.sh index 1b240ea38..0a78fe990 100755 --- a/scripts/release.sh +++ b/scripts/release.sh | |||
@@ -53,7 +53,7 @@ zip -r "PeerTube/$zip_name" "$directory_name/CREDITS.md" "$directory_name/FAQ.md | |||
53 | "$directory_name/dist" "$directory_name/package.json" \ | 53 | "$directory_name/dist" "$directory_name/package.json" \ |
54 | "$directory_name/scripts" "$directory_name/support" \ | 54 | "$directory_name/scripts" "$directory_name/support" \ |
55 | "$directory_name/tsconfig.json" "$directory_name/yarn.lock" \ | 55 | "$directory_name/tsconfig.json" "$directory_name/yarn.lock" \ |
56 | "$directory_name/server/" \ | 56 | "$directory_name/server/" "$directory_name/shared/" \ |
57 | || exit -1 | 57 | || exit -1 |
58 | rm "$directory_name" || exit -1 | 58 | rm "$directory_name" || exit -1 |
59 | 59 | ||
diff --git a/server/controllers/client.ts b/server/controllers/client.ts index bb02f5075..c85bd8a5e 100644 --- a/server/controllers/client.ts +++ b/server/controllers/client.ts | |||
@@ -85,6 +85,8 @@ function addOpenGraphAndOEmbedTags (htmlStringPage: string, video: VideoModel) { | |||
85 | ] | 85 | ] |
86 | 86 | ||
87 | const schemaTags = { | 87 | const schemaTags = { |
88 | '@context': 'http://schema.org', | ||
89 | '@type': 'VideoObject', | ||
88 | name: videoNameEscaped, | 90 | name: videoNameEscaped, |
89 | description: videoDescriptionEscaped, | 91 | description: videoDescriptionEscaped, |
90 | duration: video.getActivityStreamDuration(), | 92 | duration: video.getActivityStreamDuration(), |
@@ -95,25 +97,21 @@ function addOpenGraphAndOEmbedTags (htmlStringPage: string, video: VideoModel) { | |||
95 | } | 97 | } |
96 | 98 | ||
97 | let tagsString = '' | 99 | let tagsString = '' |
100 | |||
101 | // Opengraph | ||
98 | Object.keys(openGraphMetaTags).forEach(tagName => { | 102 | Object.keys(openGraphMetaTags).forEach(tagName => { |
99 | const tagValue = openGraphMetaTags[tagName] | 103 | const tagValue = openGraphMetaTags[tagName] |
100 | 104 | ||
101 | tagsString += `<meta property="${tagName}" content="${tagValue}" />` | 105 | tagsString += `<meta property="${tagName}" content="${tagValue}" />` |
102 | }) | 106 | }) |
103 | 107 | ||
108 | // OEmbed | ||
104 | for (const oembedLinkTag of oembedLinkTags) { | 109 | for (const oembedLinkTag of oembedLinkTags) { |
105 | tagsString += `<link rel="alternate" type="${oembedLinkTag.type}" href="${oembedLinkTag.href}" title="${oembedLinkTag.title}" />` | 110 | tagsString += `<link rel="alternate" type="${oembedLinkTag.type}" href="${oembedLinkTag.href}" title="${oembedLinkTag.title}" />` |
106 | } | 111 | } |
107 | 112 | ||
108 | tagsString += '<div itemprop="video" itemscope itemtype="http://schema.org/VideoObject">' | 113 | // Schema.org |
109 | tagsString += '<h2>Video: <span itemprop="name">' + schemaTags.name + '</span></h2>' | 114 | tagsString += `<script type="application/ld+json">${JSON.stringify(schemaTags)}</script>` |
110 | |||
111 | Object.keys(schemaTags).forEach(tagName => { | ||
112 | const tagValue = schemaTags[tagName] | ||
113 | tagsString += `<meta itemprop="${tagName}" content="${tagValue}" />` | ||
114 | }) | ||
115 | |||
116 | tagsString += '</div>' | ||
117 | 115 | ||
118 | return htmlStringPage.replace(OPENGRAPH_AND_OEMBED_COMMENT, tagsString) | 116 | return htmlStringPage.replace(OPENGRAPH_AND_OEMBED_COMMENT, tagsString) |
119 | } | 117 | } |