X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server%2Fcontrollers%2Fclient.ts;h=b5dc7b7eddf13d9ca2cc121dfa16ff065852e8f8;hb=244e76a552ef05a5067134b1065d26dd89246d8c;hp=39e046727291714afa75ded7b1a0945dfd8f859b;hpb=da854ddd502cd70685ef779c673b9e63757b8aa0;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server/controllers/client.ts b/server/controllers/client.ts index 39e046727..b5dc7b7ed 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 })) @@ -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) }