diff --git a/GanjooRazor/Areas/Admin/Pages/ModifyPage.cshtml b/GanjooRazor/Areas/Admin/Pages/ModifyPage.cshtml index 465e062f..12465911 100644 --- a/GanjooRazor/Areas/Admin/Pages/ModifyPage.cshtml +++ b/GanjooRazor/Areas/Admin/Pages/ModifyPage.cshtml @@ -149,7 +149,7 @@ } - @if (Model.PageInformation.GanjoorPageType == RMuseum.Models.Ganjoor.GanjoorPageType.CatPage || Model.PageInformation.GanjoorPageType == RMuseum.Models.Ganjoor.GanjoorPageType.PoetPage ) + @if (Model.PageInformation.GanjoorPageType == RMuseum.Models.Ganjoor.GanjoorPageType.CatPage || Model.PageInformation.GanjoorPageType == RMuseum.Models.Ganjoor.GanjoorPageType.PoetPage) { @@ -179,6 +179,9 @@ + + + @@ -270,6 +273,9 @@ + + + diff --git a/RMuseum/Models/Ganjoor/GanjoorTOC.cs b/RMuseum/Models/Ganjoor/GanjoorTOC.cs index c7864501..1a8e4c99 100644 --- a/RMuseum/Models/Ganjoor/GanjoorTOC.cs +++ b/RMuseum/Models/Ganjoor/GanjoorTOC.cs @@ -15,5 +15,8 @@ TitlesAndFirstCouplet = 7, TitlesAndFirstCenteredVerse = 8, TitlesAndFirstCenteredCouplet = 9, + AlphabeticWithFirstVerseNotSorted = 10, + AlphabeticWithSecondVerseNotSorted = 11, + AlphabeticWithFirstCoupletNotSorted = 12, } } diff --git a/RMuseum/Services/Implementation/GanjoorService-Partials/GanjoorService-TOC.cs b/RMuseum/Services/Implementation/GanjoorService-Partials/GanjoorService-TOC.cs index c295113c..26b6c587 100644 --- a/RMuseum/Services/Implementation/GanjoorService-Partials/GanjoorService-TOC.cs +++ b/RMuseum/Services/Implementation/GanjoorService-Partials/GanjoorService-TOC.cs @@ -132,7 +132,7 @@ namespace RMuseum.Services.Implementation if (verses.Length > 0) { - if (options == GanjoorTOC.TitlesAndFirstVerse || options == GanjoorTOC.AlphabeticWithFirstVerse) + if (options == GanjoorTOC.TitlesAndFirstVerse || options == GanjoorTOC.AlphabeticWithFirstVerse || options == GanjoorTOC.AlphabeticWithFirstVerseNotSorted) { var excerpt = verses[0].Text; if ( @@ -158,7 +158,7 @@ namespace RMuseum.Services.Implementation title += $": {excerpt}"; } else - if (options == GanjoorTOC.AlphabeticWithSecondVerse || options == GanjoorTOC.TitlesAndSecondVerse) + if (options == GanjoorTOC.AlphabeticWithSecondVerse || options == GanjoorTOC.AlphabeticWithSecondVerseNotSorted || options == GanjoorTOC.TitlesAndSecondVerse) { if (verses.Length > 1) { @@ -170,7 +170,7 @@ namespace RMuseum.Services.Implementation } } else - if (options == GanjoorTOC.AlphabeticWithFirstCouplet || options == GanjoorTOC.TitlesAndFirstCouplet) + if (options == GanjoorTOC.AlphabeticWithFirstCouplet || options == GanjoorTOC.AlphabeticWithFirstCoupletNotSorted || options == GanjoorTOC.TitlesAndFirstCouplet) { if (verses.Length > 1) { @@ -372,6 +372,12 @@ namespace RMuseum.Services.Implementation options == GanjoorTOC.AlphabeticWithFirstVerse || options == GanjoorTOC.AlphabeticWithSecondVerse + || + options == GanjoorTOC.AlphabeticWithFirstCoupletNotSorted + || + options == GanjoorTOC.AlphabeticWithFirstVerseNotSorted + || + options == GanjoorTOC.AlphabeticWithSecondVerseNotSorted ) { var taggedPoems = poems.Where(p => !string.IsNullOrEmpty(p.RhymeLetters)).ToArray(); @@ -383,8 +389,8 @@ namespace RMuseum.Services.Implementation var randomPoemVerses = await context.GanjoorVerses.AsNoTracking().Where(p => p.PoemId == randomPoem.Id).OrderBy(v => v.VOrder).ToArrayAsync(); if (randomPoemVerses.Length > 1) { - string versePosition = options == GanjoorTOC.AlphabeticWithFirstVerse ? "اول" : "دوم"; - string sampleVerse = options == GanjoorTOC.AlphabeticWithFirstVerse ? randomPoemVerses[0].Text : randomPoemVerses[1].Text; + string versePosition = options == GanjoorTOC.AlphabeticWithFirstVerse || options == GanjoorTOC.AlphabeticWithFirstVerseNotSorted ? "اول" : "دوم"; + string sampleVerse = options == GanjoorTOC.AlphabeticWithFirstVerse || options == GanjoorTOC.AlphabeticWithFirstVerseNotSorted ? randomPoemVerses[0].Text : randomPoemVerses[1].Text; html += $"

مثلاً برای پیدا کردن شعری که مصرع «{sampleVerse}» مصرع {versePosition} یکی از بیتهای آن است باید شعرهایی را نگاه کنید که آخر حرف قافیهٔ آنها «{randomPoem.RhymeLetters.Substring(randomPoem.RhymeLetters.Length - 1)}» است.

{Environment.NewLine}"; } @@ -406,16 +412,26 @@ namespace RMuseum.Services.Implementation } } } - var fa = new CultureInfo("fa-IR"); - if (foundLastChars.Contains("و") && foundLastChars.Contains("ی") && foundLastChars.IndexOf("ه") == (foundLastChars.IndexOf("و") - 1)) + if( + options == GanjoorTOC.AlphabeticWithFirstCouplet + || + options == GanjoorTOC.AlphabeticWithFirstVerse + || + options == GanjoorTOC.AlphabeticWithSecondVerse + ) { - foundLastChars.Sort((a, b) => a == "ه" && b == "و" ? -1 : a == "و" && b == "ه" ? 1 : fa.CompareInfo.Compare(a, b)); - } - else - { - foundLastChars.Sort((a, b) => fa.CompareInfo.Compare(a, b)); + var fa = new CultureInfo("fa-IR"); + if (foundLastChars.Contains("و") && foundLastChars.Contains("ی") && foundLastChars.IndexOf("ه") == (foundLastChars.IndexOf("و") - 1)) + { + foundLastChars.Sort((a, b) => a == "ه" && b == "و" ? -1 : a == "و" && b == "ه" ? 1 : fa.CompareInfo.Compare(a, b)); + } + else + { + foundLastChars.Sort((a, b) => fa.CompareInfo.Compare(a, b)); + } } + foreach (var poemLastChar in foundLastChars) { string rep = poemLastChar == "ا" ? "الف" : poemLastChar; @@ -449,9 +465,14 @@ namespace RMuseum.Services.Implementation options == GanjoorTOC.AlphabeticWithFirstVerse || options == GanjoorTOC.AlphabeticWithSecondVerse + || + options == GanjoorTOC.AlphabeticWithFirstCoupletNotSorted + || + options == GanjoorTOC.AlphabeticWithFirstVerseNotSorted + || + options == GanjoorTOC.AlphabeticWithSecondVerseNotSorted ) { - if (!string.IsNullOrEmpty(poem.RhymeLetters)) { string poemLast = poem.RhymeLetters.Substring(poem.RhymeLetters.Length - 1);