fix broken source code url and add text on no results
This commit is contained in:
parent
1e6a5278c7
commit
6a6bbfcb51
@ -1,21 +1,34 @@
|
||||
<!-- source code: https://https://git.matdoes.dev/mat/metasearch2 -->
|
||||
<!-- source code: https://github.com/mat-1/metasearch2 -->
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>metasearch</title>
|
||||
<link rel="stylesheet" href="/style.css">
|
||||
<link rel="stylesheet" href="/style.css" />
|
||||
<script src="/script.js" defer></script>
|
||||
<link rel="search" type="application/opensearchdescription+xml" title="metasearch" href="/opensearch.xml"/>
|
||||
</head>
|
||||
<body>
|
||||
<link
|
||||
rel="search"
|
||||
type="application/opensearchdescription+xml"
|
||||
title="metasearch"
|
||||
href="/opensearch.xml"
|
||||
/>
|
||||
</head>
|
||||
<body>
|
||||
<div class="main-container">
|
||||
<h1>metasearch</h1>
|
||||
<form action="/search" method="get" class="search-form">
|
||||
<input type="text" name="q" placeholder="Search" id="search-input" autofocus onfocus="this.select()" autocomplete="off">
|
||||
<input type="submit" value="Search">
|
||||
<input
|
||||
type="text"
|
||||
name="q"
|
||||
placeholder="Search"
|
||||
id="search-input"
|
||||
autofocus
|
||||
onfocus="this.select()"
|
||||
autocomplete="off"
|
||||
/>
|
||||
<input type="submit" value="Search" />
|
||||
</form>
|
||||
</div>
|
||||
</body>
|
||||
</body>
|
||||
</html>
|
@ -95,7 +95,7 @@ fn render_featured_snippet(featured_snippet: &engines::FeaturedSnippet) -> Strin
|
||||
|
||||
fn render_results(response: Response) -> String {
|
||||
let mut html = String::new();
|
||||
if let Some(infobox) = response.infobox {
|
||||
if let Some(infobox) = &response.infobox {
|
||||
html.push_str(&format!(
|
||||
r#"<div class="infobox">{infobox_html}{engines_html}</div>"#,
|
||||
infobox_html = &infobox.html,
|
||||
@ -103,19 +103,28 @@ fn render_results(response: Response) -> String {
|
||||
));
|
||||
}
|
||||
|
||||
if let Some(answer) = response.answer {
|
||||
if let Some(answer) = &response.answer {
|
||||
html.push_str(&format!(
|
||||
r#"<div class="answer">{answer_html}{engines_html}</div>"#,
|
||||
answer_html = &answer.html,
|
||||
engines_html = render_engine_list(&[answer.engine])
|
||||
));
|
||||
}
|
||||
if let Some(featured_snippet) = response.featured_snippet {
|
||||
if let Some(featured_snippet) = &response.featured_snippet {
|
||||
html.push_str(&render_featured_snippet(&featured_snippet));
|
||||
}
|
||||
for result in &response.search_results {
|
||||
html.push_str(&render_search_result(result));
|
||||
}
|
||||
|
||||
if response.infobox.is_none()
|
||||
&& response.answer.is_none()
|
||||
&& response.featured_snippet.is_none()
|
||||
&& response.search_results.is_empty()
|
||||
{
|
||||
html.push_str(r#"<p>No results.</p>"#);
|
||||
}
|
||||
|
||||
html
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user