allow exception of poets in the similars page

#469
This commit is contained in:
Hamid Reza Mohammadi 2025-02-27 18:09:08 +03:30
parent 8f10475ec6
commit 54a6685c34
2 changed files with 32 additions and 2 deletions

View File

@ -27,6 +27,17 @@
var stickyEnabled = cookieValue != "false";
</script>
<script>
function deletePoetFromSearch(poetId, poetName){
if(!confirm('آیا می‌خواهید '+ poetName+ ' را از نتایج حذف کنید؟')) return;
const currentUrl = new URL(window.location.href);
const params = currentUrl.searchParams;
params.append('e', poetId.toString());
currentUrl.search = params.toString();
window.location.href = currentUrl.toString();
}
</script>
@if (Model.CanEdit)
{
<script>
@ -340,8 +351,10 @@
@($"{(poem.CoupletsCount ?? 0).ToPersianNumbers()} بیت")
</div>
<img src="@($"{GanjooRazor.APIRoot.InternetUrl}{poem.Category.Poet.ImageUrl}")" alt="@($"{poem.Category.Poet.Nickname}")" />
<div class="poet">
<img src="@($"{GanjooRazor.APIRoot.InternetUrl}{poem.Category.Poet.ImageUrl}")" alt="@($"{poem.Category.Poet.Nickname}")" />
<a role="button" onclick="deletePoetFromSearch(@poem.Category.Poet.Id, '@(poem.Category.Poet.Nickname)')" class="actionlink" title="حذف @($"{poem.Category.Poet.Nickname}") از نتایج"><i class="notranslate noindent-info-button close-button"></i></a>
</div>
<div class="spacer">&nbsp;</div>

View File

@ -87,6 +87,8 @@ namespace GanjooRazor.Pages
public bool Quoted { get; set; }
public bool ExactSearch { get; set; }
public int[] ExceptPoetId { get; set; }
/// <summary>
/// can edit
@ -405,11 +407,26 @@ namespace GanjooRazor.Pages
title += $" شامل کلیدواژهٔ «{Query}»";
}
List<int> exceptPoetId = new List<int>();
foreach (var e in Request.Query["e"])
{
exceptPoetId.Add(int.Parse(e));
}
ExceptPoetId = exceptPoetId.ToArray();
string url = $"{APIRoot.Url}/api/ganjoor/poems/similar?PageNumber={pageNumber}&PageSize=20&metre={Metre}&rhyme={Rhyme}&poetId={PoetId}&catId={CatId}&language={Language}&format={(int)Format}&coupletCountsFrom={CoupletCountsFrom}&coupletCountsTo={CoupletCountsTo}";
if(!string.IsNullOrEmpty(Query))
{
url += $"&term={Query}";
}
string exceptUrl = "";
foreach (var e in exceptPoetId)
{
exceptUrl += $"&e={e}";
}
url += exceptUrl;
var response = await _httpClient.GetAsync(url);
if (!response.IsSuccessStatusCode)