Spaces:
Runtime error
Runtime error
File size: 5,283 Bytes
c1a5b70 0ec8914 c1a5b70 0ec8914 c1a5b70 0ec8914 1a2a833 0ec8914 1a2a833 0ec8914 5e2669b 0ec8914 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 |
//! A module that handles the view for the search page in the `websurfx` frontend.
use maud::{html, Markup, PreEscaped};
use crate::{
models::aggregation_models::SearchResults,
templates::partials::{footer::footer, header::header, search_bar::search_bar},
};
/// A function that handles the html code for the search page view in the search engine frontend.
///
/// # Arguments
///
/// * `colorscheme` - It takes the colorscheme name as an argument.
/// * `theme` - It takes the theme name as an argument.
/// * `query` - It takes the current search query provided by the user as an argument.
/// * `search_results` - It takes the aggregated search results as an argument.
///
/// # Returns
///
/// It returns the compiled html markup code as a result.
pub fn search(
colorscheme: &str,
theme: &str,
animation: &Option<String>,
query: &str,
search_results: &SearchResults,
) -> Markup {
html!(
(header(colorscheme, theme, animation))
main class="results"{
(search_bar(&search_results.engine_errors_info, search_results.safe_search_level, query))
.results_aggregated{
@if !search_results.results.is_empty() {
@for result in search_results.results.iter(){
.result {
h1{a href=(result.url){(PreEscaped(&result.title))}}
small{(result.url)}
p{(PreEscaped(&result.description))}
.upstream_engines{
@for name in result.clone().engine{
span{(name)}
}
}
}
}
}
@else if search_results.disallowed{
.result_disallowed{
.description{
p{
"Your search - "{span class="user_query"{(query)}}" -
has been disallowed."
}
p class="description_paragraph"{"Dear user,"}
p class="description_paragraph"{
"The query - "{span class="user_query"{(query)}}" - has
been blacklisted via server configuration and hence disallowed by the
server. Henceforth no results could be displayed for your query."
}
}
img src="./images/barricade.png" alt="Image of a Barricade";
}
}
@else if search_results.filtered {
.result_filtered{
.description{
p{
"Your search - "{span class="user_query"{(query)}}" -
has been filtered."
}
p class="description_paragraph"{"Dear user,"}
p class="description_paragraph"{
"All the search results contain results that has been configured to be
filtered out via server configuration and henceforth has been
completely filtered out."
}
}
img src="./images/filter.png" alt="Image of a paper inside a funnel";
}
}
@else if search_results.no_engines_selected {
.result_engine_not_selected{
.description{
p{
"No results could be fetched for your search '{span class="user_query"{(query)}}'."
}
p class="description_paragraph"{"Dear user,"}
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."
}
}
img src="./images/no_selection.png" alt="Image of a white cross inside a red circle";
}
}
@else {
.result_not_found {
p{"Your search - "{(query)}" - did not match any documents."}
p class="suggestions"{"Suggestions:"}
ul{
li{"Make sure that all words are spelled correctly."}
li{"Try different keywords."}
li{"Try more general keywords."}
}
img src="./images/no_results.gif" alt="Man fishing gif";
}
}
}
.page_navigation {
button type="button" onclick="navigate_backward()"{
(PreEscaped("←")) "previous"
}
button type="button" onclick="navigate_forward()"{"next" (PreEscaped("→"))}
}
}
script src="static/index.js"{}
script src="static/search_area_options.js"{}
script src="static/pagination.js"{}
script src="static/error_box.js"{}
(footer())
)
}
|