diff --git a/TajikGanjoor/Pages/Index.cshtml b/TajikGanjoor/Pages/Index.cshtml index 876fd761..c38f18fa 100644 --- a/TajikGanjoor/Pages/Index.cshtml +++ b/TajikGanjoor/Pages/Index.cshtml @@ -24,40 +24,9 @@

@poet.Nickname

} } - - @if (Model.IsPoetPage) + else { -

- @Model.GanjoorPage.PoetOrCat.Poet.Description -

- } - - @if (Model.IsCatPage && !string.IsNullOrEmpty(@Model.GanjoorPage.PoetOrCat.Cat.Description)) - { -

- @Model.GanjoorPage.PoetOrCat.Cat.Description -

- } - - @if (Model.IsPoetPage || Model.IsCatPage) - { - @foreach (var cat in Model.GanjoorPage.PoetOrCat.Cat.Children) - { -

- @cat.Title -

- } - @foreach (var poem in Model.GanjoorPage.PoetOrCat.Cat.Poems) - { -

- @poem.Title -

- } - } - - @if(Model.IsPoemPage) - { - @Html.Raw(Model.HtmlText) + @Html.Raw(Model.GanjoorPage.HtmlText) } diff --git a/TajikGanjoor/Pages/Index.cshtml.cs b/TajikGanjoor/Pages/Index.cshtml.cs index f293ea24..b80be894 100644 --- a/TajikGanjoor/Pages/Index.cshtml.cs +++ b/TajikGanjoor/Pages/Index.cshtml.cs @@ -25,7 +25,6 @@ namespace TajikGanjoor.Pages public string PreviousUrl { get; set; } public string PreviousTitle { get; set; } public string BreadCrumpUrls { get; set; } - public string HtmlText { get; set; } public async Task OnGetAsync() { if (bool.Parse(Configuration["MaintenanceMode"] ?? false.ToString())) @@ -71,7 +70,6 @@ namespace TajikGanjoor.Pages { case GanjoorPageType.PoemPage: GanjoorPage.PoetOrCat = GanjoorPage.Poem.Category; - HtmlText = PrepareHtmlText(new List(GanjoorPage.Poem.Verses)); PrepareNextPre(); IsPoemPage = true; break; @@ -236,85 +234,6 @@ namespace TajikGanjoor.Pages } } - private string PrepareHtmlText(List verses) - { - string htmlText = ""; - int coupletIndex = 0; - for (int vIndex = 0; vIndex < verses.Count; vIndex++) - { - GanjoorVerseViewModel v = verses[vIndex]; - if (v.VersePosition == VersePosition.CenteredVerse1) - { - coupletIndex++; - if (((vIndex + 1) < verses.Count) && (verses[vIndex + 1].VersePosition == VersePosition.CenteredVerse2)) - { - htmlText += $"

{v.Text}

{Environment.NewLine}"; - } - else - { - htmlText += $"

{v.Text}

{Environment.NewLine}"; - - } - } - else - if (v.VersePosition == VersePosition.CenteredVerse2) - { - htmlText += $"

{v.Text}

{Environment.NewLine}"; - } - else - - if (v.VersePosition == VersePosition.Right) - { - coupletIndex++; - htmlText += $"

{v.Text}

{Environment.NewLine}"; - } - else - if (v.VersePosition == VersePosition.Left) - { - htmlText += $"

{v.Text}

{Environment.NewLine}"; - } - else - if (v.VersePosition == VersePosition.Comment) - { - htmlText += $"

{v.Text}

{Environment.NewLine}"; - } - else - if (v.VersePosition == VersePosition.Paragraph || v.VersePosition == VersePosition.Single) - { - coupletIndex++; - string[] lines = v.Text.Split(new char[] { '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries); - - string cssClass = v.VersePosition == VersePosition.Paragraph ? "n" : "l"; - - if (lines.Length != 0) - { - if (v.Text.Length / lines.Length < 150) - { - htmlText += $"

{v.Text.Replace("\r\n", " ")}

{Environment.NewLine}"; - } - else - { - foreach (string line in lines) - htmlText += $"

{line}

{Environment.NewLine}"; - } - } - else - { - if (string.IsNullOrEmpty(v.Text)) - { - htmlText += $"

 

{Environment.NewLine}";//empty line! - } - else - { - htmlText += $"

{v.Text}

{Environment.NewLine}";//not brave enough to ignore it! - } - - } - } - } - return htmlText.Trim(); - } - public string? LastError { get; set; } public bool AggressiveCacheEnabled