X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server%2Fcontrollers%2Fclient.ts;h=20f7e5c9c2a613abee62adb73310615c11f991b5;hb=8be1afa12b700b93ed92365cab05c0ef81d643aa;hp=39e046727291714afa75ded7b1a0945dfd8f859b;hpb=da854ddd502cd70685ef779c673b9e63757b8aa0;p=github%2FChocobozzz%2FPeerTube.git
diff --git a/server/controllers/client.ts b/server/controllers/client.ts
index 39e046727..20f7e5c9c 100644
--- a/server/controllers/client.ts
+++ b/server/controllers/client.ts
@@ -10,7 +10,7 @@ import { VideoModel } from '../models/video/video'
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')
@@ -25,6 +25,17 @@ clientsRouter.use('/videos/embed', (req: express.Request, res: express.Response,
})
// Static HTML/CSS/JS client files
+
+const staticClientFiles = [
+ 'manifest.json',
+ 'ngsw-worker.js',
+ 'ngsw.json'
+]
+for (const staticClientFile of staticClientFiles) {
+ const path = join(root(), 'client', 'dist', staticClientFile)
+ clientsRouter.use('/' + staticClientFile, express.static(path, { maxAge: STATIC_MAX_AGE }))
+}
+
clientsRouter.use('/client', express.static(distPath, { maxAge: STATIC_MAX_AGE }))
clientsRouter.use('/client/assets/images', express.static(assetsImagesPath, { maxAge: STATIC_MAX_AGE }))
@@ -66,8 +77,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,
@@ -84,17 +95,39 @@ function addOpenGraphAndOEmbedTags (htmlStringPage: string, video: VideoModel) {
}
]
+ const schemaTags = {
+ '@context': 'http://schema.org',
+ '@type': 'VideoObject',
+ name: videoNameEscaped,
+ description: videoDescriptionEscaped,
+ thumbnailUrl: previewUrl,
+ uploadDate: video.createdAt.toISOString(),
+ duration: video.getActivityStreamDuration(),
+ contentUrl: videoUrl,
+ embedUrl: embedUrl,
+ interactionCount: video.views
+ }
+
let tagsString = ''
+
+ // Opengraph
Object.keys(openGraphMetaTags).forEach(tagName => {
const tagValue = openGraphMetaTags[tagName]
tagsString += ``
})
+ // OEmbed
for (const oembedLinkTag of oembedLinkTags) {
tagsString += ``
}
+ // Schema.org
+ tagsString += ``
+
+ // SEO
+ tagsString += ``
+
return htmlStringPage.replace(OPENGRAPH_AND_OEMBED_COMMENT, tagsString)
}