mirror of
https://github.com/yawaflua/yaflay.ru.git
synced 2025-12-09 20:19:32 +02:00
98 lines
4.2 KiB
Plaintext
98 lines
4.2 KiB
Plaintext
@page "{id?}"
|
|
@model BlogModel
|
|
@using yawaflua.ru.Models.Tables
|
|
@using Newtonsoft.Json
|
|
@{
|
|
string path = $"{this.Request.Scheme}://{this.Request.Host}";
|
|
if (Model.Id != 0)
|
|
{
|
|
var request = await Startup.client.GetAsync(path + "/api/Blog/" + Model.Id);
|
|
Blogs? Post = JsonConvert.DeserializeObject<Blogs>(request.Content.ReadAsStringAsync().Result);
|
|
if (Post == null)
|
|
{
|
|
ViewData["Title"] = "Blogs";
|
|
<h1 align="center">Что-то не так...</h1>
|
|
<h1 align="center">Пост не найден, но ты держи яблочко -> 🍎</h1>
|
|
} else
|
|
{
|
|
ViewData["Title"] = Post.Title;
|
|
ViewData["og:title"] = Post.Title;
|
|
ViewData["og:url"] = this.Request.Host.Host + this.Request.Path.ToString();
|
|
ViewData["og:description"] = Post.Annotation;
|
|
ViewData["og:image"] = Post.ImageUrl;
|
|
|
|
<p align="left">
|
|
<h1 align="left">@Html.Raw(Post.Title)</h1>
|
|
<h5>@Post.dateTime</h5>
|
|
</p>
|
|
<div id="blogId" style="display:none;">@Model.Id</div>
|
|
<p align="center"><img src="@Post.ImageUrl" style="width:50vmax;"/></p>
|
|
<p align="center">@Html.Raw(Post.Text)</p>
|
|
string userUrl = "https://discord.com/users/" + Post.authorId;
|
|
<h6 align="left">Статья подготовлена <a href="@userUrl">@Post.authorNickname</a></h6>
|
|
<div class="container my-5 py-5 bg-dark text-muted">
|
|
<div class="row d-flex justify-content-center">
|
|
<div class="col-md-12 col-lg-10">
|
|
<div class="card text-muted bg-dark">
|
|
<div class="card-body position-static p-4" id="allComments">
|
|
<h4 class="mb-0" id="commentBar">Последние комментарии</h4>
|
|
|
|
<h1 align="center">Дальше тьма...</h1>
|
|
|
|
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
}
|
|
|
|
<div class="card-footer text-white bg-dark mb-3 py-3 border-0" >
|
|
<div class="d-flex flex-start w-100">
|
|
<div class="form-outline w-100">
|
|
<label for="userEmail" class="form-label">Адрес электронной почты</label>
|
|
<input type="email" class="form-control bg-dark text-white" id="userEmail" placeholder="name@example.com" name="userEmail">
|
|
<label for="commentText" class="form-label">Комментарий</label>
|
|
<input type="text" class="form-control bg-dark text-white" id="commentText" rows="4" name="commentText">
|
|
</div>
|
|
</div>
|
|
<div class="float-end mt-2 pt-1">
|
|
<button type="button" class="btn btn-primary btn-sm" id="postComment" >Запостить коммент</button>
|
|
</div>
|
|
</div>
|
|
|
|
|
|
}
|
|
|
|
else
|
|
{
|
|
ViewData["Title"] = "Blog";
|
|
var request = await Startup.client.GetAsync(path + "/api/Blog/");
|
|
Blogs[]? allBlogs = JsonConvert.DeserializeObject<Blogs[]>(request.Content.ReadAsStringAsync().Result);
|
|
if (allBlogs.Length == 0)
|
|
{
|
|
<p>
|
|
<h1 align="center">Ничего нет...</h1>
|
|
<h1 align="center">Вот вам банан -> 🍌</h1>
|
|
</p>
|
|
}
|
|
else
|
|
{
|
|
foreach (Blogs blog in allBlogs)
|
|
{
|
|
<div class="card text-white bg-dark mb-3 text-center" style="width: 18rem;">
|
|
<img src="@blog.ImageUrl" class="card-img-top" />
|
|
<div class="card-body ">
|
|
<h5 class="card-title">@Html.Raw(blog.Title)</h5>
|
|
<p class="card-text">@Html.Raw(blog.Annotation)</p>
|
|
<a href="/Blog/@blog.Id" class="btn btn-primary center">Читать</a>
|
|
</div>
|
|
</div>
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|