upgrade deps

This commit is contained in:
mat 2024-07-03 02:59:50 +00:00
parent 130d976d45
commit c7e1d768b2
15 changed files with 255 additions and 261 deletions

414
Cargo.lock generated

File diff suppressed because it is too large Load Diff

View File

@ -42,7 +42,7 @@ reqwest = { version = "0.12.5", default-features = false, features = [
scraper = "0.19.0"
serde = { version = "1.0.203", features = ["derive"] }
# 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-stream = "0.1.15"
toml = { version = "0.8.14", default-features = false, features = ["parse"] }

View File

@ -83,7 +83,7 @@ pub fn parse_response(
html.push_str(
&html! {
h2."answer-dictionary-word" {
h2.answer-dictionary-word {
a href={ "https://en.wiktionary.org/wiki/" (mediawiki_key) } {
(word)
}
@ -95,7 +95,7 @@ pub fn parse_response(
for entry in entries {
html.push_str(
&html! {
span."answer-dictionary-part-of-speech" {
span.answer-dictionary-part-of-speech {
(entry.part_of_speech.to_lowercase())
}
}
@ -130,7 +130,7 @@ pub fn parse_response(
let example_html = cleaner.clean(example).to_string();
html.push_str(
&html! {
blockquote."answer-dictionary-example" {
blockquote.answer-dictionary-example {
(PreEscaped(example_html))
}
}

View File

@ -15,7 +15,7 @@ pub fn request(query: &str) -> EngineResponse {
};
EngineResponse::answer_html(html! {
p."answer-query" { (query) " =" }
p.answer-query { (query) " =" }
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) {
result_html.push_str(
&html! {
span."answer-comment" { " = " (num) }
span.answer-comment { " = " (num) }
}
.into_string(),
);

View File

@ -14,6 +14,6 @@ pub fn request(query: &SearchQuery) -> EngineResponse {
// `contenteditable="plaintext-only"` attribute currently only works on Chrome.
// This should be updated when the attribute becomes available in more browsers
EngineResponse::answer_html(html! {
div."answer-notepad" contenteditable {}
div.answer-notepad contenteditable {}
})
}

View File

@ -24,7 +24,7 @@ pub fn request(query: &str) -> EngineResponse {
};
EngineResponse::answer_html(html! {
p."answer-query" { (query_html) " =" }
p.answer-query { (query_html) " =" }
h3 { b { (result_html) } }
})
}

View File

@ -154,14 +154,14 @@ fn render_thesaurus_html(
ThesaurusResponse { word, items }: ThesaurusResponse,
) -> PreEscaped<String> {
html! {
h2."answer-thesaurus-word" {
h2.answer-thesaurus-word {
a href={ "https://www.thesaurus.com/browse/" (word) } {
(word)
}
}
div."answer-thesaurus-items" {
div.answer-thesaurus-items {
@for item in items {
div."answer-thesaurus-item" {
div.answer-thesaurus-item {
(render_thesaurus_item_html(item))
}
}
@ -183,10 +183,10 @@ fn render_thesaurus_item_html(
html.push_str(
&html! {
span."answer-thesaurus-word-description" {
span."answer-thesaurus-part-of-speech" { (part_of_speech.to_lowercase()) }
span.answer-thesaurus-word-description {
span.answer-thesaurus-part-of-speech { (part_of_speech.to_lowercase()) }
", as in "
span."answer-thesaurus-as-in" { (as_in) }
span.answer-thesaurus-as-in { (as_in) }
}
}
.into_string(),
@ -199,12 +199,12 @@ fn render_thesaurus_item_html(
html! {
div.{ "answer-thesaurus-" (strength.to_lowercase().replace(' ', "-")) } {
h3."answer-thesaurus-category-title" {
h3.answer-thesaurus-category-title {
(strength)
" "
(if matches.len() == 1 { "match" } else { "matches" })
}
ul."answer-thesaurus-list" {
ul.answer-thesaurus-list {
@for synonym in matches {
li {
a href={ "https://www.thesaurus.com/browse/" (synonym) } { (synonym) }

View File

@ -10,10 +10,10 @@ pub fn request(query: &str) -> EngineResponse {
match evaluate(query) {
None => EngineResponse::new(),
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 {
b { (time.format("%-I:%M %P")) }
span."answer-comment" {
span.answer-comment {
"(" (time.format("%B %-d")) ")"
}
}
@ -34,7 +34,7 @@ pub fn request(query: &str) -> EngineResponse {
};
EngineResponse::answer_html(html! {
p."answer-query" {
p.answer-query {
(source_time.format("%-I:%M %P"))
" "
(timezone_to_string(source_timezone))
@ -44,7 +44,7 @@ pub fn request(query: &str) -> EngineResponse {
h3 {
b { (target_time.format("%-I:%M %P")) }
" "
span."answer-comment" {
span.answer-comment {
(timezone_to_string(target_timezone)) " (" (delta) ")"
}
}

View File

@ -60,14 +60,14 @@ pub fn parse_response(HttpResponse { res, body, .. }: &HttpResponse) -> Option<P
" "
a href=(url) { (title) }
@if category == "Crate" {
span."infobox-docs_rs-version" { (version) }
span.infobox-docs_rs-version { (version) }
}
}
};
Some(html! {
(title_html)
div."infobox-docs_rs-doc" {
div.infobox-docs_rs-doc {
(PreEscaped(doc_html))
}
})

View File

@ -73,7 +73,7 @@ pub fn parse_response(body: &str) -> Option<PreEscaped<String>> {
a href=(url) {
h1 { (title) }
}
div."infobox-github-readme" {
div.infobox-github-readme {
(PreEscaped(readme_html))
}
})

View File

@ -69,15 +69,11 @@ pub fn parse_response(
.clean(&doc_html)
.to_string();
let title_html = html! {
Some(html! {
h2 {
a href=(url) { (page_title) }
}
};
Some(html! {
(title_html)
div."infobox-mdn-article" {
div.infobox-mdn-article {
(PreEscaped(doc_html))
}
})

View File

@ -46,15 +46,11 @@ pub fn parse_response(HttpResponse { res, body, .. }: &HttpResponse) -> Option<P
.clean(&doc_html)
.to_string();
let title_html = html! {
Some(html! {
h2 {
a href=(url) { (page_title) }
}
};
Some(html! {
(title_html)
div."infobox-minecraft_wiki-article" {
div.infobox-minecraft_wiki-article {
(PreEscaped(doc_html))
}
})

View File

@ -60,7 +60,7 @@ pub fn parse_response(body: &str) -> Option<PreEscaped<String>> {
a href=(url) {
h2 { (title) }
}
div."infobox-stackexchange-answer" {
div.infobox-stackexchange-answer {
(PreEscaped(answer_html))
}
})

View File

@ -25,8 +25,8 @@ use crate::{
fn render_beginning_of_html(search: &SearchQuery) -> String {
let form_html = html! {
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";
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";
@if search.tab != SearchTab::default() {
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::Downloading => "downloading".to_string(),
EngineProgressUpdate::Parsing => "parsing".to_string(),
EngineProgressUpdate::Done => {
html! { span."progress-update-done" { "done" } }.into_string()
}
EngineProgressUpdate::Done => html! { span.progress-update-done { "done" } }.into_string(),
EngineProgressUpdate::Error(msg) => {
html! { span."progress-update-error" { (msg) } }.into_string()
html! { span.progress-update-error { (msg) } }.into_string()
}
};
html! {
span."progress-update-time" {
span.progress-update-time {
(format!("{time_ms:>4}"))
"ms"
}

View File

@ -13,7 +13,7 @@ pub fn render_results(response: Response) -> PreEscaped<String> {
if let Some(infobox) = &response.infobox {
html.push_str(
&html! {
div."infobox" {
div.infobox {
(infobox.html)
(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 {
html.push_str(
&html! {
div."answer" {
div.answer {
(answer.html)
(render_engine_list(&[answer.engine], &response.config))
}
@ -56,12 +56,12 @@ fn render_search_result(
config: &Config,
) -> PreEscaped<String> {
html! {
div."search-result" {
a."search-result-anchor" rel="noreferrer" href=(result.result.url) {
span."search-result-url" { (result.result.url) }
h3."search-result-title" { (result.result.title) }
div.search-result {
a.search-result-anchor rel="noreferrer" href=(result.result.url) {
span.search-result-url { (result.result.url) }
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))
}
}
@ -72,11 +72,11 @@ fn render_featured_snippet(
config: &Config,
) -> PreEscaped<String> {
html! {
div."featured-snippet" {
p."search-result-description" { (featured_snippet.description) }
a."search-result-anchor" rel="noreferrer" href=(featured_snippet.url) {
span."search-result-url" { (featured_snippet.url) }
h3."search-result-title" { (featured_snippet.title) }
div.featured-snippet {
p.search-result-description { (featured_snippet.description) }
a.search-result-anchor rel="noreferrer" href=(featured_snippet.url) {
span.search-result-url { (featured_snippet.url) }
h3.search-result-title { (featured_snippet.title) }
}
(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> {
html! {
div."infobox"."postsearch-infobox" {
div.infobox.postsearch-infobox {
(infobox.html)
(render_engine_list(&[infobox.engine], &config))
}