diff --git a/GanjooRazor/.config/dotnet-tools.json b/DiwanRazor/.config/dotnet-tools.json similarity index 100% rename from GanjooRazor/.config/dotnet-tools.json rename to DiwanRazor/.config/dotnet-tools.json diff --git a/GanjooRazor/APIRoot.cs b/DiwanRazor/APIRoot.cs similarity index 99% rename from GanjooRazor/APIRoot.cs rename to DiwanRazor/APIRoot.cs index 9279ca3b..963b6b27 100644 --- a/GanjooRazor/APIRoot.cs +++ b/DiwanRazor/APIRoot.cs @@ -1,7 +1,7 @@ using Microsoft.Extensions.Configuration; using System.IO; -namespace GanjooRazor +namespace DiwanRazor { /// /// API Root diff --git a/GanjooRazor/Areas/Admin/Pages/Banners.cshtml b/DiwanRazor/Areas/Admin/Pages/Banners.cshtml similarity index 93% rename from GanjooRazor/Areas/Admin/Pages/Banners.cshtml rename to DiwanRazor/Areas/Admin/Pages/Banners.cshtml index f8b2d6f3..4b65dd96 100644 --- a/GanjooRazor/Areas/Admin/Pages/Banners.cshtml +++ b/DiwanRazor/Areas/Admin/Pages/Banners.cshtml @@ -1,5 +1,5 @@ @page -@model GanjooRazor.Areas.Admin.Pages.BannersModel +@model DiwanRazor.Areas.Admin.Pages.BannersModel @addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers @{ Layout = "_AdminLayout"; @@ -46,7 +46,7 @@ متن جایگزین: نشانی مقصد: - @banner.AlternateText + @banner.AlternateText @if (banner.Active) { فعال diff --git a/GanjooRazor/Areas/Admin/Pages/Banners.cshtml.cs b/DiwanRazor/Areas/Admin/Pages/Banners.cshtml.cs similarity index 84% rename from GanjooRazor/Areas/Admin/Pages/Banners.cshtml.cs rename to DiwanRazor/Areas/Admin/Pages/Banners.cshtml.cs index 65a4cd25..be028f37 100644 --- a/GanjooRazor/Areas/Admin/Pages/Banners.cshtml.cs +++ b/DiwanRazor/Areas/Admin/Pages/Banners.cshtml.cs @@ -1,16 +1,16 @@ -using GanjooRazor.Models; -using GanjooRazor.Utils; +using DiwanRazor.Models; +using DiwanRazor.Utils; using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.RazorPages; using Newtonsoft.Json; -using RMuseum.Models.Ganjoor.ViewModels; +using RMuseum.Models.Diwan.ViewModels; using System.IO; using System.Net; using System.Net.Http; using System.Text; using System.Threading.Tasks; -namespace GanjooRazor.Areas.Admin.Pages +namespace DiwanRazor.Areas.Admin.Pages { public class BannersModel : PageModel { @@ -29,7 +29,7 @@ namespace GanjooRazor.Areas.Admin.Pages /// /// banners /// - public GanjoorSiteBannerViewModel[] Banners { get; set; } + public DiwanSiteBannerViewModel[] Banners { get; set; } public async Task OnGetAsync() { @@ -38,9 +38,9 @@ namespace GanjooRazor.Areas.Admin.Pages LastMessage = ""; - using (HttpClient secureClient = new HttpClient(new GanjoorReloginHandler(Request, Response))) + using (HttpClient secureClient = new HttpClient(new DiwanReloginHandler(Request, Response))) { - if (await GanjoorSessionChecker.PrepareClient(secureClient, Request, Response)) + if (await DiwanSessionChecker.PrepareClient(secureClient, Request, Response)) { var response = await secureClient.GetAsync($"{APIRoot.Url}/api/banners"); if (!response.IsSuccessStatusCode) @@ -49,7 +49,7 @@ namespace GanjooRazor.Areas.Admin.Pages } else { - Banners = JsonConvert.DeserializeObject(await response.Content.ReadAsStringAsync()); + Banners = JsonConvert.DeserializeObject(await response.Content.ReadAsStringAsync()); } } else @@ -69,11 +69,11 @@ namespace GanjooRazor.Areas.Admin.Pages public async Task OnPutEditAsync(int id, string alt, string url, bool active) { LastMessage = ""; - using (HttpClient secureClient = new HttpClient(new GanjoorReloginHandler(Request, Response))) + using (HttpClient secureClient = new HttpClient(new DiwanReloginHandler(Request, Response))) { - if (await GanjoorSessionChecker.PrepareClient(secureClient, Request, Response)) + if (await DiwanSessionChecker.PrepareClient(secureClient, Request, Response)) { - GanjoorSiteBannerModifyViewModel model = new GanjoorSiteBannerModifyViewModel() + DiwanSiteBannerModifyViewModel model = new DiwanSiteBannerModifyViewModel() { AlternateText = alt, TargetUrl = url, @@ -99,9 +99,9 @@ namespace GanjooRazor.Areas.Admin.Pages public async Task OnDeleteAsync(int id) { - using (HttpClient secureClient = new HttpClient(new GanjoorReloginHandler(Request, Response))) + using (HttpClient secureClient = new HttpClient(new DiwanReloginHandler(Request, Response))) { - if (await GanjoorSessionChecker.PrepareClient(secureClient, Request, Response)) + if (await DiwanSessionChecker.PrepareClient(secureClient, Request, Response)) { var response = await secureClient.DeleteAsync($"{APIRoot.Url}/api/banners?id={id}"); @@ -122,9 +122,9 @@ namespace GanjooRazor.Areas.Admin.Pages public async Task OnPostAsync(BannerUploadModel Upload) { LastMessage = ""; - using (HttpClient secureClient = new HttpClient(new GanjoorReloginHandler(Request, Response))) + using (HttpClient secureClient = new HttpClient(new DiwanReloginHandler(Request, Response))) { - if (await GanjoorSessionChecker.PrepareClient(secureClient, Request, Response)) + if (await DiwanSessionChecker.PrepareClient(secureClient, Request, Response)) { MultipartFormDataContent form = new MultipartFormDataContent(); diff --git a/GanjooRazor/Areas/Admin/Pages/CatDel.cshtml b/DiwanRazor/Areas/Admin/Pages/CatDel.cshtml similarity index 95% rename from GanjooRazor/Areas/Admin/Pages/CatDel.cshtml rename to DiwanRazor/Areas/Admin/Pages/CatDel.cshtml index f54b0f9f..28e61eb7 100644 --- a/GanjooRazor/Areas/Admin/Pages/CatDel.cshtml +++ b/DiwanRazor/Areas/Admin/Pages/CatDel.cshtml @@ -1,5 +1,5 @@ @page -@model GanjooRazor.Areas.Admin.Pages.CatDelModel +@model DiwanRazor.Areas.Admin.Pages.CatDelModel @addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers @{ Layout = "_AdminLayout"; diff --git a/GanjooRazor/Areas/Admin/Pages/CatDel.cshtml.cs b/DiwanRazor/Areas/Admin/Pages/CatDel.cshtml.cs similarity index 81% rename from GanjooRazor/Areas/Admin/Pages/CatDel.cshtml.cs rename to DiwanRazor/Areas/Admin/Pages/CatDel.cshtml.cs index 9fe83355..4258d354 100644 --- a/GanjooRazor/Areas/Admin/Pages/CatDel.cshtml.cs +++ b/DiwanRazor/Areas/Admin/Pages/CatDel.cshtml.cs @@ -1,13 +1,13 @@ -using GanjooRazor.Utils; +using DiwanRazor.Utils; using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.RazorPages; using Newtonsoft.Json.Linq; using Newtonsoft.Json; -using RMuseum.Models.Ganjoor.ViewModels; +using RMuseum.Models.Diwan.ViewModels; using System.Net.Http; using System.Threading.Tasks; -namespace GanjooRazor.Areas.Admin.Pages +namespace DiwanRazor.Areas.Admin.Pages { public class CatDelModel : PageModel { @@ -28,7 +28,7 @@ namespace GanjooRazor.Areas.Admin.Pages /// /// category /// - public GanjoorPoetCompleteViewModel Cat { get; set; } + public DiwanPoetCompleteViewModel Cat { get; set; } /// @@ -42,26 +42,26 @@ namespace GanjooRazor.Areas.Admin.Pages return Redirect("/"); LastResult = ""; - var response = await _httpClient.GetAsync($"{APIRoot.Url}/api/ganjoor/cat/{Request.Query["id"]}"); + var response = await _httpClient.GetAsync($"{APIRoot.Url}/api/diwan/cat/{Request.Query["id"]}"); if (!response.IsSuccessStatusCode) { LastResult = JsonConvert.DeserializeObject(await response.Content.ReadAsStringAsync()); return Page(); } - Cat = JObject.Parse(await response.Content.ReadAsStringAsync()).ToObject(); + Cat = JObject.Parse(await response.Content.ReadAsStringAsync()).ToObject(); return Page(); } public async Task OnPostAsync() { LastResult = ""; - using (HttpClient secureClient = new HttpClient(new GanjoorReloginHandler(Request, Response))) + using (HttpClient secureClient = new HttpClient(new DiwanReloginHandler(Request, Response))) { - await GanjoorSessionChecker.PrepareClient(secureClient, Request, Response); + await DiwanSessionChecker.PrepareClient(secureClient, Request, Response); - var response = await secureClient.DeleteAsync($"{APIRoot.Url}/api/ganjoor/cat/{Request.Query["id"]}"); + var response = await secureClient.DeleteAsync($"{APIRoot.Url}/api/diwan/cat/{Request.Query["id"]}"); if (!response.IsSuccessStatusCode) { diff --git a/GanjooRazor/Areas/Admin/Pages/CatTrans.cshtml b/DiwanRazor/Areas/Admin/Pages/CatTrans.cshtml similarity index 98% rename from GanjooRazor/Areas/Admin/Pages/CatTrans.cshtml rename to DiwanRazor/Areas/Admin/Pages/CatTrans.cshtml index 843d2c47..148eb443 100644 --- a/GanjooRazor/Areas/Admin/Pages/CatTrans.cshtml +++ b/DiwanRazor/Areas/Admin/Pages/CatTrans.cshtml @@ -1,5 +1,5 @@ @page -@model GanjooRazor.Areas.Admin.Pages.CatTransModel +@model DiwanRazor.Areas.Admin.Pages.CatTransModel @addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers @{ Layout = "_AdminLayout"; diff --git a/GanjooRazor/Areas/Admin/Pages/CatTrans.cshtml.cs b/DiwanRazor/Areas/Admin/Pages/CatTrans.cshtml.cs similarity index 81% rename from GanjooRazor/Areas/Admin/Pages/CatTrans.cshtml.cs rename to DiwanRazor/Areas/Admin/Pages/CatTrans.cshtml.cs index de23fbce..8eeb87ad 100644 --- a/GanjooRazor/Areas/Admin/Pages/CatTrans.cshtml.cs +++ b/DiwanRazor/Areas/Admin/Pages/CatTrans.cshtml.cs @@ -3,17 +3,17 @@ using System.Linq; using System.Net.Http; using System.Text; using System.Threading.Tasks; -using GanjooRazor.Utils; +using DiwanRazor.Utils; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.RazorPages; using Microsoft.Extensions.Caching.Memory; using Newtonsoft.Json; using Newtonsoft.Json.Linq; -using RMuseum.Models.Ganjoor; -using RMuseum.Models.Ganjoor.ViewModels; +using RMuseum.Models.Diwan; +using RMuseum.Models.Diwan.ViewModels; -namespace GanjooRazor.Areas.Admin.Pages +namespace DiwanRazor.Areas.Admin.Pages { public class CatTransModel : PageModel { @@ -25,7 +25,7 @@ namespace GanjooRazor.Areas.Admin.Pages /// /// poems /// - public GanjoorDuplicateViewModel[] Poems { get; set; } + public DiwanDuplicateViewModel[] Poems { get; set; } /// @@ -47,11 +47,11 @@ namespace GanjooRazor.Areas.Admin.Pages return false; } CatId = int.Parse(Request.Query["id"]); - using (HttpClient secureClient = new HttpClient(new GanjoorReloginHandler(Request, Response))) + using (HttpClient secureClient = new HttpClient(new DiwanReloginHandler(Request, Response))) { - if (await GanjoorSessionChecker.PrepareClient(secureClient, Request, Response)) + if (await DiwanSessionChecker.PrepareClient(secureClient, Request, Response)) { - HttpResponseMessage response = await secureClient.GetAsync($"{APIRoot.Url}/api/ganjoor/duplicates/{CatId}"); + HttpResponseMessage response = await secureClient.GetAsync($"{APIRoot.Url}/api/diwan/duplicates/{CatId}"); if (!response.IsSuccessStatusCode) { LastMessage = JsonConvert.DeserializeObject(await response.Content.ReadAsStringAsync()); @@ -59,7 +59,7 @@ namespace GanjooRazor.Areas.Admin.Pages } else { - Poems = JsonConvert.DeserializeObject(await response.Content.ReadAsStringAsync()); + Poems = JsonConvert.DeserializeObject(await response.Content.ReadAsStringAsync()); if(!string.IsNullOrEmpty(Request.Query["empty"])) { @@ -89,11 +89,11 @@ namespace GanjooRazor.Areas.Admin.Pages public async Task OnPostFindDuplicatesAsync() { CatId = int.Parse(Request.Query["id"]); - using (HttpClient secureClient = new HttpClient(new GanjoorReloginHandler(Request, Response))) + using (HttpClient secureClient = new HttpClient(new DiwanReloginHandler(Request, Response))) { - if (await GanjoorSessionChecker.PrepareClient(secureClient, Request, Response)) + if (await DiwanSessionChecker.PrepareClient(secureClient, Request, Response)) { - HttpResponseMessage response = await secureClient.PostAsync($"{APIRoot.Url}/api/ganjoor/duplicates/{CatId}/{DestCatId}?hardTry=true", null); + HttpResponseMessage response = await secureClient.PostAsync($"{APIRoot.Url}/api/diwan/duplicates/{CatId}/{DestCatId}?hardTry=true", null); if (!response.IsSuccessStatusCode) { LastMessage = JsonConvert.DeserializeObject(await response.Content.ReadAsStringAsync()); @@ -116,11 +116,11 @@ namespace GanjooRazor.Areas.Admin.Pages public async Task OnPostFinalizeAsync() { CatId = int.Parse(Request.Query["id"]); - using (HttpClient secureClient = new HttpClient(new GanjoorReloginHandler(Request, Response))) + using (HttpClient secureClient = new HttpClient(new DiwanReloginHandler(Request, Response))) { - if (await GanjoorSessionChecker.PrepareClient(secureClient, Request, Response)) + if (await DiwanSessionChecker.PrepareClient(secureClient, Request, Response)) { - HttpResponseMessage response = await secureClient.PutAsync($"{APIRoot.Url}/api/ganjoor/duplicates/finish/{CatId}/{DestCatId}", null); + HttpResponseMessage response = await secureClient.PutAsync($"{APIRoot.Url}/api/diwan/duplicates/finish/{CatId}/{DestCatId}", null); if (!response.IsSuccessStatusCode) { LastMessage = JsonConvert.DeserializeObject(await response.Content.ReadAsStringAsync()); @@ -142,11 +142,11 @@ namespace GanjooRazor.Areas.Admin.Pages public async Task OnDeleteAsync(int id) { - using (HttpClient secureClient = new HttpClient(new GanjoorReloginHandler(Request, Response))) + using (HttpClient secureClient = new HttpClient(new DiwanReloginHandler(Request, Response))) { - if (await GanjoorSessionChecker.PrepareClient(secureClient, Request, Response)) + if (await DiwanSessionChecker.PrepareClient(secureClient, Request, Response)) { - HttpResponseMessage response = await secureClient.DeleteAsync($"{APIRoot.Url}/api/ganjoor/duplicates/{id}"); + HttpResponseMessage response = await secureClient.DeleteAsync($"{APIRoot.Url}/api/diwan/duplicates/{id}"); if (!response.IsSuccessStatusCode) { LastMessage = JsonConvert.DeserializeObject(await response.Content.ReadAsStringAsync()); diff --git a/GanjooRazor/Areas/Admin/Pages/CatUtils.cshtml b/DiwanRazor/Areas/Admin/Pages/CatUtils.cshtml similarity index 98% rename from GanjooRazor/Areas/Admin/Pages/CatUtils.cshtml rename to DiwanRazor/Areas/Admin/Pages/CatUtils.cshtml index 16ad90ff..5daff3f8 100644 --- a/GanjooRazor/Areas/Admin/Pages/CatUtils.cshtml +++ b/DiwanRazor/Areas/Admin/Pages/CatUtils.cshtml @@ -1,5 +1,5 @@ @page -@model GanjooRazor.Areas.Admin.Pages.CatUtilsModel +@model DiwanRazor.Areas.Admin.Pages.CatUtilsModel @using DNTPersianUtils.Core @addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers @{ @@ -317,9 +317,9 @@ @if (poem.MainSections.Length <= 1) { - @if(poem.MainSections.Length == 1 && @poem.MainSections[0].GanjoorMetre != null) + @if(poem.MainSections.Length == 1 && @poem.MainSections[0].DiwanMetre != null) { - @poem.MainSections[0].GanjoorMetre.Rhythm + @poem.MainSections[0].DiwanMetre.Rhythm } @@ -352,9 +352,9 @@ @s.Excerpt - @if (s.GanjoorMetre != null) + @if (s.DiwanMetre != null) { - @s.GanjoorMetre.Rhythm + @s.DiwanMetre.Rhythm } @@ -451,9 +451,9 @@ diff --git a/GanjooRazor/Areas/Admin/Pages/CatUtils.cshtml.cs b/DiwanRazor/Areas/Admin/Pages/CatUtils.cshtml.cs similarity index 83% rename from GanjooRazor/Areas/Admin/Pages/CatUtils.cshtml.cs rename to DiwanRazor/Areas/Admin/Pages/CatUtils.cshtml.cs index d6e2e5c2..ae73b227 100644 --- a/GanjooRazor/Areas/Admin/Pages/CatUtils.cshtml.cs +++ b/DiwanRazor/Areas/Admin/Pages/CatUtils.cshtml.cs @@ -1,20 +1,20 @@ -using GanjooRazor.Pages; -using GanjooRazor.Utils; +using DiwanRazor.Pages; +using DiwanRazor.Utils; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc; using Microsoft.Extensions.Caching.Memory; using Newtonsoft.Json; using Newtonsoft.Json.Linq; -using RMuseum.Models.Ganjoor; -using RMuseum.Models.Ganjoor.ViewModels; +using RMuseum.Models.Diwan; +using RMuseum.Models.Diwan.ViewModels; using System.IO; using System.Net.Http; using System.Text; using System.Threading.Tasks; -namespace GanjooRazor.Areas.Admin.Pages +namespace DiwanRazor.Areas.Admin.Pages { - public class CatUtilsModel : GanjoorPageModelBase + public class CatUtilsModel : DiwanPageModelBase { /// /// constructor @@ -28,21 +28,21 @@ namespace GanjooRazor.Areas.Admin.Pages /// /// category /// - public GanjoorPoetCompleteViewModel Cat { get; set; } + public DiwanPoetCompleteViewModel Cat { get; set; } /// /// cat page /// - public GanjoorPageCompleteViewModel PageInformation { get; set; } + public DiwanPageCompleteViewModel PageInformation { get; set; } [BindProperty] - public GanjoorBatchNamingModel NamingModel { get; set; } + public DiwanBatchNamingModel NamingModel { get; set; } /// /// rythm /// - public GanjoorMetre[] Rhythms { get; set; } + public DiwanMetre[] Rhythms { get; set; } /// @@ -58,18 +58,18 @@ namespace GanjooRazor.Areas.Admin.Pages /// /// numbering patterns /// - public GanjoorNumbering[] Numberings { get; set; } + public DiwanNumbering[] Numberings { get; set; } /// /// numbering model /// [BindProperty] - public GanjoorNumbering NumberingModel { get; set; } + public DiwanNumbering NumberingModel { get; set; } - public GanjoorLanguage[] Languages { get; set; } + public DiwanLanguage[] Languages { get; set; } [BindProperty] - public GanjoorCatViewModel CatMeta { get; set; } + public DiwanCatViewModel CatMeta { get; set; } public PoemRelatedImageEx[] PoemRelatedImages { get; set; } @@ -82,7 +82,7 @@ namespace GanjooRazor.Areas.Admin.Pages return; } - Languages = JsonConvert.DeserializeObject(await response.Content.ReadAsStringAsync()); + Languages = JsonConvert.DeserializeObject(await response.Content.ReadAsStringAsync()); } [BindProperty] @@ -90,17 +90,17 @@ namespace GanjooRazor.Areas.Admin.Pages private async Task GetInformationAsync() { - var response = await _httpClient.GetAsync($"{APIRoot.Url}/api/ganjoor/cat?url={Request.Query["url"]}&poems=true&mainSections=true"); + var response = await _httpClient.GetAsync($"{APIRoot.Url}/api/diwan/cat?url={Request.Query["url"]}&poems=true&mainSections=true"); if (!response.IsSuccessStatusCode) { LastMessage = await ReadErrorMessageAsync(response); return false; } - Cat = JsonConvert.DeserializeObject(await response.Content.ReadAsStringAsync()); + Cat = JsonConvert.DeserializeObject(await response.Content.ReadAsStringAsync()); if (CatMeta == null) { - CatMeta = new GanjoorCatViewModel() + CatMeta = new DiwanCatViewModel() { Id = Cat.Cat.Id, BookName = Cat.Cat.BookName, @@ -110,21 +110,21 @@ namespace GanjooRazor.Areas.Admin.Pages } - var pageQuery = await _httpClient.GetAsync($"{APIRoot.Url}/api/ganjoor/page?url={Request.Query["url"]}"); + var pageQuery = await _httpClient.GetAsync($"{APIRoot.Url}/api/diwan/page?url={Request.Query["url"]}"); if (!pageQuery.IsSuccessStatusCode) { LastMessage = await ReadErrorMessageAsync(pageQuery); return false; } - PageInformation = JObject.Parse(await pageQuery.Content.ReadAsStringAsync()).ToObject(); + PageInformation = JObject.Parse(await pageQuery.Content.ReadAsStringAsync()).ToObject(); - var rhythmsResponse = await _httpClient.GetAsync($"{APIRoot.Url}/api/ganjoor/rhythms"); + var rhythmsResponse = await _httpClient.GetAsync($"{APIRoot.Url}/api/diwan/rhythms"); if (!rhythmsResponse.IsSuccessStatusCode) { LastMessage = await ReadErrorMessageAsync(rhythmsResponse); return false; } - Rhythms = JsonConvert.DeserializeObject(await rhythmsResponse.Content.ReadAsStringAsync()); + Rhythms = JsonConvert.DeserializeObject(await rhythmsResponse.Content.ReadAsStringAsync()); var numberings = await _httpClient.GetAsync($"{APIRoot.Url}/api/numberings/cat/{Cat.Cat.Id}"); if (!numberings.IsSuccessStatusCode) @@ -132,11 +132,11 @@ namespace GanjooRazor.Areas.Admin.Pages LastMessage = await ReadErrorMessageAsync(numberings); return false; } - Numberings = JsonConvert.DeserializeObject(await numberings.Content.ReadAsStringAsync()); + Numberings = JsonConvert.DeserializeObject(await numberings.Content.ReadAsStringAsync()); if (!string.IsNullOrEmpty(Request.Query["images"])) { - var images = await _httpClient.GetAsync($"{APIRoot.Url}/api/ganjoor/cat/{Cat.Cat.Id}/images"); + var images = await _httpClient.GetAsync($"{APIRoot.Url}/api/diwan/cat/{Cat.Cat.Id}/images"); if (!images.IsSuccessStatusCode) { LastMessage = await ReadErrorMessageAsync(images); @@ -168,7 +168,7 @@ namespace GanjooRazor.Areas.Admin.Pages await GetInformationAsync(); - NamingModel = new GanjoorBatchNamingModel() + NamingModel = new DiwanBatchNamingModel() { StartWithNotIncludingSpaces = "شمارهٔ ", RemovePreviousPattern = true, @@ -176,7 +176,7 @@ namespace GanjooRazor.Areas.Admin.Pages Simulate = true }; - NumberingModel = new GanjoorNumbering() + NumberingModel = new DiwanNumbering() { Name = Cat.Cat.Title, StartCatId = Cat.Cat.Id, @@ -191,11 +191,11 @@ namespace GanjooRazor.Areas.Admin.Pages /// /// /// - public async Task OnPostAsync(GanjoorBatchNamingModel NamingModel) + public async Task OnPostAsync(DiwanBatchNamingModel NamingModel) { await GetInformationAsync(); - NumberingModel = new GanjoorNumbering() + NumberingModel = new DiwanNumbering() { Name = Cat.Cat.Title, StartCatId = Cat.Cat.Id, @@ -205,15 +205,15 @@ namespace GanjooRazor.Areas.Admin.Pages // Full-page form post: re-renders the page with LastMessage on failure rather than // returning a bare error result, so this keeps its own client/session block instead of // going through WithSecureClientAsync (which is for AJAX-style handlers). - using (HttpClient secureClient = new HttpClient(new GanjoorReloginHandler(Request, Response))) + using (HttpClient secureClient = new HttpClient(new DiwanReloginHandler(Request, Response))) { - await GanjoorSessionChecker.PrepareClient(secureClient, Request, Response); + await DiwanSessionChecker.PrepareClient(secureClient, Request, Response); if (Request.Form["renameSubcats"].Count == 1) { foreach (var subCat in Cat.Cat.Children) { - HttpResponseMessage response = await secureClient.PutAsync($"{APIRoot.Url}/api/ganjoor/cat/recaptionpoems/{subCat.Id}", new StringContent(JsonConvert.SerializeObject(NamingModel), Encoding.UTF8, "application/json")); + HttpResponseMessage response = await secureClient.PutAsync($"{APIRoot.Url}/api/diwan/cat/recaptionpoems/{subCat.Id}", new StringContent(JsonConvert.SerializeObject(NamingModel), Encoding.UTF8, "application/json")); if (!response.IsSuccessStatusCode) { LastMessage = await ReadErrorMessageAsync(response); @@ -227,7 +227,7 @@ namespace GanjooRazor.Areas.Admin.Pages } else { - HttpResponseMessage response = await secureClient.PutAsync($"{APIRoot.Url}/api/ganjoor/cat/recaptionpoems/{Cat.Cat.Id}", new StringContent(JsonConvert.SerializeObject(NamingModel), Encoding.UTF8, "application/json")); + HttpResponseMessage response = await secureClient.PutAsync($"{APIRoot.Url}/api/diwan/cat/recaptionpoems/{Cat.Cat.Id}", new StringContent(JsonConvert.SerializeObject(NamingModel), Encoding.UTF8, "application/json")); if (!response.IsSuccessStatusCode) { LastMessage = await ReadErrorMessageAsync(response); @@ -245,12 +245,12 @@ namespace GanjooRazor.Areas.Admin.Pages return Page(); } - public async Task OnPostNumberingAsync(GanjoorNumbering NumberingModel) + public async Task OnPostNumberingAsync(DiwanNumbering NumberingModel) { // Same note as OnPostAsync above re: full-page form post. - using (HttpClient secureClient = new HttpClient(new GanjoorReloginHandler(Request, Response))) + using (HttpClient secureClient = new HttpClient(new DiwanReloginHandler(Request, Response))) { - await GanjoorSessionChecker.PrepareClient(secureClient, Request, Response); + await DiwanSessionChecker.PrepareClient(secureClient, Request, Response); HttpResponseMessage response = await secureClient.PostAsync($"{APIRoot.Url}/api/numberings", new StringContent(JsonConvert.SerializeObject(NumberingModel), Encoding.UTF8, "application/json")); if (!response.IsSuccessStatusCode) @@ -261,7 +261,7 @@ namespace GanjooRazor.Areas.Admin.Pages await GetInformationAsync(); - NamingModel = new GanjoorBatchNamingModel() + NamingModel = new DiwanBatchNamingModel() { StartWithNotIncludingSpaces = "شمارهٔ ", RemovePreviousPattern = true, @@ -289,7 +289,7 @@ namespace GanjooRazor.Areas.Admin.Pages { return WithSecureClientAsync(async secureClient => { - var response = await secureClient.PutAsync($"{APIRoot.Url}/api/ganjoor/cat/startassigningrhymes/{id}/{false}", null); + var response = await secureClient.PutAsync($"{APIRoot.Url}/api/diwan/cat/startassigningrhymes/{id}/{false}", null); if (!response.IsSuccessStatusCode) { return new BadRequestObjectResult(await ReadErrorMessageAsync(response)); @@ -302,7 +302,7 @@ namespace GanjooRazor.Areas.Admin.Pages { return WithSecureClientAsync(async secureClient => { - var response = await secureClient.PutAsync($"{APIRoot.Url}/api/ganjoor/cat/subcats/startgentoc/{id}", null); + var response = await secureClient.PutAsync($"{APIRoot.Url}/api/diwan/cat/subcats/startgentoc/{id}", null); if (!response.IsSuccessStatusCode) { return new BadRequestObjectResult(await ReadErrorMessageAsync(response)); @@ -315,7 +315,7 @@ namespace GanjooRazor.Areas.Admin.Pages { return WithSecureClientAsync(async secureClient => { - var response = await secureClient.PutAsync($"{APIRoot.Url}/api/ganjoor/cat/startassigningrhythms/{id}/{false}?rhythm={rhythm}", null); + var response = await secureClient.PutAsync($"{APIRoot.Url}/api/diwan/cat/startassigningrhythms/{id}/{false}?rhythm={rhythm}", null); if (!response.IsSuccessStatusCode) { return new BadRequestObjectResult(await ReadErrorMessageAsync(response)); @@ -328,7 +328,7 @@ namespace GanjooRazor.Areas.Admin.Pages { return WithSecureClientAsync(async secureClient => { - var response = await secureClient.PutAsync($"{APIRoot.Url}/api/ganjoor/cat/{id}/regenrelatedsections", null); + var response = await secureClient.PutAsync($"{APIRoot.Url}/api/diwan/cat/{id}/regenrelatedsections", null); if (!response.IsSuccessStatusCode) { return new BadRequestObjectResult(await ReadErrorMessageAsync(response)); @@ -341,7 +341,7 @@ namespace GanjooRazor.Areas.Admin.Pages { return WithSecureClientAsync(async secureClient => { - var response = await secureClient.PutAsync($"{APIRoot.Url}/api/ganjoor/cat/language/{id}/{language}", null); + var response = await secureClient.PutAsync($"{APIRoot.Url}/api/diwan/cat/language/{id}/{language}", null); if (!response.IsSuccessStatusCode) { return new BadRequestObjectResult(await ReadErrorMessageAsync(response)); @@ -350,11 +350,11 @@ namespace GanjooRazor.Areas.Admin.Pages }, new OkObjectResult(false)); } - public Task OnPostSetCategoryPoemFormatAsync(int id, GanjoorPoemFormat format) + public Task OnPostSetCategoryPoemFormatAsync(int id, DiwanPoemFormat format) { return WithSecureClientAsync(async secureClient => { - var response = await secureClient.PutAsync($"{APIRoot.Url}/api/ganjoor/cat/poemformat/{id}/{format}", null); + var response = await secureClient.PutAsync($"{APIRoot.Url}/api/diwan/cat/poemformat/{id}/{format}", null); if (!response.IsSuccessStatusCode) { return new BadRequestObjectResult(await ReadErrorMessageAsync(response)); @@ -395,9 +395,9 @@ namespace GanjooRazor.Areas.Admin.Pages // Full-page form post (file upload): re-renders the page with LastMessage, so this keeps // its own client/session block rather than using WithSecureClientAsync. - using (HttpClient secureClient = new HttpClient(new GanjoorReloginHandler(Request, Response))) + using (HttpClient secureClient = new HttpClient(new DiwanReloginHandler(Request, Response))) { - await GanjoorSessionChecker.PrepareClient(secureClient, Request, Response); + await DiwanSessionChecker.PrepareClient(secureClient, Request, Response); MultipartFormDataContent form = new MultipartFormDataContent(); @@ -407,7 +407,7 @@ namespace GanjooRazor.Areas.Admin.Pages var fileContent = stream.ToArray(); form.Add(new ByteArrayContent(fileContent, 0, fileContent.Length), Cat.Poet.Nickname, SQLiteDb.FileName); - HttpResponseMessage response = await secureClient.PostAsync($"{APIRoot.Url}/api/ganjoor/sqlite/import/cat/{Cat.Cat.Id}", form); + HttpResponseMessage response = await secureClient.PostAsync($"{APIRoot.Url}/api/diwan/sqlite/import/cat/{Cat.Cat.Id}", form); if (!response.IsSuccessStatusCode) { LastMessage = await ReadErrorMessageAsync(response); @@ -426,7 +426,7 @@ namespace GanjooRazor.Areas.Admin.Pages { return WithSecureClientAsync(async secureClient => { - var response = await secureClient.DeleteAsync($"{APIRoot.Url}/api/ganjoor/poem/{id}"); + var response = await secureClient.DeleteAsync($"{APIRoot.Url}/api/diwan/poem/{id}"); if (!response.IsSuccessStatusCode) { return new BadRequestObjectResult(await ReadErrorMessageAsync(response)); @@ -439,7 +439,7 @@ namespace GanjooRazor.Areas.Admin.Pages { return WithSecureClientAsync(async secureClient => { - var response = await secureClient.PutAsync($"{APIRoot.Url}/api/ganjoor/cat/reslugpoems/{id}", null); + var response = await secureClient.PutAsync($"{APIRoot.Url}/api/diwan/cat/reslugpoems/{id}", null); if (!response.IsSuccessStatusCode) { return new BadRequestObjectResult(await ReadErrorMessageAsync(response)); @@ -448,16 +448,16 @@ namespace GanjooRazor.Areas.Admin.Pages }, new OkObjectResult(false)); } - public async Task OnPostUpdateCatMeta(GanjoorCatViewModel CatMeta) + public async Task OnPostUpdateCatMeta(DiwanCatViewModel CatMeta) { await GetInformationAsync(); // Full-page form post: re-renders the page with LastMessage on failure (or redirects on // success), so this keeps its own client/session block rather than using // WithSecureClientAsync. - using (HttpClient secureClient = new HttpClient(new GanjoorReloginHandler(Request, Response))) + using (HttpClient secureClient = new HttpClient(new DiwanReloginHandler(Request, Response))) { - await GanjoorSessionChecker.PrepareClient(secureClient, Request, Response); + await DiwanSessionChecker.PrepareClient(secureClient, Request, Response); CatMeta.BookName ??= ""; CatMeta.MapName ??= ""; @@ -478,7 +478,7 @@ namespace GanjooRazor.Areas.Admin.Pages form.Add(new ByteArrayContent(fileContent, 0, fileContent.Length), CatMeta.BookName, CatMeta.NewImage.FileName); } } - HttpResponseMessage response = await secureClient.PutAsync($"{APIRoot.Url}/api/ganjoor/cat/extra/{Cat.Cat.Id}", form); + HttpResponseMessage response = await secureClient.PutAsync($"{APIRoot.Url}/api/diwan/cat/extra/{Cat.Cat.Id}", form); if (!response.IsSuccessStatusCode) { LastMessage = await ReadErrorMessageAsync(response); @@ -497,7 +497,7 @@ namespace GanjooRazor.Areas.Admin.Pages // consistent with the rest of this file via WithSecureClientAsync. return WithSecureClientAsync(async secureClient => { - HttpResponseMessage response = await secureClient.DeleteAsync($"{APIRoot.Url}/api/ganjoor/naskban?naskbanUrl={url}"); + HttpResponseMessage response = await secureClient.DeleteAsync($"{APIRoot.Url}/api/diwan/naskban?naskbanUrl={url}"); if (!response.IsSuccessStatusCode) { return new BadRequestObjectResult(await ReadErrorMessageAsync(response)); @@ -510,7 +510,7 @@ namespace GanjooRazor.Areas.Admin.Pages { return WithSecureClientAsync(async secureClient => { - HttpResponseMessage response = await secureClient.GetAsync($"{APIRoot.Url}/api/ganjoor/source?sourceUrlSlug={tag}"); + HttpResponseMessage response = await secureClient.GetAsync($"{APIRoot.Url}/api/diwan/source?sourceUrlSlug={tag}"); if (!response.IsSuccessStatusCode) { return new BadRequestObjectResult(await ReadErrorMessageAsync(response)); @@ -531,7 +531,7 @@ namespace GanjooRazor.Areas.Admin.Pages }; } - HttpResponseMessage responsePost = await secureClient.PutAsync($"{APIRoot.Url}/api/ganjoor/source/{id}", + HttpResponseMessage responsePost = await secureClient.PutAsync($"{APIRoot.Url}/api/diwan/source/{id}", new StringContent(JsonConvert.SerializeObject(source), Encoding.UTF8, "application/json") ); if (!responsePost.IsSuccessStatusCode) diff --git a/GanjooRazor/Areas/Admin/Pages/DonationEdit.cshtml b/DiwanRazor/Areas/Admin/Pages/DonationEdit.cshtml similarity index 93% rename from GanjooRazor/Areas/Admin/Pages/DonationEdit.cshtml rename to DiwanRazor/Areas/Admin/Pages/DonationEdit.cshtml index 8b6644ec..43860cb0 100644 --- a/GanjooRazor/Areas/Admin/Pages/DonationEdit.cshtml +++ b/DiwanRazor/Areas/Admin/Pages/DonationEdit.cshtml @@ -1,5 +1,5 @@ @page -@model GanjooRazor.Areas.Admin.Pages.DonationEditModel +@model DiwanRazor.Areas.Admin.Pages.DonationEditModel @addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers @{ Layout = "_AdminLayout"; diff --git a/GanjooRazor/Areas/Admin/Pages/DonationEdit.cshtml.cs b/DiwanRazor/Areas/Admin/Pages/DonationEdit.cshtml.cs similarity index 87% rename from GanjooRazor/Areas/Admin/Pages/DonationEdit.cshtml.cs rename to DiwanRazor/Areas/Admin/Pages/DonationEdit.cshtml.cs index dd9e5daf..458ba8e4 100644 --- a/GanjooRazor/Areas/Admin/Pages/DonationEdit.cshtml.cs +++ b/DiwanRazor/Areas/Admin/Pages/DonationEdit.cshtml.cs @@ -1,13 +1,13 @@ using System.Net.Http; using System.Text; using System.Threading.Tasks; -using GanjooRazor.Utils; +using DiwanRazor.Utils; using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.RazorPages; using Newtonsoft.Json; using RMuseum.Models.Accounting.ViewModels; -namespace GanjooRazor.Areas.Admin.Pages +namespace DiwanRazor.Areas.Admin.Pages { public class DonationEditModel : PageModel { @@ -44,7 +44,7 @@ namespace GanjooRazor.Areas.Admin.Pages return Page(); } - var donation = JsonConvert.DeserializeObject(await response.Content.ReadAsStringAsync()); + var donation = JsonConvert.DeserializeObject(await response.Content.ReadAsStringAsync()); Donation = new UpdateDateDescriptionViewModel() { @@ -58,9 +58,9 @@ namespace GanjooRazor.Areas.Admin.Pages public async Task OnPostAsync() { LastMessage = ""; - using (HttpClient secureClient = new HttpClient(new GanjoorReloginHandler(Request, Response))) + using (HttpClient secureClient = new HttpClient(new DiwanReloginHandler(Request, Response))) { - await GanjoorSessionChecker.PrepareClient(secureClient, Request, Response); + await DiwanSessionChecker.PrepareClient(secureClient, Request, Response); HttpResponseMessage response = await secureClient.PutAsync($"{APIRoot.Url}/api/donations/{Request.Query["id"]}", new StringContent(JsonConvert.SerializeObject(Donation), Encoding.UTF8, "application/json")); if (!response.IsSuccessStatusCode) { diff --git a/GanjooRazor/Areas/Admin/Pages/Donations.cshtml b/DiwanRazor/Areas/Admin/Pages/Donations.cshtml similarity index 98% rename from GanjooRazor/Areas/Admin/Pages/Donations.cshtml rename to DiwanRazor/Areas/Admin/Pages/Donations.cshtml index f6b9a8e7..b29884a9 100644 --- a/GanjooRazor/Areas/Admin/Pages/Donations.cshtml +++ b/DiwanRazor/Areas/Admin/Pages/Donations.cshtml @@ -1,5 +1,5 @@ @page -@model GanjooRazor.Areas.Admin.Pages.DonationsModel +@model DiwanRazor.Areas.Admin.Pages.DonationsModel @addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers @{ Layout = "_AdminLayout"; diff --git a/GanjooRazor/Areas/Admin/Pages/Donations.cshtml.cs b/DiwanRazor/Areas/Admin/Pages/Donations.cshtml.cs similarity index 86% rename from GanjooRazor/Areas/Admin/Pages/Donations.cshtml.cs rename to DiwanRazor/Areas/Admin/Pages/Donations.cshtml.cs index 4896b503..fdce1dbc 100644 --- a/GanjooRazor/Areas/Admin/Pages/Donations.cshtml.cs +++ b/DiwanRazor/Areas/Admin/Pages/Donations.cshtml.cs @@ -4,14 +4,14 @@ using System.Net.Http; using System.Text; using System.Threading.Tasks; using DNTPersianUtils.Core; -using GanjooRazor.Utils; +using DiwanRazor.Utils; using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.RazorPages; using Newtonsoft.Json; using RMuseum.Models.Accounting.ViewModels; using RMuseum.Utils; -namespace GanjooRazor.Areas.Admin.Pages +namespace DiwanRazor.Areas.Admin.Pages { public class DonationsModel : PageModel { @@ -39,12 +39,12 @@ namespace GanjooRazor.Areas.Admin.Pages public string EmailContent { get; set; } [BindProperty] - public GanjoorDonationViewModel Donation { get; set; } + public DiwanDonationViewModel Donation { get; set; } /// /// donations /// - public GanjoorDonationViewModel[] Donations { get; set; } + public DiwanDonationViewModel[] Donations { get; set; } /// /// show account info @@ -60,11 +60,11 @@ namespace GanjooRazor.Areas.Admin.Pages return; } - Donations = JsonConvert.DeserializeObject(await response.Content.ReadAsStringAsync()); + Donations = JsonConvert.DeserializeObject(await response.Content.ReadAsStringAsync()); - using (HttpClient secureClient = new HttpClient(new GanjoorReloginHandler(Request, Response))) + using (HttpClient secureClient = new HttpClient(new DiwanReloginHandler(Request, Response))) { - if (await GanjoorSessionChecker.PrepareClient(secureClient, Request, Response)) + if (await DiwanSessionChecker.PrepareClient(secureClient, Request, Response)) { HttpResponseMessage resAccountInfo = await secureClient.GetAsync($"{APIRoot.Url}/api/donations/accountinfo/visible"); if (!resAccountInfo.IsSuccessStatusCode) @@ -87,7 +87,7 @@ namespace GanjooRazor.Areas.Admin.Pages LastMessage = ""; - Donation = new GanjoorDonationViewModel() + Donation = new DiwanDonationViewModel() { RecordDate = DateTime.Now.Date, Unit = "تومان" @@ -101,7 +101,7 @@ namespace GanjooRazor.Areas.Admin.Pages if(donation != null) { int rowNumber = Donations.Length - Array.IndexOf(Donations, donation); - string donorName = GanjoorHtmlTools.StripHtmlTags(donation.DonorName); + string donorName = DiwanHtmlTools.StripHtmlTags(donation.DonorName); if(donorName.StartsWith("آقای")) { donorName = $"جناب {donorName}"; @@ -121,12 +121,12 @@ namespace GanjooRazor.Areas.Admin.Pages return Page(); } - public async Task OnPostAsync(GanjoorDonationViewModel Donation) + public async Task OnPostAsync(DiwanDonationViewModel Donation) { LastMessage = ""; - using (HttpClient secureClient = new HttpClient(new GanjoorReloginHandler(Request, Response))) + using (HttpClient secureClient = new HttpClient(new DiwanReloginHandler(Request, Response))) { - if (await GanjoorSessionChecker.PrepareClient(secureClient, Request, Response)) + if (await DiwanSessionChecker.PrepareClient(secureClient, Request, Response)) { Donation.ImportedRecord = false; @@ -159,9 +159,9 @@ namespace GanjooRazor.Areas.Admin.Pages public async Task OnPostRebuildPageAsync() { - using (HttpClient secureClient = new HttpClient(new GanjoorReloginHandler(Request, Response))) + using (HttpClient secureClient = new HttpClient(new DiwanReloginHandler(Request, Response))) { - if (await GanjoorSessionChecker.PrepareClient(secureClient, Request, Response)) + if (await DiwanSessionChecker.PrepareClient(secureClient, Request, Response)) { HttpResponseMessage response = await secureClient.PutAsync($"{APIRoot.Url}/api/donations/page", null); if(!response.IsSuccessStatusCode) @@ -176,9 +176,9 @@ namespace GanjooRazor.Areas.Admin.Pages public async Task OnDeleteAsync(int id) { - using (HttpClient secureClient = new HttpClient(new GanjoorReloginHandler(Request, Response))) + using (HttpClient secureClient = new HttpClient(new DiwanReloginHandler(Request, Response))) { - if (await GanjoorSessionChecker.PrepareClient(secureClient, Request, Response)) + if (await DiwanSessionChecker.PrepareClient(secureClient, Request, Response)) { var response = await secureClient.DeleteAsync($"{APIRoot.Url}/api/donations/{id}"); if (!response.IsSuccessStatusCode) diff --git a/GanjooRazor/Areas/Admin/Pages/EarlierVersion.cshtml b/DiwanRazor/Areas/Admin/Pages/EarlierVersion.cshtml similarity index 97% rename from GanjooRazor/Areas/Admin/Pages/EarlierVersion.cshtml rename to DiwanRazor/Areas/Admin/Pages/EarlierVersion.cshtml index 9499a886..19be3f7f 100644 --- a/GanjooRazor/Areas/Admin/Pages/EarlierVersion.cshtml +++ b/DiwanRazor/Areas/Admin/Pages/EarlierVersion.cshtml @@ -1,5 +1,5 @@ @page -@model GanjooRazor.Areas.Admin.Pages.EarlierVersionModel +@model DiwanRazor.Areas.Admin.Pages.EarlierVersionModel @addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers @{ Layout = "_AdminLayout"; diff --git a/GanjooRazor/Areas/Admin/Pages/EarlierVersion.cshtml.cs b/DiwanRazor/Areas/Admin/Pages/EarlierVersion.cshtml.cs similarity index 74% rename from GanjooRazor/Areas/Admin/Pages/EarlierVersion.cshtml.cs rename to DiwanRazor/Areas/Admin/Pages/EarlierVersion.cshtml.cs index 27828bfe..1e4cdc1e 100644 --- a/GanjooRazor/Areas/Admin/Pages/EarlierVersion.cshtml.cs +++ b/DiwanRazor/Areas/Admin/Pages/EarlierVersion.cshtml.cs @@ -1,12 +1,12 @@ -using GanjooRazor.Utils; +using DiwanRazor.Utils; using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.RazorPages; using Newtonsoft.Json; -using RMuseum.Models.Ganjoor.ViewModels; +using RMuseum.Models.Diwan.ViewModels; using System.Net.Http; using System.Threading.Tasks; -namespace GanjooRazor.Areas.Admin.Pages +namespace DiwanRazor.Areas.Admin.Pages { public class EarlierVersionModel : PageModel { @@ -19,7 +19,7 @@ namespace GanjooRazor.Areas.Admin.Pages /// model /// [BindProperty] - public GanjoorModifyPageViewModel EarlierVersion { get; set; } + public DiwanModifyPageViewModel EarlierVersion { get; set; } public async Task OnGetAsync() { @@ -29,18 +29,18 @@ namespace GanjooRazor.Areas.Admin.Pages LastMessage = ""; - using (HttpClient secureClient = new HttpClient(new GanjoorReloginHandler(Request, Response))) + using (HttpClient secureClient = new HttpClient(new DiwanReloginHandler(Request, Response))) { - if (await GanjoorSessionChecker.PrepareClient(secureClient, Request, Response)) + if (await DiwanSessionChecker.PrepareClient(secureClient, Request, Response)) { - var response = await secureClient.GetAsync($"{APIRoot.Url}/api/ganjoor/oldversion/{Request.Query["id"]}"); + var response = await secureClient.GetAsync($"{APIRoot.Url}/api/diwan/oldversion/{Request.Query["id"]}"); if (!response.IsSuccessStatusCode) { LastMessage = JsonConvert.DeserializeObject(await response.Content.ReadAsStringAsync()); return Page(); } - EarlierVersion = JsonConvert.DeserializeObject(await response.Content.ReadAsStringAsync()); + EarlierVersion = JsonConvert.DeserializeObject(await response.Content.ReadAsStringAsync()); } else diff --git a/GanjooRazor/Areas/Admin/Pages/EditQuoted.cshtml b/DiwanRazor/Areas/Admin/Pages/EditQuoted.cshtml similarity index 61% rename from GanjooRazor/Areas/Admin/Pages/EditQuoted.cshtml rename to DiwanRazor/Areas/Admin/Pages/EditQuoted.cshtml index 202e7ea0..984ad318 100644 --- a/GanjooRazor/Areas/Admin/Pages/EditQuoted.cshtml +++ b/DiwanRazor/Areas/Admin/Pages/EditQuoted.cshtml @@ -1,5 +1,5 @@ @page -@model GanjooRazor.Areas.Admin.Pages.EditQuotedModel +@model DiwanRazor.Areas.Admin.Pages.EditQuotedModel @using DNTPersianUtils.Core @addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers @{ @@ -122,11 +122,11 @@

-@if (Model.GanjoorQuotedPoem != null && Model.Couplets != null) +@if (Model.DiwanQuotedPoem != null && Model.Couplets != null) { - @if ((Model.GanjoorPage != null && Model.GanjoorPage.NoIndex) || !string.IsNullOrEmpty(Model.PinterestUrl)) + @if ((Model.DiwanPage != null && Model.DiwanPage.NoIndex) || !string.IsNullOrEmpty(Model.PinterestUrl)) { } - @if (Model.GanjoorPage != null) + @if (Model.DiwanPage != null) { if (Model.IsPoemPage) { ". Instead it is serialized // as a JSON string literal (which escapes '<', '>', '&', quotes, etc.) and then diff --git a/GanjooRazor/Pages/GanjoorPage.cshtml.cs b/DiwanRazor/Pages/DiwanPage.cshtml.cs similarity index 74% rename from GanjooRazor/Pages/GanjoorPage.cshtml.cs rename to DiwanRazor/Pages/DiwanPage.cshtml.cs index b05bffed..9552162b 100644 --- a/GanjooRazor/Pages/GanjoorPage.cshtml.cs +++ b/DiwanRazor/Pages/DiwanPage.cshtml.cs @@ -1,5 +1,5 @@ using DNTPersianUtils.Core; -using GanjooRazor.Utils; +using DiwanRazor.Utils; using KontorService.Models.Reporting.ViewModels; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc; @@ -7,10 +7,10 @@ using Microsoft.AspNetCore.OutputCaching; using Microsoft.Extensions.Configuration; using Newtonsoft.Json; using Newtonsoft.Json.Linq; -using RMuseum.Models.Ganjoor; -using RMuseum.Models.Ganjoor.ViewModels; -using RMuseum.Models.GanjoorAudio; -using RMuseum.Models.GanjoorAudio.ViewModels; +using RMuseum.Models.Diwan; +using RMuseum.Models.Diwan.ViewModels; +using RMuseum.Models.DiwanAudio; +using RMuseum.Models.DiwanAudio.ViewModels; using RMuseum.Services.Implementation; using RMuseum.Utils; using System; @@ -21,17 +21,17 @@ using System.Net.Http; using System.Text; using System.Threading.Tasks; -namespace GanjooRazor.Pages +namespace DiwanRazor.Pages { /// - /// Renders a single Ganjoor content page (poem/poet/category). Split out of IndexModel, which + /// Renders a single Diwan content page (poem/poet/category). Split out of IndexModel, which /// used to serve both this and the home page from one class dispatching on - /// Request.Path == "/" - see _HomePagePartial.cshtml / _GanjoorPagePartial.cshtml, and - /// Startup.cs's AddPageRoute("/GanjoorPage", "{*url}") which now owns the site's catch-all route + /// Request.Path == "/" - see _HomePagePartial.cshtml / _DiwanPagePartial.cshtml, and + /// Startup.cs's AddPageRoute("/DiwanPage", "{*url}") which now owns the site's catch-all route /// (Index.cshtml keeps its own automatic "/" route unchanged, so home is unaffected). /// - [OutputCache(PolicyName = "GanjoorPublicPage")] - public partial class GanjoorPageModel : LoginPartialEnabledPageModel + [OutputCache(PolicyName = "DiwanPublicPage")] + public partial class DiwanPageModel : LoginPartialEnabledPageModel { /// /// Persian stop words excluded from category word-count listings when remStopWords is @@ -56,12 +56,12 @@ namespace GanjooRazor.Pages public bool ReadOnlyMode => GetConfigFlag("ReadOnlyMode"); - public const int GanjoorSlashVaznPageId = 39401; + public const int DiwanSlashVaznPageId = 39401; /// /// constructor /// - public GanjoorPageModel(IConfiguration configuration, + public DiwanPageModel(IConfiguration configuration, HttpClient httpClient, PoetCacheService poetCache ) : base(httpClient, configuration) @@ -77,7 +77,7 @@ namespace GanjooRazor.Pages /// /// banner /// - public GanjoorSiteBannerViewModel Banner { get; set; } + public DiwanSiteBannerViewModel Banner { get; set; } /// /// If the response failed, stores the API's error message in and @@ -94,7 +94,7 @@ namespace GanjooRazor.Pages return true; } - public _CommentPartialModel GetCommentModel(GanjoorCommentSummaryViewModel comment, int poemId) + public _CommentPartialModel GetCommentModel(DiwanCommentSummaryViewModel comment, int poemId) { return new _CommentPartialModel() { @@ -120,11 +120,11 @@ namespace GanjooRazor.Pages }; } - public _QuotedPoemPartialModel GetQuotedPoemModel(GanjoorQuotedPoemViewModel quotedPoem, GanjoorPageCompleteViewModel page, bool canEdit) + public _QuotedPoemPartialModel GetQuotedPoemModel(DiwanQuotedPoemViewModel quotedPoem, DiwanPageCompleteViewModel page, bool canEdit) { return new _QuotedPoemPartialModel() { - GanjoorQuotedPoemViewModel = quotedPoem, + DiwanQuotedPoemViewModel = quotedPoem, PoetImageUrl = page.PoetOrCat.Poet.ImageUrl, PoetNickName = page.PoetOrCat.Poet.Nickname, CanEdit = canEdit, @@ -134,14 +134,14 @@ namespace GanjooRazor.Pages /// /// re-fetch a poem's comments sorted by rating, oldest, or newest (AJAX, called from sortComments() in bk.js) /// - public async Task OnGetCommentsPartialAsync(int poemId, GanjoorCommentSortOrder sortOrder = GanjoorCommentSortOrder.TopRated) + public async Task OnGetCommentsPartialAsync(int poemId, DiwanCommentSortOrder sortOrder = DiwanCommentSortOrder.TopRated) { - var response = await _httpClient.GetAsync($"{APIRoot.Url}/api/ganjoor/poem/{poemId}/comments?sortOrder={sortOrder}"); + var response = await _httpClient.GetAsync($"{APIRoot.Url}/api/diwan/poem/{poemId}/comments?sortOrder={sortOrder}"); if (!response.IsSuccessStatusCode) { return BadRequest(await ReadErrorMessageAsync(response)); } - var comments = JArray.Parse(await response.Content.ReadAsStringAsync()).ToObject(); + var comments = JArray.Parse(await response.Content.ReadAsStringAsync()).ToObject(); LoggedIn = !string.IsNullOrEmpty(Request.Cookies["Token"]); @@ -149,32 +149,32 @@ namespace GanjooRazor.Pages && Guid.TryParse(Request.Cookies["UserId"], out Guid userId) && userId != Guid.Empty) { - using (HttpClient secureClient = new HttpClient(new GanjoorReloginHandler(Request, Response))) + using (HttpClient secureClient = new HttpClient(new DiwanReloginHandler(Request, Response))) { - if (await GanjoorSessionChecker.PrepareClient(secureClient, Request, Response)) + if (await DiwanSessionChecker.PrepareClient(secureClient, Request, Response)) { - GanjoorUserBookmarkViewModel[] bookmarks = Array.Empty(); - HttpResponseMessage bookmarksResponse = await secureClient.GetAsync($"{APIRoot.Url}/api/ganjoor/bookmark/{poemId}"); + DiwanUserBookmarkViewModel[] bookmarks = Array.Empty(); + HttpResponseMessage bookmarksResponse = await secureClient.GetAsync($"{APIRoot.Url}/api/diwan/bookmark/{poemId}"); if (bookmarksResponse.IsSuccessStatusCode) { - bookmarks = JsonConvert.DeserializeObject(await bookmarksResponse.Content.ReadAsStringAsync()); + bookmarks = JsonConvert.DeserializeObject(await bookmarksResponse.Content.ReadAsStringAsync()); } - foreach (GanjoorCommentSummaryViewModel comment in comments) + foreach (DiwanCommentSummaryViewModel comment in comments) { comment.MyComment = comment.UserId == userId; comment.IsBookmarked = bookmarks.Where(b => b.CoupletIndex == -comment.Id).Any(); _markMyReplies(comment, userId, bookmarks); } - HttpResponseMessage ratingsResponse = await secureClient.GetAsync($"{APIRoot.Url}/api/ganjoor/poem/{poemId}/comments/myratings"); + HttpResponseMessage ratingsResponse = await secureClient.GetAsync($"{APIRoot.Url}/api/diwan/poem/{poemId}/comments/myratings"); if (ratingsResponse.IsSuccessStatusCode) { - var ratings = JsonConvert.DeserializeObject(await ratingsResponse.Content.ReadAsStringAsync()); + var ratings = JsonConvert.DeserializeObject(await ratingsResponse.Content.ReadAsStringAsync()); if (ratings.Length > 0) { var ratingsDic = ratings.ToDictionary(r => r.CommentId, r => r.Value); - foreach (GanjoorCommentSummaryViewModel comment in comments) + foreach (DiwanCommentSummaryViewModel comment in comments) { _applyCommentRatings(comment, ratingsDic); } @@ -184,7 +184,7 @@ namespace GanjooRazor.Pages } } - return Partial("~/Pages/Partials/GanjoorPage/_CommentsListPartial.cshtml", new _CommentsListPartialModel() + return Partial("~/Pages/Partials/DiwanPage/_CommentsListPartial.cshtml", new _CommentsListPartialModel() { Comments = comments, PoemId = poemId, @@ -202,7 +202,7 @@ namespace GanjooRazor.Pages /// public Task OnPostComment(string comment, int poemId, int inReplytoId, int coupletIndex) { - var unauthorized = Partial("~/Pages/Partials/GanjoorPage/_CommentPartial.cshtml", new _CommentPartialModel() + var unauthorized = Partial("~/Pages/Partials/DiwanPage/_CommentPartial.cshtml", new _CommentPartialModel() { Comment = null, Error = NotLoggedInMessage, @@ -212,7 +212,7 @@ namespace GanjooRazor.Pages return WithSecureClientAsync(async secureClient => { var stringContent = new StringContent( - JsonConvert.SerializeObject(new GanjoorCommentPostViewModel() + JsonConvert.SerializeObject(new DiwanCommentPostViewModel() { HtmlComment = comment, InReplyToId = inReplytoId == 0 ? null : inReplytoId, @@ -221,18 +221,18 @@ namespace GanjooRazor.Pages }), Encoding.UTF8, "application/json"); - var response = await secureClient.PostAsync($"{APIRoot.Url}/api/ganjoor/comment", stringContent); + var response = await secureClient.PostAsync($"{APIRoot.Url}/api/diwan/comment", stringContent); if (response.StatusCode == HttpStatusCode.OK) { - var resComment = JsonConvert.DeserializeObject(await response.Content.ReadAsStringAsync()); + var resComment = JsonConvert.DeserializeObject(await response.Content.ReadAsStringAsync()); resComment.MyComment = true; - return Partial("~/Pages/Partials/GanjoorPage/_CommentPartial.cshtml", new _CommentPartialModel() + return Partial("~/Pages/Partials/DiwanPage/_CommentPartial.cshtml", new _CommentPartialModel() { Comment = resComment, Error = "", - InReplyTo = inReplytoId == 0 ? null : new GanjoorCommentSummaryViewModel(), + InReplyTo = inReplytoId == 0 ? null : new DiwanCommentSummaryViewModel(), LoggedIn = !string.IsNullOrEmpty(Request.Cookies["Token"]), PoemId = poemId, }); @@ -241,7 +241,7 @@ namespace GanjooRazor.Pages string rawError = await ReadErrorMessageAsync(response); var sanitizerInfo = TryParseSanitizerTextDroppedError(rawError); - return Partial("~/Pages/Partials/GanjoorPage/_CommentPartial.cshtml", new _CommentPartialModel() + return Partial("~/Pages/Partials/DiwanPage/_CommentPartial.cshtml", new _CommentPartialModel() { Comment = null, Error = sanitizerInfo != null ? sanitizerInfo.Message : rawError, @@ -257,7 +257,7 @@ namespace GanjooRazor.Pages { return WithSecureClientAsync(async secureClient => { - var response = await secureClient.DeleteAsync($"{APIRoot.Url}/api/ganjoor/comment?id={id}"); + var response = await secureClient.DeleteAsync($"{APIRoot.Url}/api/diwan/comment?id={id}"); if (!response.IsSuccessStatusCode) { return new BadRequestObjectResult(await ReadErrorMessageAsync(response)); @@ -270,7 +270,7 @@ namespace GanjooRazor.Pages { return WithSecureClientAsync(async secureClient => { - var response = await secureClient.PutAsync($"{APIRoot.Url}/api/ganjoor/comment/{id}", new StringContent(JsonConvert.SerializeObject(comment), Encoding.UTF8, "application/json")); + var response = await secureClient.PutAsync($"{APIRoot.Url}/api/diwan/comment/{id}", new StringContent(JsonConvert.SerializeObject(comment), Encoding.UTF8, "application/json")); if (!response.IsSuccessStatusCode) { return await BadRequestFromApiErrorAsync(response); @@ -286,12 +286,12 @@ namespace GanjooRazor.Pages { return WithSecureClientAsync(async secureClient => { - var response = await secureClient.PostAsync($"{APIRoot.Url}/api/ganjoor/poem/comment/{id}/rate?value={value}", null); + var response = await secureClient.PostAsync($"{APIRoot.Url}/api/diwan/poem/comment/{id}/rate?value={value}", null); if (!response.IsSuccessStatusCode) { return new BadRequestObjectResult(await ReadErrorMessageAsync(response)); } - var result = JsonConvert.DeserializeObject(await response.Content.ReadAsStringAsync()); + var result = JsonConvert.DeserializeObject(await response.Content.ReadAsStringAsync()); return new JsonResult(result); }); } @@ -299,7 +299,7 @@ namespace GanjooRazor.Pages /// /// Poets (for this page's own #hdr2 author dropdown - same pattern as Search/Simi/etc.) /// - public List Poets { get; set; } + public List Poets { get; set; } public bool IsPoetPage { get; set; } @@ -307,7 +307,7 @@ namespace GanjooRazor.Pages public bool IsPoemPage { get; set; } - public string CanonicalUrl => $"{Configuration["SiteUrl"]}{GanjoorPage.FullUrl}"; + public string CanonicalUrl => $"{Configuration["SiteUrl"]}{DiwanPage.FullUrl}"; public bool CanEdit { get; set; } @@ -319,7 +319,7 @@ namespace GanjooRazor.Pages public string ActiveTab { get; set; } - private void _preparePoemExcerpt(GanjoorPoemSummaryViewModel poem) + private void _preparePoemExcerpt(DiwanPoemSummaryViewModel poem) { if (poem == null || poem.Excerpt == null) { @@ -345,11 +345,11 @@ namespace GanjooRazor.Pages /// private async Task _markMyCommentsAndBringUpMyRecitations() { - if (GanjoorPage == null) + if (DiwanPage == null) { return; } - if (GanjoorPage.Poem == null) + if (DiwanPage.Poem == null) { return; } @@ -365,29 +365,29 @@ namespace GanjooRazor.Pages { return; } - foreach (GanjoorCommentSummaryViewModel comment in GanjoorPage.Poem.Comments) + foreach (DiwanCommentSummaryViewModel comment in DiwanPage.Poem.Comments) { comment.MyComment = comment.UserId == userId; _markMyReplies(comment, userId, null); } - if (GanjoorPage.Poem.Recitations.Length > 0) + if (DiwanPage.Poem.Recitations.Length > 0) { - using (HttpClient secureClient = new HttpClient(new GanjoorReloginHandler(Request, Response))) + using (HttpClient secureClient = new HttpClient(new DiwanReloginHandler(Request, Response))) { - if (await GanjoorSessionChecker.PrepareClient(secureClient, Request, Response)) + if (await DiwanSessionChecker.PrepareClient(secureClient, Request, Response)) { - HttpResponseMessage response = await secureClient.GetAsync($"{APIRoot.Url}/api/ganjoor/poem/{GanjoorPage.Poem.Id}/recitations/upvotes"); + HttpResponseMessage response = await secureClient.GetAsync($"{APIRoot.Url}/api/diwan/poem/{DiwanPage.Poem.Id}/recitations/upvotes"); if (response.IsSuccessStatusCode) { var upVotedIds = JsonConvert.DeserializeObject(await response.Content.ReadAsStringAsync()); if (upVotedIds.Length > 0) { - foreach (var recitation in GanjoorPage.Poem.Recitations) + foreach (var recitation in DiwanPage.Poem.Recitations) { recitation.UpVotedByUser = upVotedIds.Contains(recitation.Id); } - Array.Sort(GanjoorPage.Poem.Recitations, (a, b) => b.UpVotedByUser == a.UpVotedByUser ? a.AudioOrder.CompareTo(b.AudioOrder) : b.UpVotedByUser.CompareTo(a.UpVotedByUser)); + Array.Sort(DiwanPage.Poem.Recitations, (a, b) => b.UpVotedByUser == a.UpVotedByUser ? a.AudioOrder.CompareTo(b.AudioOrder) : b.UpVotedByUser.CompareTo(a.UpVotedByUser)); } } @@ -395,20 +395,20 @@ namespace GanjooRazor.Pages } } - if (GanjoorPage.Poem.Comments.Length > 0) + if (DiwanPage.Poem.Comments.Length > 0) { - using (HttpClient secureClient = new HttpClient(new GanjoorReloginHandler(Request, Response))) + using (HttpClient secureClient = new HttpClient(new DiwanReloginHandler(Request, Response))) { - if (await GanjoorSessionChecker.PrepareClient(secureClient, Request, Response)) + if (await DiwanSessionChecker.PrepareClient(secureClient, Request, Response)) { - HttpResponseMessage response = await secureClient.GetAsync($"{APIRoot.Url}/api/ganjoor/poem/{GanjoorPage.Poem.Id}/comments/myratings"); + HttpResponseMessage response = await secureClient.GetAsync($"{APIRoot.Url}/api/diwan/poem/{DiwanPage.Poem.Id}/comments/myratings"); if (response.IsSuccessStatusCode) { - var ratings = JsonConvert.DeserializeObject(await response.Content.ReadAsStringAsync()); + var ratings = JsonConvert.DeserializeObject(await response.Content.ReadAsStringAsync()); if (ratings.Length > 0) { var ratingsDic = ratings.ToDictionary(r => r.CommentId, r => r.Value); - foreach (GanjoorCommentSummaryViewModel comment in GanjoorPage.Poem.Comments) + foreach (DiwanCommentSummaryViewModel comment in DiwanPage.Poem.Comments) { _applyCommentRatings(comment, ratingsDic); } @@ -419,7 +419,7 @@ namespace GanjooRazor.Pages } } - private void _applyCommentRatings(GanjoorCommentSummaryViewModel comment, Dictionary ratings) + private void _applyCommentRatings(DiwanCommentSummaryViewModel comment, Dictionary ratings) { if (ratings.TryGetValue(comment.Id, out short value)) { @@ -431,7 +431,7 @@ namespace GanjooRazor.Pages } } - private void _markMyReplies(GanjoorCommentSummaryViewModel parent, Guid userId, GanjoorUserBookmarkViewModel[] bookmarks) + private void _markMyReplies(DiwanCommentSummaryViewModel parent, Guid userId, DiwanUserBookmarkViewModel[] bookmarks) { foreach (var reply in parent.Replies) { @@ -509,62 +509,62 @@ namespace GanjooRazor.Pages private void _prepareNextPre() { - switch (GanjoorPage.GanjoorPageType) + switch (DiwanPage.DiwanPageType) { - case GanjoorPageType.PoemPage: + case DiwanPageType.PoemPage: { - if (GanjoorPage.Poem.Next != null) + if (DiwanPage.Poem.Next != null) { - NextUrl = GanjoorPage.PoetOrCat.Cat.FullUrl + "/" + GanjoorPage.Poem.Next.UrlSlug; - NextTitle = GanjoorPage.Poem.Next.Title + ": " + GanjoorPage.Poem.Next.Excerpt; + NextUrl = DiwanPage.PoetOrCat.Cat.FullUrl + "/" + DiwanPage.Poem.Next.UrlSlug; + NextTitle = DiwanPage.Poem.Next.Title + ": " + DiwanPage.Poem.Next.Excerpt; } else - if (GanjoorPage.Poem.MixedModeOrder > 0 - && GanjoorPage.Poem.Category.Cat.Children.Where(c => c.MixedModeOrder == 0 || c.MixedModeOrder > GanjoorPage.Poem.MixedModeOrder).Any()) + if (DiwanPage.Poem.MixedModeOrder > 0 + && DiwanPage.Poem.Category.Cat.Children.Where(c => c.MixedModeOrder == 0 || c.MixedModeOrder > DiwanPage.Poem.MixedModeOrder).Any()) { - var nextCat = GanjoorPage.Poem.Category.Cat.Children.Where(c => c.MixedModeOrder == 0 || c.MixedModeOrder > GanjoorPage.Poem.MixedModeOrder).OrderBy(c => c.MixedModeOrder).First(); + var nextCat = DiwanPage.Poem.Category.Cat.Children.Where(c => c.MixedModeOrder == 0 || c.MixedModeOrder > DiwanPage.Poem.MixedModeOrder).OrderBy(c => c.MixedModeOrder).First(); NextUrl = nextCat.FullUrl; NextTitle = nextCat.Title; } else - if (GanjoorPage.Poem.Category.Cat.Next != null) + if (DiwanPage.Poem.Category.Cat.Next != null) { - NextUrl = GanjoorPage.Poem.Category.Cat.Next.FullUrl; - NextTitle = GanjoorPage.Poem.Category.Cat.Next.Title; + NextUrl = DiwanPage.Poem.Category.Cat.Next.FullUrl; + NextTitle = DiwanPage.Poem.Category.Cat.Next.Title; } - if (GanjoorPage.Poem.Previous != null) + if (DiwanPage.Poem.Previous != null) { - PreviousUrl = GanjoorPage.PoetOrCat.Cat.FullUrl + "/" + GanjoorPage.Poem.Previous.UrlSlug; - PreviousTitle = GanjoorPage.Poem.Previous.Title + ": " + GanjoorPage.Poem.Previous.Excerpt; + PreviousUrl = DiwanPage.PoetOrCat.Cat.FullUrl + "/" + DiwanPage.Poem.Previous.UrlSlug; + PreviousTitle = DiwanPage.Poem.Previous.Title + ": " + DiwanPage.Poem.Previous.Excerpt; } else - if (GanjoorPage.Poem.MixedModeOrder > 0 - && GanjoorPage.Poem.Category.Cat.Children.Where(c => c.MixedModeOrder != 0 && c.MixedModeOrder < GanjoorPage.Poem.MixedModeOrder).Any()) + if (DiwanPage.Poem.MixedModeOrder > 0 + && DiwanPage.Poem.Category.Cat.Children.Where(c => c.MixedModeOrder != 0 && c.MixedModeOrder < DiwanPage.Poem.MixedModeOrder).Any()) { - var prevCat = GanjoorPage.Poem.Category.Cat.Children.Where(c => c.MixedModeOrder != 0 && c.MixedModeOrder < GanjoorPage.Poem.MixedModeOrder).OrderByDescending(c => c.MixedModeOrder).First(); + var prevCat = DiwanPage.Poem.Category.Cat.Children.Where(c => c.MixedModeOrder != 0 && c.MixedModeOrder < DiwanPage.Poem.MixedModeOrder).OrderByDescending(c => c.MixedModeOrder).First(); PreviousUrl = prevCat.FullUrl; PreviousTitle = prevCat.Title; } else - if (GanjoorPage.Poem.Category.Cat.Previous != null) + if (DiwanPage.Poem.Category.Cat.Previous != null) { - PreviousUrl = GanjoorPage.Poem.Category.Cat.Previous.FullUrl; - PreviousTitle = GanjoorPage.Poem.Category.Cat.Previous.Title; + PreviousUrl = DiwanPage.Poem.Category.Cat.Previous.FullUrl; + PreviousTitle = DiwanPage.Poem.Category.Cat.Previous.Title; } } break; - case GanjoorPageType.CatPage: + case DiwanPageType.CatPage: { - if (GanjoorPage.PoetOrCat.Cat.Next != null) + if (DiwanPage.PoetOrCat.Cat.Next != null) { - NextUrl = GanjoorPage.PoetOrCat.Cat.Next.FullUrl; - NextTitle = GanjoorPage.PoetOrCat.Cat.Next.Title; + NextUrl = DiwanPage.PoetOrCat.Cat.Next.FullUrl; + NextTitle = DiwanPage.PoetOrCat.Cat.Next.Title; } - if (GanjoorPage.PoetOrCat.Cat.Previous != null) + if (DiwanPage.PoetOrCat.Cat.Previous != null) { - PreviousUrl = GanjoorPage.PoetOrCat.Cat.Previous.FullUrl; - PreviousTitle = GanjoorPage.PoetOrCat.Cat.Previous.Title; + PreviousUrl = DiwanPage.PoetOrCat.Cat.Previous.FullUrl; + PreviousTitle = DiwanPage.PoetOrCat.Cat.Previous.Title; } } break; @@ -575,22 +575,22 @@ namespace GanjooRazor.Pages private void _prepareRelatedSecions() { - SectionsWithRelated = new List(); - SectionsWithMetreAndRhymes = new List(); - MutiPartPoemPage = GanjoorPage.Poem.Verses.Where(v => v.VersePosition == VersePosition.Paragraph || v.VersePosition == VersePosition.Single).Any() + SectionsWithRelated = new List(); + SectionsWithMetreAndRhymes = new List(); + MutiPartPoemPage = DiwanPage.Poem.Verses.Where(v => v.VersePosition == VersePosition.Paragraph || v.VersePosition == VersePosition.Single).Any() || - GanjoorPage.Poem.Sections.Count(s => s.SectionType == PoemSectionType.WholePoem && s.VerseType == VersePoemSectionType.First) != 1; + DiwanPage.Poem.Sections.Count(s => s.SectionType == PoemSectionType.WholePoem && s.VerseType == VersePoemSectionType.First) != 1; if ( !MutiPartPoemPage ) { - foreach (var section in GanjoorPage.Poem.Sections) + foreach (var section in DiwanPage.Poem.Sections) { if (section.Top6RelatedSections.Length > 0) { SectionsWithRelated.Add(section); } - if (section.SectionType == PoemSectionType.WholePoem && section.GanjoorMetre != null && !string.IsNullOrEmpty(section.RhymeLetters)) + if (section.SectionType == PoemSectionType.WholePoem && section.DiwanMetre != null && !string.IsNullOrEmpty(section.RhymeLetters)) { SectionsWithMetreAndRhymes.Add(section); } @@ -598,7 +598,7 @@ namespace GanjooRazor.Pages } } - public GanjoorPoetSuggestedPictureViewModel Photo { get; set; } + public DiwanPoetSuggestedPictureViewModel Photo { get; set; } /// /// Get. Unlike the old IndexModel.OnGetAsync, this never needs to check @@ -632,7 +632,7 @@ namespace GanjooRazor.Pages var breadCrumbList = new GoogleBreadCrumbList(); Banner = null; - var pageLoadResult = await LoadGanjoorPageAsync(); + var pageLoadResult = await LoadDiwanPageAsync(); if (pageLoadResult != null) { return pageLoadResult; @@ -713,7 +713,7 @@ namespace GanjooRazor.Pages /// private async Task RedirectByPageIdAsync(string pageId) { - var pageUrlResponse = await _httpClient.GetAsync($"{APIRoot.Url}/api/ganjoor/pageurl?id={pageId}"); + var pageUrlResponse = await _httpClient.GetAsync($"{APIRoot.Url}/api/diwan/pageurl?id={pageId}"); if (await CaptureErrorIfFailedAsync(pageUrlResponse)) { return Page(); @@ -723,19 +723,19 @@ namespace GanjooRazor.Pages } /// - /// Fetches the GanjoorPage for the current URL and applies the page-type-specific preparation + /// Fetches the DiwanPage for the current URL and applies the page-type-specific preparation /// that depends only on the page payload itself (excerpts, related sections, next/previous /// links). Returns null to let OnGetAsync continue, or a terminal IActionResult /// (redirect/404/error page) to short-circuit. /// - private async Task LoadGanjoorPageAsync() + private async Task LoadDiwanPageAsync() { - var pageQuery = await _httpClient.GetAsync($"{APIRoot.Url}/api/ganjoor/page?url={Request.Path}"); + var pageQuery = await _httpClient.GetAsync($"{APIRoot.Url}/api/diwan/page?url={Request.Path}"); if (!pageQuery.IsSuccessStatusCode) { if (pageQuery.StatusCode == HttpStatusCode.NotFound) { - var redirectQuery = await _httpClient.GetAsync($"{APIRoot.Url}/api/ganjoor/redirecturl?url={Request.Path}"); + var redirectQuery = await _httpClient.GetAsync($"{APIRoot.Url}/api/diwan/redirecturl?url={Request.Path}"); if (redirectQuery.IsSuccessStatusCode) { var redirectUrl = JsonConvert.DeserializeObject(await redirectQuery.Content.ReadAsStringAsync()); @@ -748,27 +748,27 @@ namespace GanjooRazor.Pages return Page(); } - GanjoorPage = JObject.Parse(await pageQuery.Content.ReadAsStringAsync()).ToObject(); - if (!string.IsNullOrEmpty(GanjoorPage.HtmlText)) + DiwanPage = JObject.Parse(await pageQuery.Content.ReadAsStringAsync()).ToObject(); + if (!string.IsNullOrEmpty(DiwanPage.HtmlText)) { - GanjoorPage.HtmlText = GanjoorPage.HtmlText.Replace("https://ganjoor.net/", "/").Replace("http://ganjoor.net/", "/"); + DiwanPage.HtmlText = DiwanPage.HtmlText.Replace("https://ganjoor.net/", "/").Replace("http://ganjoor.net/", "/"); } - switch (GanjoorPage.GanjoorPageType) + switch (DiwanPage.DiwanPageType) { - case GanjoorPageType.PoemPage: + case DiwanPageType.PoemPage: await _markMyCommentsAndBringUpMyRecitations(); - _preparePoemExcerpt(GanjoorPage.Poem.Next); - _preparePoemExcerpt(GanjoorPage.Poem.Previous); - GanjoorPage.PoetOrCat = GanjoorPage.Poem.Category; + _preparePoemExcerpt(DiwanPage.Poem.Next); + _preparePoemExcerpt(DiwanPage.Poem.Previous); + DiwanPage.PoetOrCat = DiwanPage.Poem.Category; _prepareNextPre(); _prepareRelatedSecions(); IsPoemPage = true; break; - case GanjoorPageType.PoetPage: + case DiwanPageType.PoetPage: IsPoetPage = true; break; - case GanjoorPageType.CatPage: + case DiwanPageType.CatPage: _prepareNextPre(); IsCatPage = true; break; @@ -785,7 +785,7 @@ namespace GanjooRazor.Pages { if (IsPoetPage || IsCatPage) { - var catHasAnyRecitationQuery = await _httpClient.GetAsync($"{APIRoot.Url}/api/audio/catany/{GanjoorPage.PoetOrCat.Cat.Id}"); + var catHasAnyRecitationQuery = await _httpClient.GetAsync($"{APIRoot.Url}/api/audio/catany/{DiwanPage.PoetOrCat.Cat.Id}"); if (await CaptureErrorIfFailedAsync(catHasAnyRecitationQuery)) { return Page(); @@ -795,12 +795,12 @@ namespace GanjooRazor.Pages if (IsPoetPage) { - var responsePhotos = await _httpClient.GetAsync($"{APIRoot.Url}/api/poetphotos/poet/{GanjoorPage.PoetOrCat.Poet.Id}"); + var responsePhotos = await _httpClient.GetAsync($"{APIRoot.Url}/api/poetphotos/poet/{DiwanPage.PoetOrCat.Poet.Id}"); if (await CaptureErrorIfFailedAsync(responsePhotos)) { return Page(); } - var photos = JArray.Parse(await responsePhotos.Content.ReadAsStringAsync()).ToObject>(); + var photos = JArray.Parse(await responsePhotos.Content.ReadAsStringAsync()).ToObject>(); if (photos.Any()) { Photo = photos.First(); @@ -809,7 +809,7 @@ namespace GanjooRazor.Pages if (IsPoemPage) { - HtmlLanguage = string.IsNullOrEmpty(GanjoorPage.Poem.Language) ? "ur-PK" : GanjoorPage.Poem.Language; + HtmlLanguage = string.IsNullOrEmpty(DiwanPage.Poem.Language) ? "ur-PK" : DiwanPage.Poem.Language; if (GetConfigFlag("BannersEnabled")) { var bannerQuery = await _httpClient.GetAsync($"{APIRoot.Url}/api/banners/random"); @@ -820,7 +820,7 @@ namespace GanjooRazor.Pages var bannerResponse = await bannerQuery.Content.ReadAsStringAsync(); if (!string.IsNullOrEmpty(bannerResponse)) { - Banner = JObject.Parse(bannerResponse).ToObject(); + Banner = JObject.Parse(bannerResponse).ToObject(); } } } @@ -855,83 +855,83 @@ namespace GanjooRazor.Pages private void BuildPoetPageTitleAndBreadCrumbs(GoogleBreadCrumbList breadCrumbList) { - ViewData["Title"] = $"دیوان » {GanjoorPage.PoetOrCat.Poet.Nickname}"; - breadCrumbList.AddItem(GanjoorPage.PoetOrCat.Poet.Nickname, GanjoorPage.PoetOrCat.Cat.FullUrl, $"{APIRoot.InternetUrl + GanjoorPage.PoetOrCat.Poet.ImageUrl}"); + ViewData["Title"] = $"دیوان » {DiwanPage.PoetOrCat.Poet.Nickname}"; + breadCrumbList.AddItem(DiwanPage.PoetOrCat.Poet.Nickname, DiwanPage.PoetOrCat.Cat.FullUrl, $"{APIRoot.InternetUrl + DiwanPage.PoetOrCat.Poet.ImageUrl}"); } private void BuildCatPageTitleAndBreadCrumbs(GoogleBreadCrumbList breadCrumbList) { string title = $"دیوان » "; bool poetCat = true; - foreach (var gran in GanjoorPage.PoetOrCat.Cat.Ancestors) + foreach (var gran in DiwanPage.PoetOrCat.Cat.Ancestors) { title += $"{gran.Title} » "; - breadCrumbList.AddItem(gran.Title, gran.FullUrl, poetCat ? $"{APIRoot.InternetUrl + GanjoorPage.PoetOrCat.Poet.ImageUrl}" : "https://i.ganjoor.net/cat.png"); + breadCrumbList.AddItem(gran.Title, gran.FullUrl, poetCat ? $"{APIRoot.InternetUrl + DiwanPage.PoetOrCat.Poet.ImageUrl}" : "https://i.ganjoor.net/cat.png"); poetCat = false; } - breadCrumbList.AddItem(GanjoorPage.PoetOrCat.Cat.Title, GanjoorPage.PoetOrCat.Cat.FullUrl, "https://i.ganjoor.net/cat.png"); - title += GanjoorPage.PoetOrCat.Cat.Title; + breadCrumbList.AddItem(DiwanPage.PoetOrCat.Cat.Title, DiwanPage.PoetOrCat.Cat.FullUrl, "https://i.ganjoor.net/cat.png"); + title += DiwanPage.PoetOrCat.Cat.Title; ViewData["Title"] = title; } private void BuildPoemPageTitleAndBreadCrumbs(GoogleBreadCrumbList breadCrumbList) { - ViewData["Title"] = $"دیوان » {GanjoorPage.Poem.FullTitle}"; + ViewData["Title"] = $"دیوان » {DiwanPage.Poem.FullTitle}"; bool poetCat = true; - foreach (var gran in GanjoorPage.Poem.Category.Cat.Ancestors) + foreach (var gran in DiwanPage.Poem.Category.Cat.Ancestors) { - breadCrumbList.AddItem(gran.Title, gran.FullUrl, poetCat ? $"{APIRoot.InternetUrl + GanjoorPage.PoetOrCat.Poet.ImageUrl}" : "https://i.ganjoor.net/cat.png"); + breadCrumbList.AddItem(gran.Title, gran.FullUrl, poetCat ? $"{APIRoot.InternetUrl + DiwanPage.PoetOrCat.Poet.ImageUrl}" : "https://i.ganjoor.net/cat.png"); poetCat = false; } - breadCrumbList.AddItem(GanjoorPage.PoetOrCat.Cat.Title, GanjoorPage.PoetOrCat.Cat.FullUrl, "https://i.ganjoor.net/cat.png"); + breadCrumbList.AddItem(DiwanPage.PoetOrCat.Cat.Title, DiwanPage.PoetOrCat.Cat.FullUrl, "https://i.ganjoor.net/cat.png"); - var aiMuseumImage = GanjoorPage.Poem.Images.FirstOrDefault(i => i.TargetPageUrl.StartsWith("https://museum.ganjoor.net/items/ai")); + var aiMuseumImage = DiwanPage.Poem.Images.FirstOrDefault(i => i.TargetPageUrl.StartsWith("https://museum.ganjoor.net/items/ai")); if (aiMuseumImage != null) { - breadCrumbList.AddItem(GanjoorPage.Poem.Title, GanjoorPage.Poem.FullUrl, aiMuseumImage.ThumbnailImageUrl.Replace("/thumb/", "/orig/")); + breadCrumbList.AddItem(DiwanPage.Poem.Title, DiwanPage.Poem.FullUrl, aiMuseumImage.ThumbnailImageUrl.Replace("/thumb/", "/orig/")); } - else if (GanjoorPage.Poem.Images.Any()) + else if (DiwanPage.Poem.Images.Any()) { - breadCrumbList.AddItem(GanjoorPage.Poem.Title, GanjoorPage.Poem.FullUrl, GanjoorPage.Poem.Images.First().ThumbnailImageUrl.Replace("/thumb/", "/orig/")); + breadCrumbList.AddItem(DiwanPage.Poem.Title, DiwanPage.Poem.FullUrl, DiwanPage.Poem.Images.First().ThumbnailImageUrl.Replace("/thumb/", "/orig/")); } else { - breadCrumbList.AddItem(GanjoorPage.Poem.Title, GanjoorPage.Poem.FullUrl, "https://i.ganjoor.net/poem.png"); + breadCrumbList.AddItem(DiwanPage.Poem.Title, DiwanPage.Poem.FullUrl, "https://i.ganjoor.net/poem.png"); } } private void BuildGenericPageTitleAndBreadCrumbs(GoogleBreadCrumbList breadCrumbList) { - if (GanjoorPage.PoetOrCat != null) + if (DiwanPage.PoetOrCat != null) { bool poetCat = true; string fullTitle = "دیوان » "; - if (GanjoorPage.PoetOrCat.Cat.Ancestors.Count == 0) + if (DiwanPage.PoetOrCat.Cat.Ancestors.Count == 0) { - fullTitle += $"{GanjoorPage.PoetOrCat.Poet.Nickname} » "; + fullTitle += $"{DiwanPage.PoetOrCat.Poet.Nickname} » "; } else { - foreach (var gran in GanjoorPage.PoetOrCat.Cat.Ancestors) + foreach (var gran in DiwanPage.PoetOrCat.Cat.Ancestors) { - breadCrumbList.AddItem(gran.Title, gran.FullUrl, poetCat ? $"{APIRoot.InternetUrl + GanjoorPage.PoetOrCat.Poet.ImageUrl}" : "https://i.ganjoor.net/cat.png"); + breadCrumbList.AddItem(gran.Title, gran.FullUrl, poetCat ? $"{APIRoot.InternetUrl + DiwanPage.PoetOrCat.Poet.ImageUrl}" : "https://i.ganjoor.net/cat.png"); poetCat = false; fullTitle += $"{gran.Title} » "; } } - ViewData["Title"] = $"{fullTitle}{GanjoorPage.Title}"; - breadCrumbList.AddItem(GanjoorPage.PoetOrCat.Poet.Nickname, GanjoorPage.PoetOrCat.Cat.FullUrl, $"{APIRoot.InternetUrl + GanjoorPage.PoetOrCat.Poet.ImageUrl}"); + ViewData["Title"] = $"{fullTitle}{DiwanPage.Title}"; + breadCrumbList.AddItem(DiwanPage.PoetOrCat.Poet.Nickname, DiwanPage.PoetOrCat.Cat.FullUrl, $"{APIRoot.InternetUrl + DiwanPage.PoetOrCat.Poet.ImageUrl}"); } else { - ViewData["Title"] = $"دیوان » {GanjoorPage.FullTitle}"; + ViewData["Title"] = $"دیوان » {DiwanPage.FullTitle}"; } - breadCrumbList.AddItem(GanjoorPage.Title, GanjoorPage.FullUrl, "https://i.ganjoor.net/cat.png"); + breadCrumbList.AddItem(DiwanPage.Title, DiwanPage.FullUrl, "https://i.ganjoor.net/cat.png"); } private async Task LoadCategoryGeoTagsAsync() { - var tagsResponse = await _httpClient.GetAsync($"{APIRoot.Url}/api/ganjoor/cat/{GanjoorPage.PoetOrCat.Cat.Id}/geotag"); + var tagsResponse = await _httpClient.GetAsync($"{APIRoot.Url}/api/diwan/cat/{DiwanPage.PoetOrCat.Cat.Id}/geotag"); if (await CaptureErrorIfFailedAsync(tagsResponse)) { return Page(); @@ -942,38 +942,38 @@ namespace GanjooRazor.Pages public async Task OnGetBNumPartialAsync(int poemId, int coupletIndex) { - var responseCoupletComments = await _httpClient.GetAsync($"{APIRoot.Url}/api/ganjoor/poem/{poemId}/comments?coupletIndex={coupletIndex}"); + var responseCoupletComments = await _httpClient.GetAsync($"{APIRoot.Url}/api/diwan/poem/{poemId}/comments?coupletIndex={coupletIndex}"); if (!responseCoupletComments.IsSuccessStatusCode) { return BadRequest(await ReadErrorMessageAsync(responseCoupletComments)); } - var comments = JArray.Parse(await responseCoupletComments.Content.ReadAsStringAsync()).ToObject>(); + var comments = JArray.Parse(await responseCoupletComments.Content.ReadAsStringAsync()).ToObject>(); var responseCoupletNumbers = await _httpClient.GetAsync($"{APIRoot.Url}/api/numberings/couplet/{poemId}/{coupletIndex}"); if (!responseCoupletNumbers.IsSuccessStatusCode) { return BadRequest(await ReadErrorMessageAsync(responseCoupletNumbers)); } - var numbers = JArray.Parse(await responseCoupletNumbers.Content.ReadAsStringAsync()).ToObject>(); + var numbers = JArray.Parse(await responseCoupletNumbers.Content.ReadAsStringAsync()).ToObject>(); - var responseCoupletSections = await _httpClient.GetAsync($"{APIRoot.Url}/api/ganjoor/couplet/{poemId}/{coupletIndex}/sections"); + var responseCoupletSections = await _httpClient.GetAsync($"{APIRoot.Url}/api/diwan/couplet/{poemId}/{coupletIndex}/sections"); if (!responseCoupletSections.IsSuccessStatusCode) { return BadRequest(await ReadErrorMessageAsync(responseCoupletSections)); } - var responseVerses = await _httpClient.GetAsync($"{APIRoot.Url}/api/ganjoor/poem/{poemId}/verses?coupletIndex={coupletIndex}"); + var responseVerses = await _httpClient.GetAsync($"{APIRoot.Url}/api/diwan/poem/{poemId}/verses?coupletIndex={coupletIndex}"); if (!responseVerses.IsSuccessStatusCode) { return BadRequest(await ReadErrorMessageAsync(responseVerses)); } - var verses = JArray.Parse(await responseVerses.Content.ReadAsStringAsync()).ToObject>(); - var sections = JArray.Parse(await responseCoupletSections.Content.ReadAsStringAsync()).ToObject>(); - var sectionsWithMetreAndRhymes = new List(); + var verses = JArray.Parse(await responseVerses.Content.ReadAsStringAsync()).ToObject>(); + var sections = JArray.Parse(await responseCoupletSections.Content.ReadAsStringAsync()).ToObject>(); + var sectionsWithMetreAndRhymes = new List(); foreach (var section in sections) { - if (section.GanjoorMetreId != null && !string.IsNullOrEmpty(section.RhymeLetters)) + if (section.DiwanMetreId != null && !string.IsNullOrEmpty(section.RhymeLetters)) { - if (!sectionsWithMetreAndRhymes.Any(s => s.GanjoorMetreId == section.GanjoorMetreId && s.RhymeLetters == section.RhymeLetters)) + if (!sectionsWithMetreAndRhymes.Any(s => s.DiwanMetreId == section.DiwanMetreId && s.RhymeLetters == section.RhymeLetters)) { sectionsWithMetreAndRhymes.Add(section); } @@ -987,34 +987,34 @@ namespace GanjooRazor.Pages if (Guid.TryParse(Request.Cookies["UserId"], out Guid userId)) if (userId != Guid.Empty) { - using (HttpClient secureClient = new HttpClient(new GanjoorReloginHandler(Request, Response))) + using (HttpClient secureClient = new HttpClient(new DiwanReloginHandler(Request, Response))) { - if (await GanjoorSessionChecker.PrepareClient(secureClient, Request, Response)) + if (await DiwanSessionChecker.PrepareClient(secureClient, Request, Response)) { - HttpResponseMessage responseIsBookmarked = await secureClient.GetAsync($"{APIRoot.Url}/api/ganjoor/bookmark/{poemId}"); + HttpResponseMessage responseIsBookmarked = await secureClient.GetAsync($"{APIRoot.Url}/api/diwan/bookmark/{poemId}"); if (!responseIsBookmarked.IsSuccessStatusCode) { return BadRequest(await ReadErrorMessageAsync(responseIsBookmarked)); } - var bookmarks = JsonConvert.DeserializeObject(await responseIsBookmarked.Content.ReadAsStringAsync()); + var bookmarks = JsonConvert.DeserializeObject(await responseIsBookmarked.Content.ReadAsStringAsync()); if (bookmarks.Where(b => b.CoupletIndex == coupletIndex).Any()) isBookmarked = true; - foreach (GanjoorCommentSummaryViewModel comment in comments) + foreach (DiwanCommentSummaryViewModel comment in comments) { comment.MyComment = comment.UserId == userId; comment.IsBookmarked = bookmarks.Where(b => b.CoupletIndex == -comment.Id).Any(); _markMyReplies(comment, userId, bookmarks); } - HttpResponseMessage responseRatings = await secureClient.GetAsync($"{APIRoot.Url}/api/ganjoor/poem/{poemId}/comments/myratings"); + HttpResponseMessage responseRatings = await secureClient.GetAsync($"{APIRoot.Url}/api/diwan/poem/{poemId}/comments/myratings"); if (responseRatings.IsSuccessStatusCode) { - var ratings = JsonConvert.DeserializeObject(await responseRatings.Content.ReadAsStringAsync()); + var ratings = JsonConvert.DeserializeObject(await responseRatings.Content.ReadAsStringAsync()); if (ratings.Length > 0) { var ratingsDic = ratings.ToDictionary(r => r.CommentId, r => r.Value); - foreach (GanjoorCommentSummaryViewModel comment in comments) + foreach (DiwanCommentSummaryViewModel comment in comments) { _applyCommentRatings(comment, ratingsDic); } @@ -1025,7 +1025,7 @@ namespace GanjooRazor.Pages } } - return Partial("~/Pages/Partials/GanjoorPage/_BNumPartial.cshtml", new _BNumPartialModel() + return Partial("~/Pages/Partials/DiwanPage/_BNumPartial.cshtml", new _BNumPartialModel() { PoemId = poemId, CoupletIndex = coupletIndex, @@ -1043,7 +1043,7 @@ namespace GanjooRazor.Pages { return WithSecureClientAsync(async secureClient => { - var response = await secureClient.PostAsync($"{APIRoot.Url}/api/ganjoor/bookmark/switch/ret/{poemId}/{coupletIndex}", null); + var response = await secureClient.PostAsync($"{APIRoot.Url}/api/diwan/bookmark/switch/ret/{poemId}/{coupletIndex}", null); if (!response.IsSuccessStatusCode) { return new BadRequestObjectResult(await ReadErrorMessageAsync(response)); @@ -1057,7 +1057,7 @@ namespace GanjooRazor.Pages { return WithSecureClientAsync(async secureClient => { - var response = await secureClient.GetAsync($"{APIRoot.Url}/api/ganjoor/bookmark/{poemId}/{coupletIndex}"); + var response = await secureClient.GetAsync($"{APIRoot.Url}/api/diwan/bookmark/{poemId}/{coupletIndex}"); if (!response.IsSuccessStatusCode) { return new BadRequestObjectResult(await ReadErrorMessageAsync(response)); @@ -1071,12 +1071,12 @@ namespace GanjooRazor.Pages { return WithSecureClientAsync(async secureClient => { - var response = await secureClient.GetAsync($"{APIRoot.Url}/api/ganjoor/bookmark/{poemId}"); + var response = await secureClient.GetAsync($"{APIRoot.Url}/api/diwan/bookmark/{poemId}"); if (!response.IsSuccessStatusCode) { return new BadRequestObjectResult(await ReadErrorMessageAsync(response)); } - var res = JsonConvert.DeserializeObject(await response.Content.ReadAsStringAsync()); + var res = JsonConvert.DeserializeObject(await response.Content.ReadAsStringAsync()); return new OkObjectResult(res); }); } @@ -1088,7 +1088,7 @@ namespace GanjooRazor.Pages { return WithSecureClientAsync(async secureClient => { - var response = await secureClient.GetAsync($"{APIRoot.Url}/api/ganjoor/poem/{poemId}/recitations/upvotes"); + var response = await secureClient.GetAsync($"{APIRoot.Url}/api/diwan/poem/{poemId}/recitations/upvotes"); if (!response.IsSuccessStatusCode) { return new BadRequestObjectResult(await ReadErrorMessageAsync(response)); @@ -1121,7 +1121,7 @@ namespace GanjooRazor.Pages { return new BadRequestObjectResult(await ReadErrorMessageAsync(response)); } - var res = JsonConvert.DeserializeObject(await response.Content.ReadAsStringAsync()); + var res = JsonConvert.DeserializeObject(await response.Content.ReadAsStringAsync()); if (res.KeepTrack == false) { if (Request.Cookies["KeepHistory"] != null) @@ -1145,7 +1145,7 @@ namespace GanjooRazor.Pages { return WithSecureClientAsync(async secureClient => { - var response = await secureClient.PutAsync($"{APIRoot.Url}/api/ganjoor/bookmark/{id}", new StringContent(JsonConvert.SerializeObject(note), Encoding.UTF8, "application/json")); + var response = await secureClient.PutAsync($"{APIRoot.Url}/api/diwan/bookmark/{id}", new StringContent(JsonConvert.SerializeObject(note), Encoding.UTF8, "application/json")); if (!response.IsSuccessStatusCode) { return await BadRequestFromApiErrorAsync(response); @@ -1192,12 +1192,12 @@ namespace GanjooRazor.Pages public async Task OnGetMoreQuotedPoemsForRelatedPoemPartialAsync(int poemId, int relatedPoemId, string poetImageUrl, string poetNickName, bool canEdit) { - string url = $"{APIRoot.Url}/api/ganjoor/poem/{poemId}/quoteds/{relatedPoemId}?published=true"; + string url = $"{APIRoot.Url}/api/diwan/poem/{poemId}/quoteds/{relatedPoemId}?published=true"; var response = await _httpClient.GetAsync(url); if (!response.IsSuccessStatusCode) return BadRequest(await ReadErrorMessageAsync(response)); - var quoteds = JArray.Parse(await response.Content.ReadAsStringAsync()).ToObject>(); + var quoteds = JArray.Parse(await response.Content.ReadAsStringAsync()).ToObject>(); if (!quoteds.Any()) { return BadRequest("مورد دیگری یافت نشد."); @@ -1209,9 +1209,9 @@ namespace GanjooRazor.Pages quoteds.Remove(mainList); } - return Partial("~/Pages/Partials/GanjoorPage/_MultipleQuotedPoemsPartial.cshtml", new _MultipleQuotedPoemsPartialModel() + return Partial("~/Pages/Partials/DiwanPage/_MultipleQuotedPoemsPartial.cshtml", new _MultipleQuotedPoemsPartialModel() { - GanjoorQuotedPoems = quoteds.ToArray(), + DiwanQuotedPoems = quoteds.ToArray(), PoetImageUrl = poetImageUrl, PoetNickName = poetNickName, CanEdit = canEdit @@ -1220,29 +1220,29 @@ namespace GanjooRazor.Pages public async Task OnGetMoreQuotedPoemsPartialAsync(int poemId, int skip, string poetImageUrl, string poetNickName, bool canEdit) { - string url = $"{APIRoot.Url}/api/ganjoor/poem/{poemId}/quoteds?skip={skip}&itemsCount=1000"; + string url = $"{APIRoot.Url}/api/diwan/poem/{poemId}/quoteds?skip={skip}&itemsCount=1000"; var response = await _httpClient.GetAsync(url); if (!response.IsSuccessStatusCode) return BadRequest(await ReadErrorMessageAsync(response)); - var quoteds = JArray.Parse(await response.Content.ReadAsStringAsync()).ToObject>(); + var quoteds = JArray.Parse(await response.Content.ReadAsStringAsync()).ToObject>(); - return Partial("~/Pages/Partials/GanjoorPage/_MultipleQuotedPoemsPartial.cshtml", new _MultipleQuotedPoemsPartialModel() + return Partial("~/Pages/Partials/DiwanPage/_MultipleQuotedPoemsPartial.cshtml", new _MultipleQuotedPoemsPartialModel() { - GanjoorQuotedPoems = quoteds.ToArray(), + DiwanQuotedPoems = quoteds.ToArray(), PoetImageUrl = poetImageUrl, PoetNickName = poetNickName, CanEdit = canEdit }); } - public string PoemBlockClass => GanjoorPage != null && GanjoorPage.Poem != null && GanjoorPage.Poem.ClaimedByMultiplePoets ? "poem ribbon-parent" : "poem"; + public string PoemBlockClass => DiwanPage != null && DiwanPage.Poem != null && DiwanPage.Poem.ClaimedByMultiplePoets ? "poem ribbon-parent" : "poem"; public Task OnPostMarkAsTextOriginalAsync(int bookId, int categoryId) { return WithSecureClientAsync(async secureClient => { - var response = await secureClient.PutAsync($"{APIRoot.Url}/api/ganjoor/naskban/textoriginal/{bookId}/{categoryId}/true", null); + var response = await secureClient.PutAsync($"{APIRoot.Url}/api/diwan/naskban/textoriginal/{bookId}/{categoryId}/true", null); if (!response.IsSuccessStatusCode) { return new BadRequestObjectResult(await ReadErrorMessageAsync(response)); @@ -1257,7 +1257,7 @@ namespace GanjooRazor.Pages { var response = await secureClient.DeleteAsync( relatedImageType == PoemRelatedImageType.MuseumLink - ? $"{APIRoot.Url}/api/artifacts/ganjoor?linkId={linkId}&removeItemLink={removeItemLink}" + ? $"{APIRoot.Url}/api/artifacts/diwan?linkId={linkId}&removeItemLink={removeItemLink}" : $"{APIRoot.Url}/api/artifacts/pinterest?linkId={linkId}"); if (!response.IsSuccessStatusCode) { @@ -1276,7 +1276,7 @@ namespace GanjooRazor.Pages } var categoryTop1Recitations = JsonConvert.DeserializeObject(await catTop1RecitationsQuery.Content.ReadAsStringAsync()); - return Partial("~/Pages/Partials/GanjoorPage/_AudioPlayerPartial.cshtml", new _AudioPlayerPartialModel() + return Partial("~/Pages/Partials/DiwanPage/_AudioPlayerPartial.cshtml", new _AudioPlayerPartialModel() { LoggedIn = !string.IsNullOrEmpty(Request.Cookies["Token"]), Recitations = categoryTop1Recitations, @@ -1287,21 +1287,21 @@ namespace GanjooRazor.Pages /// /// on-demand "شخصیت‌ها" (characters) tab on a poet/category page - fetches the - /// category-scoped person/relation graph (see GanjoorRelatedPersonService.GetCatPersonGraphAsync) + /// category-scoped person/relation graph (see DiwanRelatedPersonService.GetCatPersonGraphAsync) /// and renders it with the same peoplegraph.js force-directed viewer used by /PeopleGraph /// /// /// public async Task OnGetPersonGraphAsync(int catId) { - var response = await _httpClient.GetAsync($"{APIRoot.Url}/api/ganjoor/cat/{catId}/persongraph"); + var response = await _httpClient.GetAsync($"{APIRoot.Url}/api/diwan/cat/{catId}/persongraph"); if (!response.IsSuccessStatusCode) { return BadRequest(await ReadErrorMessageAsync(response)); } - var graph = JsonConvert.DeserializeObject(await response.Content.ReadAsStringAsync()); + var graph = JsonConvert.DeserializeObject(await response.Content.ReadAsStringAsync()); - return Partial("~/Pages/Partials/GanjoorPage/_PersonGraphPartial.cshtml", new _PersonGraphPartialModel() + return Partial("~/Pages/Partials/DiwanPage/_PersonGraphPartial.cshtml", new _PersonGraphPartialModel() { CatId = catId, Graph = graph, @@ -1310,7 +1310,7 @@ namespace GanjooRazor.Pages private async Task<_CategoryWordsCountPartialModel> _GetCategoryWordCountsAsync(int catId, int poetId, bool remStopWords = false) { - var wordSumsResponse = await _httpClient.GetAsync($"{APIRoot.Url}/api/ganjoor/wordsums/{catId}"); + var wordSumsResponse = await _httpClient.GetAsync($"{APIRoot.Url}/api/diwan/wordsums/{catId}"); if (!wordSumsResponse.IsSuccessStatusCode) { return null; @@ -1321,7 +1321,7 @@ namespace GanjooRazor.Pages return null; } int pageSize = remStopWords ? 200 : 100; - var wordCountsResponse = await _httpClient.GetAsync($"{APIRoot.Url}/api/ganjoor/wordcounts/{catId}?PageNumber=1&PageSize={pageSize}"); + var wordCountsResponse = await _httpClient.GetAsync($"{APIRoot.Url}/api/diwan/wordcounts/{catId}?PageNumber=1&PageSize={pageSize}"); if (!wordCountsResponse.IsSuccessStatusCode) { return null; @@ -1353,7 +1353,7 @@ namespace GanjooRazor.Pages return BadRequest("خطا در دسترسی به شمارش واژگان"); } - return Partial("~/Pages/Partials/GanjoorPage/_CategoryWordsCountPartial.cshtml", res); + return Partial("~/Pages/Partials/DiwanPage/_CategoryWordsCountPartial.cshtml", res); } public async Task OnGetSearchCategoryWordCountsAsync(int catId, int poetId, string term, int totalWordCount) @@ -1362,14 +1362,14 @@ namespace GanjooRazor.Pages { term = term.Trim(); } - var wordCountsResponse = await _httpClient.GetAsync($"{APIRoot.Url}/api/ganjoor/wordcounts/{catId}?PageNumber=1&PageSize=100&term={term}"); + var wordCountsResponse = await _httpClient.GetAsync($"{APIRoot.Url}/api/diwan/wordcounts/{catId}?PageNumber=1&PageSize=100&term={term}"); if (!wordCountsResponse.IsSuccessStatusCode) { return BadRequest(await ReadErrorMessageAsync(wordCountsResponse)); } var wordCounts = JsonConvert.DeserializeObject(await wordCountsResponse.Content.ReadAsStringAsync()); - return Partial("~/Pages/Partials/GanjoorPage/_CategoryWordsCountTablePartial.cshtml", new _CategoryWordsCountTablePartialModel() + return Partial("~/Pages/Partials/DiwanPage/_CategoryWordsCountTablePartial.cshtml", new _CategoryWordsCountTablePartialModel() { CatId = catId, PoetId = poetId, @@ -1380,12 +1380,12 @@ namespace GanjooRazor.Pages public async Task OnGetPoemWordCountsAsync(int poemId) { - var poemQuery = await _httpClient.GetAsync($"{APIRoot.Url}/api/ganjoor/poem/{poemId}"); + var poemQuery = await _httpClient.GetAsync($"{APIRoot.Url}/api/diwan/poem/{poemId}"); if (!poemQuery.IsSuccessStatusCode) { return BadRequest(await ReadErrorMessageAsync(poemQuery)); } - var poem = JObject.Parse(await poemQuery.Content.ReadAsStringAsync()).ToObject(); + var poem = JObject.Parse(await poemQuery.Content.ReadAsStringAsync()).ToObject(); List counts = new List(); foreach (var verse in poem.Verses.Where(v => v.VersePosition != VersePosition.Comment)) @@ -1420,7 +1420,7 @@ namespace GanjooRazor.Pages RowNmbrInCat = 0, }); - return Partial("~/Pages/Partials/GanjoorPage/_CategoryWordsCountTablePartial.cshtml", new _CategoryWordsCountTablePartialModel() + return Partial("~/Pages/Partials/DiwanPage/_CategoryWordsCountTablePartial.cshtml", new _CategoryWordsCountTablePartialModel() { CatId = -1, PoetId = -1, @@ -1433,13 +1433,13 @@ namespace GanjooRazor.Pages public async Task OnGetSimilarPoemsPartialAsync(int poemId, int skip, string prosodyMetre, string rhymeLetters, string poemFullUrl, int sectionIndex) { - string url = $"{APIRoot.Url}/api/ganjoor/section/{poemId}/{sectionIndex}/related?skip={skip}&itemsCount=21"; + string url = $"{APIRoot.Url}/api/diwan/section/{poemId}/{sectionIndex}/related?skip={skip}&itemsCount=21"; var response = await _httpClient.GetAsync(url); if (!response.IsSuccessStatusCode) return BadRequest(await ReadErrorMessageAsync(response)); - var relatedSections = JArray.Parse(await response.Content.ReadAsStringAsync()).ToObject>(); + var relatedSections = JArray.Parse(await response.Content.ReadAsStringAsync()).ToObject>(); - return Partial("~/Pages/Partials/GanjoorPage/_SimiPartialView.cshtml", new _SimiPartialViewModel() + return Partial("~/Pages/Partials/DiwanPage/_SimiPartialView.cshtml", new _SimiPartialViewModel() { RelatedSections = relatedSections.ToArray(), Rhythm = prosodyMetre, @@ -1453,12 +1453,12 @@ namespace GanjooRazor.Pages public async Task OnGetSimilarPoemsFromPoetPartialAsync(int poetId, string prosodyMetre, string rhymeLetters, string skipPoemFullUrl1, string skipPoemFullUrl2) { - string url = $"{APIRoot.Url}/api/ganjoor/poems/similar?metre={prosodyMetre}&rhyme={rhymeLetters}&poetId={poetId}"; + string url = $"{APIRoot.Url}/api/diwan/poems/similar?metre={prosodyMetre}&rhyme={rhymeLetters}&poetId={poetId}"; var response = await _httpClient.GetAsync(url); if (!response.IsSuccessStatusCode) return BadRequest(await ReadErrorMessageAsync(response)); - var poems = JArray.Parse(await response.Content.ReadAsStringAsync()).ToObject>(); + var poems = JArray.Parse(await response.Content.ReadAsStringAsync()).ToObject>(); if (poems.Any(p => p.FullUrl == skipPoemFullUrl1)) poems.RemoveAll(p => p.FullUrl == skipPoemFullUrl1); //TODO: fix errors here if (poems.Any(p => p.FullUrl == skipPoemFullUrl2)) @@ -1466,10 +1466,10 @@ namespace GanjooRazor.Pages foreach (var poem in poems) { - poem.HtmlText = GanjoorPoemTools.GetPoemHtmlExcerpt(poem.HtmlText); + poem.HtmlText = DiwanPoemTools.GetPoemHtmlExcerpt(poem.HtmlText); } - return Partial("~/Pages/Partials/GanjoorPage/_SimiPartialFromPoetView.cshtml", new _SimiPartialFromPoetViewModel() + return Partial("~/Pages/Partials/DiwanPage/_SimiPartialFromPoetView.cshtml", new _SimiPartialFromPoetViewModel() { Poems = poems, }); diff --git a/GanjooRazor/Pages/GanjoorPageModelBase.cs b/DiwanRazor/Pages/DiwanPageModelBase.cs similarity index 88% rename from GanjooRazor/Pages/GanjoorPageModelBase.cs rename to DiwanRazor/Pages/DiwanPageModelBase.cs index 2a7b36f8..2a40d36b 100644 --- a/GanjooRazor/Pages/GanjoorPageModelBase.cs +++ b/DiwanRazor/Pages/DiwanPageModelBase.cs @@ -4,12 +4,12 @@ using Newtonsoft.Json; using System; using System.Net.Http; using System.Threading.Tasks; -using GanjooRazor.Utils; +using DiwanRazor.Utils; -namespace GanjooRazor.Pages +namespace DiwanRazor.Pages { /// - /// Base class for Razor page models that call the Ganjoor API. + /// Base class for Razor page models that call the Diwan API. /// /// Centralizes three patterns that were previously copy-pasted across dozens of page-model /// files in this project (Index.cshtml.cs alone had ~35+10+14 copies before this class existed): @@ -20,9 +20,9 @@ namespace GanjooRazor.Pages /// (the base class used by public-site pages) derives /// from this. Admin/User-area page models that used to derive directly from /// can derive from this instead to get the same helpers without inheriting the public-site-specific - /// properties (GanjoorPage, NextUrl, etc.) that live on . + /// properties (DiwanPage, NextUrl, etc.) that live on . /// - public class GanjoorPageModelBase : PageModel + public class DiwanPageModelBase : PageModel { /// /// Message shown whenever an action requiring a session couldn't prepare an authenticated @@ -36,7 +36,7 @@ namespace GanjooRazor.Pages /// protected readonly HttpClient _httpClient; - protected GanjoorPageModelBase(HttpClient httpClient) + protected DiwanPageModelBase(HttpClient httpClient) { _httpClient = httpClient; } @@ -51,7 +51,7 @@ namespace GanjooRazor.Pages /// /// Shape of the special error string the API sends (still just a plain string, see - /// GanjoorService._BuildSanitizerDroppedTextError on the RMuseum side) when a comment/note/ + /// DiwanService._BuildSanitizerDroppedTextError on the RMuseum side) when a comment/note/ /// suggestion was rejected because sanitizing it had to drop real text. Message is the /// human-readable explanation; RemainingText is the plain text that would have remained, /// so the client can diff it against what the user actually typed and show exactly what @@ -86,7 +86,7 @@ namespace GanjooRazor.Pages /// /// Runs against an HttpClient authenticated from the current - /// session cookies (via ). If the session + /// session cookies (via ). If the session /// can't be prepared (missing/expired cookies), returns /// (defaulting to a 400 with ) instead of every handler /// re-implementing the same using/if/else block. @@ -123,8 +123,8 @@ namespace GanjooRazor.Pages Func> operation, IActionResult unauthorizedResult = null) { - using var secureClient = new HttpClient(new GanjoorReloginHandler(Request, Response)); - if (!await GanjoorSessionChecker.PrepareClient(secureClient, Request, Response)) + using var secureClient = new HttpClient(new DiwanReloginHandler(Request, Response)); + if (!await DiwanSessionChecker.PrepareClient(secureClient, Request, Response)) { return unauthorizedResult ?? new BadRequestObjectResult(NotLoggedInMessage); } diff --git a/GanjooRazor/Pages/Error.cshtml b/DiwanRazor/Pages/Error.cshtml similarity index 100% rename from GanjooRazor/Pages/Error.cshtml rename to DiwanRazor/Pages/Error.cshtml diff --git a/GanjooRazor/Pages/Error.cshtml.cs b/DiwanRazor/Pages/Error.cshtml.cs similarity index 97% rename from GanjooRazor/Pages/Error.cshtml.cs rename to DiwanRazor/Pages/Error.cshtml.cs index c3dbc011..76edf564 100644 --- a/GanjooRazor/Pages/Error.cshtml.cs +++ b/DiwanRazor/Pages/Error.cshtml.cs @@ -4,7 +4,7 @@ using Microsoft.AspNetCore.Mvc.RazorPages; using Microsoft.Extensions.Logging; using System.Diagnostics; -namespace GanjooRazor.Pages +namespace DiwanRazor.Pages { [ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)] public class ErrorModel : PageModel diff --git a/GanjooRazor/Pages/FAQ.cshtml b/DiwanRazor/Pages/FAQ.cshtml similarity index 94% rename from GanjooRazor/Pages/FAQ.cshtml rename to DiwanRazor/Pages/FAQ.cshtml index b5b30f8a..ce85f2d2 100644 --- a/GanjooRazor/Pages/FAQ.cshtml +++ b/DiwanRazor/Pages/FAQ.cshtml @@ -1,5 +1,5 @@ @page -@model GanjooRazor.Pages.FAQModel +@model DiwanRazor.Pages.FAQModel @{ Layout = "_Layout"; } @@ -30,7 +30,7 @@ else @Model.Question.Question
-
+
@Html.Raw(Model.Question.AnswerExcerpt)
@@ -51,7 +51,7 @@ else