divan/DivanRazor/Pages/Search.cshtml
Anas Rashid 4fd832dbcb Urdu public pages (#2); hide unconfigured semantic search; safe defaults
- translate reading-path views (poet, category, poem, search, header, login, partials)
  from Persian to Urdu (exact-run dictionary, 262 strings; AI-summary data marker kept)
- semantic search widget only when SemanticSearchAPIRoot is configured
- appsettings defaults: no Ganjoor tracking script, no Ganjoor semantic search,
  API/site roots default to the local Divan stack instead of api.ganjoor.net

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-05 00:18:00 +02:00

178 lines
8.5 KiB
Plaintext

@page
@model DivanRazor.Pages.SearchModel
@using DNTPersianUtils.Core
@{
Layout = "_Layout";
}
@section Head {
<meta name="robots" content="noindex, nofollow" />
<script src="/js/chart.js"></script>
}
@if (!string.IsNullOrEmpty(Model.LastError))
{
@Model.LastError
}
else
{
<partial name="_SearchHeaderPartial" model="@(new _SearchHeaderPartialModel(){ Poets = Model.Poets, SelectedPoetId = Model.PoetId, SearchQuery = Model.Query, ShowExactSearchHiddenField = Model.ExactSearch, CurrentCategory = Model.Poet?.Cat, SelectedCategoryId = Model.CatId })" />
<!-- #hdr2 -->
<div id="fa">
<div id="maincnt">
<partial name="_InlineLoginPartial" model="Model" />
<div class="spacer">&nbsp;</div>
@if (!string.IsNullOrEmpty(Model.AlternativeSearchPhrase))
{
if (Model.Quoted)
{
<div class="poem">
<a role="button" class="pagebutton" href="/search?s=@Model.AlternativeSearchPhrase&amp;author=@Model.PoetId">@Model.AlternativeSearchPhraseDescription</a>
</div>
}
else
{
<div class="poem">
<a role="button" class="pagebutton" href="/search?s=@Model.AlternativeSearchPhrase&amp;author=@Model.PoetId">@Model.AlternativeSearchPhraseDescription</a>
</div>
}
}
@if (!string.IsNullOrEmpty(Model.PagingToolsHtml))
{
@Html.Raw(Model.PagingToolsHtml)
<div class="spacer">&nbsp;</div>
}
@if (Model.Poems == null)
{
<div class="poem">
<h2>مطلوبہ شعر نہیں ملا.</h2>
<p>
<strong>بہتر نتائج کے لیے تجاویز:</strong>
</p>
<p>
الف) <strong>پورا شعر لکھنے کے بجائے اس کے کلیدی الفاظ تلاش کریں.</strong> اشعار مختلف نسخوں میں مختلف صورتوں میں نقل ہوئے ہیں، اس لیے آپ کے ذہن میں موجود صورت ہمارے متن سے مختلف ہو سکتی ہے۔ مثلاً غالب کا مصرع «ہزاروں خواہشیں ایسی کہ ہر خواہش پہ دم نکلے» تلاش کرنے کے لیے «خواہشیں» اور «دم» جیسے الفاظ تلاش کرنا بہتر ہے.
</p>
<p>
ب) جو الفاظ الگ یا ملا کر لکھے جا سکتے ہیں، انہیں پہلے الگ الگ آزمائیں (<strong>جا سکتا</strong> نہ کہ <del>جاسکتا</del> یا <del>جا سکتا</del>).
</p>
<p>
ج) اگر آپ شاعر کا نام جانتے ہیں تو تلاش کے خانے کے ساتھ والی فہرست سے اسے منتخب کریں؛ اس طرح دوسرے شعرا کے نتائج کم ہو جائیں گے.
</p>
<p>
د) اگر آپ تلاش کی بنیادی تکنیکوں سے واقف نہیں یا <strong>عموماً مطلوبہ نتائج نہیں ملتے</strong> تو <a href="http://hrmoh.ir/1385/04/18/howto-search-better/" title="انٹرنیٹ پر بہتر تلاش کی تجاویز">یہ تحریر</a> دیکھ لیں.
</p>
</div>
}
else
{
@if (Model.StatsAtTop && Model.QueryIsSingleWord)
{
<div class="sitem">
@* Model.Query is the untrusted "s" search-query string. It must never be
interpolated into a javascript: href/onclick - HTML-encoding alone does
not stop it breaking out of the JS string literal there, because the
browser HTML-decodes the attribute before handing it to the JS engine.
Passing it through a data-* attribute keeps it as inert text. *@
<a href="javascript:void(0)" data-search-query="@Model.Query" data-poet-id="@Model.PoetId" data-cat-id="@Model.CatId" onclick="loadWordCountsByCat(this.dataset.searchQuery, this.dataset.poetId, this.dataset.catId, false); return false;" id="load-word-counts" class="pagebutton comments-link">
الفاظ کی تعداد دیکھیں «@Model.QueryDin» حصوں کے لحاظ سے
</a>
<div id="wordcounts-placeholder">
</div>
</div>
}
for (int poemIndex = 0; poemIndex < Model.Poems.Count; poemIndex++)
{
var poem = Model.Poems[poemIndex];
<div class="sitem">
@if (Model.PaginationMetadata != null)
{
<div class="circled-number-diff">@(((Model.PaginationMetadata.currentPage - 1) * Model.PaginationMetadata.pageSize + poemIndex + 1).ToPersianNumbers())</div>
}
<h2>
<a href="@poem.FullUrl">@poem.FullTitle</a>
</h2>
<div class="spacer">&nbsp;</div>
<div class="sit">
@Html.Raw(poem.PlainText)
</div>
<div class="poet">
<img src="@($"{DivanRazor.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>
</div>
}
}
@if (!string.IsNullOrEmpty(Model.PagingToolsHtml))
{
<div class="spacer">&nbsp;</div>
@Html.Raw(Model.PagingToolsHtml)
<div class="spacer">&nbsp;</div>
<div>
کل نتائج: @Model.PaginationMetadata.totalCount.ToPersianNumbers() تخلیق
<div>
<small>ایک تخلیق میں عبارت کئی بار آ سکتی ہے؛ تکرار سمیت شمار کے لیے الفاظ کی تعداد دیکھیں.</small>
</div>
</div>
}
@if (!Model.StatsAtTop && Model.QueryIsSingleWord)
{
<div class="sitem">
@* See the matching comment above for why this is a data-* attribute, not a javascript: href. *@
<a href="javascript:void(0)" data-search-query="@Model.Query" data-poet-id="@Model.PoetId" data-cat-id="@Model.CatId" onclick="loadWordCountsByCat(this.dataset.searchQuery, this.dataset.poetId, this.dataset.catId, false); return false;" id="load-word-counts" class="pagebutton comments-link">
الفاظ کی تعداد دیکھیں «@Model.QueryDin» حصوں کے لحاظ سے
</a>
<div id="wordcounts-placeholder">
</div>
</div>
}
</div>
<partial name="_FooterPartial" model=@(new _FooterPartialModel(){StickyEnabled = true}) />
</div>
@if (ViewData["TrackingScript"] != null && !string.IsNullOrEmpty(ViewData["TrackingScript"].ToString()))
{
@Html.Raw(ViewData["TrackingScript"])
}
}
@if (Model.StatsAtTop && Model.QueryIsSingleWord)
{
<script>
loadWordCountsByCat('@Model.QueryDin', @Model.PoetId, @Model.CatId, true);
</script>
}