Browse Source

Merge branch 'master' of https://github.com/volosoft/abp

pull/441/head
Halil ibrahim Kalkan 8 years ago
parent
commit
66f8144dda
  1. 2
      modules/blogging/src/Volo.Blogging.Application.Contracts/Volo/Blogging/Posts/IPostAppService.cs
  2. 56
      modules/blogging/src/Volo.Blogging.Application/Volo/Blogging/Comments/CommentAppService.cs
  3. 17
      modules/blogging/src/Volo.Blogging.Application/Volo/Blogging/Posts/PostAppService.cs
  4. 2
      modules/blogging/src/Volo.Blogging.Domain/Volo/Blogging/Comments/ICommentRepository.cs
  5. 6
      modules/blogging/src/Volo.Blogging.EntityFrameworkCore/Volo/Blogging/Comments/EfCoreCommentRepository.cs
  6. 35
      modules/blogging/src/Volo.Blogging.Web/Areas/Blog/Controllers/CommentsController.cs
  7. 1
      modules/blogging/src/Volo.Blogging.Web/BloggingWebModule.cs
  8. 7
      modules/blogging/src/Volo.Blogging.Web/Localization/Resources/Blogging/Web/en.json
  9. 9
      modules/blogging/src/Volo.Blogging.Web/Localization/Resources/Blogging/Web/tr.json
  10. 44
      modules/blogging/src/Volo.Blogging.Web/Pages/Blog/BloggingPage.cs
  11. 96
      modules/blogging/src/Volo.Blogging.Web/Pages/Blog/Posts/Detail.cshtml
  12. 7
      modules/blogging/src/Volo.Blogging.Web/Pages/Blog/Posts/Detail.cshtml.cs
  13. 4
      modules/blogging/src/Volo.Blogging.Web/Pages/Blog/Posts/Edit.cshtml
  14. 3
      modules/blogging/src/Volo.Blogging.Web/Pages/Blog/Posts/Edit.cshtml.cs
  15. 12
      modules/blogging/src/Volo.Blogging.Web/Pages/Blog/Posts/Index.cshtml
  16. 5
      modules/blogging/src/Volo.Blogging.Web/Pages/Blog/Posts/Index.cshtml.cs
  17. 2
      modules/blogging/src/Volo.Blogging.Web/Pages/Blog/Posts/New.cshtml
  18. 74
      modules/blogging/src/Volo.Blogging.Web/Pages/Blog/Posts/detail.js
  19. 2
      modules/blogging/src/Volo.Blogging.Web/Pages/Blog/Posts/edit.js
  20. 6
      modules/blogging/src/Volo.Blogging.Web/Pages/Blog/Posts/new.js
  21. 93
      modules/blogging/src/Volo.Blogging.Web/Pages/Blog/Tags/Posts.cshtml
  22. 34
      modules/blogging/src/Volo.Blogging.Web/Pages/Blog/Tags/Posts.cshtml.cs

2
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<ListResultDto<PostWithDetailsDto>> GetListByBlogId(Guid id);
Task<ListResultDto<PostWithDetailsDto>> GetListByBlogIdAndTagName(Guid blogId, string tagName);
Task<PostWithDetailsDto> GetForReadingAsync(GetPostInput input);

56
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<CommentDto> 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, CommentDto>(comment);
}
[Authorize(BloggingPermissions.Comments.Update)]
public async Task<CommentDto> 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<CommentDto> UpdateAsAdminAsync(Guid id, Comment comment, UpdateCommentDto input)
{
return await UpdateCommentAsync(id, comment, input);
}
private async Task<CommentDto> 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, CommentDto>(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);
}
}
}
}

17
modules/blogging/src/Volo.Blogging.Application/Volo/Blogging/Posts/PostAppService.cs

@ -32,7 +32,7 @@ namespace Volo.Blogging.Posts
_commentRepository = commentRepository;
}
public async Task<ListResultDto<PostWithDetailsDto>> GetListByBlogId(Guid id)
public async Task<ListResultDto<PostWithDetailsDto>> 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<PostWithDetailsDto>(postDtos);
}
public async Task<ListResultDto<PostWithDetailsDto>> 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<PostWithDetailsDto>(all.Where(p=>p.Tags.Any(t=>t.Id == tag.Id)).ToList());
return new ListResultDto<PostWithDetailsDto>(postDtos);
}
public async Task<PostWithDetailsDto> GetForReadingAsync(GetPostInput input)

2
modules/blogging/src/Volo.Blogging.Domain/Volo/Blogging/Comments/ICommentRepository.cs

@ -10,5 +10,7 @@ namespace Volo.Blogging.Comments
Task<List<Comment>> GetListOfPostAsync(
Guid postId
);
Task<List<Comment>> GetRepliesOfComment(Guid id);
}
}

6
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<List<Comment>> GetRepliesOfComment(Guid id)
{
return await DbSet
.Where(a => a.RepliedCommentId == id).ToListAsync();
}
}
}

35
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);
}
}
}

1
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<BloggingWebModule>();

7
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",

9
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"
}

44
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;
}
}
}

96
modules/blogging/src/Volo.Blogging.Web/Pages/Blog/Posts/Detail.cshtml

@ -30,7 +30,7 @@
<p class="tags">
@foreach (var tag in Model.Post.Tags)
{
<a asp-page="/Blog/Tags/Posts" asp-route-blogShortName="@Model.BlogShortName" asp-route-tagName="@tag.Name" class="tag">@tag.Name</a>
<a asp-page="/Blog/Posts/Index" asp-route-blogShortName="@Model.BlogShortName" asp-route-tagName="@tag.Name" class="tag">@tag.Name</a>
}
</p>
<h1>
@ -44,7 +44,7 @@
<img src="https://placeimg.com/60/60/people" class="article-avatar">
</a>
<a href="#">
<strong> Halil İbrahim Kalkan</strong>, @Model.Post.CreationTime.ToString("dd/MM/yyyy hh/mm")
<strong> Halil İbrahim Kalkan</strong>, @ConvertDatetimeToTimeAgo(Model.Post.CreationTime)
</a>
<span class="seperator">|</span>
<a href="#">
@ -94,7 +94,7 @@
<h5>@L["TagsInThisArticle"]</h5>
@foreach (var tag in Model.Post.Tags)
{
<a asp-page="/Blog/Tags/Posts" asp-route-blogShortName="@Model.BlogShortName" asp-route-tagName="@tag.Name" class="tag">@tag.Name</a>
<a asp-page="/Blog/Posts/Index" asp-route-blogShortName="@Model.BlogShortName" asp-route-tagName="@tag.Name" class="tag">@tag.Name</a>
}
</div>
<div class="comment-form mt-4">
@ -122,9 +122,9 @@
<div class="media-body">
<h5 class="comment-owner">
Armağan Ünlü
<span class="float-right">@commentWithRepliesDto.Comment.CreationTime.ToString("dd/MM/yyyy hh/mm")</span>
<span class="float-right">@ConvertDatetimeToTimeAgo(commentWithRepliesDto.Comment.CreationTime)</span>
</h5>
<p>
<p id="@commentWithRepliesDto.Comment.Id">
@commentWithRepliesDto.Comment.Text
</p>
<div class="comment-buttons">
@ -132,15 +132,21 @@
<a href="#" class="tag" data-relpyid="@commentWithRepliesDto.Comment.Id">
<i class="fa fa-reply" aria-hidden="true"></i> @L["Reply"]
</a>
@if (await Authorization.IsGrantedAsync(BloggingPermissions.Comments.Delete))
{
<span class="seperator">|</span>
<a href="#" class="tag" data-deleteid="@commentWithRepliesDto.Comment.Id">
<i class="fa fa-trash" aria-hidden="true"></i> @L["Delete"]
</a>
}
<span class="seperator">|</span>
<a href="tag.html" class="tag">
<i class="fa fa-chevron-up" aria-hidden="true"></i><span class="count count-up">44</span>
</a>
<span class="seperator">|</span>
<a href="tag.html" class="tag">
<i class="fa fa-chevron-down" aria-hidden="true"></i><span class="count count-down">8</span>
</a>
@if (await Authorization.IsGrantedAsync(BloggingPermissions.Comments.Update) || (CurrentUser.Id == commentWithRepliesDto.Comment.CreatorId))
{
<span class="seperator">|</span>
<a href="#" class="tag" data-updateid="@commentWithRepliesDto.Comment.Id">
<i class="fa fa-pencil" aria-hidden="true"></i> @L["Edit"]
</a>
}
</div>
<div class="comment-form mt-4 replyForm">
@ -159,6 +165,23 @@
</div>
</div>
</div>
@if (await Authorization.IsGrantedAsync(BloggingPermissions.Comments.Update) || (CurrentUser.Id == commentWithRepliesDto.Comment.CreatorId))
{
<div class="comment-form mt-4 editForm">
<div class="clearfix bg-light p-4">
<div>
<form class="editFormClass">
<input name="commentId" value="@commentWithRepliesDto.Comment.Id" hidden/>
<div class="form-group">
<textarea class="form-control no-border" name="text" id="textBoxId" rows="4">@commentWithRepliesDto.Comment.Text</textarea>
</div>
<abp-button button-type="Primary" class="btn-rounded float-right" type="submit" text="@L["Submit"].Value"/>
</form>
</div>
</div>
</div>
}
@foreach (var reply in commentWithRepliesDto.Replies)
{
@ -167,23 +190,31 @@
<div class="media-body">
<h5 class="comment-owner">
Zlatan Ibrahimovic
<span class="float-right">@reply.CreationTime.ToString("dd/MM/yyyy hh/mm")</span>
<span class="float-right">@ConvertDatetimeToTimeAgo(reply.CreationTime)</span>
</h5>
<p>
<p id="@reply.Id">
@reply.Text
</p>
<div class="comment-buttons">
<a href="#" class="tag" data-relpyid="@commentWithRepliesDto.Comment.Id">
<i class="fa fa-reply" aria-hidden="true"></i> @L["Reply"]
</a>
<span class="seperator">|</span>
<a href="tag.html" class="tag">
<i class="fa fa-chevron-up" aria-hidden="true"></i><span class="count count-up">44</span>
</a>
<span class="seperator">|</span>
<a href="tag.html" class="tag">
<i class="fa fa-chevron-down" aria-hidden="true"></i><span class="count count-down">8</span>
</a>
@if (await Authorization.IsGrantedAsync(BloggingPermissions.Comments.Delete) || (CurrentUser.Id == commentWithRepliesDto.Comment.CreatorId))
{
<span class="seperator">|</span>
<a href="#" class="tag" data-deleteid="@reply.Id">
<i class="fa fa-trash" aria-hidden="true"></i> @L["Delete"]
</a>
}
@if (await Authorization.IsGrantedAsync(BloggingPermissions.Comments.Update) || (CurrentUser.Id == commentWithRepliesDto.Comment.CreatorId))
{
<span class="seperator">|</span>
<a href="#" class="tag" data-updateid="@reply.Id">
<i class="fa fa-pencil" aria-hidden="true"></i> @L["Edit"]
</a>
}
</div>
<div class="comment-form mt-4 replyForm">
@ -201,6 +232,23 @@
</div>
</div>
</div>
@if (await Authorization.IsGrantedAsync(BloggingPermissions.Comments.Update) || (CurrentUser.Id == commentWithRepliesDto.Comment.CreatorId))
{
<div class="comment-form mt-4 editForm">
<div class="clearfix bg-light p-4">
<div>
<form class="editFormClass">
<input name="commentId" value="@reply.Id" hidden/>
<div class="form-group">
<textarea class="form-control no-border" name="text" id="textBoxId" rows="4">@reply.Text</textarea>
</div>
<abp-button button-type="Primary" class="btn-rounded float-right" type="submit" text="@L["Submit"].Value"/>
</form>
</div>
</div>
</div>
}
</div>
</div>
}
@ -210,4 +258,4 @@
</div>
</div>
</div>
</div>
</div>

7
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);

4
modules/blogging/src/Volo.Blogging.Web/Pages/Blog/Posts/Edit.cshtml

@ -47,9 +47,9 @@
</div>
<div class="mt-3 d-flex flex-row-reverse">
<abp-button type="submit" form="edit-post-form" text="@L["Submit"].Value" icon="check" />
<abp-button button-type="Primary" type="submit" form="edit-post-form" text="@L["Submit"].Value" icon="check" />
<a asp-page="./Index" class="btn btn-default mr-2"><span>@L["Cancel"]</span></a>
<a asp-page="/Blog/Posts/Detail" asp-route-postUrl="@Model.Post.Url" asp-route-blogShortName="@Model.BlogShortName" class="btn btn-default mr-2"><span>@L["Cancel"]</span></a>
</div>
</div>

3
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; }

12
modules/blogging/src/Volo.Blogging.Web/Pages/Blog/Posts/Index.cshtml

@ -46,7 +46,7 @@
<p class="tags">
@foreach (var tag in post.Tags)
{
<a asp-page="/Blog/Tags/Posts" asp-route-blogShortName="@Model.BlogShortName" asp-route-tagName="@tag.Name" class="tag">@tag.Name</a>
<a asp-page="/Blog/Posts/Index" asp-route-blogShortName="@Model.BlogShortName" asp-route-tagName="@tag.Name" class="tag">@tag.Name</a>
}
</p>
<h2>
@ -65,7 +65,7 @@
<img src="https://placeimg.com/120/120/people" class="article-avatar">
</a>
<a href="#">
<strong>Armağan Ünlü</strong>, @((DateTime.Today - post.CreationTime).Days) @L["DaysAgo"]
<strong>Armağan Ünlü</strong>, @ConvertDatetimeToTimeAgo(post.CreationTime)
</a>
<span class="seperator">|</span>
<a href="#">
@ -132,7 +132,7 @@
<div class="article-infos">
<div class="user-card">
<a href="#">
<strong>Armağan Ünlü</strong>, @((DateTime.Today - post.CreationTime).Days) @L["DaysAgo"]
<strong>Armağan Ünlü</strong>, @ConvertDatetimeToTimeAgo(post.CreationTime)
</a>
</div>
</div>
@ -188,7 +188,7 @@
<p class="tags">
@foreach (var tag in post.Tags)
{
<a asp-page="/Blog/Tags/Posts" asp-route-blogShortName="@Model.BlogShortName" asp-route-tagName="@tag.Name" class="tag">@tag.Name</a>
<a asp-page="/Blog/Posts/Index" asp-route-blogShortName="@Model.BlogShortName" asp-route-tagName="@tag.Name" class="tag">@tag.Name</a>
}
</p>
<h3>
@ -204,7 +204,7 @@
<img src="https://placeimg.com/120/120/pople" class="article-avatar">
</a>
<a href="#">
<strong>Armağan Ünlü</strong>, @((DateTime.Today - post.CreationTime).Days) @L["DaysAgo"]
<strong>Armağan Ünlü</strong>, @ConvertDatetimeToTimeAgo(post.CreationTime)
</a>
<span class="seperator">|</span>
<a href="#">
@ -234,7 +234,7 @@
<div class="popular-tags">
@foreach (var popularTag in Model.PopularTags)
{
<a asp-page="/Blog/Tags/Posts" asp-route-blogShortName="@Model.BlogShortName" asp-route-tagName="@popularTag.Name">@popularTag.Name <span>(@popularTag.UsageCount @L["Posts"])</span></a>
<a asp-page="/Blog/Posts/Index" asp-route-blogShortName="@Model.BlogShortName" asp-route-tagName="@popularTag.Name">@popularTag.Name <span>(@popularTag.UsageCount @L["Posts"])</span></a>
}
</div>

5
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<PostWithDetailsDto> Posts { get; set; }
public IReadOnlyList<TagDto> 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}));
}
}

2
modules/blogging/src/Volo.Blogging.Web/Pages/Blog/Posts/New.cshtml

@ -47,7 +47,7 @@
</div>
<div class="mt-3 d-flex flex-row-reverse">
<abp-button type="submit" form="new-post-form" text="@L["Submit"].Value" icon="check" />
<abp-button button-type="Primary" type="submit" form="new-post-form" text="@L["Submit"].Value" icon="check" />
<a asp-page="./Index" class="btn btn-default mr-2"><span>@L["Cancel"]</span></a>
</div>

74
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);

2
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']");

6
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);
});

93
modules/blogging/src/Volo.Blogging.Web/Pages/Blog/Tags/Posts.cshtml

@ -1,93 +0,0 @@
@page
@inherits Volo.Blogging.Pages.Blog.BloggingPage
@using Volo.Blogging.Pages.Blog.Tags
@model PostsModel
@{
}
@section scripts {
<abp-script-bundle name="@typeof(PostsModel).FullName">
<abp-script src="/Pages/Blog/Shared/Scripts/blog.js" />
</abp-script-bundle>
}
@section styles {
<abp-style-bundle name="@typeof(PostsModel).FullName">
<abp-style src="/Pages/Blog/Shared/Styles/blog.css" />
</abp-style-bundle>
}
<div class="container last-post-section pb-5">
<div class="row">
<div class="col-md-8">
<div class="row">
<div class="col">
<div class="titline">
<h2>#@Model.TagName</h2>
</div>
</div>
</div>
@for (var index = 0; index < Model.Posts.Count; index++)
{
var post = Model.Posts[index];
var oddPost = index % 2 == 1;
<section class="box-articles">
<div class="row @(oddPost?"align-middle":"")">
<div class="col-md-4 order-md-@(oddPost?"last":"first")">
<div class="img-container">
<a asp-page="/Blog/Posts/Detail" asp-route-postUrl="@post.Url" asp-route-blogShortName="@Model.BlogShortName">
<img src="https://placeimg.com/480/270/tech" class="box-article-img">
</a>
<div class="user-link-icons">
<a class="add-bookmark" href="#">
<i class="fa fa-bookmark"></i>
</a>
<a class="share-article" href="#">
<i class="fa fa-share-alt"></i>
</a>
</div>
</div>
</div>
<div class="col-md-8 order-md-@(oddPost?"first":"last")">
<p class="tags">
@foreach (var tag in post.Tags)
{
<a asp-page="/Blog/Tags/Posts" asp-route-blogShortName="@Model.BlogShortName" asp-route-tagName="@tag.Name" class="tag">@tag.Name</a>
}
</p>
<h3>
<a asp-page="/Blog/Posts/Detail" asp-route-postUrl="@post.Url" asp-route-blogShortName="@Model.BlogShortName">@post.Title</a>
</h3>
<p>
@(post.Content == null ? "" : (post.Content.Length > 250 ? post.Content.Substring(0, 150) : post.Content))...
</p>
<div class="article-owner">
<div class="article-infos">
<div class="user-card">
<a href="#">
<img src="https://placeimg.com/120/120/pople" class="article-avatar">
</a>
<a href="#">
<strong>Armağan Ünlü</strong>, @((DateTime.Today - post.CreationTime).Days) @L["DaysAgo"]
</a>
<span class="seperator">|</span>
<a href="#">
<i class="fa fa-eye"></i> @post.ReadCount
</a>
<span class="seperator">|</span>
<a href="#">
<i class="fa fa-comment"></i> @post.CommentCount
</a>
</div>
</div>
</div>
</div>
</div>
</section>
}
</div>
</div>
</div>

34
modules/blogging/src/Volo.Blogging.Web/Pages/Blog/Tags/Posts.cshtml.cs

@ -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<PostWithDetailsDto> 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;
}
}
}
Loading…
Cancel
Save