@Model.BlogPost.Title
- @@@Model.BlogPost.Author?.UserName
+
+ @@@Model.BlogPost.Author?.UserName
+
@Model.BlogPost.CreationTime
-
@if (!Model.BlogPost.Content.IsNullOrEmpty())
{
@Html.Raw(await MarkdownRenderer.RenderAsync(Model.BlogPost.Content))
diff --git a/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/Public/CmsKit/Blogs/Index.cshtml b/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/Public/CmsKit/Blogs/Index.cshtml
index 32c5585f8e..4ae3c007c7 100644
--- a/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/Public/CmsKit/Blogs/Index.cshtml
+++ b/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/Public/CmsKit/Blogs/Index.cshtml
@@ -8,12 +8,40 @@
@model IndexModel
@section styles{
-
+
}
+
+@section scripts {
+
+
+
+}
+
@{
const string dummyImageSource = "https://dummyimage.com/320x180/a3a3a3/fff.png";
}
+
+
+
+
+
+
+
+
@foreach (var blog in Model.Blogs.Items)
{
@@ -21,16 +49,16 @@
@if (blog.CoverImageMediaId != null)
{
-
+
}
else
{
-
+
}
@blog.Title
- @@@blog.Author?.UserName
+ @@@blog.Author?.UserName
@blog.CreationTime
@blog.ShortDescription
@@ -42,11 +70,10 @@
-
}
-
+
-
\ No newline at end of file
+
diff --git a/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/Public/CmsKit/Blogs/Index.cshtml.cs b/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/Public/CmsKit/Blogs/Index.cshtml.cs
index 30d4c6bcf2..c9dc49931d 100644
--- a/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/Public/CmsKit/Blogs/Index.cshtml.cs
+++ b/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/Public/CmsKit/Blogs/Index.cshtml.cs
@@ -7,6 +7,7 @@ using System.Threading.Tasks;
using Volo.Abp.Application.Dtos;
using Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Pagination;
using Volo.CmsKit.Public.Blogs;
+using Volo.CmsKit.Users;
namespace Volo.CmsKit.Public.Web.Pages.Public.CmsKit.Blogs;
@@ -19,10 +20,16 @@ public class IndexModel : CmsKitPublicPageModelBase
[BindProperty(SupportsGet = true)]
public int CurrentPage { get; set; } = 1;
+
+ [BindProperty(SupportsGet = true)]
+ public Guid? AuthorId { get; set; }
public PagedResultDto
Blogs { get; private set; }
public PagerModel PagerModel => new PagerModel(Blogs.TotalCount, Blogs.Items.Count, CurrentPage, PageSize, Request.Path.ToString());
+
+ [BindProperty(SupportsGet = true)]
+ public List Authors { get; set; }
protected IBlogPostPublicAppService BlogPostPublicAppService { get; }
@@ -35,10 +42,13 @@ public class IndexModel : CmsKitPublicPageModelBase
{
Blogs = await BlogPostPublicAppService.GetListAsync(
BlogSlug,
- new PagedAndSortedResultRequestDto
+ new BlogPostGetListInput
{
SkipCount = PageSize * (CurrentPage - 1),
- MaxResultCount = PageSize
+ MaxResultCount = PageSize,
+ AuthorId = AuthorId
});
+
+ Authors = await BlogPostPublicAppService.GetAuthorsHasBlogPostsAsync();
}
}
diff --git a/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/Public/CmsKit/Blogs/index.css b/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/Public/CmsKit/Blogs/index.css
index 161bb41190..19137de2cb 100644
--- a/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/Public/CmsKit/Blogs/index.css
+++ b/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/Public/CmsKit/Blogs/index.css
@@ -3,4 +3,8 @@
.popover {
min-width: 276px;
+}
+
+.author-name-span{
+ cursor: pointer;
}
\ No newline at end of file
diff --git a/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/Public/CmsKit/Blogs/index.js b/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/Public/CmsKit/Blogs/index.js
new file mode 100644
index 0000000000..0d567d1650
--- /dev/null
+++ b/modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/Public/CmsKit/Blogs/index.js
@@ -0,0 +1,18 @@
+$(function () {
+ var $selectAuthor = $('#AuthorSelect');
+ var $authorNameSpan = $('.author-name-span');
+
+ $selectAuthor.on('change', function () {
+ var authorId = $selectAuthor.val();
+ reloadPageWithQueryString({'authorId': authorId});
+ });
+
+ $authorNameSpan.click(function () {
+ var authorId = $(this).data('author-id');
+ reloadPageWithQueryString({'authorId': authorId});
+ });
+
+ function reloadPageWithQueryString(param) {
+ window.location.href = window.location.pathname + "?" + $.param(param);
+ }
+});
diff --git a/modules/cms-kit/src/Volo.CmsKit.Public.Web/wwwroot/client-proxies/cms-kit-proxy.js b/modules/cms-kit/src/Volo.CmsKit.Public.Web/wwwroot/client-proxies/cms-kit-proxy.js
index a135611cac..6b2e3f1b04 100644
--- a/modules/cms-kit/src/Volo.CmsKit.Public.Web/wwwroot/client-proxies/cms-kit-proxy.js
+++ b/modules/cms-kit/src/Volo.CmsKit.Public.Web/wwwroot/client-proxies/cms-kit-proxy.js
@@ -112,6 +112,28 @@
})();
+ // controller volo.cmsKit.public.globalResources.globalResourcePublic
+
+ (function(){
+
+ abp.utils.createNamespace(window, 'volo.cmsKit.public.globalResources.globalResourcePublic');
+
+ volo.cmsKit.public.globalResources.globalResourcePublic.getGlobalScript = function(ajaxParams) {
+ return abp.ajax($.extend(true, {
+ url: abp.appPath + 'api/cms-kit-public/global-resources/script',
+ type: 'GET'
+ }, ajaxParams));
+ };
+
+ volo.cmsKit.public.globalResources.globalResourcePublic.getGlobalStyle = function(ajaxParams) {
+ return abp.ajax($.extend(true, {
+ url: abp.appPath + 'api/cms-kit-public/global-resources/style',
+ type: 'GET'
+ }, ajaxParams));
+ };
+
+ })();
+
// controller volo.cmsKit.public.comments.commentPublic
(function(){
diff --git a/modules/cms-kit/test/Volo.CmsKit.Application.Tests/Blogs/BlogPostPublicAppService_Tests.cs b/modules/cms-kit/test/Volo.CmsKit.Application.Tests/Blogs/BlogPostPublicAppService_Tests.cs
index 2301941920..64725fc700 100644
--- a/modules/cms-kit/test/Volo.CmsKit.Application.Tests/Blogs/BlogPostPublicAppService_Tests.cs
+++ b/modules/cms-kit/test/Volo.CmsKit.Application.Tests/Blogs/BlogPostPublicAppService_Tests.cs
@@ -7,6 +7,7 @@ using System.Threading.Tasks;
using Volo.Abp.Application.Dtos;
using Volo.Abp.Domain.Entities;
using Volo.CmsKit.Public.Blogs;
+using Volo.CmsKit.Users;
using Xunit;
namespace Volo.CmsKit.Blogs;
@@ -17,16 +18,26 @@ public class BlogPostPublicAppService_Tests : CmsKitApplicationTestBase
private readonly CmsKitTestData cmsKitTestData;
+ private readonly ICmsUserRepository userRepository;
+
+ private readonly IBlogRepository blogRepository;
+ private readonly IBlogPostRepository blogPostRepository;
+
+ private readonly BlogPostManager blogPostManager;
public BlogPostPublicAppService_Tests()
{
blogPostAppService = GetRequiredService();
cmsKitTestData = GetRequiredService();
+ userRepository = GetRequiredService();
+ blogRepository = GetRequiredService();
+ blogPostManager = GetRequiredService();
+ blogPostRepository = GetRequiredService();
}
[Fact]
public async Task GetListAsync_ShouldWorkProperly_WithExistingBlog()
{
- var blogPosts = await blogPostAppService.GetListAsync(cmsKitTestData.BlogSlug, new PagedAndSortedResultRequestDto { MaxResultCount = 2 });
+ var blogPosts = await blogPostAppService.GetListAsync(cmsKitTestData.BlogSlug, new BlogPostGetListInput { MaxResultCount = 2 });
blogPosts.ShouldNotBeNull();
blogPosts.TotalCount.ShouldBe(2);
@@ -62,4 +73,49 @@ public class BlogPostPublicAppService_Tests : CmsKitApplicationTestBase
exception.EntityType.ShouldBe(typeof(Blog));
}
+
+ [Fact]
+ public async Task GetListAsync_ShouldFilterByUser()
+ {
+ var user2 = await userRepository.GetAsync(cmsKitTestData.User2Id);
+ var blog = await blogRepository.GetAsync(cmsKitTestData.Blog_Id);
+
+ var blogPost = await blogPostManager.CreateAsync(
+ user2,
+ blog,
+ cmsKitTestData.BlogPost_1_Title + "by user2",
+ cmsKitTestData.BlogPost_1_Slug + "by user2",
+ "Short desc 1",
+ "Blog Post 1 Content"
+ );
+
+ await blogPostRepository.InsertAsync(blogPost);
+
+ //should get all not filtered by user
+ var blogPosts = await blogPostAppService.GetListAsync(cmsKitTestData.BlogSlug,
+ new BlogPostGetListInput {});
+
+ blogPosts.ShouldNotBeNull();
+ blogPosts.TotalCount.ShouldBe(3);
+ blogPosts.Items.ShouldNotBeEmpty();
+ blogPosts.Items.Count.ShouldBe(3);
+
+ //should get only one filtered by user
+ blogPosts = await blogPostAppService.GetListAsync(cmsKitTestData.BlogSlug,
+ new BlogPostGetListInput {AuthorId = user2.Id});
+
+ blogPosts.ShouldNotBeNull();
+ blogPosts.TotalCount.ShouldBe(1);
+ blogPosts.Items.ShouldNotBeEmpty();
+ blogPosts.Items.Count.ShouldBe(1);
+
+ //should get filtered by user1
+ blogPosts = await blogPostAppService.GetListAsync(cmsKitTestData.BlogSlug,
+ new BlogPostGetListInput {AuthorId = cmsKitTestData.User1Id});
+
+ blogPosts.ShouldNotBeNull();
+ blogPosts.TotalCount.ShouldBe(2);
+ blogPosts.Items.ShouldNotBeEmpty();
+ blogPosts.Items.Count.ShouldBe(2);
+ }
}
diff --git a/modules/cms-kit/test/Volo.CmsKit.TestBase/Blogs/BlogPostRepository_Test.cs b/modules/cms-kit/test/Volo.CmsKit.TestBase/Blogs/BlogPostRepository_Test.cs
index 0479ce75b2..4d696e916d 100644
--- a/modules/cms-kit/test/Volo.CmsKit.TestBase/Blogs/BlogPostRepository_Test.cs
+++ b/modules/cms-kit/test/Volo.CmsKit.TestBase/Blogs/BlogPostRepository_Test.cs
@@ -145,4 +145,14 @@ public abstract class BlogPostRepository_Test : CmsKitTestBase x.Id == testData.User1Id);
+ }
}