diff --git a/modules/blogging/src/Volo.Blogging.Application.Contracts/Volo/Blogging/Posts/IPostAppService.cs b/modules/blogging/src/Volo.Blogging.Application.Contracts/Volo/Blogging/Posts/IPostAppService.cs index cc2da9521d..fc1e536b45 100644 --- a/modules/blogging/src/Volo.Blogging.Application.Contracts/Volo/Blogging/Posts/IPostAppService.cs +++ b/modules/blogging/src/Volo.Blogging.Application.Contracts/Volo/Blogging/Posts/IPostAppService.cs @@ -7,8 +7,6 @@ namespace Volo.Blogging.Posts { public interface IPostAppService : IApplicationService { - Task> GetListByBlogId(Guid id); - Task> GetListByBlogIdAndTagName(Guid blogId, string tagName); Task GetForReadingAsync(GetPostInput input); diff --git a/modules/blogging/src/Volo.Blogging.Application/Volo/Blogging/Comments/CommentAppService.cs b/modules/blogging/src/Volo.Blogging.Application/Volo/Blogging/Comments/CommentAppService.cs index 0fe0666820..a3e17bc109 100644 --- a/modules/blogging/src/Volo.Blogging.Application/Volo/Blogging/Comments/CommentAppService.cs +++ b/modules/blogging/src/Volo.Blogging.Application/Volo/Blogging/Comments/CommentAppService.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Linq; using System.Threading.Tasks; using Microsoft.AspNetCore.Authorization; using Volo.Abp.Application.Services; @@ -8,7 +9,7 @@ using Volo.Blogging.Comments.Dtos; namespace Volo.Blogging.Comments { - [Authorize(BloggingPermissions.Comments.Default)] + // [Authorize(BloggingPermissions.Comments.Default)] public class CommentAppService : ApplicationService, ICommentAppService { private readonly ICommentRepository _commentRepository; @@ -39,6 +40,13 @@ namespace Volo.Blogging.Comments } } + hierarchicalComments = hierarchicalComments.OrderByDescending(c => c.Comment.CreationTime).ToList(); + + foreach (var hierarchicalComment in hierarchicalComments) + { + hierarchicalComment.Replies = hierarchicalComment.Replies.OrderBy(c => c.CreationTime).ToList(); + } + return hierarchicalComments; } @@ -53,18 +61,33 @@ namespace Volo.Blogging.Comments [Authorize(BloggingPermissions.Comments.Create)] public async Task CreateAsync(CreateCommentDto input) { - var comment = new Comment(_guidGenerator.Create(), input.PostId, input.RepliedCommentId,input.Text); + var comment = new Comment(_guidGenerator.Create(), input.PostId, input.RepliedCommentId, input.Text); comment = await _commentRepository.InsertAsync(comment); return ObjectMapper.Map(comment); } - [Authorize(BloggingPermissions.Comments.Update)] public async Task UpdateAsync(Guid id, UpdateCommentDto input) { var comment = await _commentRepository.GetAsync(id); + if (CurrentUser.Id != comment.CreatorId) + { + return await UpdateAsAdminAsync(id, comment, input); + } + + return await UpdateCommentAsync(id, comment, input); + } + + [Authorize(BloggingPermissions.Comments.Update)] + private async Task UpdateAsAdminAsync(Guid id, Comment comment, UpdateCommentDto input) + { + return await UpdateCommentAsync(id, comment, input); + } + + private async Task UpdateCommentAsync(Guid id, Comment comment, UpdateCommentDto input) + { comment.SetText(input.Text); comment = await _commentRepository.UpdateAsync(comment); @@ -72,10 +95,35 @@ namespace Volo.Blogging.Comments return ObjectMapper.Map(comment); } - [Authorize(BloggingPermissions.Comments.Delete)] public async Task DeleteAsync(Guid id) + { + var comment = await _commentRepository.GetAsync(id); + + if (CurrentUser.Id != comment.CreatorId) + { + await DeleteAsAdminAsync(id); + return; + } + + await DeleteCommentAsync(id); + } + + [Authorize(BloggingPermissions.Comments.Delete)] + private async Task DeleteAsAdminAsync(Guid id) + { + await DeleteCommentAsync(id); + } + + private async Task DeleteCommentAsync(Guid id) { await _commentRepository.DeleteAsync(id); + + var replies = await _commentRepository.GetRepliesOfComment(id); + + foreach (var reply in replies) + { + await _commentRepository.DeleteAsync(reply.Id); + } } } } diff --git a/modules/blogging/src/Volo.Blogging.Application/Volo/Blogging/Posts/PostAppService.cs b/modules/blogging/src/Volo.Blogging.Application/Volo/Blogging/Posts/PostAppService.cs index 0df97fdd1e..f39f9f369e 100644 --- a/modules/blogging/src/Volo.Blogging.Application/Volo/Blogging/Posts/PostAppService.cs +++ b/modules/blogging/src/Volo.Blogging.Application/Volo/Blogging/Posts/PostAppService.cs @@ -32,7 +32,7 @@ namespace Volo.Blogging.Posts _commentRepository = commentRepository; } - public async Task> GetListByBlogId(Guid id) + public async Task> GetListByBlogIdAndTagName(Guid id, string tagName) { var posts = _postRepository.GetPostsByBlogId(id); @@ -50,16 +50,13 @@ namespace Volo.Blogging.Posts postDto.CommentCount = (await _commentRepository.GetListAsync()).Count(p => p.PostId == postDto.Id); } - return new ListResultDto(postDtos); - } - - public async Task> GetListByBlogIdAndTagName(Guid blogId, string tagName) - { - var all = (await GetListByBlogId(blogId)).Items; - - var tag = await _tagRepository.GetByNameAsync(tagName); + if (!tagName.IsNullOrWhiteSpace()) + { + var tag = await _tagRepository.GetByNameAsync(tagName); + postDtos = postDtos.Where(p => p.Tags.Any(t => t.Id == tag.Id)).ToList(); + } - return new ListResultDto(all.Where(p=>p.Tags.Any(t=>t.Id == tag.Id)).ToList()); + return new ListResultDto(postDtos); } public async Task GetForReadingAsync(GetPostInput input) diff --git a/modules/blogging/src/Volo.Blogging.Domain/Volo/Blogging/Comments/ICommentRepository.cs b/modules/blogging/src/Volo.Blogging.Domain/Volo/Blogging/Comments/ICommentRepository.cs index 841114c2af..fb91a7816e 100644 --- a/modules/blogging/src/Volo.Blogging.Domain/Volo/Blogging/Comments/ICommentRepository.cs +++ b/modules/blogging/src/Volo.Blogging.Domain/Volo/Blogging/Comments/ICommentRepository.cs @@ -10,5 +10,7 @@ namespace Volo.Blogging.Comments Task> GetListOfPostAsync( Guid postId ); + + Task> GetRepliesOfComment(Guid id); } } diff --git a/modules/blogging/src/Volo.Blogging.EntityFrameworkCore/Volo/Blogging/Comments/EfCoreCommentRepository.cs b/modules/blogging/src/Volo.Blogging.EntityFrameworkCore/Volo/Blogging/Comments/EfCoreCommentRepository.cs index 5fc57c14b6..3713d0464d 100644 --- a/modules/blogging/src/Volo.Blogging.EntityFrameworkCore/Volo/Blogging/Comments/EfCoreCommentRepository.cs +++ b/modules/blogging/src/Volo.Blogging.EntityFrameworkCore/Volo/Blogging/Comments/EfCoreCommentRepository.cs @@ -23,5 +23,11 @@ namespace Volo.Blogging.Comments .OrderBy(a => a.CreationTime) .ToListAsync(); } + + public async Task> GetRepliesOfComment(Guid id) + { + return await DbSet + .Where(a => a.RepliedCommentId == id).ToListAsync(); + } } } diff --git a/modules/blogging/src/Volo.Blogging.Web/Areas/Blog/Controllers/CommentsController.cs b/modules/blogging/src/Volo.Blogging.Web/Areas/Blog/Controllers/CommentsController.cs new file mode 100644 index 0000000000..4c8176351d --- /dev/null +++ b/modules/blogging/src/Volo.Blogging.Web/Areas/Blog/Controllers/CommentsController.cs @@ -0,0 +1,35 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Mvc; +using Volo.Abp.AspNetCore.Mvc; +using Volo.Blogging.Comments; +using Volo.Blogging.Comments.Dtos; + +namespace Volo.Blogging.Areas.Blog.Controllers +{ + [Area("Blog")] + [Route("Blog/[controller]/[action]")] + public class CommentsController : AbpController + { + private readonly ICommentAppService _commentAppService; + + public CommentsController(ICommentAppService commentAppService) + { + _commentAppService = commentAppService; + } + + [HttpPost] + public async Task Delete(Guid id) + { + await _commentAppService.DeleteAsync(id); + } + + [HttpPost] + public async Task Update(Guid id, UpdateCommentDto commentDto) + { + await _commentAppService.UpdateAsync(id, commentDto); + } + } +} diff --git a/modules/blogging/src/Volo.Blogging.Web/BloggingWebModule.cs b/modules/blogging/src/Volo.Blogging.Web/BloggingWebModule.cs index 44f8b7cd8d..9ec9c04d94 100644 --- a/modules/blogging/src/Volo.Blogging.Web/BloggingWebModule.cs +++ b/modules/blogging/src/Volo.Blogging.Web/BloggingWebModule.cs @@ -61,7 +61,6 @@ namespace Volo.Blogging options.Conventions.AddPageRoute("/Blog/Posts/Detail", "blog/{blogShortName}/{postUrl}"); options.Conventions.AddPageRoute("/Blog/Posts/Edit", "blog/{blogShortName}/posts/edit/{postId}"); options.Conventions.AddPageRoute("/Blog/Posts/New", "blog/{blogShortName}/posts/new"); - options.Conventions.AddPageRoute("/Blog/Tags/Posts", "blog/{blogShortName}/{tagName}/posts"); }); context.Services.AddAssemblyOf(); diff --git a/modules/blogging/src/Volo.Blogging.Web/Localization/Resources/Blogging/Web/en.json b/modules/blogging/src/Volo.Blogging.Web/Localization/Resources/Blogging/Web/en.json index 8b0ab73c2b..5b3e3c470b 100644 --- a/modules/blogging/src/Volo.Blogging.Web/Localization/Resources/Blogging/Web/en.json +++ b/modules/blogging/src/Volo.Blogging.Web/Localization/Resources/Blogging/Web/en.json @@ -5,6 +5,13 @@ "Title": "Title", "ContinueReading": "Continue Reading", "DaysAgo": "days ago", + "YearsAgo": "years ago", + "MonthsAgo": "months ago", + "WeeksAgo": "weeks ago", + "MinutesAgo": "minutes ago", + "SecondsAgo": "seconds ago", + "HoursAgo": "hours ago", + "Now": "now", "Content": "Content", "SeeAll": "See All", "PopularTags": "Popular Tags", diff --git a/modules/blogging/src/Volo.Blogging.Web/Localization/Resources/Blogging/Web/tr.json b/modules/blogging/src/Volo.Blogging.Web/Localization/Resources/Blogging/Web/tr.json index be713a517b..965965a70a 100644 --- a/modules/blogging/src/Volo.Blogging.Web/Localization/Resources/Blogging/Web/tr.json +++ b/modules/blogging/src/Volo.Blogging.Web/Localization/Resources/Blogging/Web/tr.json @@ -5,6 +5,13 @@ "Title": "Başlık", "ContinueReading": "Devamı...", "DaysAgo": "Gün Önce", + "YearsAgo": "yıl önce", + "MonthsAgo": "ay önce", + "WeeksAgo": "hafta önce", + "MinutesAgo": "dakika önce", + "SecondsAgo": "saniye önce", + "HoursAgo": "saat önce", + "Now": "şimdi", "Content": "İçerik", "SeeAll": "Hepsini Gör", "PopularTags": "Popüler Etiketler", @@ -13,7 +20,7 @@ "LeaveComment": "Yorum Bırak", "TagsInThisArticle": "Makalenin Etiketleri", "Posts": "Yazılar", - "Edit": "Düzelt", + "Edit": "Düzenle", "Comment": "Yorum", "WhatIsNew": "Yeniler" } diff --git a/modules/blogging/src/Volo.Blogging.Web/Pages/Blog/BloggingPage.cs b/modules/blogging/src/Volo.Blogging.Web/Pages/Blog/BloggingPage.cs index 7a07772219..1adcc10e8b 100644 --- a/modules/blogging/src/Volo.Blogging.Web/Pages/Blog/BloggingPage.cs +++ b/modules/blogging/src/Volo.Blogging.Web/Pages/Blog/BloggingPage.cs @@ -1,4 +1,5 @@ -using Microsoft.AspNetCore.Mvc.Localization; +using System; +using Microsoft.AspNetCore.Mvc.Localization; using Microsoft.AspNetCore.Mvc.Razor.Internal; using Volo.Abp.AspNetCore.Mvc.UI.RazorPages; using Volo.Blogging.Localization; @@ -21,5 +22,46 @@ namespace Volo.Blogging.Pages.Blog return title; } + + public string ConvertDatetimeToTimeAgo(DateTime dt) + { + var timeDiff = DateTime.Now - dt; + + var diffInDays = (int) timeDiff.TotalDays; + + if (diffInDays >= 365) + { + return diffInDays / 365 + L["YearsAgo"].Value; + } + if (diffInDays >= 30) + { + return diffInDays / 30 + L["MonthsAgo"].Value; + } + if (diffInDays >= 7) + { + return diffInDays / 7 + L["WeeksAgo"].Value; + } + if (diffInDays >= 1) + { + return diffInDays + L["DaysAgo"].Value; + } + + var diffInSeconds = (int) timeDiff.TotalSeconds; + + if (diffInSeconds >= 3600) + { + return diffInSeconds / 3600 + L["HoursAgo"].Value; + } + if (diffInSeconds >= 60) + { + return diffInSeconds / 60 + L["MinutesAgo"].Value; + } + if (diffInSeconds >= 1) + { + return diffInSeconds + L["SecondsAgo"].Value; + } + + return L["Now"].Value; + } } } diff --git a/modules/blogging/src/Volo.Blogging.Web/Pages/Blog/Posts/Detail.cshtml b/modules/blogging/src/Volo.Blogging.Web/Pages/Blog/Posts/Detail.cshtml index 0efcf13817..df1a9e7a53 100644 --- a/modules/blogging/src/Volo.Blogging.Web/Pages/Blog/Posts/Detail.cshtml +++ b/modules/blogging/src/Volo.Blogging.Web/Pages/Blog/Posts/Detail.cshtml @@ -30,7 +30,7 @@

@foreach (var tag in Model.Post.Tags) { - @tag.Name + @tag.Name }

@@ -44,7 +44,7 @@ - Halil İbrahim Kalkan, @Model.Post.CreationTime.ToString("dd/MM/yyyy hh/mm") + Halil İbrahim Kalkan, @ConvertDatetimeToTimeAgo(Model.Post.CreationTime) | @@ -94,7 +94,7 @@
@L["TagsInThisArticle"]
@foreach (var tag in Model.Post.Tags) { -
@tag.Name + @tag.Name }
@@ -122,9 +122,9 @@
Armağan Ünlü - @commentWithRepliesDto.Comment.CreationTime.ToString("dd/MM/yyyy hh/mm") + @ConvertDatetimeToTimeAgo(commentWithRepliesDto.Comment.CreationTime)
-

+

@commentWithRepliesDto.Comment.Text

@@ -132,15 +132,21 @@ @L["Reply"] + @if (await Authorization.IsGrantedAsync(BloggingPermissions.Comments.Delete)) + { + | + + @L["Delete"] + + } - | - - 44 - - | - - 8 - + @if (await Authorization.IsGrantedAsync(BloggingPermissions.Comments.Update) || (CurrentUser.Id == commentWithRepliesDto.Comment.CreatorId)) + { + | + + @L["Edit"] + + }
@@ -159,6 +165,23 @@
+ + @if (await Authorization.IsGrantedAsync(BloggingPermissions.Comments.Update) || (CurrentUser.Id == commentWithRepliesDto.Comment.CreatorId)) + { +
+
+
+
+ +
+ +
+ + +
+
+
+ } @foreach (var reply in commentWithRepliesDto.Replies) { @@ -167,23 +190,31 @@
Zlatan Ibrahimovic - @reply.CreationTime.ToString("dd/MM/yyyy hh/mm") + @ConvertDatetimeToTimeAgo(reply.CreationTime)
-

+

@reply.Text

@L["Reply"] - | - - 44 - - | - - 8 - + + @if (await Authorization.IsGrantedAsync(BloggingPermissions.Comments.Delete) || (CurrentUser.Id == commentWithRepliesDto.Comment.CreatorId)) + { + | + + @L["Delete"] + + } + + @if (await Authorization.IsGrantedAsync(BloggingPermissions.Comments.Update) || (CurrentUser.Id == commentWithRepliesDto.Comment.CreatorId)) + { + | + + @L["Edit"] + + }
@@ -201,6 +232,23 @@
+ + @if (await Authorization.IsGrantedAsync(BloggingPermissions.Comments.Update) || (CurrentUser.Id == commentWithRepliesDto.Comment.CreatorId)) + { +
+
+
+
+ +
+ +
+ + +
+
+
+ } } @@ -210,4 +258,4 @@ - \ No newline at end of file + diff --git a/modules/blogging/src/Volo.Blogging.Web/Pages/Blog/Posts/Detail.cshtml.cs b/modules/blogging/src/Volo.Blogging.Web/Pages/Blog/Posts/Detail.cshtml.cs index a653af7cff..a4736b3d4e 100644 --- a/modules/blogging/src/Volo.Blogging.Web/Pages/Blog/Posts/Detail.cshtml.cs +++ b/modules/blogging/src/Volo.Blogging.Web/Pages/Blog/Posts/Detail.cshtml.cs @@ -62,6 +62,13 @@ namespace Volo.Blogging.Pages.Blog.Posts await GetData(); } + public async void OnDeleteAsync(Guid commentId) + { + await _commentAppService.DeleteAsync(commentId); + + await GetData(); + } + private async Task GetData() { Blog = await _blogAppService.GetByShortNameAsync(BlogShortName); diff --git a/modules/blogging/src/Volo.Blogging.Web/Pages/Blog/Posts/Edit.cshtml b/modules/blogging/src/Volo.Blogging.Web/Pages/Blog/Posts/Edit.cshtml index fc9740b600..e6d79c0185 100644 --- a/modules/blogging/src/Volo.Blogging.Web/Pages/Blog/Posts/Edit.cshtml +++ b/modules/blogging/src/Volo.Blogging.Web/Pages/Blog/Posts/Edit.cshtml @@ -47,9 +47,9 @@ diff --git a/modules/blogging/src/Volo.Blogging.Web/Pages/Blog/Posts/Edit.cshtml.cs b/modules/blogging/src/Volo.Blogging.Web/Pages/Blog/Posts/Edit.cshtml.cs index e2f0aab317..0aa2778bad 100644 --- a/modules/blogging/src/Volo.Blogging.Web/Pages/Blog/Posts/Edit.cshtml.cs +++ b/modules/blogging/src/Volo.Blogging.Web/Pages/Blog/Posts/Edit.cshtml.cs @@ -14,6 +14,9 @@ namespace Volo.Blogging.Pages.Blog.Posts private readonly IPostAppService _postAppService; private readonly IBlogAppService _blogAppService; + [BindProperty(SupportsGet = true)] + public string BlogShortName { get; set; } + [BindProperty(SupportsGet = true)] public string PostId { get; set; } diff --git a/modules/blogging/src/Volo.Blogging.Web/Pages/Blog/Posts/Index.cshtml b/modules/blogging/src/Volo.Blogging.Web/Pages/Blog/Posts/Index.cshtml index 2b8410034a..3ce970e11b 100644 --- a/modules/blogging/src/Volo.Blogging.Web/Pages/Blog/Posts/Index.cshtml +++ b/modules/blogging/src/Volo.Blogging.Web/Pages/Blog/Posts/Index.cshtml @@ -46,7 +46,7 @@

@foreach (var tag in post.Tags) { - @tag.Name + @tag.Name }

@@ -65,7 +65,7 @@ - Armağan Ünlü, @((DateTime.Today - post.CreationTime).Days) @L["DaysAgo"] + Armağan Ünlü, @ConvertDatetimeToTimeAgo(post.CreationTime) | @@ -132,7 +132,7 @@ @@ -188,7 +188,7 @@

@foreach (var tag in post.Tags) { - @tag.Name + @tag.Name }

@@ -204,7 +204,7 @@ - Armağan Ünlü, @((DateTime.Today - post.CreationTime).Days) @L["DaysAgo"] + Armağan Ünlü, @ConvertDatetimeToTimeAgo(post.CreationTime) | @@ -234,7 +234,7 @@ diff --git a/modules/blogging/src/Volo.Blogging.Web/Pages/Blog/Posts/Index.cshtml.cs b/modules/blogging/src/Volo.Blogging.Web/Pages/Blog/Posts/Index.cshtml.cs index 9d6a9cb635..eb9b8b9574 100644 --- a/modules/blogging/src/Volo.Blogging.Web/Pages/Blog/Posts/Index.cshtml.cs +++ b/modules/blogging/src/Volo.Blogging.Web/Pages/Blog/Posts/Index.cshtml.cs @@ -18,6 +18,9 @@ namespace Volo.Blogging.Pages.Blog.Posts [BindProperty(SupportsGet = true)] public string BlogShortName { get; set; } + [BindProperty(SupportsGet = true)] + public string TagName { get; set; } + public IReadOnlyList Posts { get; set; } public IReadOnlyList PopularTags { get; set; } @@ -32,7 +35,7 @@ namespace Volo.Blogging.Pages.Blog.Posts public async Task OnGetAsync() { var blog = await _blogAppService.GetByShortNameAsync(BlogShortName); - Posts = (await _postAppService.GetListByBlogId(blog.Id)).Items; + Posts = (await _postAppService.GetListByBlogIdAndTagName(blog.Id, TagName)).Items; PopularTags = (await _tagAppService.GetPopularTags(new GetPopularTagsInput {ResultCount = 10})); } } diff --git a/modules/blogging/src/Volo.Blogging.Web/Pages/Blog/Posts/New.cshtml b/modules/blogging/src/Volo.Blogging.Web/Pages/Blog/Posts/New.cshtml index 2b0cca5e77..8dad66e684 100644 --- a/modules/blogging/src/Volo.Blogging.Web/Pages/Blog/Posts/New.cshtml +++ b/modules/blogging/src/Volo.Blogging.Web/Pages/Blog/Posts/New.cshtml @@ -47,7 +47,7 @@ diff --git a/modules/blogging/src/Volo.Blogging.Web/Pages/Blog/Posts/detail.js b/modules/blogging/src/Volo.Blogging.Web/Pages/Blog/Posts/detail.js index 8225e2244f..9a15b035bc 100644 --- a/modules/blogging/src/Volo.Blogging.Web/Pages/Blog/Posts/detail.js +++ b/modules/blogging/src/Volo.Blogging.Web/Pages/Blog/Posts/detail.js @@ -1,25 +1,81 @@ (function ($) { $('div .replyForm').hide(); + $('div .editForm').hide(); + + $('form[class="editFormClass"]').submit(function (event) { + event.preventDefault(); + var form = $(this).serializeFormToObject(); + + $.ajax({ + type: "POST", + url: "/Blog/Comments/Update", + data: { + id: form.commentId, + commentDto: { + text: form.text + } + }, + success: function (response) { + $('div .editForm').hide(); + $('#' + form.commentId).text(form.text); + } + }); + }); $('a').click(function (event) { - var data = $(this).attr('data-relpyid'); + var linkElement = $(this); + var data = linkElement.attr('data-relpyid'); + + if (data != '' && data !== undefined) { - if (data == '' || data === undefined) { + event.preventDefault(); + + var div = $(this).parent().next(); + + if (div.is(":hidden")) { + $('div .replyForm').hide(); + div.show(); + } else { + div.hide(); + } return; } - event.preventDefault(); + data = $(this).attr('data-deleteid'); + + if (data != '' && data !== undefined) { - var div = $(this).parent().next(); + event.preventDefault(); - if (div.is(":hidden")) { - $('div .replyForm').hide(); - div.show(); - } else { - div.hide(); + $.ajax({ + type: "POST", + url: "/Blog/Comments/Delete", + data: { id: data }, + success: function (response) { + linkElement.parent().parent().parent().remove(); + } + }); } + data = $(this).attr('data-updateid'); + + if (data != '' && data !== undefined) { + + event.preventDefault(); + + var div = $(this).parent().next().next(); + + if (div.is(":hidden")) { + $('div .editForm').hide(); + div.show(); + } else { + div.hide(); + } + return; + } + + }); })(jQuery); diff --git a/modules/blogging/src/Volo.Blogging.Web/Pages/Blog/Posts/edit.js b/modules/blogging/src/Volo.Blogging.Web/Pages/Blog/Posts/edit.js index e912f65528..1b31da77ca 100644 --- a/modules/blogging/src/Volo.Blogging.Web/Pages/Blog/Posts/edit.js +++ b/modules/blogging/src/Volo.Blogging.Web/Pages/Blog/Posts/edit.js @@ -47,8 +47,6 @@ } }).data(editorDataKey); - - $container.find("form#edit-post-form").submit(function (e) { var $postTextInput = $form.find("input[name='Post.Content']"); diff --git a/modules/blogging/src/Volo.Blogging.Web/Pages/Blog/Posts/new.js b/modules/blogging/src/Volo.Blogging.Web/Pages/Blog/Posts/new.js index 5fd102ff28..54ce131681 100644 --- a/modules/blogging/src/Volo.Blogging.Web/Pages/Blog/Posts/new.js +++ b/modules/blogging/src/Volo.Blogging.Web/Pages/Blog/Posts/new.js @@ -46,8 +46,6 @@ } }).data(editorDataKey); - - $container.find("form#new-post-form").submit(function (e) { var $postTextInput = $form.find("input[name='Post.Content']"); @@ -65,8 +63,8 @@ title = title.substring(0, 64); } - title = title.replace(' ','-'); - + title = title.replace(' ', '-'); + title = title.replace(new RegExp(' ', 'g'), '-'); $('#Post_Url').val(title); }); diff --git a/modules/blogging/src/Volo.Blogging.Web/Pages/Blog/Tags/Posts.cshtml b/modules/blogging/src/Volo.Blogging.Web/Pages/Blog/Tags/Posts.cshtml deleted file mode 100644 index ff643406b0..0000000000 --- a/modules/blogging/src/Volo.Blogging.Web/Pages/Blog/Tags/Posts.cshtml +++ /dev/null @@ -1,93 +0,0 @@ -@page -@inherits Volo.Blogging.Pages.Blog.BloggingPage -@using Volo.Blogging.Pages.Blog.Tags -@model PostsModel -@{ -} - -@section scripts { - - - -} -@section styles { - - - -} - -
-
-
-
-
-
-

#@Model.TagName

-
-
-
- - @for (var index = 0; index < Model.Posts.Count; index++) - { - var post = Model.Posts[index]; - var oddPost = index % 2 == 1; - -
-
-
-
- - - - -
-
-
-

- @foreach (var tag in post.Tags) - { - @tag.Name - } -

-

- @post.Title -

-

- @(post.Content == null ? "" : (post.Content.Length > 250 ? post.Content.Substring(0, 150) : post.Content))... -

-
- -
-
-
-
- } - -
- -
-
\ No newline at end of file diff --git a/modules/blogging/src/Volo.Blogging.Web/Pages/Blog/Tags/Posts.cshtml.cs b/modules/blogging/src/Volo.Blogging.Web/Pages/Blog/Tags/Posts.cshtml.cs deleted file mode 100644 index bb040e021b..0000000000 --- a/modules/blogging/src/Volo.Blogging.Web/Pages/Blog/Tags/Posts.cshtml.cs +++ /dev/null @@ -1,34 +0,0 @@ -using System.Collections.Generic; -using Microsoft.AspNetCore.Mvc; -using Microsoft.AspNetCore.Mvc.RazorPages; -using Volo.Blogging.Blogs; -using Volo.Blogging.Posts; - -namespace Volo.Blogging.Pages.Blog.Tags -{ - public class PostsModel : PageModel - { - private readonly IPostAppService _postAppService; - private readonly IBlogAppService _blogAppService; - - [BindProperty(SupportsGet = true)] - public string BlogShortName { get; set; } - - [BindProperty(SupportsGet = true)] - public string TagName { get; set; } - - public IReadOnlyList Posts { get; set; } - - public PostsModel(IPostAppService postAppService, IBlogAppService blogAppService) - { - _postAppService = postAppService; - _blogAppService = blogAppService; - } - - public async void OnGetAsync() - { - var blog = await _blogAppService.GetByShortNameAsync(BlogShortName); - Posts = (await _postAppService.GetListByBlogIdAndTagName(blog.Id, TagName)).Items; - } - } -} \ No newline at end of file