#420 ReviewQuoteds admin page
This commit is contained in:
parent
9b43199999
commit
995072fc44
322
GanjooRazor/Areas/Admin/Pages/ReviewQuoteds.cshtml
Normal file
322
GanjooRazor/Areas/Admin/Pages/ReviewQuoteds.cshtml
Normal file
@ -0,0 +1,322 @@
|
||||
@page
|
||||
@using DNTPersianUtils.Core
|
||||
@model GanjooRazor.Areas.Admin.Pages.ReviewQuotedsModel
|
||||
@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers
|
||||
@{
|
||||
Layout = "_AdminLayout";
|
||||
ViewData["Title"] = "بازبینی مشقهای شعر پیشنهادی";
|
||||
}
|
||||
|
||||
<h1>@ViewData["Title"]</h1>
|
||||
|
||||
@if (!string.IsNullOrEmpty(Model.FatalError))
|
||||
{
|
||||
<p>@Model.FatalError</p>
|
||||
}
|
||||
else if (@Model.GanjoorQuotedPoem == null)
|
||||
{
|
||||
<p>پیشنهادی وجود ندارد.</p>
|
||||
}
|
||||
else
|
||||
{
|
||||
<form method="post">
|
||||
<table>
|
||||
<tr>
|
||||
<td>
|
||||
بیت مرجع از <a href="/?p=@Model.GanjoorQuotedPoem.PoemId">شعر</a>:
|
||||
<input type="hidden" asp-for="GanjoorQuotedPoem.Id" />
|
||||
<input type="hidden" asp-for="GanjoorQuotedPoem.PoemId" />
|
||||
<input type="hidden" asp-for="GanjoorQuotedPoem.PoetId" />
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<select asp-for="GanjoorQuotedPoem.CoupletIndex" style="width:100%">
|
||||
@foreach (var item in Model.Couplets)
|
||||
{
|
||||
<option value="@item.Item1">@($"{(item.Item1 + 1).ToPersianNumbers()} - {item.Item2}")</option>
|
||||
}
|
||||
</select>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
مصرع اول مهم است:
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<input asp-for="GanjoorQuotedPoem.CoupletVerse1ShouldBeEmphasized" />
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
مصرع دوم مهم است:
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<input asp-for="GanjoorQuotedPoem.CoupletVerse2ShouldBeEmphasized" />
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
شاعر مرجع:
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<input asp-for="GanjoorQuotedPoem.PoetId" />
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<a onclick="finalizeSelectPage()" class="pagebutton" role="button" id="finalize-select" style="display:none">انتخاب کردم</a>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<iframe id="select-poem" src="/" height="600" style="display:none;width:100%;margin:auto"></iframe>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td>
|
||||
<a onclick="selectGanjoorPage()" class="pagebutton" role="button" id="display-frame">گزینش شعر مرتبط</a>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<input asp-for="GanjoorQuotedPoem.RelatedPoemId" />
|
||||
</td>
|
||||
</tr>
|
||||
@if (Model.GanjoorQuotedPoem.RelatedPoemId != null)
|
||||
{
|
||||
<tr>
|
||||
<td>
|
||||
<a href="/?p=@Model.GanjoorQuotedPoem.RelatedPoemId">مشاهدهٔ شعر مرتبط</a>
|
||||
</td>
|
||||
</tr>
|
||||
}
|
||||
|
||||
<tr>
|
||||
<td>
|
||||
بیت مرتبط:
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<select asp-for="GanjoorQuotedPoem.RelatedCoupletIndex" style="width:100%;">
|
||||
@foreach (var item in Model.RelatedCouplets)
|
||||
{
|
||||
<option value="@item.Item1">@($"{(item.Item1 + 1).ToPersianNumbers()} - {item.Item2}")</option>
|
||||
}
|
||||
</select>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
مصرع اول مرتبط (خارج از گنجور):
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<input asp-for="GanjoorQuotedPoem.RelatedCoupletVerse1" size="65" />
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
مصرع اول مهم است:
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<input asp-for="GanjoorQuotedPoem.RelatedCoupletVerse1ShouldBeEmphasized" />
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
مصرع دوم مرتبط (خارج از گنجور):
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<input asp-for="GanjoorQuotedPoem.RelatedCoupletVerse2" size="65" />
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td>
|
||||
مصرع دوم مهم است:
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<input asp-for="GanjoorQuotedPoem.RelatedCoupletVerse2ShouldBeEmphasized" />
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
ترتیب:
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<input asp-for="GanjoorQuotedPoem.SortOrder" />
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
این شعر قدیمیتر از شعر مرتبط است:
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<input asp-for="GanjoorQuotedPoem.IsPriorToRelated" />
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
نمایش در فهرست اصلی:
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<input asp-for="GanjoorQuotedPoem.ChosenForMainList" />
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
مستقیماً ارتباط ندارد:
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<input asp-for="GanjoorQuotedPoem.IndirectQuotation" />
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
منتسب به هر دو شاعر:
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<input asp-for="GanjoorQuotedPoem.ClaimedByBothPoets" />
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
شاعر:
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<input asp-for="GanjoorQuotedPoem.RelatedPoetId" />
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<input asp-for="GanjoorQuotedPoem.CachedRelatedPoemPoetName" />
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
سالمرگ شاعر:
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<input asp-for="GanjoorQuotedPoem.CachedRelatedPoemPoetDeathYearInLHijri" />
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
نشانی صفحهٔ شاعر:
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<input asp-for="GanjoorQuotedPoem.CachedRelatedPoemPoetUrl" style="direction:ltr" size="65" />
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
تصویر شاعر:
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<input asp-for="GanjoorQuotedPoem.CachedRelatedPoemPoetImage" style="direction:ltr" size="65" />
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
عنوان شعر:
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<input asp-for="GanjoorQuotedPoem.CachedRelatedPoemFullTitle" size="65" />
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
نشانی شعر:
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<input asp-for="GanjoorQuotedPoem.CachedRelatedPoemFullUrl" style="direction:ltr" size="65" />
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td>
|
||||
یادداشت:
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<textarea asp-for="GanjoorQuotedPoem.Note" rows="4" cols="80" class="editor"></textarea>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
منتشر شده:
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<input asp-for="GanjoorQuotedPoem.Published" />
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
تعداد همسانها:
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<input asp-for="GanjoorQuotedPoem.SamePoemsQuotedCount" />
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<input type="submit" value="ذخیره" />
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
|
||||
|
||||
<tr><td><hr /></td></tr>
|
||||
<tr>
|
||||
<td>
|
||||
<a role="button" onclick="deleteThisOne('@Model.GanjoorQuotedPoem.Id')" class="actionlink" title="حذف">حذف <i class="noindent-info-button delete-icon"></i></a>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</form>
|
||||
|
||||
|
||||
}
|
||||
168
GanjooRazor/Areas/Admin/Pages/ReviewQuoteds.cshtml.cs
Normal file
168
GanjooRazor/Areas/Admin/Pages/ReviewQuoteds.cshtml.cs
Normal file
@ -0,0 +1,168 @@
|
||||
using GanjooRazor.Utils;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Mvc.RazorPages;
|
||||
using Newtonsoft.Json;
|
||||
using RMuseum.Models.Ganjoor.ViewModels;
|
||||
using RSecurityBackend.Models.Generic;
|
||||
using System.Net.Http;
|
||||
using System.Threading.Tasks;
|
||||
using System.Linq;
|
||||
using System;
|
||||
using RMuseum.Models.Ganjoor;
|
||||
using System.Collections.Generic;
|
||||
using Newtonsoft.Json.Linq;
|
||||
|
||||
namespace GanjooRazor.Areas.Admin.Pages
|
||||
{
|
||||
[IgnoreAntiforgeryToken(Order = 1001)]
|
||||
public class ReviewQuotedsModel : PageModel
|
||||
{
|
||||
/// <summary>
|
||||
/// suggestion
|
||||
/// </summary>
|
||||
[BindProperty]
|
||||
public GanjoorQuotedPoemViewModel GanjoorQuotedPoem { get; set; }
|
||||
/// <summary>
|
||||
/// fatal error
|
||||
/// </summary>
|
||||
public string FatalError { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// skip
|
||||
/// </summary>
|
||||
public int Skip { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// total count
|
||||
/// </summary>
|
||||
public int TotalCount { get; set; }
|
||||
|
||||
public Tuple<int, string>[] Couplets { get; set; }
|
||||
|
||||
public Tuple<int, string>[] RelatedCouplets { get; set; }
|
||||
|
||||
public GanjoorPoemCompleteViewModel Poem { get; set; }
|
||||
|
||||
public GanjoorPoemCompleteViewModel RelatedPoem { get; set; }
|
||||
|
||||
private Tuple<int, string>[] GetCouplets(GanjoorVerseViewModel[] verses)
|
||||
{
|
||||
int coupetIndex = -1;
|
||||
string coupletText = "";
|
||||
List<Tuple<int, string>> couplets = new List<Tuple<int, string>>();
|
||||
int verseIndex = 0;
|
||||
bool incompleteCouplet = false;
|
||||
while (verseIndex < verses.Length)
|
||||
{
|
||||
switch (verses[verseIndex].VersePosition)
|
||||
{
|
||||
case VersePosition.Comment:
|
||||
incompleteCouplet = false;
|
||||
if (!string.IsNullOrEmpty(coupletText))
|
||||
{
|
||||
couplets.Add(new Tuple<int, string>(coupetIndex, coupletText));
|
||||
coupletText = "";
|
||||
}
|
||||
break;
|
||||
case VersePosition.Paragraph:
|
||||
case VersePosition.Single:
|
||||
incompleteCouplet = false;
|
||||
if (!string.IsNullOrEmpty(coupletText))
|
||||
{
|
||||
couplets.Add(new Tuple<int, string>(coupetIndex, coupletText));
|
||||
coupletText = "";
|
||||
}
|
||||
coupetIndex++;
|
||||
couplets.Add(new Tuple<int, string>(coupetIndex, verses[verseIndex].Text));
|
||||
break;
|
||||
case VersePosition.Right:
|
||||
case VersePosition.CenteredVerse1:
|
||||
incompleteCouplet = false;
|
||||
if (!string.IsNullOrEmpty(coupletText))
|
||||
{
|
||||
couplets.Add(new Tuple<int, string>(coupetIndex, coupletText));
|
||||
}
|
||||
coupetIndex++;
|
||||
coupletText = verses[verseIndex].Text;
|
||||
break;
|
||||
case VersePosition.Left:
|
||||
case VersePosition.CenteredVerse2:
|
||||
incompleteCouplet = true;
|
||||
coupletText += $" - {verses[verseIndex].Text}";
|
||||
break;
|
||||
}
|
||||
verseIndex++;
|
||||
}
|
||||
|
||||
|
||||
if (incompleteCouplet && !string.IsNullOrEmpty(coupletText))
|
||||
couplets.Add(new Tuple<int, string>(coupetIndex, coupletText));
|
||||
|
||||
return couplets.ToArray();
|
||||
}
|
||||
public async Task<IActionResult> OnGetAsync()
|
||||
{
|
||||
if (string.IsNullOrEmpty(Request.Cookies["Token"]))
|
||||
return Redirect("/");
|
||||
|
||||
FatalError = "";
|
||||
TotalCount = 0;
|
||||
Skip = string.IsNullOrEmpty(Request.Query["skip"]) ? 0 : int.Parse(Request.Query["skip"]);
|
||||
RelatedCouplets = [];
|
||||
using (HttpClient secureClient = new HttpClient())
|
||||
{
|
||||
if (await GanjoorSessionChecker.PrepareClient(secureClient, Request, Response))
|
||||
{
|
||||
var nextResponse = await secureClient.GetAsync($"{APIRoot.Url}/api/ganjoor/quoted/suggestion/next?skip={Skip}");
|
||||
if (!nextResponse.IsSuccessStatusCode)
|
||||
{
|
||||
FatalError = JsonConvert.DeserializeObject<string>(await nextResponse.Content.ReadAsStringAsync());
|
||||
return Page();
|
||||
}
|
||||
|
||||
string paginnationMetadata = nextResponse.Headers.GetValues("paging-headers").FirstOrDefault();
|
||||
if (!string.IsNullOrEmpty(paginnationMetadata))
|
||||
{
|
||||
TotalCount = JsonConvert.DeserializeObject<PaginationMetadata>(paginnationMetadata).totalCount;
|
||||
}
|
||||
GanjoorQuotedPoem = JsonConvert.DeserializeObject<GanjoorQuotedPoemViewModel>(await nextResponse.Content.ReadAsStringAsync());
|
||||
|
||||
if(GanjoorQuotedPoem != null)
|
||||
{
|
||||
var poemQuery = await secureClient.GetAsync($"{APIRoot.Url}/api/ganjoor/poem/{GanjoorQuotedPoem.PoemId}");
|
||||
if (!poemQuery.IsSuccessStatusCode)
|
||||
{
|
||||
FatalError = JsonConvert.DeserializeObject<string>(await poemQuery.Content.ReadAsStringAsync());
|
||||
return Page();
|
||||
}
|
||||
Poem = JObject.Parse(await poemQuery.Content.ReadAsStringAsync()).ToObject<GanjoorPoemCompleteViewModel>();
|
||||
|
||||
Couplets = GetCouplets(Poem.Verses);
|
||||
|
||||
if (GanjoorQuotedPoem.RelatedPoemId != null)
|
||||
{
|
||||
var relPoemQuery = await secureClient.GetAsync($"{APIRoot.Url}/api/ganjoor/poem/{GanjoorQuotedPoem.RelatedPoemId}");
|
||||
if (!relPoemQuery.IsSuccessStatusCode)
|
||||
{
|
||||
FatalError = JsonConvert.DeserializeObject<string>(await relPoemQuery.Content.ReadAsStringAsync());
|
||||
return Page();
|
||||
}
|
||||
RelatedPoem = JObject.Parse(await relPoemQuery.Content.ReadAsStringAsync()).ToObject<GanjoorPoemCompleteViewModel>();
|
||||
|
||||
RelatedCouplets = GetCouplets(RelatedPoem.Verses);
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
FatalError = "لطفاً از گنجور خارج و مجددا به آن وارد شوید.";
|
||||
}
|
||||
}
|
||||
return Page();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -272,6 +272,13 @@
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="navbar-collapse collapse d-sm-inline-flex justify-content-between">
|
||||
<ul class="navbar-nav flex-grow-1">
|
||||
<li class="nav-item">
|
||||
<a class="nav-link text-dark" asp-area="Admin" asp-page="ReviewQuoteds">مشقها</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="navbar-collapse collapse d-sm-inline-flex justify-content-between">
|
||||
<ul class="navbar-nav flex-grow-1">
|
||||
<li class="nav-item">
|
||||
|
||||
Loading…
Reference in New Issue
Block a user