mirror of https://github.com/abpframework/abp.git
22 changed files with 322 additions and 195 deletions
@ -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,25 +1,81 @@ |
|||||
(function ($) { |
(function ($) { |
||||
|
|
||||
$('div .replyForm').hide(); |
$('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) { |
$('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; |
return; |
||||
} |
} |
||||
|
|
||||
event.preventDefault(); |
data = $(this).attr('data-deleteid'); |
||||
|
|
||||
|
if (data != '' && data !== undefined) { |
||||
|
|
||||
var div = $(this).parent().next(); |
event.preventDefault(); |
||||
|
|
||||
if (div.is(":hidden")) { |
$.ajax({ |
||||
$('div .replyForm').hide(); |
type: "POST", |
||||
div.show(); |
url: "/Blog/Comments/Delete", |
||||
} else { |
data: { id: data }, |
||||
div.hide(); |
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); |
})(jQuery); |
||||
|
|||||
@ -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> |
|
||||
@ -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…
Reference in new issue