-
Notifications
You must be signed in to change notification settings - Fork 0
Feedback #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: feedback
Are you sure you want to change the base?
Feedback #1
Conversation
|
||
## Description | ||
Frobnicator is going to be a platformer game similar to Super Mario Bros made using Bevy game engine. | ||
|
||
CollabRustAtor is going to be a live collaborative rust code editor and compiler (web app, client-server architecture) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
to brzmi jak bardzo dużo
In the second part I'm going to add: | ||
|
||
1. rooms- files can be saved to database (one file per one room), other users can see the changes after refreshing the page (or by clicking the button to reload the file content only- for better user experience); | ||
2. concurrent editing- every client will be connected to WebSocket server and send/receive pieces of information about new file changes in certain room. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
a jak ma działać to uruchamianie? Jak ma działać kompilowanie? Edytowanie kodu z podświetlaniem składni a uruchamianie go to kompletnie różne rzeczy
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Z tego co widziałem Rust standardowo potrafi wywoływać shellowe komendy (std::process::Command), więc widziałbym to tak:
-
użytkownik będący w danym pokoju klikając przycisk "Compile/Run" wysyła zapytanie POST do serwera (z kodem/numerem pokoju/...- tak, by serwer poznał kod do uruchomienia)
-
Serwer bierze kod (z zapytania/bazy) i tworzy tymczasowy plik z kodem jako zawartość (wywołuje komendę), a potem go u siebie kompiluje (komendą) i uruchamia (komendą) i zwraca klientowi wynik komendy/komend (błąd kompilacji/panic/wynik wykonania)
-
pokazujemy wynik z serwera na froncie
(W celach bezpieczeństwa (użytkownik może chcieć uruchomić kod z nieskończoną pętlą/ też uruchamiać shellowe komendy/robić inne niebezpieczne rzeczy), komendy miałyby timeout (np. serwer wywołuje "timeout 5 cargo ..." zamiast "cargo ...") i byłyby uruchamiane np. na maszynie wirtualnej)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Antyczne wersje zależności:
tokio matches 0.2.25; latest is 1.23.0
uuid matches 0.4.0; latest is 1.2.2
warp matches 0.2.5; latest is 0.3.3
Winny jest ten tutorial sprzed dwóch lat :) https://levelup.gitconnected.com/building-an-api-using-warp-and-tokio-26a52173860a
Kiepska obsługa błędów.
Prawdopodobnie przez tego dockera nie udaje mi się połączyć frontu z backendem.
4/5
frontend/src/main.rs
Outdated
} | ||
let on_textarea_keydown = |e: KeyboardEvent| { | ||
let text_area = e.target().unwrap().unchecked_into::<HtmlTextAreaElement>(); | ||
if e.key_code() == 9 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
magiczna stała
frontend/src/main.rs
Outdated
format!("{}px", e.client_height()) | ||
} | ||
}; | ||
let rows = &html.lines().count() - 2; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
magiczna stała
#[derive(Serialize, Deserialize)] | ||
#[serde()] | ||
pub struct Res { | ||
pub errors: SpecificResponse, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tę strukturę można by lepiej zaprojektować, bo jeśli jest compile error, to przecież nie będzie outputu z runtime'u
frontend/src/main.rs
Outdated
syntax, | ||
html, | ||
div, | ||
code_response: Res { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do tego jest trait Default
frontend/src/main.rs
Outdated
} | ||
Msg::SendCode => { | ||
let code = self.code.clone(); | ||
_ctx.link().send_message(Msg::SetResponse(Res { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nazwy zaczynające się od _ to zwyczajowo nazwy dla zmiennych niewykorzystywanych
frontend/src/main.rs
Outdated
Msg::SetContent(content) => { | ||
self.code = content + "\n"; | ||
self.html = | ||
highlighted_html_for_string(&self.code, &self.ss, &self.syntax, &self.theme) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
backend/src/run_code.rs
Outdated
|
||
pub async fn code_handler(body: Code) -> Result<impl warp::Reply, Rejection> { | ||
let s = format!( | ||
"docker run -v $(pwd):/home --rm rust sh -c 'echo \"{}\" | cat > /home/a.in; rustc /home/a.in > /home/compile.txt 2> /home/compile_err.txt; timeout 10 ./a > /home/run.txt 2> /home/run_err.txt; status=$?; if [ $status -eq 127 ]; then echo \"\" | cat > /home/run_err.txt; fi; if [ $status -eq 124 ]; then echo \"Timed out\" | cat > /home/run_err.txt; fi;'", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
budzi mój niepokój uruchamianie tego w ten sposób, nie prościej byłoby wykryć przy uruchamianiu backendu czy użytkownik ma zainstalowany kompilator rusta i wyświetlić błąd jeśli nie ma?
backend/src/run_code.rs
Outdated
pub async fn code_handler(body: Code) -> Result<impl warp::Reply, Rejection> { | ||
let s = format!( | ||
"docker run -v $(pwd):/home --rm rust sh -c 'echo \"{}\" | cat > /home/a.in; rustc /home/a.in > /home/compile.txt 2> /home/compile_err.txt; timeout 10 ./a > /home/run.txt 2> /home/run_err.txt; status=$?; if [ $status -eq 127 ]; then echo \"\" | cat > /home/run_err.txt; fi; if [ $status -eq 124 ]; then echo \"Timed out\" | cat > /home/run_err.txt; fi;'", | ||
&body.code.replace('\"', "\\\"") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Super to wyszło, 5/5!
<link rel="preconnect" href="https://fonts.googleapis.com" /> | ||
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin /> | ||
<link | ||
href="https://fonts.googleapis.com/css2?family=Poppins&family=Roboto&display=swap" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nieużywanie czcionki o stałych szerokościach znaków w edytorze kodu jest posunięciem co najmniej kontrowersyjnym ;)
👋! GitHub Classroom created this pull request as a place for your teacher to leave feedback on your work. It will update automatically. Don’t close or merge this pull request, unless you’re instructed to do so by your teacher.
In this pull request, your teacher can leave comments and feedback on your code. Click the Subscribe button to be notified if that happens.
Click the Files changed or Commits tab to see all of the changes pushed to
main
since the assignment started. Your teacher can see this too.Notes for teachers
Use this PR to leave feedback. Here are some tips:
main
since the assignment started. To leave comments on specific lines of code, put your cursor over a line of code and click the blue + (plus sign). To learn more about comments, read “Commenting on a pull request”.main
. Click a commit to see specific changes.For more information about this pull request, read “Leaving assignment feedback in GitHub”.
Subscribed: @YannVoytaa