docs: #310 displaying similar poems for couplets

This commit is contained in:
Hamid Reza Mohammadi 2022-05-01 20:40:04 +04:30
parent 9a950dd92e
commit 8ebe4d1f32
5 changed files with 49 additions and 4 deletions

View File

@ -786,6 +786,13 @@ namespace GanjooRazor.Pages
}
var numbers = JArray.Parse(await responseCoupletNumbers.Content.ReadAsStringAsync()).ToObject<List<GanjoorCoupletNumberViewModel>>();
var responseCoupletSections = await _httpClient.GetAsync($"{APIRoot.Url}/api/ganjoor/couplet/{poemId}/{coupletIndex}/sections");
if(!responseCoupletSections.IsSuccessStatusCode)
{
return BadRequest(JsonConvert.DeserializeObject<string>(await responseCoupletSections.Content.ReadAsStringAsync()));
}
var sections = JArray.Parse(await responseCoupletSections.Content.ReadAsStringAsync()).ToObject<List<GanjoorPoemSection>>();
bool isBookmarked = false;
if (!string.IsNullOrEmpty(Request.Cookies["UserId"]))
@ -827,7 +834,9 @@ namespace GanjooRazor.Pages
LoggedIn = !string.IsNullOrEmpty(Request.Cookies["Token"]),
Comments = comments,
IsBookmarked = isBookmarked,
Numbers = numbers
Numbers = numbers,
Sections = sections,
SectionsWithMetreAndRhymes = sections.Where(s => s.GanjoorMetreId != null && !string.IsNullOrEmpty(s.RhymeLetters) && s.SectionType != RMuseum.Models.Ganjoor.PoemSectionType.WholePoem).ToList(),
}
}
};

View File

@ -52,6 +52,20 @@
<a role="button" id="bookmark-@Model.CoupletIndex" class="cursor-pointer" onclick="switchBookmark(@Model.PoemId, @Model.CoupletIndex)" title="@Model.BookmarkingText"><i class="material-icons color-white" id="bookmark-icon-@Model.CoupletIndex">@Model.BookmarkingIcon</i></a>
<a role="button" id="listen-@Model.CoupletIndex" class="cursor-pointer" onclick="editCouplet(@Model.PoemId, @Model.CoupletIndex)" title="ویرایش از اینجا"><i class="material-icons color-white">edit</i></a>
}
@if (Model.SectionsWithMetreAndRhymes.Any())
{
<text>
<a role="button" class="pagebutton" href="@Html.Raw($"/simi/?v={Uri.EscapeDataString(Model.SectionsWithMetreAndRhymes.First().GanjoorMetre.Rhythm)}&amp;g={Uri.EscapeDataString(Model.SectionsWithMetreAndRhymes.First().RhymeLetters)}")">موارد هم آهنگ<i class="info-buttons rhyming-poems"></i></a>
</text>
@for (int nSectionIndex = 1; nSectionIndex < Model.SectionsWithMetreAndRhymes.Count; nSectionIndex++)
{
<text>
<a role="button" class="pagebutton" href="@Html.Raw($"/simi/?v={Uri.EscapeDataString(Model.SectionsWithMetreAndRhymes[nSectionIndex].GanjoorMetre.Rhythm)}&amp;g={Uri.EscapeDataString(Model.SectionsWithMetreAndRhymes[nSectionIndex].RhymeLetters)}")">موارد هم آهنگ (وزن @((nSectionIndex + 1).ToPersianNumbers()))<i class="info-buttons rhyming-poems"></i></a>
</text>
}
}
</div>

View File

@ -1,4 +1,5 @@
using Microsoft.AspNetCore.Mvc.RazorPages;
using RMuseum.Models.Ganjoor;
using RMuseum.Models.Ganjoor.ViewModels;
using System.Collections.Generic;
@ -58,6 +59,17 @@ namespace GanjooRazor.Pages
/// </summary>
public List<GanjoorCommentSummaryViewModel> Comments { get; set; }
/// <summary>
/// sections
/// </summary>
public List<GanjoorPoemSection> Sections { get; set; }
/// <summary>
/// a subset of sections
/// </summary>
public List<GanjoorPoemSection> SectionsWithMetreAndRhymes { get; set; }
public _CommentPartialModel GetCommentModel(GanjoorCommentSummaryViewModel comment)
{
return new _CommentPartialModel()

View File

@ -1689,10 +1689,12 @@
<param name="destCatId"></param>
<returns></returns>
</member>
<member name="M:RMuseum.Controllers.GanjoorController.StartFillingPoemSectionsCoupletIndex">
<member name="M:RMuseum.Controllers.GanjoorController.GetCoupletSectionsAsync(System.Int32,System.Int32)">
<summary>
sectionizing poems
get couplet sections
</summary>
<param name="poemId"></param>
<param name="coupletIndex"></param>
<returns></returns>
</member>
<member name="P:RMuseum.Controllers.GanjoorController.ReadOnlyMode">
@ -11996,6 +11998,14 @@
</summary>
<returns></returns>
</member>
<member name="M:RMuseum.Services.IGanjoorService.GetCoupletSectionsAsync(System.Int32,System.Int32)">
<summary>
get couplet sections
</summary>
<param name="poemId"></param>
<param name="coupletIndex"></param>
<returns></returns>
</member>
<member name="T:RMuseum.Services.IGanjoorTranslationService">
<summary>
translation service implementation

View File

@ -511,7 +511,7 @@ namespace RMuseum.Services.Implementation
/// <returns></returns>
public async Task<RServiceResult<GanjoorPoemSection[]>> GetCoupletSectionsAsync(int poemId, int coupletIndex)
{
var firstVerse = await _context.GanjoorVerses.AsNoTracking().Where(v => v.PoemId == poemId && v.CoupletIndex == coupletIndex).OrderBy(v => v.VOrder).SingleOrDefaultAsync();
var firstVerse = await _context.GanjoorVerses.AsNoTracking().Where(v => v.PoemId == poemId && v.CoupletIndex == coupletIndex).OrderBy(v => v.VOrder).FirstOrDefaultAsync();
if (firstVerse == null)
return new RServiceResult<GanjoorPoemSection[]>(null);//not found
try