docs: maintaining exact search status inside the search page

This commit is contained in:
Hamid Reza Mohammadi 2022-07-23 22:37:29 +04:30
parent 5687ed5324
commit 678e043940
2 changed files with 8 additions and 1 deletions

View File

@ -42,6 +42,10 @@
<div class="actionbox">
<form action="/search" method="get" id="searchform">
<input type="text" name="s" id="s" class="inputText" value="@Model.Query" placeholder="جستجو" />
@if(Model.ExactSearch)
{
<input type="hidden" name="es" id="es" value="1" />
}
<select name="author" id="author" onchange="onSelectedPoetChanged()">
@{

View File

@ -145,6 +145,8 @@ namespace GanjooRazor.Pages
public bool Quoted { get; set; }
public bool ExactSearch { get; set; }
public async Task<IActionResult> OnGetAsync()
{
if (bool.Parse(Configuration["MaintenanceMode"]))
@ -155,7 +157,8 @@ namespace GanjooRazor.Pages
LoggedIn = !string.IsNullOrEmpty(Request.Cookies["Token"]);
Query = Request.Query["s"].ApplyCorrectYeKe().Trim();
bool quotes = Query.IndexOf("\"") != -1 || Request.Query["es"] == "1";
ExactSearch = Request.Query["es"] == "1";
bool quotes = Query.IndexOf("\"") != -1 || ExactSearch;
Query = LanguageUtils.MakeTextSearchable(Query); //replace zwnj with space
if (quotes)
Query = $"\"{Query}\"";