Skip to content

Commit

Permalink
server tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
tomfran committed Jan 23, 2024
1 parent 68d4d64 commit 0d6e3b6
Show file tree
Hide file tree
Showing 8 changed files with 25 additions and 12 deletions.
Binary file modified .DS_Store
Binary file not shown.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,6 @@ Cargo.lock
/data

# TODO
todo.md
todo.md

/misc
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[workspace]

resolver = "2"
members = ["search", "client"]
members = ["search", "server"]
2 changes: 1 addition & 1 deletion search/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ fn main() {
let build_index = action == "build";

let index_path = format!("{}/index/index", base_path);
let tokenizer_path = format!("{}/tokenizer/bert-base-uncased", base_path);
let tokenizer_path = format!("{}/tokenizer/roberta-large", base_path);
let docs_path = format!("{}/docs", base_path);

if build_index {
Expand Down
2 changes: 1 addition & 1 deletion client/Cargo.toml → server/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[package]
name = "client"
name = "server"
version = "0.1.0"
edition = "2021"

Expand Down
4 changes: 2 additions & 2 deletions client/src/main.rs → server/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,13 @@ async fn main() {
let args: Vec<String> = env::args().collect();

if args.len() < 2 {
println!("Usage: cargo run --bin client <base_path>");
println!("Usage: cargo run --bin server <base_path>");
return;
}

let base_path = &args[1];
let index_path = format!("{}/index/index", base_path);
let tokenizer_path = format!("{}/tokenizer/bert-base-uncased", base_path);
let tokenizer_path = format!("{}/tokenizer/roberta-large", base_path);

let state = Arc::new(AppState {
query_processor: Mutex::new(QueryProcessor::build_query_processor(
Expand Down
16 changes: 13 additions & 3 deletions client/templates/index.html → server/templates/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
}
</style>


<title>search-rs</title>
</head>

Expand All @@ -32,10 +31,21 @@
<!-- Main Content -->
<div class="container mx-auto mt-16 max-w-3xl">

<div class="flex content-center mb-16">
<div class="text-6xl font-medium mr-6">
<a href="https://github.com/tomfran/search-rs">
search-rs
</a>
</div>
<div class="w-20 h-20 flex justify-center items-center">
<img alt="Rust's Crab" src="https://rustacean.net/assets/rustacean-flat-noshadow.png" />
</div>
</div>

<!-- Search Heading -->
<div class="mb-6">
<h1 class="text-3xl font-bold my-3">Index on {{index_path}}</h1>
<input type="text" class="w-full mt-10 p-4 rounded-md bg-neutral-800 text-white"
<h1 class="text-3xl font-medium mb-10">Index on {{index_path}}</h1>
<input type="text" class="outline-neutral-900 w-full p-4 rounded-md bg-neutral-800 text-white"
placeholder="Enter your search query..." autofocus name="query" hx-post="/query" hx-ext='json-enc'
hx-target=".search-results" hx-trigger="keyup[keyCode==13]">
</div>
Expand Down
7 changes: 4 additions & 3 deletions client/templates/query.html → server/templates/query.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,16 @@ <h1 class=" font-light text-sm mt-1 mb-6">Query time: {{ time_ms }}ms</h1>
{% for doc in documents %}

<div>
<div class="bg-neutral-800 p-4 rounded-md shadow-md mb-6">
<h2 class="text-xl font-semibold mb-2">
<div class="bg-neutral-800 p-6 rounded-md shadow-md mb-6">
<h2 class="text-xl font-semibold mb-4">
{{ doc.path }}
</h2>
<p class="text-neutral-300">
{{ doc.content }}
{{ doc.content|truncate(300) }}
</p>
</div>
</div>

{% endfor %}

</div>

0 comments on commit 0d6e3b6

Please sign in to comment.