fix: Improvements;

This commit is contained in:
Myzel394 2024-02-22 16:48:35 +01:00
parent a230e8b9db
commit 877ecd1fee
No known key found for this signature in database
GPG Key ID: DEC4AAB876F73185
12 changed files with 575 additions and 45 deletions

18
Cargo.lock generated
View File

@ -557,6 +557,15 @@ dependencies = [
"windows-sys 0.52.0", "windows-sys 0.52.0",
] ]
[[package]]
name = "html-escape"
version = "0.2.13"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6d1ad449764d627e22bfd7cd5e8868264fc9236e07c752972b4080cd351cb476"
dependencies = [
"utf8-width",
]
[[package]] [[package]]
name = "http" name = "http"
version = "0.2.11" version = "0.2.11"
@ -1631,12 +1640,15 @@ dependencies = [
"async-trait", "async-trait",
"bytes", "bytes",
"futures", "futures",
"html-escape",
"lazy-regex", "lazy-regex",
"lazy_static", "lazy_static",
"log",
"mio", "mio",
"regex", "regex",
"reqwest", "reqwest",
"rocket", "rocket",
"rustc-hash",
"rustls", "rustls",
"rustls-pemfile", "rustls-pemfile",
"tokio", "tokio",
@ -1952,6 +1964,12 @@ version = "2.1.3"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "daf8dba3b7eb870caf1ddeed7bc9d2a049f3cfdfae7cb521b087cc33ae4c49da" checksum = "daf8dba3b7eb870caf1ddeed7bc9d2a049f3cfdfae7cb521b087cc33ae4c49da"
[[package]]
name = "utf8-width"
version = "0.1.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "86bd8d4e895da8537e5315b8254664e6b769c4ff3db18321b297a1e7004392e3"
[[package]] [[package]]
name = "valuable" name = "valuable"
version = "0.1.0" version = "0.1.0"

View File

@ -9,12 +9,15 @@ edition = "2021"
async-trait = "0.1.77" async-trait = "0.1.77"
bytes = "1.5.0" bytes = "1.5.0"
futures = "0.3.30" futures = "0.3.30"
html-escape = "0.2.13"
lazy-regex = "3.1.0" lazy-regex = "3.1.0"
lazy_static = "1.4.0" lazy_static = "1.4.0"
log = "0.4.20"
mio = { version = "0.8.10", features = ["net", "os-poll", ] } mio = { version = "0.8.10", features = ["net", "os-poll", ] }
regex = "1.10.3" regex = "1.10.3"
reqwest = { version = "0.11.23", features = ["stream"] } reqwest = { version = "0.11.23", features = ["stream"] }
rocket = "0.5.0" rocket = "0.5.0"
rustc-hash = "1.1.0"
rustls = { path = "../rustls/rustls", features = ["logging"] } rustls = { path = "../rustls/rustls", features = ["logging"] }
rustls-pemfile = "2" rustls-pemfile = "2"
tokio = {version = "1.35.1", features = ["full"]} tokio = {version = "1.35.1", features = ["full"]}

View File

@ -14,7 +14,7 @@ pub mod bing {
lazy_static! { lazy_static! {
static ref RESULTS_START: Regex = Regex::new(r#"id="b_results""#).unwrap(); static ref RESULTS_START: Regex = Regex::new(r#"id="b_results""#).unwrap();
static ref SINGLE_RESULT: Regex = Regex::new(r#"<li class="b_algo".*?<h2.*?><a href="(?P<url>.+?)".*?>(?P<title>.+?)</a></h2>.*?((<div class="b_caption.*?<p.*?)|(<p class="b_lineclamp3.*?))><span.*?</span>(?P<description>.*?)</p>.*?</li>"#).unwrap(); static ref SINGLE_RESULT: Regex = Regex::new(r#"<li class="b_algo".*?<h2.*?><a href="(?P<url>.+?)".*?>(?P<title>.+?)</a></h2>.*?((<div class="b_caption.*?<p.*?)|(<p class="b_lineclamp.*?))><span.*?</span>(?P<description>.*?)</p>.*?</li>"#).unwrap();
} }
#[derive(Clone, Debug)] #[derive(Clone, Debug)]

View File

@ -1,14 +1,16 @@
pub mod engine_base { pub mod engine_base {
use std::{fmt::Display, sync::Arc}; use core::fmt;
use std::{fmt::Debug, fmt::Display, sync::Arc};
use futures::{lock::Mutex, Future, StreamExt}; use futures::{lock::Mutex, Future, StreamExt};
use lazy_static::lazy_static; use lazy_static::lazy_static;
use regex::Regex; use regex::Regex;
use reqwest::{Error, Response}; use reqwest::{Error, Response};
use rustc_hash::FxHashMap;
use tokio::sync::mpsc::Sender; use tokio::sync::mpsc::Sender;
use urlencoding::decode; use urlencoding::decode;
use crate::utils::utils::decode_html_text; use crate::utils::utils::{decode_html_text, hash_string};
lazy_static! { lazy_static! {
static ref STRIP: Regex = Regex::new(r"[\s\n]+").unwrap(); static ref STRIP: Regex = Regex::new(r"[\s\n]+").unwrap();
@ -41,6 +43,16 @@ pub mod engine_base {
pub engine: SearchEngine, pub engine: SearchEngine,
} }
impl SearchResult {
pub fn get_html_id(&self) -> String {
format!(
"html-id-{}-{}",
hash_string(&self.url),
self.url[self.url.len() - 5..].to_string(),
)
}
}
pub trait EngineBase { pub trait EngineBase {
fn parse_next<'a>(&mut self) -> Option<SearchResult>; fn parse_next<'a>(&mut self) -> Option<SearchResult>;
@ -61,7 +73,9 @@ pub mod engine_base {
request: impl Future<Output = Result<Response, Error>>, request: impl Future<Output = Result<Response, Error>>,
tx: Sender<SearchResult>, tx: Sender<SearchResult>,
) -> Result<(), ()> { ) -> Result<(), ()> {
let mut stream = request.await.unwrap().bytes_stream(); let req = request.await.unwrap();
let url = req.url().clone();
let mut stream = req.bytes_stream();
while let Some(chunk) = stream.next().await { while let Some(chunk) = stream.next().await {
let buffer = chunk.unwrap(); let buffer = chunk.unwrap();

View File

@ -1,20 +0,0 @@
<!DOCTYPE html>
<html lang="en">
<head>
<title>tifsep</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href="tailwind.css" rel="stylesheet">
</head>
<body class="bg-gray-700">
<header class="flex items-center justify-between px-10 py-2">
<input type="search" class="w-40 rounded-full bg-gray-500 text-white px-4 py-1" placeholder="Search">
</header>
<main>
<ul>
<!-- </ul> -->
<!-- </main> -->
<!-- </body> -->
<!-- </html> -->

View File

@ -1,15 +1,15 @@
use std::str; use std::str;
use std::sync::Arc;
use engines::bing::bing::Bing; use engines::bing::bing::Bing;
use engines::brave::brave::Brave; use engines::brave::brave::Brave;
use engines::duckduckgo::duckduckgo::DuckDuckGo; use engines::duckduckgo::duckduckgo::DuckDuckGo;
use engines::engine_base::engine_base::SearchResult; use engines::engine_base::engine_base::SearchResult;
use futures::lock::Mutex;
use lazy_static::lazy_static; use lazy_static::lazy_static;
use regex::Regex;
use rocket::response::content::{RawCss, RawHtml}; use rocket::response::content::{RawCss, RawHtml};
use rocket::response::stream::TextStream; use rocket::response::stream::TextStream;
use rocket::time::Instant; use rocket::time::Instant;
use static_files::static_files::{render_beginning_html, render_finished_css};
use tokio::sync::mpsc; use tokio::sync::mpsc;
use crate::static_files::static_files::read_file_contents; use crate::static_files::static_files::read_file_contents;
@ -25,13 +25,16 @@ pub mod utils;
extern crate rocket; extern crate rocket;
lazy_static! { lazy_static! {
static ref HTML_BEGINNING: String = read_file_contents("./src/html/beginning.html").unwrap(); static ref HTML_BEGINNING: String =
static ref HTML_END: String = read_file_contents("./src/html/end.html").unwrap(); read_file_contents("./src/public/html/beginning.html").unwrap();
static ref TAILWIND_CSS: String = read_file_contents("./tailwindcss/output.css").unwrap(); static ref SET_VALUE_REPLACE: Regex = Regex::new(r#"\{\% search_value \%\}"#).unwrap();
static ref HTML_END: String = read_file_contents("./src/public/html/end.html").unwrap();
static ref TAILWIND_CSS: String = read_file_contents("./src/public/css/style.css").unwrap();
static ref FINISHED_CSS: String = read_file_contents("./src/public/css/finished.css").unwrap();
static ref FINISHED_NAME_REPLACE: Regex = Regex::new(r#"(__engine__)"#).unwrap();
static ref FINISHED_TIME_REPLACE: Regex = Regex::new(r#"{% time %}"#).unwrap();
} }
const USER_AGENT: &str = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/121.0.0.0 Safari/537.3";
#[get("/search")] #[get("/search")]
fn search_get() -> &'static str { fn search_get() -> &'static str {
"<html> "<html>
@ -44,7 +47,7 @@ fn search_get() -> &'static str {
</html>" </html>"
} }
#[get("/tailwind.css")] #[get("/style.css")]
fn get_tailwindcss() -> RawCss<&'static str> { fn get_tailwindcss() -> RawCss<&'static str> {
RawCss(&TAILWIND_CSS) RawCss(&TAILWIND_CSS)
} }
@ -63,41 +66,83 @@ async fn hello<'a>(query: &str) -> RawHtml<TextStream![String]> {
let tx_duckduckgo = tx.clone(); let tx_duckduckgo = tx.clone();
let tx_bing = tx.clone(); let tx_bing = tx.clone();
tokio::spawn(async move { let mut bing_finished_informed = false;
let mut brave_finished_informed = false;
let mut duckduckgo_finished_informed = false;
let now = Instant::now();
let brave_task = tokio::spawn(async move {
let mut brave = Brave::new(); let mut brave = Brave::new();
brave.search(&query_brave, tx_brave).await; brave.search(&query_brave, tx_brave).await;
}); });
tokio::spawn(async move { let duckduckgo_task = tokio::spawn(async move {
let mut duckduckgo = DuckDuckGo::new(); let mut duckduckgo = DuckDuckGo::new();
duckduckgo.search(&query_duckduckgo, tx_duckduckgo).await; duckduckgo.search(&query_duckduckgo, tx_duckduckgo).await;
}); });
tokio::spawn(async move { let bing_task = tokio::spawn(async move {
let mut bing = Bing::new(); let mut bing = Bing::new();
bing.search(&query_bing, tx_bing).await; bing.search(&query_bing, tx_bing).await;
}); });
let beginning_html = render_beginning_html(&query);
RawHtml(TextStream! { RawHtml(TextStream! {
yield HTML_BEGINNING.to_string(); yield beginning_html;
while let Some(result) = rx.recv().await { while !brave_task.is_finished() || !duckduckgo_task.is_finished() || !bing_task.is_finished() {
if !first_result_yielded { while let Some(result) = rx.recv().await {
let diff = first_result_start.elapsed().whole_milliseconds(); if !first_result_yielded {
first_result_yielded = true; let diff = first_result_start.elapsed().whole_milliseconds();
first_result_yielded = true;
yield format!("<strong>Time taken: {}ms</strong>", diff); yield format!("<strong>Time taken: {}ms</strong>", diff);
yield "<style>.fake { display: none; }</style>".to_string();
}
if !bing_finished_informed && bing_task.is_finished() {
bing_finished_informed = true;
yield render_finished_css("bing", now.elapsed().whole_milliseconds());
}
if !brave_finished_informed && brave_task.is_finished() {
brave_finished_informed = true;
yield render_finished_css("brave", now.elapsed().whole_milliseconds());
}
if !duckduckgo_finished_informed && duckduckgo_task.is_finished() {
duckduckgo_finished_informed = true;
yield render_finished_css("duckduckgo", now.elapsed().whole_milliseconds());
}
let text = format!("<li><h1>{}</h1><p>{}</p><i>{}</i></li>", &result.title, &result.description, &result.engine.to_string());
yield text.to_string();
} }
let text = format!("<li><h1>{}</h1><p>{}</p><i>{}</i></li>", &result.title, &result.description, &result.engine.to_string());
yield text.to_string();
} }
let diff = first_result_start.elapsed().whole_milliseconds(); let diff = first_result_start.elapsed().whole_milliseconds();
if !bing_finished_informed {
yield render_finished_css("bing", now.elapsed().whole_milliseconds());
}
if !brave_finished_informed {
yield render_finished_css("brave", now.elapsed().whole_milliseconds());
}
if !duckduckgo_finished_informed {
yield render_finished_css("duckduckgo", now.elapsed().whole_milliseconds());
}
yield format!("<strong>End taken: {}ms</strong>", diff); yield format!("<strong>End taken: {}ms</strong>", diff);
yield HTML_END.to_string(); yield HTML_END.to_string();
}) })

View File

@ -0,0 +1,10 @@
#search-status-__engine__::after {
content: "{% time %}ms";
animation: fadeIn 0.5s;
}
#search-status-__engine__ svg {
filter: grayscale(50%);
transform: translateY(-100%);
animation: none !important;
}

180
src/public/css/style.css Normal file
View File

@ -0,0 +1,180 @@
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
background: #2d2d2d;
font-family: Roboto, Helvetica, Arial, sans-serif;
max-width: 1200px;
margin: 0 auto;
color: #aaa;
}
main {
min-height: 100dvh;
display: grid;
grid-template-columns: 70% 30%;
gap: 2em;
margin: 2em 0;
}
header {
display: flex;
justify-content: space-between;
align-items: center;
margin: 2em 0;
}
#search-input {
display: flex;
align-items: center;
gap: 1em;
}
#search {
min-width: 10em;
font-size: 1rem;
padding: 0.5em 1.2em;
border: none;
border-radius: 10em;
background: #555;
color: #fff;
}
#search-status {
display: flex;
justify-content: center;
align-items: center;
gap: 4em;
}
#search-status>div {
position: relative;
}
#search-status>div>svg {
animation: shimmer 0.5s infinite linear;
transition: transform 0.6s cubic-bezier(0.16, 1, 0.3, 1);
width: 1.4em;
height: 1.4em;
}
@keyframes shimmer {
0%,
100% {
filter: brightness(0.4);
}
50% {
filter: brightness(1);
}
}
#search-status-bing::after {
content: "";
font-size: 0.8rem;
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
}
#search-status-duckduckgo::after {
content: "";
font-size: 0.8rem;
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
}
#search-status-brave::after {
content: "";
font-size: 0.8rem;
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
}
#back-button {
background: #555;
fill: #fff;
width: 2em;
height: 2em;
padding: 0.5em;
border-radius: 50%;
}
li {
list-style: none;
background: #222;
padding: 1em;
margin: 1em 0;
border-radius: 0.5em;
animation: moveIn 0.5s;
}
li h1 {
color: #fff;
text-decoration: none;
font-size: 1.2rem;
}
li p {
color: #aaa;
line-height: 1.5;
font-size: 0.9rem;
}
li.fake {
height: 6em;
animation: fakeShimmer 0.8s infinite linear;
}
li.fake.big {
height: 12em;
}
li.fake.small {
height: 3em;
}
@keyframes fakeShimmer {
0%,
100% {
filter: brightness(1.3)
}
50% {
filter: brightness(1)
}
}
@keyframes moveIn {
from {
opacity: 0;
transform: translateY(1em);
}
to {
opacity: 1;
transform: translateY(0);
}
}
@keyframes fadeIn {
from {
opacity: 0;
}
to {
opacity: 1;
}
}

View File

@ -0,0 +1,239 @@
<!DOCTYPE html>
<html lang="en">
<head>
<title>tifsep</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href="style.css" rel="stylesheet">
</head>
<body>
<header>
<form id="search-input" action="/searchquery" method="get">
<svg id="back-button" xmlns="http://www.w3.org/2000/svg"
viewBox="0 0 448 512"><!--!Font Awesome Free 6.5.1 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2024 Fonticons, Inc.-->
<path
d="M9.4 233.4c-12.5 12.5-12.5 32.8 0 45.3l160 160c12.5 12.5 32.8 12.5 45.3 0s12.5-32.8 0-45.3L109.2 288 416 288c17.7 0 32-14.3 32-32s-14.3-32-32-32l-306.7 0L214.6 118.6c12.5-12.5 12.5-32.8 0-45.3s-32.8-12.5-45.3 0l-160 160z" />
</svg>
<input id="search" name="query" type="search" placeholder="Search" value="{% search_value %}">
</form>
<div id="search-status">
<div id="search-status-bing">
<svg viewBox="-29.62167543756803 0.1 574.391675437568 799.8100000000002"
xmlns="http://www.w3.org/2000/svg" width="1888" height="2500">
<linearGradient id="a" gradientUnits="userSpaceOnUse" x1="286.383" x2="542.057" y1="284.169"
y2="569.112">
<stop offset="0" stop-color="#37bdff" />
<stop offset=".25" stop-color="#26c6f4" />
<stop offset=".5" stop-color="#15d0e9" />
<stop offset=".75" stop-color="#3bd6df" />
<stop offset="1" stop-color="#62dcd4" />
</linearGradient>
<linearGradient id="b" gradientUnits="userSpaceOnUse" x1="108.979" x2="100.756" y1="675.98"
y2="43.669">
<stop offset="0" stop-color="#1b48ef" />
<stop offset=".5" stop-color="#2080f1" />
<stop offset="1" stop-color="#26b8f4" />
</linearGradient>
<linearGradient id="c" gradientUnits="userSpaceOnUse" x1="256.823" x2="875.632" y1="649.719"
y2="649.719">
<stop offset="0" stop-color="#39d2ff" />
<stop offset=".5" stop-color="#248ffa" />
<stop offset="1" stop-color="#104cf5" />
</linearGradient>
<linearGradient id="d" gradientUnits="userSpaceOnUse" x1="256.823" x2="875.632" y1="649.719"
y2="649.719">
<stop offset="0" stop-color="#fff" />
<stop offset="1" />
</linearGradient>
<path
d="M249.97 277.48c-.12.96-.12 2.05-.12 3.12 0 4.16.83 8.16 2.33 11.84l1.34 2.76 5.3 13.56 27.53 70.23 24.01 61.33c6.85 12.38 17.82 22.1 31.05 27.28l4.11 1.51c.16.05.43.05.65.11l65.81 22.63v.05l25.16 8.64 1.72.58c.06 0 .16.06.22.06 4.96 1.25 9.82 2.93 14.46 4.98 10.73 4.63 20.46 11.23 28.77 19.28 3.35 3.2 6.43 6.65 9.28 10.33a88.64 88.64 0 0 1 6.64 9.72c8.78 14.58 13.82 31.72 13.82 49.97 0 3.26-.16 6.41-.49 9.61-.11 1.41-.28 2.77-.49 4.12v.11c-.22 1.43-.49 2.91-.76 4.36-.28 1.41-.54 2.81-.86 4.21-.05.16-.11.33-.17.49-.3 1.42-.68 2.82-1.07 4.23-.35 1.33-.79 2.7-1.28 3.99a42.96 42.96 0 0 1-1.51 4.16c-.49 1.4-1.07 2.82-1.72 4.16-1.78 4.11-3.9 8.06-6.28 11.83a97.889 97.889 0 0 1-10.47 13.95c30.88-33.2 51.41-76.07 56.52-123.51.86-7.78 1.3-15.67 1.3-23.61 0-5.07-.22-10.09-.55-15.13-3.89-56.89-29.79-107.77-69.32-144.08-10.9-10.09-22.81-19.07-35.62-26.69l-24.2-12.37-122.63-62.93a30.15 30.15 0 0 0-11.93-2.44c-15.88 0-28.99 12.11-30.55 27.56z"
fill="#7f7f7f" />
<path
d="M249.97 277.48c-.12.96-.12 2.05-.12 3.12 0 4.16.83 8.16 2.33 11.84l1.34 2.76 5.3 13.56 27.53 70.23 24.01 61.33c6.85 12.38 17.82 22.1 31.05 27.28l4.11 1.51c.16.05.43.05.65.11l65.81 22.63v.05l25.16 8.64 1.72.58c.06 0 .16.06.22.06 4.96 1.25 9.82 2.93 14.46 4.98 10.73 4.63 20.46 11.23 28.77 19.28 3.35 3.2 6.43 6.65 9.28 10.33a88.64 88.64 0 0 1 6.64 9.72c8.78 14.58 13.82 31.72 13.82 49.97 0 3.26-.16 6.41-.49 9.61-.11 1.41-.28 2.77-.49 4.12v.11c-.22 1.43-.49 2.91-.76 4.36-.28 1.41-.54 2.81-.86 4.21-.05.16-.11.33-.17.49-.3 1.42-.68 2.82-1.07 4.23-.35 1.33-.79 2.7-1.28 3.99a42.96 42.96 0 0 1-1.51 4.16c-.49 1.4-1.07 2.82-1.72 4.16-1.78 4.11-3.9 8.06-6.28 11.83a97.889 97.889 0 0 1-10.47 13.95c30.88-33.2 51.41-76.07 56.52-123.51.86-7.78 1.3-15.67 1.3-23.61 0-5.07-.22-10.09-.55-15.13-3.89-56.89-29.79-107.77-69.32-144.08-10.9-10.09-22.81-19.07-35.62-26.69l-24.2-12.37-122.63-62.93a30.15 30.15 0 0 0-11.93-2.44c-15.88 0-28.99 12.11-30.55 27.56z"
fill="url(#a)" />
<path
d="M31.62.1C14.17.41.16 14.69.16 32.15v559.06c.07 3.9.29 7.75.57 11.66.25 2.06.52 4.2.9 6.28 7.97 44.87 47.01 78.92 94.15 78.92 16.53 0 32.03-4.21 45.59-11.53.08-.06.22-.14.29-.14l4.88-2.95 19.78-11.64 25.16-14.93.06-496.73c0-33.01-16.52-62.11-41.81-79.4-.6-.36-1.18-.74-1.71-1.17L50.12 5.56C45.16 2.28 39.18.22 32.77.1z"
fill="#7f7f7f" />
<path
d="M31.62.1C14.17.41.16 14.69.16 32.15v559.06c.07 3.9.29 7.75.57 11.66.25 2.06.52 4.2.9 6.28 7.97 44.87 47.01 78.92 94.15 78.92 16.53 0 32.03-4.21 45.59-11.53.08-.06.22-.14.29-.14l4.88-2.95 19.78-11.64 25.16-14.93.06-496.73c0-33.01-16.52-62.11-41.81-79.4-.6-.36-1.18-.74-1.71-1.17L50.12 5.56C45.16 2.28 39.18.22 32.77.1z"
fill="url(#b)" />
<path
d="M419.81 510.84L194.72 644.26l-3.24 1.95v.71l-25.16 14.9-19.77 11.67-4.85 2.93-.33.16c-13.53 7.35-29.04 11.51-45.56 11.51-47.13 0-86.22-34.03-94.16-78.92 3.77 32.84 14.96 63.41 31.84 90.04 34.76 54.87 93.54 93.04 161.54 99.67h41.58c36.78-3.84 67.49-18.57 99.77-38.46l49.64-30.36c22.36-14.33 83.05-49.58 100.93-69.36 3.89-4.33 7.4-8.97 10.47-13.94 2.38-3.78 4.5-7.73 6.28-11.84.6-1.4 1.17-2.76 1.72-4.15.52-1.38 1.01-2.77 1.51-4.18.93-2.7 1.67-5.41 2.38-8.2.36-1.59.69-3.16 1.02-4.72 1.08-5.89 1.67-11.94 1.67-18.21 0-18.25-5.04-35.39-13.77-49.95-2-3.4-4.2-6.65-6.64-9.72-2.85-3.7-5.93-7.13-9.28-10.33-8.31-8.05-18.01-14.65-28.77-19.29-4.64-2.05-9.48-3.74-14.46-4.97-.06 0-.16-.06-.22-.06l-1.72-.58z"
fill="#7f7f7f" />
<path
d="M419.81 510.84L194.72 644.26l-3.24 1.95v.71l-25.16 14.9-19.77 11.67-4.85 2.93-.33.16c-13.53 7.35-29.04 11.51-45.56 11.51-47.13 0-86.22-34.03-94.16-78.92 3.77 32.84 14.96 63.41 31.84 90.04 34.76 54.87 93.54 93.04 161.54 99.67h41.58c36.78-3.84 67.49-18.57 99.77-38.46l49.64-30.36c22.36-14.33 83.05-49.58 100.93-69.36 3.89-4.33 7.4-8.97 10.47-13.94 2.38-3.78 4.5-7.73 6.28-11.84.6-1.4 1.17-2.76 1.72-4.15.52-1.38 1.01-2.77 1.51-4.18.93-2.7 1.67-5.41 2.38-8.2.36-1.59.69-3.16 1.02-4.72 1.08-5.89 1.67-11.94 1.67-18.21 0-18.25-5.04-35.39-13.77-49.95-2-3.4-4.2-6.65-6.64-9.72-2.85-3.7-5.93-7.13-9.28-10.33-8.31-8.05-18.01-14.65-28.77-19.29-4.64-2.05-9.48-3.74-14.46-4.97-.06 0-.16-.06-.22-.06l-1.72-.58z"
fill="url(#c)" />
<path
d="M512 595.46c0 6.27-.59 12.33-1.68 18.22-.32 1.56-.65 3.12-1.02 4.7-.7 2.8-1.44 5.51-2.37 8.22-.49 1.4-.99 2.8-1.51 4.16-.54 1.4-1.12 2.76-1.73 4.16a87.873 87.873 0 0 1-6.26 11.83 96.567 96.567 0 0 1-10.48 13.94c-17.88 19.79-78.57 55.04-100.93 69.37l-49.64 30.36c-36.39 22.42-70.77 38.29-114.13 39.38-2.05.06-4.06.11-6.05.11-2.8 0-5.56-.05-8.33-.16-73.42-2.8-137.45-42.25-174.38-100.54a213.368 213.368 0 0 1-31.84-90.04c7.94 44.89 47.03 78.92 94.16 78.92 16.52 0 32.03-4.17 45.56-11.51l.33-.17 4.85-2.92 19.77-11.67 25.16-14.9v-.71l3.24-1.95 225.09-133.43 17.33-10.27 1.72.58c.05 0 .16.06.22.06 4.98 1.23 9.83 2.92 14.46 4.97 10.76 4.64 20.45 11.24 28.77 19.29a92.13 92.13 0 0 1 9.28 10.33c2.44 3.07 4.64 6.32 6.64 9.72 8.73 14.56 13.77 31.7 13.77 49.95z"
fill="#7f7f7f" opacity=".15" />
<path
d="M512 595.46c0 6.27-.59 12.33-1.68 18.22-.32 1.56-.65 3.12-1.02 4.7-.7 2.8-1.44 5.51-2.37 8.22-.49 1.4-.99 2.8-1.51 4.16-.54 1.4-1.12 2.76-1.73 4.16a87.873 87.873 0 0 1-6.26 11.83 96.567 96.567 0 0 1-10.48 13.94c-17.88 19.79-78.57 55.04-100.93 69.37l-49.64 30.36c-36.39 22.42-70.77 38.29-114.13 39.38-2.05.06-4.06.11-6.05.11-2.8 0-5.56-.05-8.33-.16-73.42-2.8-137.45-42.25-174.38-100.54a213.368 213.368 0 0 1-31.84-90.04c7.94 44.89 47.03 78.92 94.16 78.92 16.52 0 32.03-4.17 45.56-11.51l.33-.17 4.85-2.92 19.77-11.67 25.16-14.9v-.71l3.24-1.95 225.09-133.43 17.33-10.27 1.72.58c.05 0 .16.06.22.06 4.98 1.23 9.83 2.92 14.46 4.97 10.76 4.64 20.45 11.24 28.77 19.29a92.13 92.13 0 0 1 9.28 10.33c2.44 3.07 4.64 6.32 6.64 9.72 8.73 14.56 13.77 31.7 13.77 49.95z"
fill="url(#d)" opacity=".15" />
</svg>
</div>
<div id="search-status-duckduckgo">
<svg xmlns="http://www.w3.org/2000/svg" height="800" width="1200" xml:space="preserve" y="0" x="0"
id="Layer_1" version="1.1" viewBox="0 0 120 120">
<style id="style2" type="text/css">
.st3 {
fill: #2d4f8d
}
.st4 {
fill: #d5d7d8
}
.st7 {
fill: #4c4c4c
}
</style>
<g transform="translate(-3.3 -3.3)" id="g41">
<g id="g33">
<circle id="circle4" r="60" cy="63.3" cx="63.3" fill="#de5833" />
<path id="path6"
d="M114.1 41.8c-2.8-6.6-6.8-12.5-11.8-17.5-5.1-5.1-11-9-17.5-11.8-6.8-2.9-14-4.3-21.5-4.3s-14.7 1.5-21.5 4.3c-6.6 2.8-12.5 6.8-17.5 11.8-5.1 5.1-9 11-11.8 17.5-2.9 6.8-4.3 14-4.3 21.5 0 7.4 1.5 14.7 4.3 21.5 2.8 6.6 6.8 12.5 11.8 17.5 5.1 5.1 11 9 17.5 11.8 6.8 2.9 14 4.3 21.5 4.3s14.7-1.5 21.5-4.3c6.6-2.8 12.5-6.8 17.5-11.8 5.1-5.1 9-11 11.8-17.5 2.9-6.8 4.3-14 4.3-21.5s-1.4-14.7-4.3-21.5zm-38.8 71c-3.2-5.4-11.6-20.5-11.6-31.7 0-25.8 17.3-3.7 17.3-24.3 0-4.9-2.4-22.1-17.4-25.7-3.7-4.9-12.4-9.6-26.2-7.7 0 0 2.3.7 4.9 2 0 0-5 .7-5.2 4.1 0 0 9.9-.5 15.5 1.3-12.9 1.7-19.6 8.4-18.4 20.8 1.7 17.5 9.1 48.7 11.7 59.6-19.6-7.1-33.7-25.9-33.7-48 0-28.1 22.8-51 51-51s51 22.8 51 51c0 24.1-16.6 44.2-38.9 49.6z"
fill="#fff" />
<path
d="M60.5 71.6c0-6.6 9-8.7 12.4-8.7 9.2 0 22.2-5.9 25.4-5.8 3.3.1 5.4 1.4 5.4 2.9 0 2.2-18.4 10.5-25.5 9.8-6.8-.6-8.4.1-8.4 2.9 0 2.4 4.9 4.6 10.3 4.6 8.1 0 16-3.6 18.4-1.9 2.1 1.5-5.5 6.9-14.2 6.9s-23.8-4.1-23.8-10.7z"
id="Beak_2_" fill-rule="evenodd" clip-rule="evenodd" fill="#fed30a" />
<g id="g17">
<path id="path9" d="M76.5 43.6c-2.4-3.1-6.7-3.2-8.2.4 2.3-1.8 5.1-2.2 8.2-.4z"
class="st3" />
<path id="path11" d="M49.7 43.7c-3.3-2-8.8-2.2-8.5 4.1 1.7-3.9 3.9-4.6 8.5-4.1z"
class="st3" />
<path id="path13"
d="M74.5 49.5c-1.8 0-3.3 1.5-3.3 3.3 0 1.8 1.5 3.3 3.3 3.3 1.8 0 3.3-1.5 3.3-3.3 0-1.8-1.5-3.3-3.3-3.3zm1.2 3c-.5 0-1-.4-1-1 0-.5.4-1 1-1s1 .4 1 1c-.1.6-.5 1-1 1z"
class="st3" />
<path id="path15"
d="M48.9 51.3c-2.1 0-3.8 1.7-3.8 3.8 0 2.1 1.7 3.8 3.8 3.8 2.1 0 3.8-1.7 3.8-3.8 0-2.1-1.7-3.8-3.8-3.8zm1.4 3.5c-.6 0-1.1-.5-1.1-1.1 0-.6.5-1.1 1.1-1.1.6 0 1.1.5 1.1 1.1 0 .6-.5 1.1-1.1 1.1z"
class="st3" />
</g>
<g id="g25">
<path id="path19"
d="M40.6 35.1c-4.8 3.5-7 8.9-6.3 16.5 1.7 17.5 9.1 48.8 11.7 59.7l2.7.9c-1.6-6.6-9.3-38.8-12.7-63.5-.9-6.6 1.6-10.5 4.6-13.6z"
class="st4" />
<path id="path21"
d="M52.5 30.8c.4 0 .7-.1.7-.1-5.2-2.5-13.4-2.6-15.6-2.6-.2.4-.4.9-.4 1.4-.1.1 9.6-.5 15.3 1.3z"
class="st4" />
<path id="path23"
d="M43.1 25.4c-1.6-1.1-2.9-1.8-3.7-2.2-.7.1-1.3.1-2 .2 0 0 2.3.7 4.9 2h-.2 1z"
class="st4" />
</g>
<g id="g31">
<path id="path27"
d="M83.4 91.9c-1.7-.4-8.3 4.3-10.8 6.1-.1-.5-.2-.9-.3-1.1-.3-1-6.7-.4-8.2 1.2-4-1.9-12-5.6-12.1-3.3-.3 3 0 15.5 1.6 16.4 1.2.7 8-3 11.4-4.9h.1c2.1.5 6 0 7.4-.9.2-.1.3-.3.4-.5 3.1 1.2 9.8 3.6 11.2 3.1 1.8-.5 1.4-15.6-.7-16.1z"
fill="#67bd47" />
<path id="path29"
d="M65.1 106.3c-2.1-.4-1.4-2.5-1.4-7.4-.5.3-.9.7-.9 1.1 0 4.9-.8 7.1 1.4 7.4 2.1.5 6 0 7.6-.9.3-.2.4-.5.5-1-1.5.9-5.2 1.3-7.2.8z"
fill="#43a347" />
</g>
</g>
<g id="g39">
<path id="path35"
d="M110.5 106.4c-.9 0-1.7.7-1.7 1.6 0 .9.7 1.7 1.7 1.7.9 0 1.7-.7 1.7-1.7 0-.8-.7-1.6-1.7-1.6zm.1 3c-.7 0-1.3-.6-1.3-1.3 0-.7.5-1.3 1.3-1.3.7 0 1.3.6 1.3 1.3-.1.7-.6 1.3-1.3 1.3z"
class="st7" />
<path id="path37"
d="M110.6 107.4c.2 0 .3.1.4.3l.3-.2c-.1-.2-.4-.5-.7-.5-.5 0-1 .4-1 1s.4 1 1 1c.4 0 .6-.2.7-.5l-.3-.2c-.1.2-.2.3-.4.3-.3 0-.6-.3-.6-.6.1-.3.3-.6.6-.6z"
class="st7" />
</g>
</g>
</svg>
</div>
<div id="search-status-brave">
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" viewBox="0 0 50 59"
style="enable-background:new 0 0 188 59;" xml:space="preserve">
<style type="text/css">
.st0 {
fill: #FFFFFF;
}
.st1 {
fill: url(#Head_1_);
}
.st2 {
fill: url(#path-3_2_);
}
</style>
<g>
<path id="path-3" class="st0" d="M38.8,5.8l-5-5.8H25h-8.8l-5,5.8c0,0-4.4-1.2-6.5,0.9c0,0,5.9-0.5,7.9,2.8c0,0,5.4,1.1,6.2,1.1
s2.3-0.6,3.8-1.1C24,8.9,25,8.9,25,8.9s1,0,2.4,0.5c1.5,0.5,3,1.1,3.8,1.1s6.2-1.1,6.2-1.1c2-3.3,7.9-2.8,7.9-2.8
C43.2,4.5,38.8,5.8,38.8,5.8" />
</g>
<title>Logotypes/bat/logo-dark@1x</title>
<desc>Created with Sketch.</desc>
<g id="Branding">
<g id="logo_brave" transform="translate(-46.000000, -42.000000)">
<g id="Logo_x2F_Logotypes_x2F_brave_x2F_logo-dark"
transform="translate(46.000000, 42.000000)">
<g id="Logotypes_x2F_brave_x2F_logo-dark" transform="translate(-3.910345, 0.000000)">
<g id="Group-5">
<g id="Build-Icons_x2F_Release">
<g id="Logo" transform="translate(4.510718, 0.000000)">
<linearGradient id="Head_1_" gradientUnits="userSpaceOnUse"
x1="-507.0056" y1="419.2217" x2="-506.0056" y2="419.2217"
gradientTransform="matrix(48.7978 0 0 -58.296 24740.7402 24468.0957)">
<stop offset="0" style="stop-color:#FF5500" />
<stop offset="0.4099" style="stop-color:#FF5500" />
<stop offset="0.582" style="stop-color:#FF2000" />
<stop offset="1" style="stop-color:#FF2000" />
</linearGradient>
<path id="Head" class="st1"
d="M47.1,14l1.3-3.4c0,0-1.7-1.9-3.8-4s-6.5-0.9-6.5-0.9l-5-5.8h-8.8h-8.8l-5,5.8
c0,0-4.4-1.2-6.5,0.9s-3.8,4-3.8,4L1.7,14L0,19c0,0,5,19.4,5.6,21.8c1.2,4.7,2,6.5,5.2,8.8s9.3,6.5,10.2,7.1
c1,0.6,2.2,1.7,3.3,1.7c1.1,0,2.3-1.1,3.3-1.7c1-0.6,7-4.7,10.2-7.1s4.1-4.2,5.2-8.8c0.6-2.4,5.6-21.8,5.6-21.8L47.1,14z" />
<path id="Face" class="st0" d="M24.4,36.3c0.3,0,2.5,0.8,4.2,1.7c1.7,0.9,3,1.5,3.4,1.8c0.4,0.3,0.2,0.7-0.2,1
c-0.4,0.3-5.2,4.1-5.7,4.5c-0.5,0.4-1.2,1.1-1.6,1.1s-1.2-0.7-1.6-1.1c-0.5-0.4-5.3-4.3-5.7-4.5c-0.4-0.3-0.6-0.7-0.2-1
c0.4-0.3,1.6-0.9,3.4-1.8C21.9,37,24.1,36.3,24.4,36.3z M24.4,8.9c0.2,0,1.1,0.1,2.4,0.5c1.5,0.5,3,1.1,3.8,1.1
s6.2-1.1,6.2-1.1s6.4,7.9,6.4,9.6c0,1.7-0.8,2.1-1.6,3c-0.8,0.9-4.4,4.7-4.8,5.2c-0.5,0.5-1.4,1.2-0.8,2.6
c0.6,1.3,1.4,3.1,0.5,4.8c-0.9,1.7-2.5,2.9-3.5,2.7c-1-0.2-3.4-1.5-4.2-2c-0.9-0.6-3.6-2.9-3.6-3.8c0-0.9,2.8-2.5,3.4-2.8
c0.5-0.4,2.9-1.8,3-2.3c0-0.5,0-0.7-0.7-2.1c-0.7-1.4-2-3.2-1.8-4.4c0.2-1.2,2.3-1.8,3.7-2.4c1.5-0.6,4.3-1.6,4.6-1.8
c0.4-0.2,0.3-0.3-0.8-0.4c-1.1-0.1-4.1-0.5-5.5-0.1s-3.7,1-3.9,1.3S26.8,16.9,27,18c0.2,1.1,1.2,6.3,1.3,7.2
c0.1,0.9,0.3,1.5-0.7,1.8c-1,0.2-2.6,0.6-3.2,0.6s-2.2-0.4-3.2-0.6c-1-0.2-0.8-0.8-0.7-1.8c0.1-0.9,1.1-6.1,1.3-7.2
c0.2-1.1,0-1.1-0.2-1.4c-0.2-0.3-2.5-0.9-3.9-1.3c-1.4-0.4-4.4,0-5.5,0.1s-1.2,0.3-0.8,0.4c0.4,0.2,3.2,1.2,4.6,1.8
c1.5,0.6,3.5,1.2,3.7,2.4c0.2,1.2-1.1,3-1.8,4.4c-0.7,1.4-0.7,1.5-0.7,2.1c0,0.5,2.4,1.9,3,2.3c0.5,0.4,3.4,2,3.4,2.8
c0,0.9-2.8,3.2-3.6,3.8c-0.9,0.6-3.2,1.8-4.2,2c-1,0.2-2.6-1-3.5-2.7c-0.9-1.7-0.1-3.5,0.5-4.8c0.6-1.3-0.4-2.1-0.8-2.6
c-0.5-0.5-4-4.3-4.8-5.2c-0.8-0.9-1.6-1.3-1.6-3c0-1.7,6.4-9.6,6.4-9.6s5.4,1.1,6.2,1.1s2.3-0.6,3.8-1.1
C23.3,8.9,24.2,8.9,24.4,8.9L24.4,8.9z" />
<g id="Top-Head">
<linearGradient id="path-3_2_" gradientUnits="userSpaceOnUse"
x1="-504.8141" y1="390.6573" x2="-503.8356" y2="390.6573"
gradientTransform="matrix(40.5021 0 0 -10.5044 20451.0723 4108.8623)">
<stop offset="0" style="stop-color:#FF452A" />
<stop offset="1" style="stop-color:#FF2000" />
</linearGradient>
<path id="path-3_1_" class="st2" d="M38.2,5.8l-5-5.8h-8.8h-8.8l-5,5.8c0,0-4.4-1.2-6.5,0.9c0,0,5.9-0.5,7.9,2.8
c0,0,5.4,1.1,6.2,1.1s2.3-0.6,3.8-1.1c1.5-0.5,2.4-0.5,2.4-0.5s1,0,2.4,0.5c1.5,0.5,3,1.1,3.8,1.1s6.2-1.1,6.2-1.1
c2-3.3,7.9-2.8,7.9-2.8C42.6,4.5,38.2,5.8,38.2,5.8" />
</g>
</g>
</g>
</g>
</g>
</g>
</g>
</g>
</svg>
</div>
</div>
</header>
<main>
<div id="results">
<ul>
<li class="fake small"></li>
<li class="fake big"></li>
<li class="fake"></li>
<li class="fake"></li>
<li class="fake small"></li>
<li class="fake"></li>
<li class="fake"></li>
<!-- </ul> -->
<!-- </div> -->
<!-- </main> -->
<!-- </body> -->
<!-- </html> -->

View File

@ -15,6 +15,7 @@
<!-- <main> --> <!-- <main> -->
<!-- <ul> --> <!-- <ul> -->
</ul> </ul>
</div>
</main> </main>
</body> </body>

View File

@ -1,4 +1,5 @@
pub mod static_files { pub mod static_files {
use lazy_static::lazy_static;
use std::{ use std::{
fs::File, fs::File,
io::{Error, Read}, io::{Error, Read},
@ -13,4 +14,32 @@ pub mod static_files {
Ok(contents) Ok(contents)
} }
lazy_static! {
static ref HTML_BEGINNING: String =
read_file_contents("./src/public/html/beginning.html").unwrap();
}
const HTML_BEGINNING_QUERY_REPLACE: &str = r#"{% search_value %}"#;
pub fn render_beginning_html(query: &str) -> String {
HTML_BEGINNING.replace(
&HTML_BEGINNING_QUERY_REPLACE,
&html_escape::encode_quoted_attribute(query),
)
}
lazy_static! {
static ref FINISHED_CSS: String =
read_file_contents("./src/public/css/finished.css").unwrap();
}
pub fn render_finished_css(engine: &str, time: i128) -> String {
format!(
"<style>{}</style>",
FINISHED_CSS
.replace("__engine__", engine)
.replace("{% time %}", &format!("{}ms", &time.to_string()))
)
}
} }

View File

@ -329,4 +329,15 @@ pub mod utils {
YieldRequired(T), YieldRequired(T),
Completed(T), Completed(T),
} }
/// A very fast string hasher
pub fn hash_string(input: &str) -> u64 {
let mut value: u64 = 5381;
for c in input.chars() {
value = (value << 5).wrapping_add(value).wrapping_add(c as u64);
}
value
}
} }