upgrade deps
This commit is contained in:
parent
130d976d45
commit
c7e1d768b2
414
Cargo.lock
generated
414
Cargo.lock
generated
File diff suppressed because it is too large
Load Diff
@ -42,7 +42,7 @@ reqwest = { version = "0.12.5", default-features = false, features = [
|
|||||||
scraper = "0.19.0"
|
scraper = "0.19.0"
|
||||||
serde = { version = "1.0.203", features = ["derive"] }
|
serde = { version = "1.0.203", features = ["derive"] }
|
||||||
# preserve_order is needed for google images. yippee!
|
# preserve_order is needed for google images. yippee!
|
||||||
serde_json = { version = "1.0.119", features = ["preserve_order"] }
|
serde_json = { version = "1.0.120", features = ["preserve_order"] }
|
||||||
tokio = { version = "1.38.0", features = ["rt", "macros"] }
|
tokio = { version = "1.38.0", features = ["rt", "macros"] }
|
||||||
tokio-stream = "0.1.15"
|
tokio-stream = "0.1.15"
|
||||||
toml = { version = "0.8.14", default-features = false, features = ["parse"] }
|
toml = { version = "0.8.14", default-features = false, features = ["parse"] }
|
||||||
|
@ -83,7 +83,7 @@ pub fn parse_response(
|
|||||||
|
|
||||||
html.push_str(
|
html.push_str(
|
||||||
&html! {
|
&html! {
|
||||||
h2."answer-dictionary-word" {
|
h2.answer-dictionary-word {
|
||||||
a href={ "https://en.wiktionary.org/wiki/" (mediawiki_key) } {
|
a href={ "https://en.wiktionary.org/wiki/" (mediawiki_key) } {
|
||||||
(word)
|
(word)
|
||||||
}
|
}
|
||||||
@ -95,7 +95,7 @@ pub fn parse_response(
|
|||||||
for entry in entries {
|
for entry in entries {
|
||||||
html.push_str(
|
html.push_str(
|
||||||
&html! {
|
&html! {
|
||||||
span."answer-dictionary-part-of-speech" {
|
span.answer-dictionary-part-of-speech {
|
||||||
(entry.part_of_speech.to_lowercase())
|
(entry.part_of_speech.to_lowercase())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -130,7 +130,7 @@ pub fn parse_response(
|
|||||||
let example_html = cleaner.clean(example).to_string();
|
let example_html = cleaner.clean(example).to_string();
|
||||||
html.push_str(
|
html.push_str(
|
||||||
&html! {
|
&html! {
|
||||||
blockquote."answer-dictionary-example" {
|
blockquote.answer-dictionary-example {
|
||||||
(PreEscaped(example_html))
|
(PreEscaped(example_html))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -15,7 +15,7 @@ pub fn request(query: &str) -> EngineResponse {
|
|||||||
};
|
};
|
||||||
|
|
||||||
EngineResponse::answer_html(html! {
|
EngineResponse::answer_html(html! {
|
||||||
p."answer-query" { (query) " =" }
|
p.answer-query { (query) " =" }
|
||||||
h3 { b { (result_html) } }
|
h3 { b { (result_html) } }
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@ -95,7 +95,7 @@ fn evaluate_to_html(query: &str, html: bool) -> Option<PreEscaped<String>> {
|
|||||||
if let Ok(num) = u64::from_str_radix(hex, 16) {
|
if let Ok(num) = u64::from_str_radix(hex, 16) {
|
||||||
result_html.push_str(
|
result_html.push_str(
|
||||||
&html! {
|
&html! {
|
||||||
span."answer-comment" { " = " (num) }
|
span.answer-comment { " = " (num) }
|
||||||
}
|
}
|
||||||
.into_string(),
|
.into_string(),
|
||||||
);
|
);
|
||||||
|
@ -14,6 +14,6 @@ pub fn request(query: &SearchQuery) -> EngineResponse {
|
|||||||
// `contenteditable="plaintext-only"` attribute currently only works on Chrome.
|
// `contenteditable="plaintext-only"` attribute currently only works on Chrome.
|
||||||
// This should be updated when the attribute becomes available in more browsers
|
// This should be updated when the attribute becomes available in more browsers
|
||||||
EngineResponse::answer_html(html! {
|
EngineResponse::answer_html(html! {
|
||||||
div."answer-notepad" contenteditable {}
|
div.answer-notepad contenteditable {}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -24,7 +24,7 @@ pub fn request(query: &str) -> EngineResponse {
|
|||||||
};
|
};
|
||||||
|
|
||||||
EngineResponse::answer_html(html! {
|
EngineResponse::answer_html(html! {
|
||||||
p."answer-query" { (query_html) " =" }
|
p.answer-query { (query_html) " =" }
|
||||||
h3 { b { (result_html) } }
|
h3 { b { (result_html) } }
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -154,14 +154,14 @@ fn render_thesaurus_html(
|
|||||||
ThesaurusResponse { word, items }: ThesaurusResponse,
|
ThesaurusResponse { word, items }: ThesaurusResponse,
|
||||||
) -> PreEscaped<String> {
|
) -> PreEscaped<String> {
|
||||||
html! {
|
html! {
|
||||||
h2."answer-thesaurus-word" {
|
h2.answer-thesaurus-word {
|
||||||
a href={ "https://www.thesaurus.com/browse/" (word) } {
|
a href={ "https://www.thesaurus.com/browse/" (word) } {
|
||||||
(word)
|
(word)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
div."answer-thesaurus-items" {
|
div.answer-thesaurus-items {
|
||||||
@for item in items {
|
@for item in items {
|
||||||
div."answer-thesaurus-item" {
|
div.answer-thesaurus-item {
|
||||||
(render_thesaurus_item_html(item))
|
(render_thesaurus_item_html(item))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -183,10 +183,10 @@ fn render_thesaurus_item_html(
|
|||||||
|
|
||||||
html.push_str(
|
html.push_str(
|
||||||
&html! {
|
&html! {
|
||||||
span."answer-thesaurus-word-description" {
|
span.answer-thesaurus-word-description {
|
||||||
span."answer-thesaurus-part-of-speech" { (part_of_speech.to_lowercase()) }
|
span.answer-thesaurus-part-of-speech { (part_of_speech.to_lowercase()) }
|
||||||
", as in "
|
", as in "
|
||||||
span."answer-thesaurus-as-in" { (as_in) }
|
span.answer-thesaurus-as-in { (as_in) }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.into_string(),
|
.into_string(),
|
||||||
@ -199,12 +199,12 @@ fn render_thesaurus_item_html(
|
|||||||
|
|
||||||
html! {
|
html! {
|
||||||
div.{ "answer-thesaurus-" (strength.to_lowercase().replace(' ', "-")) } {
|
div.{ "answer-thesaurus-" (strength.to_lowercase().replace(' ', "-")) } {
|
||||||
h3."answer-thesaurus-category-title" {
|
h3.answer-thesaurus-category-title {
|
||||||
(strength)
|
(strength)
|
||||||
" "
|
" "
|
||||||
(if matches.len() == 1 { "match" } else { "matches" })
|
(if matches.len() == 1 { "match" } else { "matches" })
|
||||||
}
|
}
|
||||||
ul."answer-thesaurus-list" {
|
ul.answer-thesaurus-list {
|
||||||
@for synonym in matches {
|
@for synonym in matches {
|
||||||
li {
|
li {
|
||||||
a href={ "https://www.thesaurus.com/browse/" (synonym) } { (synonym) }
|
a href={ "https://www.thesaurus.com/browse/" (synonym) } { (synonym) }
|
||||||
|
@ -10,10 +10,10 @@ pub fn request(query: &str) -> EngineResponse {
|
|||||||
match evaluate(query) {
|
match evaluate(query) {
|
||||||
None => EngineResponse::new(),
|
None => EngineResponse::new(),
|
||||||
Some(TimeResponse::Current { time, timezone }) => EngineResponse::answer_html(html! {
|
Some(TimeResponse::Current { time, timezone }) => EngineResponse::answer_html(html! {
|
||||||
p."answer-query" { "Current time in " (timezone_to_string(timezone)) }
|
p.answer-query { "Current time in " (timezone_to_string(timezone)) }
|
||||||
h3 {
|
h3 {
|
||||||
b { (time.format("%-I:%M %P")) }
|
b { (time.format("%-I:%M %P")) }
|
||||||
span."answer-comment" {
|
span.answer-comment {
|
||||||
"(" (time.format("%B %-d")) ")"
|
"(" (time.format("%B %-d")) ")"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -34,7 +34,7 @@ pub fn request(query: &str) -> EngineResponse {
|
|||||||
};
|
};
|
||||||
|
|
||||||
EngineResponse::answer_html(html! {
|
EngineResponse::answer_html(html! {
|
||||||
p."answer-query" {
|
p.answer-query {
|
||||||
(source_time.format("%-I:%M %P"))
|
(source_time.format("%-I:%M %P"))
|
||||||
" "
|
" "
|
||||||
(timezone_to_string(source_timezone))
|
(timezone_to_string(source_timezone))
|
||||||
@ -44,7 +44,7 @@ pub fn request(query: &str) -> EngineResponse {
|
|||||||
h3 {
|
h3 {
|
||||||
b { (target_time.format("%-I:%M %P")) }
|
b { (target_time.format("%-I:%M %P")) }
|
||||||
" "
|
" "
|
||||||
span."answer-comment" {
|
span.answer-comment {
|
||||||
(timezone_to_string(target_timezone)) " (" (delta) ")"
|
(timezone_to_string(target_timezone)) " (" (delta) ")"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -60,14 +60,14 @@ pub fn parse_response(HttpResponse { res, body, .. }: &HttpResponse) -> Option<P
|
|||||||
" "
|
" "
|
||||||
a href=(url) { (title) }
|
a href=(url) { (title) }
|
||||||
@if category == "Crate" {
|
@if category == "Crate" {
|
||||||
span."infobox-docs_rs-version" { (version) }
|
span.infobox-docs_rs-version { (version) }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
Some(html! {
|
Some(html! {
|
||||||
(title_html)
|
(title_html)
|
||||||
div."infobox-docs_rs-doc" {
|
div.infobox-docs_rs-doc {
|
||||||
(PreEscaped(doc_html))
|
(PreEscaped(doc_html))
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
@ -73,7 +73,7 @@ pub fn parse_response(body: &str) -> Option<PreEscaped<String>> {
|
|||||||
a href=(url) {
|
a href=(url) {
|
||||||
h1 { (title) }
|
h1 { (title) }
|
||||||
}
|
}
|
||||||
div."infobox-github-readme" {
|
div.infobox-github-readme {
|
||||||
(PreEscaped(readme_html))
|
(PreEscaped(readme_html))
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
@ -69,15 +69,11 @@ pub fn parse_response(
|
|||||||
.clean(&doc_html)
|
.clean(&doc_html)
|
||||||
.to_string();
|
.to_string();
|
||||||
|
|
||||||
let title_html = html! {
|
Some(html! {
|
||||||
h2 {
|
h2 {
|
||||||
a href=(url) { (page_title) }
|
a href=(url) { (page_title) }
|
||||||
}
|
}
|
||||||
};
|
div.infobox-mdn-article {
|
||||||
|
|
||||||
Some(html! {
|
|
||||||
(title_html)
|
|
||||||
div."infobox-mdn-article" {
|
|
||||||
(PreEscaped(doc_html))
|
(PreEscaped(doc_html))
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
@ -46,15 +46,11 @@ pub fn parse_response(HttpResponse { res, body, .. }: &HttpResponse) -> Option<P
|
|||||||
.clean(&doc_html)
|
.clean(&doc_html)
|
||||||
.to_string();
|
.to_string();
|
||||||
|
|
||||||
let title_html = html! {
|
Some(html! {
|
||||||
h2 {
|
h2 {
|
||||||
a href=(url) { (page_title) }
|
a href=(url) { (page_title) }
|
||||||
}
|
}
|
||||||
};
|
div.infobox-minecraft_wiki-article {
|
||||||
|
|
||||||
Some(html! {
|
|
||||||
(title_html)
|
|
||||||
div."infobox-minecraft_wiki-article" {
|
|
||||||
(PreEscaped(doc_html))
|
(PreEscaped(doc_html))
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
@ -60,7 +60,7 @@ pub fn parse_response(body: &str) -> Option<PreEscaped<String>> {
|
|||||||
a href=(url) {
|
a href=(url) {
|
||||||
h2 { (title) }
|
h2 { (title) }
|
||||||
}
|
}
|
||||||
div."infobox-stackexchange-answer" {
|
div.infobox-stackexchange-answer {
|
||||||
(PreEscaped(answer_html))
|
(PreEscaped(answer_html))
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
@ -25,8 +25,8 @@ use crate::{
|
|||||||
|
|
||||||
fn render_beginning_of_html(search: &SearchQuery) -> String {
|
fn render_beginning_of_html(search: &SearchQuery) -> String {
|
||||||
let form_html = html! {
|
let form_html = html! {
|
||||||
form."search-form" action="/search" method="get" {
|
form.search-form action="/search" method="get" {
|
||||||
input #"search-input" type="text" name="q" placeholder="Search" value=(search.query) autofocus onfocus="this.select()" autocomplete="off";
|
input #search-input type="text" name="q" placeholder="Search" value=(search.query) autofocus onfocus="this.select()" autocomplete="off";
|
||||||
@if search.tab != SearchTab::default() {
|
@if search.tab != SearchTab::default() {
|
||||||
input type="hidden" name="tab" value=(search.tab.to_string());
|
input type="hidden" name="tab" value=(search.tab.to_string());
|
||||||
}
|
}
|
||||||
@ -76,16 +76,14 @@ fn render_engine_progress_update(
|
|||||||
EngineProgressUpdate::Requesting => "requesting".to_string(),
|
EngineProgressUpdate::Requesting => "requesting".to_string(),
|
||||||
EngineProgressUpdate::Downloading => "downloading".to_string(),
|
EngineProgressUpdate::Downloading => "downloading".to_string(),
|
||||||
EngineProgressUpdate::Parsing => "parsing".to_string(),
|
EngineProgressUpdate::Parsing => "parsing".to_string(),
|
||||||
EngineProgressUpdate::Done => {
|
EngineProgressUpdate::Done => html! { span.progress-update-done { "done" } }.into_string(),
|
||||||
html! { span."progress-update-done" { "done" } }.into_string()
|
|
||||||
}
|
|
||||||
EngineProgressUpdate::Error(msg) => {
|
EngineProgressUpdate::Error(msg) => {
|
||||||
html! { span."progress-update-error" { (msg) } }.into_string()
|
html! { span.progress-update-error { (msg) } }.into_string()
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
html! {
|
html! {
|
||||||
span."progress-update-time" {
|
span.progress-update-time {
|
||||||
(format!("{time_ms:>4}"))
|
(format!("{time_ms:>4}"))
|
||||||
"ms"
|
"ms"
|
||||||
}
|
}
|
||||||
|
@ -13,7 +13,7 @@ pub fn render_results(response: Response) -> PreEscaped<String> {
|
|||||||
if let Some(infobox) = &response.infobox {
|
if let Some(infobox) = &response.infobox {
|
||||||
html.push_str(
|
html.push_str(
|
||||||
&html! {
|
&html! {
|
||||||
div."infobox" {
|
div.infobox {
|
||||||
(infobox.html)
|
(infobox.html)
|
||||||
(render_engine_list(&[infobox.engine], &response.config))
|
(render_engine_list(&[infobox.engine], &response.config))
|
||||||
}
|
}
|
||||||
@ -24,7 +24,7 @@ pub fn render_results(response: Response) -> PreEscaped<String> {
|
|||||||
if let Some(answer) = &response.answer {
|
if let Some(answer) = &response.answer {
|
||||||
html.push_str(
|
html.push_str(
|
||||||
&html! {
|
&html! {
|
||||||
div."answer" {
|
div.answer {
|
||||||
(answer.html)
|
(answer.html)
|
||||||
(render_engine_list(&[answer.engine], &response.config))
|
(render_engine_list(&[answer.engine], &response.config))
|
||||||
}
|
}
|
||||||
@ -56,12 +56,12 @@ fn render_search_result(
|
|||||||
config: &Config,
|
config: &Config,
|
||||||
) -> PreEscaped<String> {
|
) -> PreEscaped<String> {
|
||||||
html! {
|
html! {
|
||||||
div."search-result" {
|
div.search-result {
|
||||||
a."search-result-anchor" rel="noreferrer" href=(result.result.url) {
|
a.search-result-anchor rel="noreferrer" href=(result.result.url) {
|
||||||
span."search-result-url" { (result.result.url) }
|
span.search-result-url { (result.result.url) }
|
||||||
h3."search-result-title" { (result.result.title) }
|
h3.search-result-title { (result.result.title) }
|
||||||
}
|
}
|
||||||
p."search-result-description" { (result.result.description) }
|
p.search-result-description { (result.result.description) }
|
||||||
(render_engine_list(&result.engines.iter().copied().collect::<Vec<_>>(), config))
|
(render_engine_list(&result.engines.iter().copied().collect::<Vec<_>>(), config))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -72,11 +72,11 @@ fn render_featured_snippet(
|
|||||||
config: &Config,
|
config: &Config,
|
||||||
) -> PreEscaped<String> {
|
) -> PreEscaped<String> {
|
||||||
html! {
|
html! {
|
||||||
div."featured-snippet" {
|
div.featured-snippet {
|
||||||
p."search-result-description" { (featured_snippet.description) }
|
p.search-result-description { (featured_snippet.description) }
|
||||||
a."search-result-anchor" rel="noreferrer" href=(featured_snippet.url) {
|
a.search-result-anchor rel="noreferrer" href=(featured_snippet.url) {
|
||||||
span."search-result-url" { (featured_snippet.url) }
|
span.search-result-url { (featured_snippet.url) }
|
||||||
h3."search-result-title" { (featured_snippet.title) }
|
h3.search-result-title { (featured_snippet.title) }
|
||||||
}
|
}
|
||||||
(render_engine_list(&[featured_snippet.engine], config))
|
(render_engine_list(&[featured_snippet.engine], config))
|
||||||
}
|
}
|
||||||
@ -85,7 +85,7 @@ fn render_featured_snippet(
|
|||||||
|
|
||||||
pub fn render_infobox(infobox: &Infobox, config: &Config) -> PreEscaped<String> {
|
pub fn render_infobox(infobox: &Infobox, config: &Config) -> PreEscaped<String> {
|
||||||
html! {
|
html! {
|
||||||
div."infobox"."postsearch-infobox" {
|
div.infobox.postsearch-infobox {
|
||||||
(infobox.html)
|
(infobox.html)
|
||||||
(render_engine_list(&[infobox.engine], &config))
|
(render_engine_list(&[infobox.engine], &config))
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user