mirror of
https://github.com/Chocobozzz/PeerTube.git
synced 2025-10-04 02:09:37 +02:00
render markdown and plainify descriptions on previews
This commit is contained in:
parent
13fec08ba3
commit
84bced652c
3 changed files with 38 additions and 27 deletions
|
@ -24,6 +24,7 @@ import { VideoChannelModel } from '../models/video/video-channel'
|
|||
import { getActivityStreamDuration } from '../models/video/video-format-utils'
|
||||
import { VideoPlaylistModel } from '../models/video/video-playlist'
|
||||
import { MAccountActor, MChannelActor } from '../types/models'
|
||||
import { toSafeHtml } from '../helpers/markdown'
|
||||
|
||||
type Tags = {
|
||||
ogType: string
|
||||
|
@ -54,6 +55,10 @@ type Tags = {
|
|||
}
|
||||
}
|
||||
|
||||
const toPlainText = (content: string) => {
|
||||
return toSafeHtml(content).replace(/<[^>]+>/g, '')
|
||||
}
|
||||
|
||||
class ClientHtml {
|
||||
|
||||
private static htmlCache: { [path: string]: string } = {}
|
||||
|
@ -94,13 +99,13 @@ class ClientHtml {
|
|||
}
|
||||
|
||||
let customHtml = ClientHtml.addTitleTag(html, escapeHTML(video.name))
|
||||
customHtml = ClientHtml.addDescriptionTag(customHtml, escapeHTML(video.description))
|
||||
customHtml = ClientHtml.addDescriptionTag(customHtml, toPlainText(video.description))
|
||||
|
||||
const url = WEBSERVER.URL + video.getWatchStaticPath()
|
||||
const originUrl = video.url
|
||||
const title = escapeHTML(video.name)
|
||||
const siteName = escapeHTML(CONFIG.INSTANCE.NAME)
|
||||
const description = escapeHTML(video.description)
|
||||
const description = toPlainText(video.description)
|
||||
|
||||
const image = {
|
||||
url: WEBSERVER.URL + video.getPreviewStaticPath()
|
||||
|
@ -152,13 +157,13 @@ class ClientHtml {
|
|||
}
|
||||
|
||||
let customHtml = ClientHtml.addTitleTag(html, escapeHTML(videoPlaylist.name))
|
||||
customHtml = ClientHtml.addDescriptionTag(customHtml, escapeHTML(videoPlaylist.description))
|
||||
customHtml = ClientHtml.addDescriptionTag(customHtml, toPlainText(videoPlaylist.description))
|
||||
|
||||
const url = videoPlaylist.getWatchUrl()
|
||||
const originUrl = videoPlaylist.url
|
||||
const title = escapeHTML(videoPlaylist.name)
|
||||
const siteName = escapeHTML(CONFIG.INSTANCE.NAME)
|
||||
const description = escapeHTML(videoPlaylist.description)
|
||||
const description = toPlainText(videoPlaylist.description)
|
||||
|
||||
const image = {
|
||||
url: videoPlaylist.getThumbnailUrl()
|
||||
|
@ -236,13 +241,13 @@ class ClientHtml {
|
|||
}
|
||||
|
||||
let customHtml = ClientHtml.addTitleTag(html, escapeHTML(entity.getDisplayName()))
|
||||
customHtml = ClientHtml.addDescriptionTag(customHtml, escapeHTML(entity.description))
|
||||
customHtml = ClientHtml.addDescriptionTag(customHtml, toPlainText(entity.description))
|
||||
|
||||
const url = entity.getLocalUrl()
|
||||
const originUrl = entity.Actor.url
|
||||
const siteName = escapeHTML(CONFIG.INSTANCE.NAME)
|
||||
const title = escapeHTML(entity.getDisplayName())
|
||||
const description = escapeHTML(entity.description)
|
||||
const description = toPlainText(entity.description)
|
||||
|
||||
const image = {
|
||||
url: entity.Actor.getAvatarUrl(),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue