#440 display a suggested photo in poets' home pages

This commit is contained in:
Hamid Reza Mohammadi 2024-05-04 17:42:13 +03:30
parent 389ddd5c34
commit abf260803f
2 changed files with 64 additions and 1 deletions

View File

@ -5,6 +5,7 @@ using Microsoft.AspNetCore.Mvc.ModelBinding;
using Microsoft.AspNetCore.Mvc.ViewFeatures;
using Microsoft.Extensions.Caching.Memory;
using Microsoft.Extensions.Configuration;
using NAudio.Gui;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using RMuseum.Models.Ganjoor;
@ -627,6 +628,8 @@ namespace GanjooRazor.Pages
}
}
public GanjoorPoetSuggestedPictureViewModel Photo { get; set; }
/// <summary>
/// Get
/// </summary>
@ -737,6 +740,21 @@ namespace GanjooRazor.Pages
CategoryHasRecitations = JsonConvert.DeserializeObject<bool>(await catHasAnyRecitationQuery.Content.ReadAsStringAsync());
}
if(IsPoetPage)
{
var responsePhotos = await _httpClient.GetAsync($"{APIRoot.Url}/api/poetphotos/poet/{GanjoorPage.PoetOrCat.Poet.Id}");
if (!responsePhotos.IsSuccessStatusCode)
{
LastError = JsonConvert.DeserializeObject<string>(await responsePhotos.Content.ReadAsStringAsync());
return Page();
}
var photos = JArray.Parse(await responsePhotos.Content.ReadAsStringAsync()).ToObject<List<GanjoorPoetSuggestedPictureViewModel>>();
if(photos.Any())
{
Photo = photos.First();
}
}
if (IsPoemPage)
{
HtmlLanguage = string.IsNullOrEmpty(GanjoorPage.Poem.Language) ? "fa-IR" : GanjoorPage.Poem.Language;

View File

@ -292,7 +292,7 @@
{
@($"[{poemGeoTag.Location.Latitude},{poemGeoTag.Location.Longitude}],")
}
]).addTo(map);
]).addTo(map);
for (var i = 0; i < poemGeoTags.length; i++) {
var poemGeoTag = poemGeoTags[i];
@ -402,6 +402,51 @@
</div>
}
@if (Model.IsPoetPage)
{
<div class="related-images-frame" id="photos-section">
<div class="century">
تصویر چهره <a role="button" class="w3tooltip cursor-pointer" onclick="switch_section('face-photo', 'face-photo-collapse-button')"><i class="info-buttons collapse_circle_down" id="face-photo-collapse-button"></i><span class="w3tooltiptext">جمع شود / باز شود</span></a>
</div>
<div id="face-photo">
@if (Model.Photo == null)
{
<div class="part-title-block-alt" id="photos">
<a href="/photos?p=@Model.GanjoorPage.PoetOrCat.Cat.UrlSlug">پیشنهاد تصویر چهره برای @Model.GanjoorPage.PoetOrCat.Poet.Nickname</a>
</div>
}
else
{
<div class="ganjoor-comment">
<div class="century">
@Model.Photo.Title
@if (Model.Photo.ChosenOne)
{
<i class="noindent-info-button done-icon"></i>
}
</div>
<div class="clear-both">
<img src="@Html.Raw(Model.Photo.ExternalNormalSizeImageUrl.Replace("/norm/", "/orig/"))" alt="@Model.Photo.Title" class="max-width-100per" />
</div>
<div class="comments-like-div">
@Html.Raw(Model.Photo.Description)
</div>
<div class="part-title-block-alt" id="photos">
<a href="/photos?p=@Model.GanjoorPage.PoetOrCat.Cat.UrlSlug">مشاهده و پیشنهاد تصاویر چهره برای @Model.GanjoorPage.PoetOrCat.Poet.Nickname</a>
</div>
</div>
}
</div>
</div>
}
@if (Model.CanEdit && !Model.IsPoemPage)
{
<div class="spacer">&nbsp;</div>