From 14374ffc8e7de4cbbfe1a11be9399b8ee9f6bca5 Mon Sep 17 00:00:00 2001 From: Hamid Reza Mohammadi Date: Sun, 10 Apr 2022 20:52:54 +0430 Subject: [PATCH] docs: #306 adding HtmlText and PlainText to GanjoorPoemSection model and filling and using them --- RMuseum/Models/Ganjoor/GanjoorPoemSection.cs | 10 +++++++ RMuseum/Models/Ganjoor/GanjoorVerse.cs | 5 ++++ .../Models/Ganjoor/VersePoemSectionType.cs | 1 + RMuseum/RMuseum.xml | 15 +++++++++++ .../GanjoorService-PoemSections.cs | 27 +++++++++++++++---- .../Services/Implementation/GanjoorService.cs | 5 ++-- 6 files changed, 55 insertions(+), 8 deletions(-) diff --git a/RMuseum/Models/Ganjoor/GanjoorPoemSection.cs b/RMuseum/Models/Ganjoor/GanjoorPoemSection.cs index 2f0b5ec6..ca99141d 100644 --- a/RMuseum/Models/Ganjoor/GanjoorPoemSection.cs +++ b/RMuseum/Models/Ganjoor/GanjoorPoemSection.cs @@ -67,5 +67,15 @@ /// rhyme letters /// public string RhymeLetters { get; set; } + + /// + /// verses text + /// + public string PlainText { get; set; } + + /// + /// verses text as html (ganjoor.net format) + /// + public string HtmlText { get; set; } } } diff --git a/RMuseum/Models/Ganjoor/GanjoorVerse.cs b/RMuseum/Models/Ganjoor/GanjoorVerse.cs index b34707f5..8d95da14 100644 --- a/RMuseum/Models/Ganjoor/GanjoorVerse.cs +++ b/RMuseum/Models/Ganjoor/GanjoorVerse.cs @@ -55,6 +55,11 @@ /// public int? ThirdSectionIndex { get; set; } + /// + /// forth GanjoorPoemSection index + /// + public int? ForthSectionIndex { get; set; } + public override string ToString() { return Text; diff --git a/RMuseum/Models/Ganjoor/VersePoemSectionType.cs b/RMuseum/Models/Ganjoor/VersePoemSectionType.cs index 0590c075..ebd1a8ea 100644 --- a/RMuseum/Models/Ganjoor/VersePoemSectionType.cs +++ b/RMuseum/Models/Ganjoor/VersePoemSectionType.cs @@ -8,5 +8,6 @@ First = 1, Second = 2, Third = 3, + Forth = 4 } } diff --git a/RMuseum/RMuseum.xml b/RMuseum/RMuseum.xml index d8a1b9e5..78a4d0bd 100644 --- a/RMuseum/RMuseum.xml +++ b/RMuseum/RMuseum.xml @@ -6814,6 +6814,16 @@ rhyme letters + + + verses text + + + + + verses text as html (ganjoor.net format) + + poem translation @@ -7256,6 +7266,11 @@ third GanjoorPoemSection index + + + forth GanjoorPoemSection index + + id diff --git a/RMuseum/Services/Implementation/GanjoorService-Partials/GanjoorService-PoemSections.cs b/RMuseum/Services/Implementation/GanjoorService-Partials/GanjoorService-PoemSections.cs index 38392809..b4ab7791 100644 --- a/RMuseum/Services/Implementation/GanjoorService-Partials/GanjoorService-PoemSections.cs +++ b/RMuseum/Services/Implementation/GanjoorService-Partials/GanjoorService-PoemSections.cs @@ -6,7 +6,6 @@ using RSecurityBackend.Services.Implementation; using System; using System.Data; using System.Linq; -using System.Threading.Tasks; using System.Collections.Generic; namespace RMuseum.Services.Implementation @@ -92,7 +91,9 @@ namespace RMuseum.Services.Implementation Index = sectionIndex, Number = sectionIndex + 1, GanjoorMetreId = poem.GanjoorMetreId, - RhymeLetters = poem.RhymeLetters + RhymeLetters = poem.RhymeLetters, + HtmlText = PrepareHtmlText(singleVerses), + PlainText = PreparePlainText(singleVerses) }; context.Add(mainSection);//having a main section for مثنوی inside normal text helps keep track of related versess foreach (var verse in singleVerses) @@ -156,7 +157,9 @@ namespace RMuseum.Services.Implementation Index = sectionIndex, Number = sectionIndex + 1, GanjoorMetreId = poem.GanjoorMetreId, - RhymeLetters = poem.RhymeLetters + RhymeLetters = poem.RhymeLetters, + HtmlText = PrepareHtmlText(singleVerses), + PlainText = PreparePlainText(singleVerses) }; context.Add(mainSection);//having a main section for مثنوی inside normal text helps keep track of related versess foreach (var verse in singleVerses) @@ -250,7 +253,9 @@ namespace RMuseum.Services.Implementation Index = index, Number = index + 1, GanjoorMetreId = poem.GanjoorMetreId, - RhymeLetters = poem.RhymeLetters + RhymeLetters = poem.RhymeLetters, + HtmlText = PrepareHtmlText(nonCommentVerses), + PlainText = PreparePlainText(nonCommentVerses) }; context.Add(mainSection); index++; @@ -286,6 +291,8 @@ namespace RMuseum.Services.Implementation currentBandVerse.SecondSectionIndex = currentBandSection.Index; } currentBandSection.RhymeLetters = LanguageUtils.FindRhyme(currentBandVerses).Rhyme; + currentBandSection.HtmlText = PrepareHtmlText(currentBandVerses); + currentBandSection.PlainText = PreparePlainText(currentBandVerses); context.Add(currentBandSection); index++; @@ -311,6 +318,8 @@ namespace RMuseum.Services.Implementation currentBandVerse.SecondSectionIndex = currentBandSection.Index; } currentBandSection.RhymeLetters = LanguageUtils.FindRhyme(currentBandVerses).Rhyme; + currentBandSection.HtmlText = PrepareHtmlText(currentBandVerses); + currentBandSection.PlainText = PreparePlainText(currentBandVerses); context.Add(currentBandSection); } index++; @@ -329,6 +338,8 @@ namespace RMuseum.Services.Implementation bandVerse.SecondSectionIndex = bandSection.Index; } bandSection.RhymeLetters = LanguageUtils.FindRhyme(bandVerses).Rhyme; + bandSection.HtmlText = PrepareHtmlText(bandVerses); + bandSection.PlainText = PreparePlainText(bandVerses); context.Add(bandSection); context.UpdateRange(nonCommentVerses); } @@ -345,7 +356,9 @@ namespace RMuseum.Services.Implementation Index = index, Number = index + 1, GanjoorMetreId = poem.GanjoorMetreId, - RhymeLetters = poem.RhymeLetters + RhymeLetters = poem.RhymeLetters, + HtmlText = PrepareHtmlText(nonCommentVerses), + PlainText = PreparePlainText(nonCommentVerses) }; //checking for مثنوی phase 1 if (string.IsNullOrEmpty(poem.RhymeLetters)) @@ -391,6 +404,10 @@ namespace RMuseum.Services.Implementation rightVerse.SecondSectionIndex = verseSection.Index; leftVerse.SecondSectionIndex = verseSection.Index; + var rl = new List();rl.Add(rightVerse);rl.Add(leftVerse); + verseSection.HtmlText = PrepareHtmlText(rl); + verseSection.PlainText = PreparePlainText(rl); + context.Add(verseSection); } } diff --git a/RMuseum/Services/Implementation/GanjoorService.cs b/RMuseum/Services/Implementation/GanjoorService.cs index 6016d457..5b882465 100644 --- a/RMuseum/Services/Implementation/GanjoorService.cs +++ b/RMuseum/Services/Implementation/GanjoorService.cs @@ -2244,8 +2244,8 @@ namespace RMuseum.Services.Implementation FullTitle = section.Poem.FullTitle, FullUrl = section.Poem.FullUrl, UrlSlug = section.Poem.UrlSlug, - HtmlText = section.Poem.HtmlText, - PlainText = section.Poem.PlainText, + HtmlText = section.HtmlText, + PlainText = section.PlainText, GanjoorMetre = section.GanjoorMetre, RhymeLetters = section.RhymeLetters, MixedModeOrder = section.Poem.MixedModeOrder, @@ -2283,7 +2283,6 @@ namespace RMuseum.Services.Implementation item.Category = poet; } - } return new RServiceResult<(PaginationMetadata PagingMeta, GanjoorPoemCompleteViewModel[] Items)>(paginatedResult);