yavsc/src/Yavsc/Views/Blogspot/Details.cshtml

104 lines
4.0 KiB
Plaintext

8 years ago
@model BlogPost
@{
ViewData["Title"]=Model.Title;
}
1 year ago
@section scripts {
<script src="~/js/comment.js" asp-append-version="true"></script>
8 years ago
<script>
8 years ago
$.psc.blogcomment.prototype.options.lang = '@System.Globalization.CultureInfo.CurrentUICulture.Name';
1 year ago
$.psc.blogcomment.prototype.options.apictrlr = '/api/blogcomments/PostComment';
$.psc.blogcomment.prototype.options.authorId = '@User.GetUserId()';
$.psc.blogcomment.prototype.options.authorName = '@User.GetUserName()';
8 years ago
$(document).ready(function() {
$('#cmtBtn').click(function() {
$.ajax({
async: true,
cache: false,
type: 'POST',
method: 'POST',
contentType: "application/json",
1 year ago
data: JSON.stringify({
Content: $('#Comment').val(),
ReceiverId: @Model.Id
}),
8 years ago
error: function(xhr,data) {
if (xhr.status=400)
{
1 year ago
if (xhr.responseJSON)
{
$('#commentValidation').html(
8 years ago
xhr.responseJSON.Content);
1 year ago
} else {
$('#commentValidation').html(
8 years ago
"Une erreur est survenue : "+xhr.status+"<br/>"+
"<code><pre>"+xhr.responseText+"</pre></code>"
1 year ago
)
}
8 years ago
}
},
8 years ago
success: function (data) {
var comment = $('#Comment').val();
$('#Comment').val('');
1 year ago
$('#commentValidation').empty();
8 years ago
var htmlcmt = htmlize(comment);
var nnode = '<div data-type="blogcomment" data-id="'+data.Id+'" data-allow-edit="True" data-allow-moderate="@ViewData["moderatoFlag"]" data-date="'+data.DateCreated+'" data-username="@User.GetUserName()">'+htmlcmt+'</div>';
$('#comments').append($(nnode).blogcomment())
8 years ago
},
url:'@ViewData["apicmtctlr"]'
});
});
})
</script>
8 years ago
<style>
.avatar, .commentmeta, .blogcomment p , .subcomments {
8 years ago
display: inline-block;
}
.blogcomment {
display: inline-block;
margin:.3em;
}
8 years ago
</style>
8 years ago
}
<div class="container">
<div class="blogpost">
<h1 class="blogtitle" ismarkdown>@Model.Title</h1>
<img class="blogphoto" alt="" src="@Model.Photo" >
@Html.DisplayFor(m=>m.Author)
@Html.DisplayFor(m=>m.Content)
</div>
<div id="comments">
@if (Model.Comments!=null) {
foreach (var comment in Model.Comments.Where(c=>c.ParentId==null)) {
@Html.DisplayFor(model=>comment,"Comment","Comment")
}
}
</div>
@if (User.GetUserId()!=null) {
8 years ago
<div class="form-horizontal">
<div class="input-group" >
1 year ago
<input name="Comment" id="Comment" class="form-control" placeholder="DoCommentPlaceHolder"]"/>
8 years ago
<span class="input-group-btn">
1 year ago
<span id="commentValidation"></span>
<input type="button" value="DoComment"]" class="btn btn-secondary"
1 year ago
data-receiverId="@Model.Id" id="cmtBtn"
8 years ago
/>
</span>
</div>
8 years ago
<span asp-validation-for="Content" class="text-danger" ></span>
8 years ago
</div>
}
else {
<p><i>Vous devez être identifié pour commenter.</i> </p>
}
@if ((await AuthorizationService.AuthorizeAsync(User, Model, new EditPermission())).Succeeded) {
<a asp-action="Edit" asp-route-id="@Model.Id" class="btn btn-link">Edit</a>
}
<a asp-action="Index" class="btn btn-link">Back to List</a>
</div>