-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: move examples to crates (#13)
- Loading branch information
1 parent
e94277a
commit 5b6601c
Showing
13 changed files
with
80 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# Ignore everything | ||
* | ||
|
||
# Allow files and directories | ||
!/.cargo/ | ||
!/Cargo.toml | ||
!/Cargo.lock | ||
!/crates/new_media | ||
!/recipie.json | ||
# Ignore unnecessary files inside allowed directories | ||
# This should go after the allowed directories | ||
# **/*~ | ||
# **/*.log | ||
# **/.DS_Store | ||
# **/Thumbs.db |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
FROM rust as planner | ||
WORKDIR /app | ||
RUN cargo install cargo-chef | ||
COPY . . | ||
RUN cargo chef prepare --recipe-path recipe.json | ||
|
||
FROM rust as cacher | ||
WORKDIR /app | ||
RUN cargo install cargo-chef | ||
COPY --from=planner /app/recipe.json recipe.json | ||
RUN cargo chef cook --release --recipe-path=recipe.json | ||
|
||
FROM rust as builder | ||
COPY . /app | ||
WORKDIR /app | ||
COPY --from=cacher /app/target target | ||
COPY --from=cacher /usr/local/cargo /usr/local/cargo | ||
RUN cargo build --release | ||
|
||
FROM bitnami/minideb:bookworm | ||
COPY --from=builder /app/target/release/new_media /app/new_media | ||
WORKDIR /app | ||
|
||
EXPOSE 8080 | ||
CMD ["./new_media"] |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
"use client" | ||
|
||
import { useEffect } from "react" | ||
|
||
const validCommands : Record<string, string> = { | ||
"W": "UP", | ||
"A": "LEFT", | ||
"S": "DOWN", | ||
"D": "RIGHT", | ||
"ARROWUP": "ZOOM-IN", | ||
"ARROWDOWN": "ZOOM-OUT" | ||
} | ||
|
||
export const Controller=({socket}: {socket: WebSocket})=>{ | ||
|
||
const handle_keyboard_input = (e: KeyboardEvent) =>{ | ||
const key = e.key.toUpperCase() | ||
if(key in validCommands){ | ||
e.preventDefault(); | ||
socket.send(validCommands[key]) | ||
console.log("key down -> ", key) | ||
} | ||
} | ||
|
||
useEffect(() => { | ||
document.addEventListener("keydown", handle_keyboard_input) | ||
return () => document.removeEventListener("keydown", handle_keyboard_input) | ||
}, []); | ||
|
||
return null | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters