Browse Source

Merge branch 'master' of https://github.com/volosoft/abp

pull/7950/head
Halil ibrahim Kalkan 8 years ago
parent
commit
015c9ca745
  1. 9
      modules/blogging/src/Volo.Blogging.Web/Pages/Blog/Posts/Detail.cshtml
  2. 27
      modules/blogging/src/Volo.Blogging.Web/Pages/Blog/Posts/Detail.cshtml.cs
  3. 4
      modules/blogging/src/Volo.Blogging.Web/Pages/Blog/Posts/Index.cshtml

9
modules/blogging/src/Volo.Blogging.Web/Pages/Blog/Posts/Detail.cshtml

@ -25,12 +25,13 @@
</div>
<div class="hero-content">
<p class="tags">
<abp-row>
<p class="tags">
@foreach (var tag in Model.Post.Tags)
{
<a href="#" class="tag">@tag.Name</a>
}
</abp-row>
</p>
</p>
<h1>
<a href="#">@Model.Post.Title</a>
@ -52,7 +53,7 @@
</a>
<span class="seperator">|</span>
<a href="#">
<i class="fa fa-comment"></i> 60 @L["Comment"]
<i class="fa fa-comment"></i> @Model.CommentCount @L["Comment"]
</a>
</div>
</div>
@ -73,7 +74,7 @@
<div class="row">
<div class="col-md-8 mx-auto">
<section class="post-content">
<p>@Model.Post.Content</p>
<p>@Model.FormattedContent</p>
</section>
</div>

27
modules/blogging/src/Volo.Blogging.Web/Pages/Blog/Posts/Detail.cshtml.cs

@ -1,6 +1,9 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.Threading.Tasks;
using CommonMark;
using Microsoft.AspNetCore.Html;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.RazorPages;
using Volo.Blogging.Blogs;
@ -24,9 +27,13 @@ namespace Volo.Blogging.Pages.Blog.Posts
[BindProperty]
public PostDetailsViewModel NewComment { get; set; }
public int CommentCount { get; set; }
public PostWithDetailsDto Post { get; set; }
public IHtmlContent FormattedContent { get; set; }
public IReadOnlyList<CommentWithRepliesDto> CommentsWithReplies { get; set; }
public BlogDto Blog { get; set; }
@ -59,9 +66,29 @@ namespace Volo.Blogging.Pages.Blog.Posts
{
Blog = await _blogAppService.GetByShortNameAsync(BlogShortName);
Post = await _postAppService.GetByUrlAsync(new GetPostInput { BlogId = Blog.Id, Url = PostUrl });
FormattedContent = RenderMarkdown(Post.Content);
CommentsWithReplies = await _commentAppService.GetHierarchicalListOfPostAsync(new GetCommentListOfPostAsync() { PostId = Post.Id });
CountComments();
}
public void CountComments()
{
CommentCount = CommentsWithReplies.Count;
foreach (var commentWithReply in CommentsWithReplies)
{
CommentCount += commentWithReply.Replies.Count;
}
}
public IHtmlContent RenderMarkdown(string content)
{
byte[] bytes = Encoding.Default.GetBytes(content);
var utf8Content = Encoding.UTF8.GetString(bytes);
var html = CommonMarkConverter.Convert(utf8Content);
return new HtmlString(html);
}
public class PostDetailsViewModel
{

4
modules/blogging/src/Volo.Blogging.Web/Pages/Blog/Posts/Index.cshtml

@ -51,7 +51,7 @@
<a asp-page="./Detail" asp-route-postUrl="@post.Url" asp-route-blogShortName="@Model.BlogShortName">@post.Title</a>
</h2>
<p class="article-sum">
@(post.Content == null ? "" : (post.Content.Length > 150 ? post.Content.Substring(150) : post.Content))
@(post.Content == null ? "" : (post.Content.Length > 150 ? post.Content.Substring(0,150) : post.Content))
</p>
<a asp-page="./Detail" asp-route-postUrl="@post.Url" asp-route-blogShortName="@Model.BlogShortName" class="btn btn-primary btn-rounded">@L["ContinueReading"]</a>
@ -187,7 +187,7 @@
<a asp-page="./Detail" asp-route-postUrl="@post.Url" asp-route-blogShortName="@Model.BlogShortName">@post.Title</a>
</h3>
<p>
@(post.Content == null ? "" : (post.Content.Length > 250 ? post.Content.Substring(150) : post.Content))...
@(post.Content == null ? "" : (post.Content.Length > 250 ? post.Content.Substring(0, 150) : post.Content))...
</p>
<div class="article-owner">
<div class="article-infos">

Loading…
Cancel
Save