Skip to content

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

Open
wants to merge 17 commits into
base: feedback
Choose a base branch
from
Open

Feedback #1

wants to merge 17 commits into from

Conversation

github-classroom[bot]
Copy link
Contributor

@github-classroom github-classroom bot commented Nov 11, 2022

👋! 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:

  • Click the Files changed tab to see all of the changes pushed to 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”.
  • Click the Commits tab to see the commits pushed to main. Click a commit to see specific changes.
  • If you turned on autograding, then click the Checks tab to see the results.
  • This page is an overview. It shows commits, line comments, and general comments. You can leave a general comment below.
    For more information about this pull request, read “Leaving assignment feedback in GitHub”.

Subscribed: @YannVoytaa


## 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)

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.

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

Copy link
Contributor

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)

Copy link

@agluszak agluszak left a 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

}
let on_textarea_keydown = |e: KeyboardEvent| {
let text_area = e.target().unwrap().unchecked_into::<HtmlTextAreaElement>();
if e.key_code() == 9 {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

magiczna stała

format!("{}px", e.client_height())
}
};
let rows = &html.lines().count() - 2;

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,

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

syntax,
html,
div,
code_response: Res {

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

}
Msg::SendCode => {
let code = self.code.clone();
_ctx.link().send_message(Msg::SetResponse(Res {

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

Msg::SetContent(content) => {
self.code = content + "\n";
self.html =
highlighted_html_for_string(&self.code, &self.ss, &self.syntax, &self.theme)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


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;'",

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?

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('\"', "\\\"")

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link

@agluszak agluszak left a 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"
Copy link

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 ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants