diff --git a/GanjooRazor/Pages/Books.cshtml b/GanjooRazor/Pages/Books.cshtml deleted file mode 100644 index 2bdb2e9b..00000000 --- a/GanjooRazor/Pages/Books.cshtml +++ /dev/null @@ -1,104 +0,0 @@ -@page -@model GanjooRazor.Pages.BooksModel -@{ - Layout = null; -} - - - - - - - @ViewData["Title"] - - - - - - - - - - - -
-

-
- -
- -
-
- - - - -
-
- - - -
-
- - @if (!string.IsNullOrEmpty(Model.LastError)) - { - @Model.LastError - } - else - { -
- -
-
-
- فهرست الفبایی کتاب‌ها -
-
- @foreach (var book in Model.Books) - { - -
- @if (book.RImageId != null) - { - - @book.BookName - - } - - -
- } -
- } -
- -
- - - -
- - @if (ViewData["TrackingScript"] != null && !string.IsNullOrEmpty(ViewData["TrackingScript"].ToString())) - { - @Html.Raw(ViewData["TrackingScript"]) - } - - - diff --git a/GanjooRazor/Pages/Books.cshtml.cs b/GanjooRazor/Pages/Books.cshtml.cs deleted file mode 100644 index 11f86825..00000000 --- a/GanjooRazor/Pages/Books.cshtml.cs +++ /dev/null @@ -1,70 +0,0 @@ -using GanjooRazor.Utils; -using Microsoft.AspNetCore.Mvc; -using Newtonsoft.Json.Linq; -using RMuseum.Models.Ganjoor.ViewModels; -using System.Collections.Generic; -using System.Net.Http; -using System.Threading.Tasks; -using Microsoft.Extensions.Configuration; - -namespace GanjooRazor.Pages -{ - [IgnoreAntiforgeryToken(Order = 1001)] - public class BooksModel : LoginPartialEnabledPageModel - { - private readonly PoetCacheService _poetCache; - - public async Task OnGetAsync() - { - var maintenanceResult = TryGetMaintenanceModeResult(); - if (maintenanceResult != null) - { - return maintenanceResult; - } - - ViewData["Title"] = "فهرست کتاب‌ها"; - InitializeCommonPageState(); - - var (poetsOk, poets, poetsError) = await _poetCache.GetPoetsAsync(AggressiveCacheEnabled); - if (!poetsOk) - { - LastError = poetsError; - return Page(); - } - Poets = poets; - - var response = await _httpClient.GetAsync($"{APIRoot.Url}/api/ganjoor/books"); - if (!response.IsSuccessStatusCode) - { - LastError = await ReadErrorMessageAsync(response); - return Page(); - } - Books = JArray.Parse(await response.Content.ReadAsStringAsync()).ToObject>(); - return Page(); - } - - /// - /// books - /// - public List Books { get; set; } - - /// - /// Poets - /// - public List Poets { get; set; } - - /// - /// last error - /// - public string LastError { get; set; } - - /// - /// constructor - /// - public BooksModel(IConfiguration configuration, HttpClient httpClient, PoetCacheService poetCache) : base(httpClient, configuration) - { - _poetCache = poetCache; - } - } -} - diff --git a/GanjooRazor/Pages/Tagged.cshtml b/GanjooRazor/Pages/Tagged.cshtml deleted file mode 100644 index 97a05b96..00000000 --- a/GanjooRazor/Pages/Tagged.cshtml +++ /dev/null @@ -1,234 +0,0 @@ -@page -@model GanjooRazor.Pages.TaggedModel -@{ - Layout = null; -} - - - - - - - - - @ViewData["Title"] - - - - - - - - - - - - @if (!string.IsNullOrEmpty(Model.LastError)) - { - @Html.Raw(Model.LastError) - } - else - { -
-

گنجور

-
-
- - - - @{ - if (Model.Poet != null) - { - - } - } - - -
-
-
- - - -
- -
- - - -
- -
- @if (Model.Poems == null) - { -
-

لطفاً زبان ابیات مد نظر را وارد کنید.

-
- } - else - if (Model.Poems.Count == 0) - { -
-

شعری با مشخصات مورد نظر شما پیدا نشد.

-
- } - else - foreach (var poem in Model.Poems) - { - -
-

- @poem.FullTitle -

-
 
-
- @Html.Raw(poem.HtmlText) -
- - @($ - -
 
- -
- @if (Model.LoggedIn) - { - -
- -
-
- } - -
-
- } - -
 
- - @Html.Raw(Model.PagingToolsHtml) - -
- - - - -
- - - - - @if (ViewData["TrackingScript"] != null && !string.IsNullOrEmpty(ViewData["TrackingScript"].ToString())) - { - @Html.Raw(ViewData["TrackingScript"]) - } - - } - - - - - diff --git a/GanjooRazor/Pages/Tagged.cshtml.cs b/GanjooRazor/Pages/Tagged.cshtml.cs deleted file mode 100644 index ebeb3b92..00000000 --- a/GanjooRazor/Pages/Tagged.cshtml.cs +++ /dev/null @@ -1,202 +0,0 @@ -using DNTPersianUtils.Core; -using GanjooRazor.Utils; -using Microsoft.AspNetCore.Mvc; -using Microsoft.Extensions.Configuration; -using Newtonsoft.Json.Linq; -using Newtonsoft.Json; -using RMuseum.Models.Ganjoor.ViewModels; -using RMuseum.Models.Ganjoor; -using RMuseum.Utils; -using RSecurityBackend.Models.Generic; -using System.Collections.Generic; -using System.Linq; -using System.Net.Http; -using System.Threading.Tasks; -using System; - -namespace GanjooRazor.Pages -{ - [IgnoreAntiforgeryToken(Order = 1001)] - public class TaggedModel : LoginPartialEnabledPageModel - { - private readonly PoetCacheService _poetCache; - - /// - /// constructor - /// - public TaggedModel(HttpClient httpClient, IConfiguration configuration, PoetCacheService poetCache) : base(httpClient, configuration) - { - _poetCache = poetCache; - } - - public List Poets { get; set; } - public int PoetId { get; set; } - public GanjoorPoetCompleteViewModel Poet { get; set; } - public List Poems { get; set; } - public string PagingToolsHtml { get; set; } - public string LastError { get; set; } - public string Language { get; set; } - - public GanjoorLanguage[] Languages { get; set; } - - private async Task ReadLanguagesAsync() - { - HttpResponseMessage response = await _httpClient.GetAsync($"{APIRoot.Url}/api/translations/languages"); - if (!response.IsSuccessStatusCode) - { - LastError = await ReadErrorMessageAsync(response); - return; - } - - Languages = JsonConvert.DeserializeObject(await response.Content.ReadAsStringAsync()); - } - - public async Task OnGetPoetInformationAsync(int id) - { - if (id == 0) - { - return new OkObjectResult(null); - } - var (success, poet, error) = await _poetCache.GetPoetAsync(id, AggressiveCacheEnabled); - if (!success) - { - return BadRequest(error); - } - return new OkObjectResult(poet); - } - - public async Task OnGetAsync() - { - var maintenanceResult = TryGetMaintenanceModeResult(); - if (maintenanceResult != null) - { - return maintenanceResult; - } - - InitializeCommonPageState(); - - PoetId = string.IsNullOrEmpty(Request.Query["a"]) ? 0 : int.Parse(Request.Query["a"]); - - //todo: use html master layout or make it partial - // 1. poets - var (poetsOk, poets, poetsError) = await _poetCache.GetPoetsAsync(AggressiveCacheEnabled); - if (!poetsOk) - { - LastError = poetsError; - return Page(); - } - Poets = poets; - await ReadLanguagesAsync(); - - if (PoetId != 0) - { - var (poetOk, poet, poetError) = await _poetCache.GetPoetAsync(PoetId, AggressiveCacheEnabled); - if (!poetOk) - { - LastError = poetError; - return Page(); - } - Poet = poet; - } - - // 2. search verses - - - - var rhythmResponse = await _httpClient.GetAsync($"{APIRoot.Url}/api/ganjoor/rhythms?sortOnVerseCount=true"); - if (!rhythmResponse.IsSuccessStatusCode) - { - LastError = await ReadErrorMessageAsync(rhythmResponse); - return Page(); - } - - - int pageNumber = 1; - if (!string.IsNullOrEmpty(Request.Query["page"])) - { - pageNumber = int.Parse(Request.Query["page"]); - } - - Language = Request.Query["l"]; - - Language ??= "fa-IR"; - - - - string title = "شعرها یا ابیات "; - - if (PoetId != 0) - { - var poetInfo = Poets.Where(p => p.Id == PoetId).SingleOrDefault(); - if (poetInfo != null) - { - title += $"{poetInfo.Nickname} "; - } - } - var langModel = Languages.Where(l => l.Code == Language).FirstOrDefault(); - if (langModel != null) - { - title += $"با زبان غالب «{langModel.Name}»"; - } - - - - string url = $"{APIRoot.Url}/api/ganjoor/sections/tagged/language?PageNumber={pageNumber}&PageSize=20&language={Language}&poetId={PoetId}"; - var response = await _httpClient.GetAsync(url); - - if (!response.IsSuccessStatusCode) - { - LastError = await ReadErrorMessageAsync(response); - return Page(); - } - - Poems = JArray.Parse(await response.Content.ReadAsStringAsync()).ToObject>(); - - foreach (var poem in Poems) - { - poem.HtmlText = GanjoorPoemTools.GetPoemHtmlExcerpt(poem.HtmlText); - } - - string paginnationMetadata = response.Headers.GetValues("paging-headers").FirstOrDefault(); - PaginationMetadata paginationMetadata = JsonConvert.DeserializeObject(paginnationMetadata); - - string htmlText = ""; - if (paginationMetadata.totalPages > 1) - { - htmlText = $"
{Environment.NewLine}"; - string authorParam = PoetId != 0 ? $"&a={PoetId}" : ""; - title += $" - صفحهٔ {pageNumber.ToPersianNumbers()}"; - if (paginationMetadata.currentPage > 3) - { - htmlText += $"
۱
…"; - } - for (int i = paginationMetadata.currentPage - 2; i <= (paginationMetadata.currentPage + 2); i++) - { - if (i >= 1 && i <= paginationMetadata.totalPages) - { - if (i == paginationMetadata.currentPage) - { - htmlText += $"
{i.ToPersianNumbers()}
{Environment.NewLine}"; - } - else - { - htmlText += $"
{i.ToPersianNumbers()}
{Environment.NewLine}"; - } - } - } - if (paginationMetadata.totalPages > (paginationMetadata.currentPage + 2)) - { - htmlText += $"…
{paginationMetadata.totalPages.ToPersianNumbers()}
{Environment.NewLine}"; - } - htmlText += $"
{Environment.NewLine}"; - } - - ViewData["Title"] = $"گنجور » {title}"; - PagingToolsHtml = htmlText; - - return Page(); - } - public string HtmlText { get; set; } - - } -}