diff --git a/modules/blogging/src/Volo.Blogging.Domain.Shared/Volo/Blogging/Localization/Resources/en.json b/modules/blogging/src/Volo.Blogging.Domain.Shared/Volo/Blogging/Localization/Resources/en.json index b9f4e44bde..e0bc82f669 100644 --- a/modules/blogging/src/Volo.Blogging.Domain.Shared/Volo/Blogging/Localization/Resources/en.json +++ b/modules/blogging/src/Volo.Blogging.Domain.Shared/Volo/Blogging/Localization/Resources/en.json @@ -59,6 +59,7 @@ "ClearCacheConfirmationMessage": "Are you sure you want to clear the cache?", "MarkdownSupported": "Markdown is supported", "FileUploadInfo": "Drag, drop, or paste a copied image.", - "PostDescriptionHint": "* Will be rendered in the article link preview, supports HTML" + "PostDescriptionHint": "* Will be rendered in the article link preview, supports HTML", + "ReadMore": "Continue Reading" } } \ No newline at end of file diff --git a/modules/blogging/src/Volo.Blogging.Web/Helpers/PostCoverImageHelper.cs b/modules/blogging/src/Volo.Blogging.Web/Helpers/PostCoverImageHelper.cs new file mode 100644 index 0000000000..a2fc22daea --- /dev/null +++ b/modules/blogging/src/Volo.Blogging.Web/Helpers/PostCoverImageHelper.cs @@ -0,0 +1,48 @@ +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/Detail.cshtml b/modules/blogging/src/Volo.Blogging.Web/Pages/Blogs/Posts/Detail.cshtml index 5912e4e6c9..f893907e66 100644 --- a/modules/blogging/src/Volo.Blogging.Web/Pages/Blogs/Posts/Detail.cshtml +++ b/modules/blogging/src/Volo.Blogging.Web/Pages/Blogs/Posts/Detail.cshtml @@ -65,14 +65,19 @@
@if (Model.Post.Writer != null) { - + + + }
@if (Model.Post.Writer != null) { -
@(Model.Post.Writer.UserName) @BloggingPageHelper.ConvertDatetimeToTimeAgo(Model.Post.CreationTime)
- + +
+ @(Model.Post.Writer.UserName) @BloggingPageHelper.ConvertDatetimeToTimeAgo(Model.Post.CreationTime) +
+
} @L["WiewsWithCount", @Model.Post.ReadCount] 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 03514aaf3a..e14dadc874 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 @@ -59,11 +59,17 @@
- + + +
-
@post.Writer.UserName @BloggingPageHelper.ConvertDatetimeToTimeAgo(post.CreationTime)
- @L["WiewsWithCount", post.ReadCount] + +
+ @post.Writer.UserName @BloggingPageHelper.ConvertDatetimeToTimeAgo(post.CreationTime) +
+
+ @L["WiewsWithCount", post.ReadCount] @*| @L["CommentWithCount", post.CommentCount]*@
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 1084d2bd35..f698f9a0b9 100644 --- a/modules/blogging/src/Volo.Blogging.Web/Pages/Members/Index.cshtml +++ b/modules/blogging/src/Volo.Blogging.Web/Pages/Members/Index.cshtml @@ -1,13 +1,19 @@ @page -@using System.Text @using Microsoft.Extensions.Localization -@using Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Alert +@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 @inject ICurrentUser CurrentUser +@{ + ViewBag.Title = @Model.User.UserName.ToUpper() + " - " + L["Blogs"].Value; +} +@section styles { + +}
@@ -16,21 +22,13 @@
- @if (Model.User.UserName == CurrentUser.UserName) - { -
- -
- } - else - { - - } +
+ +
@if (Model.User.UserName != null) {

@Model.User.UserName

} - @L["UserName"].Value.ToUpper()
@Model.User.UserName
@@ -38,7 +36,7 @@
- +
@foreach (var post in Model.Posts) { @@ -46,8 +44,12 @@
- + + + + @L["Blog"].Value.ToUpper() +
-

- @if ((post.Title).Any()) - { - @foreach (var highlight in post.Title) - { - @Html.Raw(highlight) - } - } - else - { + @post.Title - } +

+

+ + @(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 13881fb408..d57534ac2b 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.Dtos; using Volo.Blogging.Members; using Volo.Blogging.Posts; diff --git a/modules/blogging/src/Volo.Blogging.Web/Pages/Members/Index.css b/modules/blogging/src/Volo.Blogging.Web/Pages/Members/Index.css new file mode 100644 index 0000000000..4c5167a694 --- /dev/null +++ b/modules/blogging/src/Volo.Blogging.Web/Pages/Members/Index.css @@ -0,0 +1,3 @@ +.post-desc { + overflow-wrap: break-word; +} \ No newline at end of file