mirror of
https://github.com/neon-mmd/websurfx.git
synced 2024-11-22 05:58:21 -05:00
Merge pull request #260 from neon-mmd/feat-inform-user-when-no-engines-are-selected
✨ Inform user with appropriate error message when none of the engines are selected
This commit is contained in:
commit
d150832672
10
Cargo.lock
generated
10
Cargo.lock
generated
@ -510,7 +510,7 @@ checksum = "4acbb09d9ee8e23699b9634375c72795d095bf268439da88562cf9b501f181fa"
|
|||||||
dependencies = [
|
dependencies = [
|
||||||
"camino",
|
"camino",
|
||||||
"cargo-platform",
|
"cargo-platform",
|
||||||
"semver 1.0.18",
|
"semver 1.0.19",
|
||||||
"serde",
|
"serde",
|
||||||
"serde_json",
|
"serde_json",
|
||||||
]
|
]
|
||||||
@ -2864,7 +2864,7 @@ version = "0.4.0"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "bfa0f585226d2e68097d4f95d113b15b83a82e819ab25717ec0590d9584ef366"
|
checksum = "bfa0f585226d2e68097d4f95d113b15b83a82e819ab25717ec0590d9584ef366"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"semver 1.0.18",
|
"semver 1.0.19",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@ -3002,9 +3002,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "semver"
|
name = "semver"
|
||||||
version = "1.0.18"
|
version = "1.0.19"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "b0293b4b29daaf487284529cc2f5675b8e57c61f70167ba415a463651fd6a918"
|
checksum = "ad977052201c6de01a8ef2aa3378c4bd23217a056337d1d6da40468d267a4fb0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"serde",
|
"serde",
|
||||||
]
|
]
|
||||||
@ -3932,7 +3932,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "websurfx"
|
name = "websurfx"
|
||||||
version = "0.22.0"
|
version = "0.23.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"actix-cors",
|
"actix-cors",
|
||||||
"actix-files",
|
"actix-files",
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "websurfx"
|
name = "websurfx"
|
||||||
version = "0.22.0"
|
version = "0.23.0"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
description = "An open-source alternative to Searx that provides clean, ad-free, and organic results with incredible speed while keeping privacy and security in mind."
|
description = "An open-source alternative to Searx that provides clean, ad-free, and organic results with incredible speed while keeping privacy and security in mind."
|
||||||
repository = "https://github.com/neon-mmd/websurfx"
|
repository = "https://github.com/neon-mmd/websurfx"
|
||||||
|
BIN
public/images/no_selection.png
Normal file
BIN
public/images/no_selection.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 92 KiB |
@ -155,7 +155,8 @@ body {
|
|||||||
height: 1.2rem;
|
height: 1.2rem;
|
||||||
}
|
}
|
||||||
.results .result_disallowed,
|
.results .result_disallowed,
|
||||||
.results .result_filtered {
|
.results .result_filtered,
|
||||||
|
.results .result_engine_not_selected {
|
||||||
display: flex;
|
display: flex;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
@ -166,18 +167,21 @@ body {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.results .result_disallowed .user_query,
|
.results .result_disallowed .user_query,
|
||||||
.results .result_filtered .user_query {
|
.results .result_filtered .user_query,
|
||||||
|
.results .result_engine_not_selected .user_query {
|
||||||
color: var(--background-color);
|
color: var(--background-color);
|
||||||
font-weight: 300;
|
font-weight: 300;
|
||||||
}
|
}
|
||||||
|
|
||||||
.results .result_disallowed img,
|
.results .result_disallowed img,
|
||||||
.results .result_filtered img {
|
.results .result_filtered img,
|
||||||
|
.results .result_engine_not_selected img {
|
||||||
width: 30rem;
|
width: 30rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
.results .result_disallowed div,
|
.results .result_disallowed div,
|
||||||
.results .result_filtered div {
|
.results .result_filtered div,
|
||||||
|
.results .result_engine_not_selected div {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
gap: 1rem;
|
gap: 1rem;
|
||||||
|
@ -45,6 +45,20 @@
|
|||||||
</div>
|
</div>
|
||||||
<img src="./images/filter.png" alt="Image of a paper inside a funnel" />
|
<img src="./images/filter.png" alt="Image of a paper inside a funnel" />
|
||||||
</div>
|
</div>
|
||||||
|
{{else}} {{#if noEnginesSelected}}
|
||||||
|
<div class="result_engine_not_selected">
|
||||||
|
<div class="description">
|
||||||
|
<p>
|
||||||
|
No results could be fetched for your search "<span class="user_query">{{{this.pageQuery}}}</span>" .
|
||||||
|
</p>
|
||||||
|
<p class="description_paragraph">Dear user,</p>
|
||||||
|
<p class="description_paragraph">
|
||||||
|
No results could be retrieved from the upstream search engines as no
|
||||||
|
upstream search engines were selected from the settings page.
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
<img src="./images/no_selection.png" alt="Image of a white cross inside a red circle" />
|
||||||
|
</div>
|
||||||
{{else}}
|
{{else}}
|
||||||
<div class="result_not_found">
|
<div class="result_not_found">
|
||||||
<p>Your search - {{{this.pageQuery}}} - did not match any documents.</p>
|
<p>Your search - {{{this.pageQuery}}} - did not match any documents.</p>
|
||||||
@ -56,7 +70,7 @@
|
|||||||
</ul>
|
</ul>
|
||||||
<img src="./images/no_results.gif" alt="Man fishing gif" />
|
<img src="./images/no_results.gif" alt="Man fishing gif" />
|
||||||
</div>
|
</div>
|
||||||
{{/if}} {{/if}} {{/if}}
|
{{/if}} {{/if}} {{/if}} {{/if}}
|
||||||
</div>
|
</div>
|
||||||
<div class="page_navigation">
|
<div class="page_navigation">
|
||||||
<button type="button" onclick="navigate_backward()">
|
<button type="button" onclick="navigate_backward()">
|
||||||
|
@ -124,6 +124,9 @@ pub struct SearchResults {
|
|||||||
pub filtered: bool,
|
pub filtered: bool,
|
||||||
/// Stores the safe search level `safesearch` provided in the search url.
|
/// Stores the safe search level `safesearch` provided in the search url.
|
||||||
pub safe_search_level: u8,
|
pub safe_search_level: u8,
|
||||||
|
/// Stores the flag option which holds the check value that whether any search engines were
|
||||||
|
/// selected or not.
|
||||||
|
pub no_engines_selected: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl SearchResults {
|
impl SearchResults {
|
||||||
@ -150,6 +153,7 @@ impl SearchResults {
|
|||||||
disallowed: Default::default(),
|
disallowed: Default::default(),
|
||||||
filtered: Default::default(),
|
filtered: Default::default(),
|
||||||
safe_search_level: Default::default(),
|
safe_search_level: Default::default(),
|
||||||
|
no_engines_selected: Default::default(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -186,4 +190,14 @@ impl SearchResults {
|
|||||||
pub fn set_safe_search_level(&mut self, safe_search_level: u8) {
|
pub fn set_safe_search_level(&mut self, safe_search_level: u8) {
|
||||||
self.safe_search_level = safe_search_level;
|
self.safe_search_level = safe_search_level;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// A getter function that gets the value of `no_engines_selected`.
|
||||||
|
pub fn no_engines_selected(&self) -> bool {
|
||||||
|
self.no_engines_selected
|
||||||
|
}
|
||||||
|
|
||||||
|
/// A setter function to set the `no_engines_selected` to true.
|
||||||
|
pub fn set_no_engines_selected(&mut self) {
|
||||||
|
self.no_engines_selected = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -205,6 +205,8 @@ async fn results(
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
match engines.is_empty() {
|
||||||
|
false => {
|
||||||
aggregate(
|
aggregate(
|
||||||
query,
|
query,
|
||||||
page,
|
page,
|
||||||
@ -216,6 +218,14 @@ async fn results(
|
|||||||
)
|
)
|
||||||
.await?
|
.await?
|
||||||
}
|
}
|
||||||
|
true => {
|
||||||
|
let mut search_results = SearchResults::default();
|
||||||
|
search_results.set_no_engines_selected();
|
||||||
|
search_results.set_page_query(query);
|
||||||
|
search_results
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
None => {
|
None => {
|
||||||
aggregate(
|
aggregate(
|
||||||
query,
|
query,
|
||||||
@ -229,7 +239,10 @@ async fn results(
|
|||||||
.await?
|
.await?
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
if results.engine_errors_info().is_empty() && results.results().is_empty() {
|
if results.engine_errors_info().is_empty()
|
||||||
|
&& results.results().is_empty()
|
||||||
|
&& !results.no_engines_selected()
|
||||||
|
{
|
||||||
results.set_filtered();
|
results.set_filtered();
|
||||||
}
|
}
|
||||||
results.add_style(&config.style);
|
results.add_style(&config.style);
|
||||||
|
Loading…
Reference in New Issue
Block a user