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

105 lines
3.9 KiB
Text
Raw Normal View History

2017-10-04 23:53:47 +02:00
@model BlogPost
@{
ViewData["Title"]=Model.Title;
}
2024-12-14 20:21:41 +00:00
@section scripts {
2017-10-20 15:14:16 +02:00
<script src="~/js/comment.js" asp-append-version="true"></script>
2017-10-04 23:53:47 +02:00
<script>
2017-10-10 20:50:05 +02:00
$.psc.blogcomment.prototype.options.lang = '@System.Globalization.CultureInfo.CurrentUICulture.Name';
2024-12-15 13:53:30 +00:00
$.psc.blogcomment.prototype.options.apictrlr = '/api/blogcomments';
2017-10-20 15:14:16 +02:00
$.psc.blogcomment.prototype.options.authorId = '@User.GetUserId()';
$.psc.blogcomment.prototype.options.authorName = '@User.GetUserName()';
2017-10-04 23:53:47 +02:00
$(document).ready(function() {
$('#cmtBtn').click(function() {
$.ajax({
async: true,
cache: false,
type: 'POST',
method: 'POST',
contentType: "application/json",
2024-12-14 20:21:41 +00:00
data: JSON.stringify({
2026-02-22 19:59:33 +00:00
Article: $('#Comment').val(),
2024-12-14 20:21:41 +00:00
ReceiverId: @Model.Id
}),
2017-10-04 23:53:47 +02:00
error: function(xhr,data) {
if (xhr.status=400)
{
2024-12-14 20:21:41 +00:00
if (xhr.responseJSON)
{
$('#commentValidation').html(
2026-02-22 19:59:33 +00:00
xhr.responseJSON.Article);
2024-12-14 20:21:41 +00:00
} else {
$('#commentValidation').html(
2017-10-04 23:53:47 +02:00
"Une erreur est survenue : "+xhr.status+"<br/>"+
"<code><pre>"+xhr.responseText+"</pre></code>"
2024-12-14 20:21:41 +00:00
)
}
2017-10-04 23:53:47 +02:00
}
},
2017-10-10 20:50:05 +02:00
success: function (data) {
var comment = $('#Comment').val();
$('#Comment').val('');
2024-12-14 20:21:41 +00:00
$('#commentValidation').empty();
2024-12-15 13:53:30 +00:00
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()">'+comment+'</div>';
2017-10-10 20:50:05 +02:00
$('#comments').append($(nnode).blogcomment())
2017-10-04 23:53:47 +02:00
},
2024-12-15 13:53:30 +00:00
url:'/api/blogcomments'
2017-10-04 23:53:47 +02:00
});
});
})
</script>
2017-10-10 20:50:05 +02:00
<style>
2017-10-20 15:14:16 +02:00
.avatar, .commentmeta, .blogcomment p , .subcomments {
2017-10-10 20:50:05 +02:00
display: inline-block;
}
2017-10-20 15:14:16 +02:00
.blogcomment {
display: inline-block;
margin:.3em;
}
2017-10-10 20:50:05 +02:00
</style>
2017-10-04 23:53:47 +02:00
}
2025-07-10 08:38:38 +01:00
<div class="post">
<div class="float-left">
2025-09-14 02:42:08 +01:00
<img class="photo" src="@Model.Photo" >
2025-07-10 08:38:38 +01:00
</div>
<h1 ismarkdown>@Model.Title</h1>
2024-12-03 01:44:58 +00:00
@Html.DisplayFor(m=>m.Author)
2026-02-22 19:59:33 +00:00
<asciidoc>@Html.DisplayFor(m=>m.Article)</asciidoc>
2024-12-15 20:48:04 +00:00
2024-12-03 01:44:58 +00:00
</div>
2017-10-20 15:14:16 +02:00
2024-12-03 01:44:58 +00:00
<div id="comments">
@if (Model.Comments!=null) {
foreach (var comment in Model.Comments.Where(c=>c.ParentId==null)) {
2024-12-15 20:48:04 +00:00
@await Component.InvokeAsync("Comment", new { id = comment.Id })
2024-12-03 01:44:58 +00:00
}
2017-10-20 15:14:16 +02:00
}
2024-12-03 01:44:58 +00:00
</div>
2017-10-20 15:14:16 +02:00
@if (User.GetUserId()!=null) {
2017-10-04 23:53:47 +02:00
<div class="form-horizontal">
<div class="input-group" >
2024-12-14 23:49:13 +00:00
<input name="Comment" id="Comment" class="form-control" placeholder="..."/>
2017-10-04 23:53:47 +02:00
<span class="input-group-btn">
2024-12-14 20:21:41 +00:00
<span id="commentValidation"></span>
2024-12-14 23:49:13 +00:00
<input type="button" value="Comment" class="btn btn-secondary"
2024-12-14 20:21:41 +00:00
data-receiverId="@Model.Id" id="cmtBtn"
2017-10-04 23:53:47 +02:00
/>
</span>
</div>
2026-02-22 19:59:33 +00:00
<span asp-validation-for="Article" class="text-danger" ></span>
2017-10-04 23:53:47 +02:00
</div>
2017-10-20 15:14:16 +02:00
}
else {
<p><i>Vous devez être identifié pour commenter.</i> </p>
}
2024-12-03 01:44:58 +00:00
@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>
2025-07-10 08:38:38 +01:00