From 3bc8ee1de171f0bd8e226542d75c842c5b2e7175 Mon Sep 17 00:00:00 2001 From: crupest Date: Sun, 24 Apr 2022 15:22:05 +0800 Subject: ... --- .../Services/Timeline/MarkdownProcessor.cs | 24 ++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) (limited to 'BackEnd/Timeline/Services') diff --git a/BackEnd/Timeline/Services/Timeline/MarkdownProcessor.cs b/BackEnd/Timeline/Services/Timeline/MarkdownProcessor.cs index ef8022c0..84b99915 100644 --- a/BackEnd/Timeline/Services/Timeline/MarkdownProcessor.cs +++ b/BackEnd/Timeline/Services/Timeline/MarkdownProcessor.cs @@ -1,4 +1,4 @@ -using Markdig; +using Markdig; using Markdig.Renderers.Normalize; using Markdig.Syntax; using Markdig.Syntax.Inlines; @@ -8,7 +8,7 @@ using System.IO; using System.Linq; using System.Text; using Timeline.Controllers; - + namespace Timeline.Services.Timeline { public class MarkdownProcessor @@ -31,6 +31,7 @@ namespace Timeline.Services.Timeline return writer.ToString(); } + [Obsolete("Use overload with 'owner'.")] /// Convert data url to true url with post id. public string Process(string text, IUrlHelper url, string timeline, long post) { @@ -44,9 +45,28 @@ namespace Timeline.Services.Timeline ); } + [Obsolete("Use overload with 'owner'.")] public byte[] Process(byte[] data, IUrlHelper url, string timeline, long post) { return Encoding.UTF8.GetBytes(Process(Encoding.UTF8.GetString(data), url, timeline, post)); + } + + /// Convert data url to true url with post id. + public string Process(string text, IUrlHelper url, string owner, string timeline, long post) + { + return Process( + text, + dataIndex => url.ActionLink( + "DataGet", + "TimelinePostV2", + new { owner, timeline, post, data_index = dataIndex } + )! + ); + } + + public byte[] Process(byte[] data, IUrlHelper url, string owner, string timeline, long post) + { + return Encoding.UTF8.GetBytes(Process(Encoding.UTF8.GetString(data), url, owner, timeline, post)); } } } -- cgit v1.2.3