mirror of https://github.com/abpframework/abp.git
18 changed files with 385 additions and 24 deletions
@ -0,0 +1,53 @@ |
|||||
|
@page "/b/{blogUrlSlug}/{blogPostUrlSlug}" |
||||
|
|
||||
|
@using Volo.CmsKit.Public.Web.Pages.CmsKit.Shared.Components.Blogs.BlogPost |
||||
|
@using Volo.CmsKit.Public.Web.Pages.CmsKit.Shared.Components.Blogs.BlogPostComment |
||||
|
@using Volo.CmsKit.Public.Web.Pages.CmsKit.Blogs |
||||
|
@using Volo.CmsKit.Public.Web.Pages |
||||
|
@using Volo.Abp.GlobalFeatures |
||||
|
@using Volo.CmsKit.GlobalFeatures |
||||
|
@using Volo.CmsKit.Public.Web.Pages.CmsKit.Shared.Components.ReactionSelection |
||||
|
@using Volo.CmsKit.Public.Web.Pages.CmsKit.Shared.Components.Rating |
||||
|
|
||||
|
@inherits CmsKitPublicPageBase |
||||
|
|
||||
|
@model BlogPostModel |
||||
|
|
||||
|
@{ |
||||
|
PageLayout.Content.Title = Model.BlogPost.Title; |
||||
|
} |
||||
|
|
||||
|
@await Component.InvokeAsync(typeof(DefaultBlogPostViewComponent), new |
||||
|
{ |
||||
|
Model.BlogUrlSlug, |
||||
|
Model.BlogPostUrlSlug |
||||
|
}) |
||||
|
|
||||
|
@if (GlobalFeatureManager.Instance.IsEnabled<ReactionsFeature>()) |
||||
|
{ |
||||
|
@await Component.InvokeAsync(typeof(ReactionSelectionViewComponent), new |
||||
|
{ |
||||
|
entityType = Volo.CmsKit.Blogs.BlogPostConsts.EntityType, |
||||
|
entityId = Model.BlogPost.Id.ToString() |
||||
|
}) |
||||
|
} |
||||
|
|
||||
|
@if (GlobalFeatureManager.Instance.IsEnabled<RatingsFeature>()) |
||||
|
{ |
||||
|
@await Component.InvokeAsync(typeof(RatingViewComponent), new |
||||
|
{ |
||||
|
entityType = Volo.CmsKit.Blogs.BlogPostConsts.EntityType, |
||||
|
entityId = Model.BlogPost.Id.ToString() |
||||
|
}) |
||||
|
} |
||||
|
|
||||
|
<hr /> |
||||
|
|
||||
|
@if (GlobalFeatureManager.Instance.IsEnabled<CommentsFeature>()) |
||||
|
{ |
||||
|
@await Component.InvokeAsync(typeof(DefaultBlogPostCommentViewComponent), new |
||||
|
{ |
||||
|
entityType = Volo.CmsKit.Blogs.BlogPostConsts.EntityType, |
||||
|
entityId = Model.BlogPost.Id.ToString() |
||||
|
}) |
||||
|
} |
||||
@ -0,0 +1,33 @@ |
|||||
|
using Microsoft.AspNetCore.Mvc; |
||||
|
using System; |
||||
|
using System.Collections.Generic; |
||||
|
using System.Linq; |
||||
|
using System.Text; |
||||
|
using System.Threading.Tasks; |
||||
|
using Volo.CmsKit.Public.Blogs; |
||||
|
|
||||
|
namespace Volo.CmsKit.Public.Web.Pages.CmsKit.Blogs |
||||
|
{ |
||||
|
public class BlogPostModel : CmsKitPublicPageModelBase |
||||
|
{ |
||||
|
[BindProperty(SupportsGet = true)] |
||||
|
public string BlogUrlSlug { get; set; } |
||||
|
|
||||
|
[BindProperty(SupportsGet = true)] |
||||
|
public string BlogPostUrlSlug { get; set; } |
||||
|
|
||||
|
public BlogPostPublicDto BlogPost { get; private set; } |
||||
|
|
||||
|
protected IBlogPostPublicAppService BlogPostPublicAppService { get; } |
||||
|
|
||||
|
public BlogPostModel(IBlogPostPublicAppService blogPostPublicAppService) |
||||
|
{ |
||||
|
BlogPostPublicAppService = blogPostPublicAppService; |
||||
|
} |
||||
|
|
||||
|
public async Task OnGetAsync() |
||||
|
{ |
||||
|
BlogPost = await BlogPostPublicAppService.GetAsync(BlogUrlSlug, BlogPostUrlSlug); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,46 @@ |
|||||
|
@page "/b/{blogUrlSlug}" |
||||
|
|
||||
|
@using Volo.CmsKit.Public.Web.Pages |
||||
|
|
||||
|
@inherits CmsKitPublicPageBase |
||||
|
|
||||
|
@model Volo.CmsKit.Public.Web.Pages.CmsKit.Blogs.IndexModel |
||||
|
|
||||
|
<abp-row id="blogs-container"> |
||||
|
@foreach (var blog in Model.Blogs.Items) |
||||
|
{ |
||||
|
<abp-column size="_12" class="m-3"> |
||||
|
<abp-card> |
||||
|
<abp-card-header> |
||||
|
<abp-card-title> |
||||
|
@blog.Title |
||||
|
</abp-card-title> |
||||
|
<abp-card-subtitle> |
||||
|
@@@blog.Creator?.UserName |
||||
|
</abp-card-subtitle> |
||||
|
</abp-card-header> |
||||
|
<abp-card-body> |
||||
|
<abp-card-text> |
||||
|
@blog.ShortDescription |
||||
|
</abp-card-text> |
||||
|
<abp-card-text> |
||||
|
<a href="/b/@Model.BlogUrlSlug/@blog.UrlSlug"> |
||||
|
<abp-button text="@L["Read"]" |
||||
|
button-type="Outline_Primary" /> |
||||
|
</a> |
||||
|
</abp-card-text> |
||||
|
</abp-card-body> |
||||
|
<abp-card-footer> |
||||
|
<abp-card-text> |
||||
|
@blog.CreationTime |
||||
|
</abp-card-text> |
||||
|
</abp-card-footer> |
||||
|
</abp-card> |
||||
|
</abp-column> |
||||
|
|
||||
|
} |
||||
|
</abp-row> |
||||
|
<abp-row> |
||||
|
<abp-paginator model="Model.PagerModel" /> |
||||
|
</abp-row> |
||||
|
|
||||
@ -0,0 +1,45 @@ |
|||||
|
using Microsoft.AspNetCore.Mvc; |
||||
|
using System; |
||||
|
using System.Collections.Generic; |
||||
|
using System.Linq; |
||||
|
using System.Text; |
||||
|
using System.Threading.Tasks; |
||||
|
using Volo.Abp.Application.Dtos; |
||||
|
using Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Pagination; |
||||
|
using Volo.CmsKit.Public.Blogs; |
||||
|
|
||||
|
namespace Volo.CmsKit.Public.Web.Pages.CmsKit.Blogs |
||||
|
{ |
||||
|
public class IndexModel : CmsKitPublicPageModelBase |
||||
|
{ |
||||
|
public const int PageSize = 12; |
||||
|
|
||||
|
[BindProperty(SupportsGet = true)] |
||||
|
public string BlogUrlSlug { get; set; } |
||||
|
|
||||
|
[BindProperty(SupportsGet = true)] |
||||
|
public int CurrentPage { get; set; } = 1; |
||||
|
|
||||
|
public PagedResultDto<BlogPostPublicDto> Blogs { get; private set; } |
||||
|
|
||||
|
public PagerModel PagerModel => new PagerModel(Blogs.TotalCount, Blogs.Items.Count, CurrentPage, PageSize, Request.Path.ToString()); |
||||
|
|
||||
|
protected IBlogPostPublicAppService BlogPostPublicAppService { get; } |
||||
|
|
||||
|
public IndexModel(IBlogPostPublicAppService blogPostPublicAppService) |
||||
|
{ |
||||
|
BlogPostPublicAppService = blogPostPublicAppService; |
||||
|
} |
||||
|
|
||||
|
public async Task OnGetAsync() |
||||
|
{ |
||||
|
Blogs = await BlogPostPublicAppService.GetListAsync( |
||||
|
BlogUrlSlug, |
||||
|
new PagedAndSortedResultRequestDto |
||||
|
{ |
||||
|
SkipCount = PageSize * (CurrentPage - 1), |
||||
|
MaxResultCount = PageSize |
||||
|
}); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,31 @@ |
|||||
|
@model Volo.CmsKit.Public.Blogs.BlogPostPublicDto |
||||
|
@using Volo.CmsKit.Public.Web.Pages.CmsKit.Shared.Components.Contents |
||||
|
@using Volo.Abp.AspNetCore.Mvc.UI.Layout |
||||
|
@using Volo.CmsKit.Localization |
||||
|
@using Microsoft.Extensions.Localization |
||||
|
|
||||
|
@inject IStringLocalizer<CmsKitResource> L |
||||
|
|
||||
|
|
||||
|
<abp-card> |
||||
|
<abp-card-header> |
||||
|
<abp-card-title>@Model.Title</abp-card-title> |
||||
|
<abp-card-subtitle>@@@Model.Creator?.UserName</abp-card-subtitle> |
||||
|
</abp-card-header> |
||||
|
<abp-card-body> |
||||
|
@await Component.InvokeAsync(typeof(ContentViewComponent), new |
||||
|
{ |
||||
|
entityType = Volo.CmsKit.Blogs.BlogPostConsts.EntityType, |
||||
|
entityId = Model.Id.ToString() |
||||
|
}) |
||||
|
</abp-card-body> |
||||
|
<abp-card-footer> |
||||
|
<abp-card-subtitle>@Model.CreationTime</abp-card-subtitle> |
||||
|
@if (Model.LastModificationTime != null) |
||||
|
{ |
||||
|
<abp-card-text><i>@L["LastModification"].Value : @Model.LastModificationTime</i></abp-card-text> |
||||
|
} |
||||
|
</abp-card-footer> |
||||
|
</abp-card> |
||||
|
|
||||
|
|
||||
@ -0,0 +1,29 @@ |
|||||
|
using Microsoft.AspNetCore.Mvc; |
||||
|
using System; |
||||
|
using System.Collections.Generic; |
||||
|
using System.Linq; |
||||
|
using System.Text; |
||||
|
using System.Threading.Tasks; |
||||
|
using Volo.Abp.AspNetCore.Mvc; |
||||
|
using Volo.CmsKit.Public.Blogs; |
||||
|
|
||||
|
namespace Volo.CmsKit.Public.Web.Pages.CmsKit.Shared.Components.Blogs.BlogPost |
||||
|
{ |
||||
|
[ViewComponent(Name = "CmsDefaultBlogPost")] |
||||
|
public class DefaultBlogPostViewComponent : AbpViewComponent |
||||
|
{ |
||||
|
protected IBlogPostPublicAppService BlogPostPublicAppService { get; } |
||||
|
|
||||
|
public DefaultBlogPostViewComponent(IBlogPostPublicAppService blogPostPublicAppService) |
||||
|
{ |
||||
|
BlogPostPublicAppService = blogPostPublicAppService; |
||||
|
} |
||||
|
|
||||
|
public virtual async Task<IViewComponentResult> InvokeAsync(string blogUrlSlug, string blogPostUrlSlug) |
||||
|
{ |
||||
|
var blogPost = await BlogPostPublicAppService.GetAsync(blogUrlSlug, blogPostUrlSlug); |
||||
|
|
||||
|
return View("~/Pages/CmsKit/Shared/Components/Blogs/BlogPost/Default.cshtml", blogPost); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,22 @@ |
|||||
|
@using Volo.CmsKit.Public.Web.Pages.CmsKit.Shared.Components.Commenting |
||||
|
@using Volo.CmsKit.Public.Web.Pages.CmsKit.Shared.Components.Blogs.BlogPostComment |
||||
|
@using Volo.CmsKit.Localization |
||||
|
@using Microsoft.Extensions.Localization |
||||
|
|
||||
|
@inject IStringLocalizer<CmsKitResource> L |
||||
|
|
||||
|
@model DefaultBlogPostCommentViewComponent.DefaultBlogPostCommentViewModel |
||||
|
|
||||
|
|
||||
|
<abp-card> |
||||
|
<abp-card-header> |
||||
|
<abp-card-title>@L["Comments"]</abp-card-title> |
||||
|
</abp-card-header> |
||||
|
<abp-card-body> |
||||
|
@await Component.InvokeAsync(typeof(CommentingViewComponent), new |
||||
|
{ |
||||
|
entityType = Model.EntityType, |
||||
|
entityId = Model.EntityId |
||||
|
}) |
||||
|
</abp-card-body> |
||||
|
</abp-card> |
||||
@ -0,0 +1,39 @@ |
|||||
|
using Microsoft.AspNetCore.Mvc; |
||||
|
using System; |
||||
|
using System.Collections.Generic; |
||||
|
using System.Linq; |
||||
|
using System.Text; |
||||
|
using System.Threading.Tasks; |
||||
|
using Volo.Abp.AspNetCore.Mvc; |
||||
|
using Volo.CmsKit.Public.Blogs; |
||||
|
|
||||
|
namespace Volo.CmsKit.Public.Web.Pages.CmsKit.Shared.Components.Blogs.BlogPostComment |
||||
|
{ |
||||
|
[ViewComponent(Name = "CmsDefaultBlogPostComment")] |
||||
|
public class DefaultBlogPostCommentViewComponent : AbpViewComponent |
||||
|
{ |
||||
|
protected IBlogPostPublicAppService BlogPostPublicAppService; |
||||
|
|
||||
|
public DefaultBlogPostCommentViewComponent(IBlogPostPublicAppService blogPostPublicAppService) |
||||
|
{ |
||||
|
BlogPostPublicAppService = blogPostPublicAppService; |
||||
|
} |
||||
|
|
||||
|
public virtual async Task<IViewComponentResult> InvokeAsync(string entityType, string entityId) |
||||
|
{ |
||||
|
return View( |
||||
|
"~/Pages/CmsKit/Shared/Components/Blogs/BlogPostComment/Default.cshtml", |
||||
|
new DefaultBlogPostCommentViewModel |
||||
|
{ |
||||
|
EntityType = entityType, |
||||
|
EntityId = entityId |
||||
|
}); |
||||
|
} |
||||
|
|
||||
|
public class DefaultBlogPostCommentViewModel |
||||
|
{ |
||||
|
public string EntityType { get; set; } |
||||
|
public string EntityId { get; set; } |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,26 @@ |
|||||
|
using Microsoft.AspNetCore.Mvc.Razor.Internal; |
||||
|
using Microsoft.Extensions.Localization; |
||||
|
using System; |
||||
|
using System.Collections.Generic; |
||||
|
using System.Linq; |
||||
|
using System.Text; |
||||
|
using System.Threading.Tasks; |
||||
|
using Volo.Abp.AspNetCore.Mvc.UI.Layout; |
||||
|
using Volo.CmsKit.Localization; |
||||
|
|
||||
|
namespace Volo.CmsKit.Public.Web.Pages |
||||
|
{ |
||||
|
public class CmsKitPublicPageBase : Microsoft.AspNetCore.Mvc.RazorPages.Page |
||||
|
{ |
||||
|
[RazorInject] |
||||
|
public IStringLocalizer<CmsKitResource> L { get; set; } |
||||
|
|
||||
|
[RazorInject] |
||||
|
public IPageLayout PageLayout { get; set; } |
||||
|
|
||||
|
public override Task ExecuteAsync() |
||||
|
{ |
||||
|
return Task.CompletedTask; // Will be overriden by razor pages. (.cshtml)
|
||||
|
} |
||||
|
} |
||||
|
} |
||||
Loading…
Reference in new issue