diff --git a/modules/blogging/app/Volo.BloggingTestApp/Pages/_ViewImports.cshtml b/modules/blogging/app/Volo.BloggingTestApp/Pages/_ViewImports.cshtml new file mode 100644 index 0000000000..caae8c9ac5 --- /dev/null +++ b/modules/blogging/app/Volo.BloggingTestApp/Pages/_ViewImports.cshtml @@ -0,0 +1,5 @@ +@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers +@addTagHelper *, Volo.Abp.AspNetCore.Mvc.UI +@addTagHelper *, Volo.Abp.AspNetCore.Mvc.UI.Bootstrap +@addTagHelper *, Volo.Abp.AspNetCore.Mvc.UI.Bundling +@addTagHelper *, Volo.Blogging.Web \ No newline at end of file diff --git a/modules/blogging/src/Volo.Blogging.Application.Contracts/Volo/Blogging/Members/IMemberAppService.cs b/modules/blogging/src/Volo.Blogging.Application.Contracts/Volo/Blogging/Members/IMemberAppService.cs index 5e06d20956..0cf992a467 100644 --- a/modules/blogging/src/Volo.Blogging.Application.Contracts/Volo/Blogging/Members/IMemberAppService.cs +++ b/modules/blogging/src/Volo.Blogging.Application.Contracts/Volo/Blogging/Members/IMemberAppService.cs @@ -6,5 +6,5 @@ namespace Volo.Blogging.Members; public interface IMemberAppService : IApplicationService { - Task FindAsync(string username); + Task GetAsync(string username); } \ No newline at end of file diff --git a/modules/blogging/src/Volo.Blogging.Application/Volo/Blogging/Members/MemberAppService.cs b/modules/blogging/src/Volo.Blogging.Application/Volo/Blogging/Members/MemberAppService.cs index d22c2fae53..936a0ae0ef 100644 --- a/modules/blogging/src/Volo.Blogging.Application/Volo/Blogging/Members/MemberAppService.cs +++ b/modules/blogging/src/Volo.Blogging.Application/Volo/Blogging/Members/MemberAppService.cs @@ -14,10 +14,10 @@ public class MemberAppService : BloggingAppServiceBase, IMemberAppService { _userRepository = userRepository; } - - public async Task FindAsync(string username) + + public async Task GetAsync(string username) { - var user = await _userRepository.FindAsync(x => x.UserName == username); + var user = await _userRepository.GetAsync(x => x.UserName == username); return ObjectMapper.Map(user); } diff --git a/modules/blogging/src/Volo.Blogging.Web/Helpers/PostCoverImageHelper.cs b/modules/blogging/src/Volo.Blogging.Web/Helpers/PostCoverImageHelper.cs deleted file mode 100644 index a2fc22daea..0000000000 --- a/modules/blogging/src/Volo.Blogging.Web/Helpers/PostCoverImageHelper.cs +++ /dev/null @@ -1,48 +0,0 @@ -using System; -using System.Linq; - -namespace Volo.Blogging.Helpers; - -public static class PostCoverImageHelper -{ - private static readonly string[] PostColors = - { - "linear-gradient(135deg, #4b2d21 0%, #7d4b37 100%)", - "linear-gradient(135deg, #41003d 0%, #a10097 100%)", - "linear-gradient(135deg, #163e4b 0%, #297791 100%)", - "linear-gradient(135deg, #660040 0%, #aa006b 100%)", - "linear-gradient(135deg, #240d88 0%, #571fff 100%)", - "linear-gradient(135deg, #0d6a88 0%, #16b0e1 100%)", - "linear-gradient(135deg, #329063 0%, #4be099 100%)", - "linear-gradient(135deg, #904432 0%, #f07153 100%)", - "linear-gradient(135deg, #903282 0%, #e04cca 100%)", - "linear-gradient(135deg, #901943 0%, #f02a70 100%)", - "linear-gradient(135deg, #2e634a 0%, #4da57b 100%)", - "linear-gradient(135deg, #9c003f 0%, #e41d6f 100%)", - "linear-gradient(135deg, #806419 0%, #d5a72a 100%)", - "linear-gradient(135deg, #545975 0%, #8890bd 100%)", - "linear-gradient(135deg, #67172a 0%, #ba2549 100%)" - }; - - public static string GetRandomColor(string postTitle) - { - long total = postTitle.Truncate(32).ToCharArray().Sum(c => c); - return PostColors[total % PostColors.Length]; - } - - public static string GetTitleCapitals(string postTitle) - { - if (postTitle.Length < 2) - { - return postTitle.ToUpperInvariant(); - } - - if (postTitle.Contains(" ")) - { - var splitted = postTitle.Split(" "); - return (splitted[0][0].ToString() + splitted[1][0].ToString()).ToUpperInvariant(); - } - - return postTitle.ToUpperInvariant().Left(2); - } -} \ No newline at end of file diff --git a/modules/blogging/src/Volo.Blogging.Web/Pages/Blogs/Posts/Index.cshtml b/modules/blogging/src/Volo.Blogging.Web/Pages/Blogs/Posts/Index.cshtml index e14dadc874..78c466e8c9 100644 --- a/modules/blogging/src/Volo.Blogging.Web/Pages/Blogs/Posts/Index.cshtml +++ b/modules/blogging/src/Volo.Blogging.Web/Pages/Blogs/Posts/Index.cshtml @@ -1,5 +1,6 @@ @page @using Microsoft.AspNetCore.Authorization +@using Volo.Blogging.Areas.Blog.Helpers.TagHelpers @using Volo.Abp.AspNetCore.Mvc.UI.Packages.OwlCarousel @using Volo.Blogging @inject IAuthorizationService Authorization diff --git a/modules/blogging/src/Volo.Blogging.Web/Pages/Members/Index.cshtml b/modules/blogging/src/Volo.Blogging.Web/Pages/Members/Index.cshtml index f698f9a0b9..cfe77816a9 100644 --- a/modules/blogging/src/Volo.Blogging.Web/Pages/Members/Index.cshtml +++ b/modules/blogging/src/Volo.Blogging.Web/Pages/Members/Index.cshtml @@ -2,7 +2,6 @@ @using Microsoft.Extensions.Localization @using Volo.Abp.AspNetCore.Mvc.UI.Bundling.TagHelpers @using Volo.Abp.Users -@using Volo.Blogging.Helpers @using Volo.Blogging.Localization @model Volo.Blogging.Pages.Members.IndexModel @inject IStringLocalizer L @@ -15,15 +14,14 @@ } - -
+
- +
@if (Model.User.UserName != null) { @@ -36,7 +34,7 @@
- +
@foreach (var post in Model.Posts) { @@ -44,7 +42,7 @@
- + @@ -65,16 +63,16 @@

- + @(post.Description.Length >= 150 ? post.Description.Substring(0, 150) + "..." : post.Description) @L["ReadMore"]

-
- @PostCoverImageHelper.GetTitleCapitals(post.Title) -
+
+ +
} diff --git a/modules/blogging/src/Volo.Blogging.Web/Pages/Members/Index.cshtml.cs b/modules/blogging/src/Volo.Blogging.Web/Pages/Members/Index.cshtml.cs index d57534ac2b..4debc19527 100644 --- a/modules/blogging/src/Volo.Blogging.Web/Pages/Members/Index.cshtml.cs +++ b/modules/blogging/src/Volo.Blogging.Web/Pages/Members/Index.cshtml.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using System.Threading.Tasks; using Microsoft.AspNetCore.Mvc; using Volo.Abp.AspNetCore.Mvc.UI.RazorPages; +using Volo.Blogging.Blogs; using Volo.Blogging.Blogs.Dtos; using Volo.Blogging.Members; using Volo.Blogging.Posts; @@ -13,9 +14,10 @@ public class IndexModel : AbpPageModel private readonly IPostAppService _postAppService; private readonly IMemberAppService _memberAppService; + public BlogUserDto User { get; set; } public List Posts { get; set; } - + public IndexModel(IPostAppService postAppService, IMemberAppService memberAppService) { _postAppService = postAppService; @@ -24,15 +26,15 @@ public class IndexModel : AbpPageModel public async Task OnGetAsync(string userName) { - User = await _memberAppService.FindAsync(userName); + User = await _memberAppService.GetAsync(userName); if (User is null) { - return Redirect("/abp"); + return Redirect("/"); } Posts = await _postAppService.GetListByUserIdAsync(User.Id); - + return Page(); }