X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server%2Flib%2Fclient-html.ts;h=84b4ca97def8477dd034e2d85a7366e36c4e8a7e;hb=597f771f3f2bfe4b1e7234a5760e23f0283e2b29;hp=c5d39445b8a2723d7ad6e4b1b3c8e004840edaf9;hpb=a24bd1ed41b43790bab6ba789580bb4e85f07d85;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server/lib/client-html.ts b/server/lib/client-html.ts index c5d39445b..84b4ca97d 100644 --- a/server/lib/client-html.ts +++ b/server/lib/client-html.ts @@ -1,4 +1,4 @@ -import * as express from 'express' +import express from 'express' import { readFile } from 'fs-extra' import { join } from 'path' import validator from 'validator' @@ -44,6 +44,8 @@ type Tags = { originUrl: string description: string + disallowIndexation?: boolean + embed?: { url: string createdAt: string @@ -162,7 +164,7 @@ class ClientHtml { let customHtml = ClientHtml.addTitleTag(html, escapeHTML(videoPlaylist.name)) customHtml = ClientHtml.addDescriptionTag(customHtml, mdToPlainText(videoPlaylist.description)) - const url = videoPlaylist.getWatchUrl() + const url = WEBSERVER.URL + videoPlaylist.getWatchStaticPath() const originUrl = videoPlaylist.url const title = escapeHTML(videoPlaylist.name) const siteName = escapeHTML(CONFIG.INSTANCE.NAME) @@ -285,7 +287,8 @@ class ClientHtml { image, ogType, twitterCard, - schemaType + schemaType, + disallowIndexation: !entity.Actor.isOwned() }) return customHtml @@ -300,7 +303,6 @@ class ClientHtml { let html = buffer.toString() - if (paramLang) html = ClientHtml.addHtmlLang(html, paramLang) html = ClientHtml.addManifestContentHash(html) html = ClientHtml.addFaviconContentHash(html) html = ClientHtml.addLogoContentHash(html) @@ -379,8 +381,9 @@ class ClientHtml { } private static addServerConfig (htmlStringPage: string, serverConfig: HTMLServerConfig) { - const serverConfigString = JSON.stringify(serverConfig) - const configScriptTag = `` + // Stringify the JSON object, and then stringify the string object so we can inject it into the HTML + const serverConfigString = JSON.stringify(JSON.stringify(serverConfig)) + const configScriptTag = `` return htmlStringPage.replace(CUSTOM_HTML_TAG_COMMENTS.SERVER_CONFIG, configScriptTag) } @@ -488,7 +491,7 @@ class ClientHtml { const twitterCardMetaTags = this.generateTwitterCardMetaTags(tagsValues) const schemaTags = this.generateSchemaTags(tagsValues) - const { url, title, embed, originUrl } = tagsValues + const { url, title, embed, originUrl, disallowIndexation } = tagsValues const oembedLinkTags: { type: string, href: string, title: string }[] = [] @@ -536,6 +539,10 @@ class ClientHtml { // SEO, use origin URL tagsString += `` + if (disallowIndexation) { + tagsString += `` + } + return htmlStringPage.replace(CUSTOM_HTML_TAG_COMMENTS.META_TAGS, tagsString) } } @@ -547,8 +554,7 @@ function sendHTML (html: string, res: express.Response) { } async function serveIndexHTML (req: express.Request, res: express.Response) { - if (req.accepts(ACCEPT_HEADERS) === 'html' || - !req.headers.accept) { + if (req.accepts(ACCEPT_HEADERS) === 'html' || !req.headers.accept) { try { await generateHTMLPage(req, res, req.params.language) return