-import * as express from 'express'
+import express from 'express'
import { readFile } from 'fs-extra'
import { join } from 'path'
import validator from 'validator'
originUrl: string
description: string
+ disallowIndexation?: boolean
+
embed?: {
url: string
createdAt: string
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)
image,
ogType,
twitterCard,
- schemaType
+ schemaType,
+ disallowIndexation: !entity.Actor.isOwned()
})
return customHtml
let html = buffer.toString()
- if (paramLang) html = ClientHtml.addHtmlLang(html, paramLang)
html = ClientHtml.addManifestContentHash(html)
html = ClientHtml.addFaviconContentHash(html)
html = ClientHtml.addLogoContentHash(html)
}
private static addServerConfig (htmlStringPage: string, serverConfig: HTMLServerConfig) {
- const serverConfigString = JSON.stringify(serverConfig)
- const configScriptTag = `<script type="application/javascript">window.PeerTubeServerConfig = '${serverConfigString}'</script>`
+ // 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 = `<script type="application/javascript">window.PeerTubeServerConfig = ${serverConfigString}</script>`
return htmlStringPage.replace(CUSTOM_HTML_TAG_COMMENTS.SERVER_CONFIG, configScriptTag)
}
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 }[] = []
// SEO, use origin URL
tagsString += `<link rel="canonical" href="${originUrl}" />`
+ if (disallowIndexation) {
+ tagsString += `<meta name="robots" content="noindex" />`
+ }
+
return htmlStringPage.replace(CUSTOM_HTML_TAG_COMMENTS.META_TAGS, tagsString)
}
}
}
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