#418 edit quoted ui
This commit is contained in:
parent
0d76e2f163
commit
f94f3542b5
@ -143,71 +143,6 @@
|
||||
<input asp-for="GanjoorQuotedPoem.RelatedPoemId" />
|
||||
</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="80" />
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
تصویر شاعر:
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<input asp-for="GanjoorQuotedPoem.CachedRelatedPoemPoetImage" style="direction:ltr" size="80" />
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
عنوان شعر:
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<input asp-for="GanjoorQuotedPoem.CachedRelatedPoemFullTitle" size="80" />
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
نشانی شعر:
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<input asp-for="GanjoorQuotedPoem.CachedRelatedPoemFullUrl" style="direction:ltr" size="80" />
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
بیت مرتبط:
|
||||
@ -216,6 +151,10 @@
|
||||
<tr>
|
||||
<td>
|
||||
<select asp-for="GanjoorQuotedPoem.RelatedCoupletIndex" style="width:500px;">
|
||||
@foreach (var item in Model.RelatedCouplets)
|
||||
{
|
||||
<option value="@item.Item1">@($"{(item.Item1 + 1).ToPersianNumbers()} - {item.Item2}")</option>
|
||||
}
|
||||
</select>
|
||||
</td>
|
||||
</tr>
|
||||
@ -279,6 +218,82 @@
|
||||
<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="80" />
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
تصویر شاعر:
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<input asp-for="GanjoorQuotedPoem.CachedRelatedPoemPoetImage" style="direction:ltr" size="80" />
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
عنوان شعر:
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<input asp-for="GanjoorQuotedPoem.CachedRelatedPoemFullTitle" size="80" />
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
نشانی شعر:
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<input asp-for="GanjoorQuotedPoem.CachedRelatedPoemFullUrl" style="direction:ltr" size="80" />
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td>
|
||||
یادداشت:
|
||||
|
||||
@ -35,9 +35,67 @@ namespace GanjooRazor.Areas.Admin.Pages
|
||||
|
||||
public Tuple<int, string>[] Couplets { get; set; }
|
||||
|
||||
public Tuple<int, string>[] RelatedCouplets { get; set; }
|
||||
|
||||
[BindProperty]
|
||||
public GanjoorQuotedPoem GanjoorQuotedPoem { 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"]))
|
||||
@ -70,58 +128,8 @@ namespace GanjooRazor.Areas.Admin.Pages
|
||||
|
||||
Poem = pageInformation.Poem;
|
||||
|
||||
int coupetIndex = -1;
|
||||
string coupletText = "";
|
||||
List<Tuple<int, string>> couplets = new List<Tuple<int, string>>();
|
||||
int verseIndex = 0;
|
||||
bool incompleteCouplet = false;
|
||||
while (verseIndex < pageInformation.Poem.Verses.Length)
|
||||
{
|
||||
switch (pageInformation.Poem.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, pageInformation.Poem.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 = pageInformation.Poem.Verses[verseIndex].Text;
|
||||
break;
|
||||
case VersePosition.Left:
|
||||
case VersePosition.CenteredVerse2:
|
||||
incompleteCouplet = true;
|
||||
coupletText += $" - {pageInformation.Poem.Verses[verseIndex].Text}";
|
||||
break;
|
||||
}
|
||||
verseIndex++;
|
||||
}
|
||||
|
||||
|
||||
if (incompleteCouplet && !string.IsNullOrEmpty(coupletText))
|
||||
couplets.Add(new Tuple<int, string>(coupetIndex, coupletText));
|
||||
|
||||
Couplets = couplets.ToArray();
|
||||
Couplets = GetCouplets(Poem.Verses);
|
||||
RelatedCouplets = [];
|
||||
|
||||
if (!string.IsNullOrEmpty(Request.Query["id"]))
|
||||
{
|
||||
@ -133,6 +141,19 @@ namespace GanjooRazor.Areas.Admin.Pages
|
||||
return Page();
|
||||
}
|
||||
GanjoorQuotedPoem = JObject.Parse(await quoteQuery.Content.ReadAsStringAsync()).ToObject<GanjoorQuotedPoem>();
|
||||
if(GanjoorQuotedPoem.RelatedPoemId != null)
|
||||
{
|
||||
var poemQuery = await _httpClient.GetAsync($"{APIRoot.Url}/api/ganjoor/poem/{GanjoorQuotedPoem.RelatedPoemId}");
|
||||
if (!poemQuery.IsSuccessStatusCode)
|
||||
{
|
||||
LastMessage = JsonConvert.DeserializeObject<string>(await poemQuery.Content.ReadAsStringAsync());
|
||||
return Page();
|
||||
}
|
||||
var relPoem = JObject.Parse(await poemQuery.Content.ReadAsStringAsync()).ToObject<GanjoorPoemCompleteViewModel>();
|
||||
|
||||
RelatedCouplets = GetCouplets(relPoem.Verses);
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
Loading…
Reference in New Issue
Block a user