aboutsummaryrefslogtreecommitdiff
path: root/BackEnd/Timeline/Controllers/TimelinePostController.cs
diff options
context:
space:
mode:
authorcrupest <crupest@outlook.com>2021-03-06 23:04:13 +0800
committerGitHub <noreply@github.com>2021-03-06 23:04:13 +0800
commitf7bf0b6609ac21165c8bd5502c0ec2b1a51bf618 (patch)
tree59507331750831118e7caa071a10e1cb8fc1e627 /BackEnd/Timeline/Controllers/TimelinePostController.cs
parent736ba716cfb87bc0e8e4979825a1693dc6010f9c (diff)
parent8f09e3172f249a9f5d229040415a0569e9d1c01b (diff)
downloadtimeline-f7bf0b6609ac21165c8bd5502c0ec2b1a51bf618.tar.gz
timeline-f7bf0b6609ac21165c8bd5502c0ec2b1a51bf618.tar.bz2
timeline-f7bf0b6609ac21165c8bd5502c0ec2b1a51bf618.zip
Merge pull request #347 from crupest/markdown
Markdown post auto translate data url.
Diffstat (limited to 'BackEnd/Timeline/Controllers/TimelinePostController.cs')
-rw-r--r--BackEnd/Timeline/Controllers/TimelinePostController.cs15
1 files changed, 13 insertions, 2 deletions
diff --git a/BackEnd/Timeline/Controllers/TimelinePostController.cs b/BackEnd/Timeline/Controllers/TimelinePostController.cs
index 4026d551..86c5c8cf 100644
--- a/BackEnd/Timeline/Controllers/TimelinePostController.cs
+++ b/BackEnd/Timeline/Controllers/TimelinePostController.cs
@@ -32,14 +32,17 @@ namespace Timeline.Controllers
private readonly TimelineMapper _timelineMapper;
+ private readonly MarkdownProcessor _markdownProcessor;
+
/// <summary>
///
/// </summary>
- public TimelinePostController(ITimelineService timelineService, ITimelinePostService timelinePostService, TimelineMapper timelineMapper)
+ public TimelinePostController(ITimelineService timelineService, ITimelinePostService timelinePostService, TimelineMapper timelineMapper, MarkdownProcessor markdownProcessor)
{
_timelineService = timelineService;
_postService = timelinePostService;
_timelineMapper = timelineMapper;
+ _markdownProcessor = markdownProcessor;
}
private bool UserHasAllTimelineManagementPermission => this.UserHasPermission(UserPermission.AllTimelineManagement);
@@ -147,7 +150,15 @@ namespace Timeline.Controllers
return await DataCacheHelper.GenerateActionResult(this,
() => _postService.GetPostDataDigest(timelineId, post, dataIndex),
- () => _postService.GetPostData(timelineId, post, dataIndex)
+ async () =>
+ {
+ var data = await _postService.GetPostData(timelineId, post, dataIndex);
+ if (data.ContentType == MimeTypes.TextMarkdown)
+ {
+ return new ByteData(_markdownProcessor.Process(data.Data, Url, timeline, post), data.ContentType);
+ }
+ return data;
+ }
);
}