This commit is contained in:
Sobuno 2025-01-03 00:45:19 +01:00
parent 36ec1daf3a
commit e33e3cc40f
5 changed files with 31 additions and 22 deletions

View File

@ -83,13 +83,13 @@ class SearchController extends Controller
$searcher->parseQuery($fullQuery);
// words from query and operators:
$query = $searcher->getWordsAsString();
$excludedWords = $searcher->getExcludedWordsAsString();
$words = $searcher->getWords();
$excludedWords = $searcher->getExcludedWords();
$operators = $searcher->getOperators();
$invalidOperators = $searcher->getInvalidOperators();
$subTitle = (string) trans('breadcrumbs.search_result', ['query' => $fullQuery]);
return view('search.index', compact('query', 'excludedWords', 'operators', 'page', 'rule', 'fullQuery', 'subTitle', 'ruleId', 'ruleChanged', 'invalidOperators'));
return view('search.index', compact('words', 'excludedWords', 'operators', 'page', 'rule', 'fullQuery', 'subTitle', 'ruleId', 'ruleChanged', 'invalidOperators'));
}
/**

View File

@ -123,9 +123,14 @@ class OperatorQuerySearch implements SearchInterface
return implode(' ', $this->words);
}
public function getExcludedWordsAsString(): string
public function getWords(): array
{
return implode(' ', $this->prohibitedWords);
return $this->words;
}
public function getExcludedWords(): array
{
return $this->prohibitedWords;
}
/**
@ -2826,16 +2831,6 @@ class OperatorQuerySearch implements SearchInterface
}
}
public function getWords(): array
{
return $this->words;
}
public function getExcludedWords(): array
{
return $this->prohibitedWords;
}
public function setDate(Carbon $date): void
{
$this->date = $date;

View File

@ -38,9 +38,10 @@ interface SearchInterface
public function getModifiers(): Collection;
public function getOperators(): Collection;
public function getWords(): array;
public function getWordsAsString(): string;
public function getExcludedWordsAsString(): string;
public function getExcludedWords(): array;
public function hasModifiers(): bool;

View File

@ -258,6 +258,11 @@ span.twitter-typeahead {
top: 46px !important;
}
.search-word {
white-space: pre;
background-color: #f5f5f5;
}
/*
.twitter-typeahead {
width:100%;

View File

@ -42,14 +42,22 @@
{{ trans('firefly.search_for_overview') |raw }}
</p>
<ul>
{% if '' != query %}
{% if words|length > 0 %}
<li>
{{- trans('firefly.search_for_query', {query: query|escape})|raw -}}
{{- trans('firefly.search_for_query', {
query: words
|map(word => '<span class="search-word">' ~ word|escape ~ '</span>')
|join(' ')
})|raw -}}
</li>
{% endif %}
{% if '' != excludedWords %}
{% if excludedWords|length > 0 %}
<li>
{{- trans('firefly.search_for_excluded_words', {excluded_words: excludedWords|escape})|raw -}}
{{- trans('firefly.search_for_excluded_words', {
excluded_words: excludedWords
|map(word => '<span class="search-word">' ~ word|escape ~ '</span>')
|join(' ')
})|raw -}}
</li>
{% endif %}
@ -75,7 +83,7 @@
</div>
</div>
</div>
{% if query or excludedWords or operators|length > 0 %}
{% if query|length > 0 or excludedWords|length > 0 or operators|length > 0 %}
<div class="row result_row">
<div class="col-lg-12 col-md-12 col-sm-12">
<div class="box search_box">
@ -130,7 +138,7 @@
</div>
</div>
{% endif %}
{% if query == "" and excludedWords == "" and operators|length == 0 %}
{% if query|length == 0 and excludedWords|length == 0 and operators|length == 0 %}
<div class="row">
<div class="col-lg-12 col-md-12 col-sm-12">
<div class="box">