diff options
author | Chocobozzz <me@florianbigard.com> | 2021-07-26 14:12:39 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2021-07-26 14:12:50 +0200 |
commit | 9162fdd36300d2478f13d6ad346ec2c323f40faa (patch) | |
tree | dea0ca43f3ea2fb72a73ca77338f5b7c990acdd7 /client/src/app/core/renderer | |
parent | 764b1a14fc494f2cfd7ea590d2f07b01df65c7ad (diff) | |
download | PeerTube-9162fdd36300d2478f13d6ad346ec2c323f40faa.tar.gz PeerTube-9162fdd36300d2478f13d6ad346ec2c323f40faa.tar.zst PeerTube-9162fdd36300d2478f13d6ad346ec2c323f40faa.zip |
Refactor video links building
Diffstat (limited to 'client/src/app/core/renderer')
-rw-r--r-- | client/src/app/core/renderer/markdown.service.ts | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/client/src/app/core/renderer/markdown.service.ts b/client/src/app/core/renderer/markdown.service.ts index ca1bf4eb9..01d44864b 100644 --- a/client/src/app/core/renderer/markdown.service.ts +++ b/client/src/app/core/renderer/markdown.service.ts | |||
@@ -1,5 +1,5 @@ | |||
1 | import * as MarkdownIt from 'markdown-it' | 1 | import * as MarkdownIt from 'markdown-it' |
2 | import { buildVideoLink } from 'src/assets/player/utils' | 2 | import { buildVideoLink, decorateVideoLink } from 'src/assets/player/utils' |
3 | import { Injectable } from '@angular/core' | 3 | import { Injectable } from '@angular/core' |
4 | import { | 4 | import { |
5 | COMPLETE_RULES, | 5 | COMPLETE_RULES, |
@@ -82,10 +82,14 @@ export class MarkdownService { | |||
82 | return this.render({ name: 'customPageMarkdownIt', markdown, withEmoji: true, additionalAllowedTags }) | 82 | return this.render({ name: 'customPageMarkdownIt', markdown, withEmoji: true, additionalAllowedTags }) |
83 | } | 83 | } |
84 | 84 | ||
85 | processVideoTimestamps (html: string) { | 85 | processVideoTimestamps (videoShortUUID: string, html: string) { |
86 | return html.replace(/((\d{1,2}):)?(\d{1,2}):(\d{1,2})/g, function (str, _, h, m, s) { | 86 | return html.replace(/((\d{1,2}):)?(\d{1,2}):(\d{1,2})/g, function (str, _, h, m, s) { |
87 | const t = (3600 * +(h || 0)) + (60 * +(m || 0)) + (+(s || 0)) | 87 | const t = (3600 * +(h || 0)) + (60 * +(m || 0)) + (+(s || 0)) |
88 | const url = buildVideoLink({ startTime: t }) | 88 | |
89 | const url = decorateVideoLink({ | ||
90 | url: buildVideoLink({ shortUUID: videoShortUUID }), | ||
91 | startTime: t | ||
92 | }) | ||
89 | return `<a class="video-timestamp" href="${url}">${str}</a>` | 93 | return `<a class="video-timestamp" href="${url}">${str}</a>` |
90 | }) | 94 | }) |
91 | } | 95 | } |