From 5927a781a31f496223721f33ea19460daa3f70ab Mon Sep 17 00:00:00 2001 From: mo8it Date: Fri, 16 May 2025 11:29:32 +0200 Subject: [PATCH 01/32] Remove Oranda --- .github/workflows/web.yml | 87 ------------------------------------- .gitignore | 4 -- CHANGELOG.md | 90 --------------------------------------- README.md | 4 -- oranda.json | 16 ------- 5 files changed, 201 deletions(-) delete mode 100644 .github/workflows/web.yml delete mode 100644 oranda.json diff --git a/.github/workflows/web.yml b/.github/workflows/web.yml deleted file mode 100644 index ec5d446221..0000000000 --- a/.github/workflows/web.yml +++ /dev/null @@ -1,87 +0,0 @@ -# Workflow to build your docs with oranda (and mdbook) -# and deploy them to Github Pages -name: Web - -# We're going to push to the gh-pages branch, so we need that permission -permissions: - contents: write - -# What situations do we want to build docs in? -# All of these work independently and can be removed / commented out -# if you don't want oranda/mdbook running in that situation -on: - # Check that a PR didn't break docs! - # - # Note that the "Deploy to Github Pages" step won't run in this mode, - # so this won't have any side-effects. But it will tell you if a PR - # completely broke oranda/mdbook. Sadly we don't provide previews (yet)! - pull_request: - - # Whenever something gets pushed to main, update the docs! - # This is great for getting docs changes live without cutting a full release. - # - # Note that if you're using cargo-dist, this will "race" the Release workflow - # that actually builds the Github Release that oranda tries to read (and - # this will almost certainly complete first). As a result you will publish - # docs for the latest commit but the oranda landing page won't know about - # the latest release. The workflow_run trigger below will properly wait for - # cargo-dist, and so this half-published state will only last for ~10 minutes. - # - # If you only want docs to update with releases, disable this, or change it to - # a "release" branch. You can, of course, also manually trigger a workflow run - # when you want the docs to update. - push: - branches: - - main - - # Whenever a workflow called "Release" completes, update the docs! - # - # If you're using cargo-dist, this is recommended, as it will ensure that - # oranda always sees the latest release right when it's available. Note - # however that Github's UI is wonky when you use workflow_run, and won't - # show this workflow as part of any commit. You have to go to the "actions" - # tab for your repo to see this one running (the gh-pages deploy will also - # only show up there). - workflow_run: - workflows: [ "Release" ] - types: - - completed - -# Alright, let's do it! -jobs: - web: - name: Build and deploy site and docs - runs-on: ubuntu-latest - steps: - # Setup - - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - uses: swatinem/rust-cache@v2 - - # If you use any mdbook plugins, here's the place to install them! - - # Install and run oranda (and mdbook) - # This will write all output to ./public/ (including copying mdbook's output to there) - - name: Install and run oranda - run: | - curl --proto '=https' --tlsv1.2 -LsSf https://github.com/axodotdev/oranda/releases/download/v0.3.1/oranda-installer.sh | sh - oranda build - - # Deploy to our gh-pages branch (creating it if it doesn't exist) - # the "public" dir that oranda made above will become the root dir - # of this branch. - # - # Note that once the gh-pages branch exists, you must - # go into repo's settings > pages and set "deploy from branch: gh-pages" - # the other defaults work fine. - - name: Deploy to Github Pages - uses: JamesIves/github-pages-deploy-action@v4.4.1 - # ONLY if we're on main (so no PRs or feature branches allowed!) - if: ${{ github.ref == 'refs/heads/main' }} - with: - branch: gh-pages - # Gotta tell the action where to find oranda's output - folder: public - token: ${{ secrets.GITHUB_TOKEN }} - single-commit: true diff --git a/.gitignore b/.gitignore index 945382c37d..ea65eb1ed8 100644 --- a/.gitignore +++ b/.gitignore @@ -6,10 +6,6 @@ Cargo.lock # State file .rustlings-state.txt -# oranda -public/ -.netlify - # OS .DS_Store .direnv/ diff --git a/CHANGELOG.md b/CHANGELOG.md index 70529775c0..6781ba89ab 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,8 +5,6 @@ - Upgrade to Rust edition 2024 - Raise the minimum supported Rust version to `1.87` - - ## 6.4.0 (2024-11-11) ### Added @@ -36,8 +34,6 @@ - Fix bad contrast in the list on terminals with a light theme. - - ## 6.3.0 (2024-08-29) ### Added @@ -77,8 +73,6 @@ - Fix the list when the terminal height is too low. - Restore the terminal after an error in the list. - - ## 6.2.0 (2024-08-09) ### Added @@ -95,8 +89,6 @@ - Run the final check of all exercises in parallel. - Small exercise improvements. - - ## 6.1.0 (2024-07-10) #### Added @@ -114,15 +106,11 @@ - Exit with a helpful error message on missing/unsupported terminal/TTY. - Mark the last exercise as done. - - ## 6.0.1 (2024-07-04) Small exercise improvements and fixes. Most importantly, fixed that the exercise `clippy1` was already solved πŸ˜… - - ## 6.0.0 (2024-07-03) This release is the result of a complete rewrite to deliver a ton of new features and improvements ✨ @@ -188,8 +176,6 @@ Do you want to create your own set of Rustlings exercises to focus on some speci Or do you want to translate the original Rustlings exercises? Then follow the link to the guide about [third-party exercises](THIRD_PARTY_EXERCISES.md)! - - ## 5.6.1 (2023-09-18) #### Changed @@ -205,8 +191,6 @@ Then follow the link to the guide about [third-party exercises](THIRD_PARTY_EXER - `as_ref_mut`: Fixed a typo in a test function name. - `enums3`: Fixed formatting with `rustfmt`. - - ## 5.6.0 (2023-09-04) #### Added @@ -246,16 +230,12 @@ Then follow the link to the guide about [third-party exercises](THIRD_PARTY_EXER - Lots of Nix housekeeping that I don't feel qualified to write about! - Improved CI workflows, we're now testing on multiple platforms at once. - - ## 5.5.1 (2023-05-17) #### Fixed - Reverted `rust-project.json` path generation due to an upstream `rust-analyzer` fix. - - ## 5.5.0 (2023-05-17) #### Added @@ -290,8 +270,6 @@ Then follow the link to the guide about [third-party exercises](THIRD_PARTY_EXER - Added a markdown linter to run on GitHub actions - Split quick installation section into two code blocks - - ## 5.4.1 (2023-03-10) #### Changed @@ -307,8 +285,6 @@ Then follow the link to the guide about [third-party exercises](THIRD_PARTY_EXER - `macros4`: Prevented auto-fix by adding `#[rustfmt::skip]` - `cli`: Actually show correct progress percentages - - ## 5.4.0 (2023-02-12) #### Changed @@ -337,8 +313,6 @@ Then follow the link to the guide about [third-party exercises](THIRD_PARTY_EXER - Bumped min Rust version to 1.58 in installation script - - ## 5.3.0 (2022-12-23) #### Added @@ -371,8 +345,6 @@ Then follow the link to the guide about [third-party exercises](THIRD_PARTY_EXER - Applied some Clippy and rustfmt formatting - Added a note on Windows PowerShell and other shell compatibility - - ## 5.2.1 (2022-09-06) #### Fixed @@ -386,8 +358,6 @@ Then follow the link to the guide about [third-party exercises](THIRD_PARTY_EXER - Fixed a typo in README.md - - ## 5.2.0 (2022-08-27) #### Added @@ -404,16 +374,12 @@ Then follow the link to the guide about [third-party exercises](THIRD_PARTY_EXER - **quiz1**: Adjusted the explanations to be consistent with the tests - - ## 5.1.1 (2022-08-17) #### Bug Fixes - Fixed an incorrect assertion in options1 - - ## 5.1.0 (2022-08-16) #### Features @@ -448,8 +414,6 @@ Then follow the link to the guide about [third-party exercises](THIRD_PARTY_EXER - Clarified manual installation instructions using `cargo install --path .` - Added a link to our Zulip in the readme file - - ## 5.0.0 (2022-07-16) #### Features @@ -522,8 +486,6 @@ Then follow the link to the guide about [third-party exercises](THIRD_PARTY_EXER - Updated spacing in Cargo.toml. - Added a GitHub actions config so that tests run on every PR/commit. - - ## 4.8.0 (2022-07-01) #### Features @@ -544,8 +506,6 @@ Then follow the link to the guide about [third-party exercises](THIRD_PARTY_EXER - Replaced the git.io URL with the fully qualified URL because of git.io's sunsetting. - Removed the deprecated Rust GitPod extension. - - ## 4.7.1 (2022-04-20) #### Features @@ -566,8 +526,6 @@ Then follow the link to the guide about [third-party exercises](THIRD_PARTY_EXER - The changelog will now be manually written instead of being automatically generated by the Git log. - - ## 4.7.0 (2022-04-14) #### Features @@ -608,8 +566,6 @@ Then follow the link to the guide about [third-party exercises](THIRD_PARTY_EXER - Add hints on how to get GCC installed (#741) ([bc56861](https://github.com/rust-lang/rustlings/commit/bc5686174463ad6f4f6b824b0e9b97c3039d4886)) - Fix some code blocks that were not highlighted ([17f9d74](https://github.com/rust-lang/rustlings/commit/17f9d7429ccd133a72e815fb5618e0ce79560929)) - - ## 4.6.0 (2021-09-25) #### Features @@ -632,8 +588,6 @@ Then follow the link to the guide about [third-party exercises](THIRD_PARTY_EXER - Clarify instructions ([df25684c](https://github.com/rust-lang/rustlings/commit/df25684cb79f8413915e00b5efef29369849cef1)) - **quiz1:** Fix inconsistent wording (#826) ([03131a3d](https://github.com/rust-lang/rustlings/commit/03131a3d35d9842598150f9da817f7cc26e2669a)) - - ## 4.5.0 (2021-07-07) #### Features @@ -654,8 +608,6 @@ Then follow the link to the guide about [third-party exercises](THIRD_PARTY_EXER - **try_from_into, from_str:** hints for dyn Error ([11d2cf0d](https://github.com/rust-lang/rustlings/commit/11d2cf0d604dee3f5023c17802d69438e69fa50e)) - **variables5:** confine the answer further ([48ffcbd2](https://github.com/rust-lang/rustlings/commit/48ffcbd2c4cc4d936c2c7480019190f179813cc5)) - - ## 4.4.0 (2021-04-24) #### Bug Fixes @@ -697,8 +649,6 @@ Then follow the link to the guide about [third-party exercises](THIRD_PARTY_EXER - updated progress percentage ([1c6f7e4b](https://github.com/rust-lang/rustlings/commit/1c6f7e4b7b9b3bd36f4da2bb2b69c549cc8bd913)) - added progress info ([c0e3daac](https://github.com/rust-lang/rustlings/commit/c0e3daacaf6850811df5bc57fa43e0f249d5cfa4)) - - ## 4.3.0 (2020-12-29) #### Features @@ -721,8 +671,6 @@ Then follow the link to the guide about [third-party exercises](THIRD_PARTY_EXER - Update description (#584) ([96347df9](https://github.com/rust-lang/rustlings/commit/96347df9df294f01153b29d9ad4ba361f665c755)) - **vec1:** Have test compare every element in a and v ([9b6c6293](https://github.com/rust-lang/rustlings/commit/9b6c629397b24b944f484f5b2bbd8144266b5695)) - - ## 4.2.0 (2020-11-07) #### Features @@ -743,8 +691,6 @@ Then follow the link to the guide about [third-party exercises](THIRD_PARTY_EXER - missing comma in test ([4fb230da](https://github.com/rust-lang/rustlings/commit/4fb230daf1251444fcf29e085cee222a91f8a37e)) - **quiz3:** Second test is for odd numbers, not even. (#553) ([18e0bfef](https://github.com/rust-lang/rustlings/commit/18e0bfef1de53071e353ba1ec5837002ff7290e6)) - - ## 4.1.0 (2020-10-05) #### Bug Fixes @@ -767,8 +713,6 @@ Then follow the link to the guide about [third-party exercises](THIRD_PARTY_EXER - **cli:** Added 'cls' command to 'watch' mode (#474) ([4f2468e1](https://github.com/rust-lang/rustlings/commit/4f2468e14f574a93a2e9b688367b5752ed96ae7b)) - **try_from_into:** Add insufficient length test (#469) ([523d18b8](https://github.com/rust-lang/rustlings/commit/523d18b873a319f7c09262f44bd40e2fab1830e5)) - - ## 4.0.0 (2020-07-08) #### Breaking Changes @@ -810,8 +754,6 @@ Then follow the link to the guide about [third-party exercises](THIRD_PARTY_EXER - **test2:** name of type String and &str (#394) ([d6c0a688](https://github.com/rust-lang/rustlings/commit/d6c0a688e6a96f93ad60d540d4b326f342fc0d45)) - **variables6:** minor typo (#419) ([524e17df](https://github.com/rust-lang/rustlings/commit/524e17df10db95f7b90a0f75cc8997182a8a4094)) - - ## 3.0.0 (2020-04-11) #### Breaking Changes @@ -834,8 +776,6 @@ Then follow the link to the guide about [third-party exercises](THIRD_PARTY_EXER - add new exercises for generics (#280) ([76be5e4e](https://github.com/rust-lang/rustlings/commit/76be5e4e991160f5fd9093f03ee2ba260e8f7229)) - **ci:** add buildkite config ([b049fa2c](https://github.com/rust-lang/rustlings/commit/b049fa2c84dba0f0c8906ac44e28fd45fba51a71)) - - ### 2.2.1 (2020-02-27) #### Bug Fixes @@ -846,8 +786,6 @@ Then follow the link to the guide about [third-party exercises](THIRD_PARTY_EXER - Add clippy lints (#269) ([1e2fd9c9](https://github.com/rust-lang/rustlings/commit/1e2fd9c92f8cd6e389525ca1a999fca4c90b5921)) - - ## 2.2.0 (2020-02-25) #### Bug Fixes @@ -875,8 +813,6 @@ Then follow the link to the guide about [third-party exercises](THIRD_PARTY_EXER - Added traits exercises (#274 but specifically #216, which originally added this :heart:) ([b559cdd](https://github.com/rust-lang/rustlings/commit/b559cdd73f32c0d0cfc1feda39f82b3e3583df17)) - - ## 2.1.0 (2019-11-27) #### Bug Fixes @@ -894,8 +830,6 @@ Then follow the link to the guide about [third-party exercises](THIRD_PARTY_EXER - **watch:** show hint while watching ([8143d57b](https://github.com/rust-lang/rustlings/commit/8143d57b4e88c51341dd4a18a14c536042cc009c)) - - ## 2.0.0 (2019-11-12) #### Bug Fixes @@ -916,8 +850,6 @@ Then follow the link to the guide about [third-party exercises](THIRD_PARTY_EXER - **cli:** check for rustc before doing anything ([36a033b8](https://github.com/rust-lang/rustlings/commit/36a033b87a6549c1e5639c908bf7381c84f4f425)) - **hint:** Add test for hint ([ce9fa6eb](https://github.com/rust-lang/rustlings/commit/ce9fa6ebbfdc3e7585d488d9409797285708316f)) - - ### 1.5.1 (2019-11-11) #### Bug Fixes @@ -929,8 +861,6 @@ Then follow the link to the guide about [third-party exercises](THIRD_PARTY_EXER - **threads:** Move Threads behind SLT ([fbe91a67](https://github.com/rust-lang/rustlings/commit/fbe91a67a482bfe64cbcdd58d06ba830a0f39da3), closes [#205](https://github.com/rust-lang/rustlings/issues/205)) - **watch:** clear screen before each `verify()` ([3aff590](https://github.com/rust-lang/rustlings/commit/3aff59085586c24196a547c2693adbdcf4432648)) - - ## 1.5.0 (2019-11-09) #### Bug Fixes @@ -955,8 +885,6 @@ Then follow the link to the guide about [third-party exercises](THIRD_PARTY_EXER - Added exercise for struct update syntax ([1c4c8764](https://github.com/rust-lang/rustlings/commit/1c4c8764ed118740cd4cee73272ddc6cceb9d959)) - **iterators2:** adds iterators2 exercise including config ([9288fccf](https://github.com/rust-lang/rustlings/commit/9288fccf07a2c5043b76d0fd6491e4cf72d76031)) - - ### 1.4.1 (2019-08-13) #### Bug Fixes @@ -965,8 +893,6 @@ Then follow the link to the guide about [third-party exercises](THIRD_PARTY_EXER - **option1:** Add test for prematurely passing exercise ([a750e4a1](https://github.com/rust-lang/rustlings/commit/a750e4a1a3006227292bb17d57d78ce84da6bfc6)) - **test1:** Swap assertion parameter order ([4086d463](https://github.com/rust-lang/rustlings/commit/4086d463a981e81d97781851d17db2ced290f446)) - - ## 1.4.0 (2019-07-13) #### Bug Fixes @@ -983,8 +909,6 @@ Then follow the link to the guide about [third-party exercises](THIRD_PARTY_EXER - **changelog:** Use clog for changelogs ([34e31232](https://github.com/rust-lang/rustlings/commit/34e31232dfddde284a341c9609b33cd27d9d5724)) - **iterators2:** adds iterators2 exercise including config ([9288fccf](https://github.com/rust-lang/rustlings/commit/9288fccf07a2c5043b76d0fd6491e4cf72d76031)) - - ### 1.3.0 (2019-06-05) #### Features @@ -1000,16 +924,12 @@ Then follow the link to the guide about [third-party exercises](THIRD_PARTY_EXER - Fix broken link (#164, @HanKruiger) - Remove highlighting and syntect (#167, @komaeda) - - ### 1.2.2 (2019-05-07) #### Bug Fixes - Reverted `--nocapture` flag since it was causing tests to pass unconditionally - - ### 1.2.1 (2019-04-22) #### Bug Fixes @@ -1017,8 +937,6 @@ Then follow the link to the guide about [third-party exercises](THIRD_PARTY_EXER - Fix the `--nocapture` feature (@komaeda) - Provide a nicer error message for when you're in the wrong directory - - ### 1.2.0 (2019-04-22) #### Features @@ -1026,8 +944,6 @@ Then follow the link to the guide about [third-party exercises](THIRD_PARTY_EXER - Add errors to exercises that compile without user changes (@yvan-sraka) - Use --nocapture when testing, enabling `println!` when running (@komaeda) - - ### 1.1.1 (2019-04-14) #### Bug fixes @@ -1040,8 +956,6 @@ Then follow the link to the guide about [third-party exercises](THIRD_PARTY_EXER - Fix links by deleting book version (@diodfr, #142) - Canonicalize paths to fix path matching (@cjpearce, #143) - - ### 1.1.0 (2019-03-20) - errors2.rs: update link to Rust book (#124) @@ -1051,16 +965,12 @@ Then follow the link to the guide about [third-party exercises](THIRD_PARTY_EXER - Give a warning when Rustlings isn't run from the right directory (#123) - Verify that rust version is recent enough to install Rustlings (#131) - - ### 1.0.1 (2019-03-06) - Adds a way to install Rustlings in one command (`curl -L https://git.io/rustlings | bash`) - Makes `rustlings watch` react to create file events (@shaunbennett, #117) - Reworks the exercise management to use an external TOML file instead of just listing them in the code - - ### 1.0.0 (2019-03-06) Initial release. diff --git a/README.md b/README.md index 3e6d6c7ca3..8480b1a3d7 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,5 @@ -
- # Rustlings πŸ¦€β€οΈ -
- Greetings and welcome to Rustlings. This project contains small exercises to get you used to reading and writing Rust code. This includes reading and responding to compiler messages! diff --git a/oranda.json b/oranda.json deleted file mode 100644 index 626e496885..0000000000 --- a/oranda.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "build": { - "path_prefix": "rustlings" - }, - "project": { - "homepage": "https://rustlings.cool", - "repository": "https://github.com/rust-lang/rustlings" - }, - "marketing": { - "analytics": { - "plausible": { - "domain": "rustlings.cool" - } - } - } -} From 08548abcc27ede812b69c399aff24b8a8ff9d041 Mon Sep 17 00:00:00 2001 From: mo8it Date: Fri, 16 May 2025 11:35:24 +0200 Subject: [PATCH 02/32] Remove .editorconfig --- .editorconfig | 7 ------- 1 file changed, 7 deletions(-) delete mode 100644 .editorconfig diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index aab09aa35d..0000000000 --- a/.editorconfig +++ /dev/null @@ -1,7 +0,0 @@ -root = true - -[*.rs] -end_of_line = lf -insert_final_newline = true -indent_style = space -indent_size = 4 From a28000acc4945bc0865f15964b3605ea9d31cedf Mon Sep 17 00:00:00 2001 From: mo8it Date: Fri, 16 May 2025 11:35:46 +0200 Subject: [PATCH 03/32] Remove markdown lint --- .github/workflows/rust.yml | 7 ++----- .markdownlint.yml | 2 -- 2 files changed, 2 insertions(+), 7 deletions(-) delete mode 100644 .markdownlint.yml diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 9a5d8693bd..2446939933 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -1,4 +1,4 @@ -name: Rustlings Tests +name: Check on: push: @@ -19,9 +19,6 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - - uses: DavidAnson/markdownlint-cli2-action@v16 - with: - globs: "exercises/**/*.md" - name: rustfmt run: cargo fmt --all --check test: @@ -40,4 +37,4 @@ jobs: - uses: actions/checkout@v4 - uses: swatinem/rust-cache@v2 - name: rustlings dev check - run: cargo run -- dev check --require-solutions + run: cargo dev check --require-solutions diff --git a/.markdownlint.yml b/.markdownlint.yml deleted file mode 100644 index d5f7e3913d..0000000000 --- a/.markdownlint.yml +++ /dev/null @@ -1,2 +0,0 @@ -# MD013/line-length Line length, Expected: 80 -MD013: false From 74ab9924b4193c0fb66f3c0e3667a4d7b4edfb18 Mon Sep 17 00:00:00 2001 From: mo8it Date: Fri, 16 May 2025 21:08:29 +0200 Subject: [PATCH 04/32] Start with Zola --- website/.gitignore | 7 ++++++ website/config.toml | 20 ++++++++++++++++ website/input.css | 54 ++++++++++++++++++++++++++++++++++++++++++++ website/justfile | 5 ++++ website/package.json | 7 ++++++ 5 files changed, 93 insertions(+) create mode 100644 website/.gitignore create mode 100644 website/config.toml create mode 100644 website/input.css create mode 100644 website/justfile create mode 100644 website/package.json diff --git a/website/.gitignore b/website/.gitignore new file mode 100644 index 0000000000..648e07746e --- /dev/null +++ b/website/.gitignore @@ -0,0 +1,7 @@ +/node_modules/ +/package-lock.json + +/public/ + +/static/main.css +/static/processed_images/ diff --git a/website/config.toml b/website/config.toml new file mode 100644 index 0000000000..d23b3314e9 --- /dev/null +++ b/website/config.toml @@ -0,0 +1,20 @@ +base_url = "https://rust-lang.github.io/rustlings" +title = "Rustlings" +description = "Small exercises to get you used to reading and writing Rust code!" + +compile_sass = false +build_search_index = false + +[markdown] +highlight_code = true + +[[extra.menu_items]] +name = "Home" +url = "/" +[[extra.menu_items]] +name = "Custom Exercises" +url = "/custom-exercises" + +[[extra.footer_items]] +name = "Repository" +url = "https://github.com/rust-lang/rustlings" diff --git a/website/input.css b/website/input.css new file mode 100644 index 0000000000..b26d9ba489 --- /dev/null +++ b/website/input.css @@ -0,0 +1,54 @@ +@import 'tailwindcss'; + +@layer base { + h1 { + @apply text-4xl mt-3 mb-3 text-gray-50 font-bold; + } + h2 { + @apply text-3xl mt-4 mb-1.5 text-gray-50 font-bold; + } + h3 { + @apply text-2xl mt-5 mb-1.5 text-gray-50 font-bold; + } + h4 { + @apply text-xl mt-6 mb-1.5 text-gray-50 font-bold; + } + p { + @apply mb-2; + } + a { + @apply text-[#F74C00] underline hover:decoration-orange-400 transition duration-300; + } + ul { + @apply mt-2 mb-3 ml-1 list-disc list-inside marker:text-sky-600; + } + ol { + @apply mt-2 mb-3 ml-1 list-decimal list-inside marker:text-sky-500; + } + li { + @apply my-0.5; + } + code { + @apply bg-white/10 px-1 pb-px pt-1 rounded-md; + } + pre code { + @apply bg-inherit p-0 text-inherit; + } + hr { + @apply my-5 rounded-full; + } + img { + @apply max-w-full w-full h-full mx-auto my-5 object-contain md:w-3/4 lg:w-3/5 rounded-sm shadow-sm; + } + blockquote { + @apply p-4 my-3 border-s-4 border-gray-300 bg-gray-800 italic; + } + + pre { + @apply px-2 pt-2 pb-px overflow-x-auto text-sm sm:text-base rounded-sm mt-2 mb-4 after:content-[attr(data-lang)] after:text-[8px] after:opacity-40 selection:bg-gray-500/75; + } + pre code mark { + @apply pb-0.5 pt-1 pr-px text-inherit rounded-xs; + } +} + diff --git a/website/justfile b/website/justfile new file mode 100644 index 0000000000..5c9c677051 --- /dev/null +++ b/website/justfile @@ -0,0 +1,5 @@ +zola: + zola serve --open + +tailwind: + fnm exec --using latest npx @tailwindcss/cli -i input.css -o static/main.css diff --git a/website/package.json b/website/package.json new file mode 100644 index 0000000000..ee8a1c8812 --- /dev/null +++ b/website/package.json @@ -0,0 +1,7 @@ +{ + "devDependencies": { + "rustywind": "^0.24", + "tailwindcss": "^4.1", + "@tailwindcss/cli": "^4.1" + } +} From 7ec698696537aac4433bb0e60fb10310a6b34bc1 Mon Sep 17 00:00:00 2001 From: mo8it Date: Fri, 16 May 2025 23:11:08 +0200 Subject: [PATCH 05/32] Add templates --- website/config.toml | 6 + website/content/_index.md | 143 ++++++++++++++++++++++ website/content/custom-exercises/index.md | 66 ++++++++++ website/input.css | 14 +-- website/justfile | 2 +- website/templates/404.html | 16 +++ website/templates/anchor-link.html | 2 + website/templates/base.html | 83 +++++++++++++ website/templates/index.html | 11 ++ website/templates/macros.html | 46 +++++++ website/templates/page.html | 11 ++ 11 files changed, 392 insertions(+), 8 deletions(-) create mode 100644 website/content/_index.md create mode 100644 website/content/custom-exercises/index.md create mode 100644 website/templates/404.html create mode 100644 website/templates/anchor-link.html create mode 100644 website/templates/base.html create mode 100644 website/templates/index.html create mode 100644 website/templates/macros.html create mode 100644 website/templates/page.html diff --git a/website/config.toml b/website/config.toml index d23b3314e9..6a9114a95b 100644 --- a/website/config.toml +++ b/website/config.toml @@ -7,6 +7,12 @@ build_search_index = false [markdown] highlight_code = true +highlight_theme = "ayu-mirage" + +insert_anchor_links = "heading" + +[extra] +logo_path = "images/happy_ferris.svg" [[extra.menu_items]] name = "Home" diff --git a/website/content/_index.md b/website/content/_index.md new file mode 100644 index 0000000000..2ad12ebb86 --- /dev/null +++ b/website/content/_index.md @@ -0,0 +1,143 @@ ++++ ++++ + +Greetings and welcome to Rustlings. +This project contains small exercises to get you used to reading and writing Rust code. +This includes reading and responding to compiler messages! + +It is recommended to do the Rustlings exercises in parallel to reading [the official Rust book](https://doc.rust-lang.org/book/), the most comprehensive resource for learning Rust πŸ“šοΈ + + + +## Getting Started + +### Installing Rust + +Before installing Rustlings, you need to have the **latest version of Rust** installed. +Visit [www.rust-lang.org/tools/install](https://www.rust-lang.org/tools/install) for further instructions on installing Rust. +This will also install _Cargo_, Rust's package/project manager. + +> 🐧 If you are on Linux, make sure you have installed `gcc` (for a linker). +> +> Deb: `sudo apt install gcc` +> +> Dnf: `sudo dnf install gcc` + +> 🍎 If you are on MacOS, make sure you have installed Xcode and its developer tools by running `xcode-select --install`. + +### Installing Rustlings + +The following command will download and compile Rustlings: + +```bash +cargo install rustlings +``` + +
+If the installation fails… (click to expand) + +- Make sure you have the latest Rust version by running `rustup update` +- Try adding the `--locked` flag: `cargo install rustlings --locked` +- Otherwise, please [report the issue](https://github.com/rust-lang/rustlings/issues/new) + +
+ +### Initialization + +After installing Rustlings, run the following command to initialize the `rustlings/` directory: + +```bash +rustlings init +``` + +
+If the command rustlings can't be found… (click to expand) + +You are probably using Linux and installed Rust using your package manager. + +Cargo installs binaries to the directory `~/.cargo/bin`. +Sadly, package managers often don't add `~/.cargo/bin` to your `PATH` environment variable. + +The solution is to … + +- either add `~/.cargo/bin` manually to `PATH` +- or to uninstall Rust from the package manager and install it using the official way with `rustup`: https://www.rust-lang.org/tools/install + +
+ +Now, go into the newly initialized directory and launch Rustlings for further instructions on getting started with the exercises: + +```bash +cd rustlings/ +rustlings +``` + +## Working environment + +### Editor + +Our general recommendation is [VS Code](https://code.visualstudio.com/) with the [rust-analyzer plugin](https://marketplace.visualstudio.com/items?itemName=rust-lang.rust-analyzer). +But any editor that supports [rust-analyzer](https://rust-analyzer.github.io/) should be enough for working on the exercises. + +### Terminal + +While working with Rustlings, please use a modern terminal for the best user experience. +The default terminal on Linux and Mac should be sufficient. +On Windows, we recommend the [Windows Terminal](https://aka.ms/terminal). + +## Doing exercises + +The exercises are sorted by topic and can be found in the subdirectory `exercises/`. +For every topic, there is an additional `README.md` file with some resources to get you started on the topic. +We highly recommend that you have a look at them before you start πŸ“šοΈ + +Most exercises contain an error that keeps them from compiling, and it's up to you to fix it! +Some exercises contain tests that need to pass for the exercise to be done βœ… + +Search for `TODO` and `todo!()` to find out what you need to change. +Ask for hints by entering `h` in the _watch mode_ πŸ’‘ + +### Watch Mode + +After the [initialization](#initialization), Rustlings can be launched by simply running the command `rustlings`. + +This will start the _watch mode_ which walks you through the exercises in a predefined order (what we think is best for newcomers). +It will rerun the current exercise automatically every time you change the exercise's file in the `exercises/` directory. + +
+If detecting file changes in the exercises/ directory fails… (click to expand) + +> You can add the **`--manual-run`** flag (`rustlings --manual-run`) to manually rerun the current exercise by entering `r` in the watch mode. +> +> Please [report the issue](https://github.com/rust-lang/rustlings/issues/new) with some information about your operating system and whether you run Rustlings in a container or virtual machine (e.g. WSL). + +
+ +### Exercise List + +In the [watch mode](#watch-mode) (after launching `rustlings`), you can enter `l` to open the interactive exercise list. + +The list allows you to… + +- See the status of all exercises (done or pending) +- `c`: Continue at another exercise (temporarily skip some exercises or go back to a previous one) +- `r`: Reset status and file of the selected exercise (you need to _reload/reopen_ its file in your editor afterwards) + +See the footer of the list for all possible keys. + +## Questions? + +If you need any help while doing the exercises and the builtin-hints aren't helpful, feel free to ask in the [_Q&A_ category of the discussions](https://github.com/rust-lang/rustlings/discussions/categories/q-a?discussions_q=) if your question wasn't asked yet πŸ’‘ + +## Continuing On + +Once you've completed Rustlings, put your new knowledge to good use! +Continue practicing your Rust skills by building your own projects, contributing to Rustlings, or finding other open-source projects to contribute to. + +## Uninstalling Rustlings + +If you want to remove Rustlings from your system, run the following command: + +```bash +cargo uninstall rustlings +``` diff --git a/website/content/custom-exercises/index.md b/website/content/custom-exercises/index.md new file mode 100644 index 0000000000..e8bef7690f --- /dev/null +++ b/website/content/custom-exercises/index.md @@ -0,0 +1,66 @@ ++++ +title = "Custom Exercises" ++++ + +Custom exercises are a set of exercises maintained by the community. +You can use the same `rustlings` program that you installed with `cargo install rustlings` to run them: + +- πŸ‡―πŸ‡΅ [Japanese Rustlings](https://github.com/sotanengel/rustlings-jp):A Japanese translation of the Rustlings exercises. +- πŸ‡¨πŸ‡³ [Simplified Chinese Rustlings](https://github.com/SandmeyerX/rustlings-zh-cn): A simplified Chinese translation of the Rustlings exercises. + +Do you want to create your own set of Rustlings exercises to focus on some specific topic? +Or do you want to translate the original Rustlings exercises? + + + +The support of Rustlings for custom exercises allows you to create your own set of Rustlings exercises to focus on some specific topic. +You could also offer a translation of the original Rustlings exercises as custom exercises. + +## Getting started + +To create custom exercises, install Rustlings and run `rustlings dev new PROJECT_NAME`. +This command will, similar to `cargo new PROJECT_NAME`, create a template directory called `PROJECT_NAME` with all what you need to get started. + +Read the comments in the generated `info.toml` file to understand its format. +It allows you to set a custom welcome and final message and specify the metadata of every exercise. + +## Create an exercise + +Here is an example of the metadata of one file: + +```toml +[[exercises]] +name = "intro1" +hint = """ +To finish this exercise, you need to … +This link might help you …""" +``` + +After entering this in `info.toml`, create the file `intro1.rs` in the `exercises/` directory. +The exercise needs to contain a `main` function, but it can be empty. +Adding tests is recommended. +Look at the official Rustlings exercises for inspiration. + +You can optionally add a solution file `intro1.rs` to the `solutions/` directory. + +Now, run `rustlings dev check`. +It will tell you about any issues with your exercises. +For example, it will tell you to run `rustlings dev update` to update the `Cargo.toml` file to include the new exercise `intro1`. + +`rustlings dev check` will also run your solutions (if you have any) to make sure that they run successfully. + +That's it! +You finished your first exercise πŸŽ‰ + +## Publish + +Now, add more exercises and publish them as a Git repository. + +Users just have to clone that repository and run `rustlings` in it to start working on your set of exercises just like the official ones. + +One difference to the official exercises is that the solution files will not be hidden until the user finishes an exercise. +But you can trust the users to not look at the solution too early πŸ˜‰ + +## Share + +After publishing your set of exercises, open an issue or a pull request in the official Rustlings repository to link to your project in the README πŸ˜ƒ diff --git a/website/input.css b/website/input.css index b26d9ba489..cd7a777b9a 100644 --- a/website/input.css +++ b/website/input.css @@ -2,22 +2,22 @@ @layer base { h1 { - @apply text-4xl mt-3 mb-3 text-gray-50 font-bold; + @apply text-4xl mt-3 mb-3 font-bold; } h2 { - @apply text-3xl mt-4 mb-1.5 text-gray-50 font-bold; + @apply text-3xl mt-4 mb-1.5 font-bold; } h3 { - @apply text-2xl mt-5 mb-1.5 text-gray-50 font-bold; + @apply text-2xl mt-5 mb-1.5 font-bold; } h4 { - @apply text-xl mt-6 mb-1.5 text-gray-50 font-bold; + @apply text-xl mt-6 mb-1.5 font-bold; } p { @apply mb-2; } a { - @apply text-[#F74C00] underline hover:decoration-orange-400 transition duration-300; + @apply text-[#FFC832] underline hover:decoration-orange-400 transition duration-300; } ul { @apply mt-2 mb-3 ml-1 list-disc list-inside marker:text-sky-600; @@ -41,11 +41,11 @@ @apply max-w-full w-full h-full mx-auto my-5 object-contain md:w-3/4 lg:w-3/5 rounded-sm shadow-sm; } blockquote { - @apply p-4 my-3 border-s-4 border-gray-300 bg-gray-800 italic; + @apply px-3 pt-2 pb-0.5 my-4 border-s-4 border-white/80 bg-white/7 rounded-sm italic; } pre { - @apply px-2 pt-2 pb-px overflow-x-auto text-sm sm:text-base rounded-sm mt-2 mb-4 after:content-[attr(data-lang)] after:text-[8px] after:opacity-40 selection:bg-gray-500/75; + @apply px-2 pt-2 pb-px overflow-x-auto text-sm sm:text-base rounded-sm mt-2 mb-4 after:content-[attr(data-lang)] after:text-[8px] after:opacity-40 selection:bg-white/15; } pre code mark { @apply pb-0.5 pt-1 pr-px text-inherit rounded-xs; diff --git a/website/justfile b/website/justfile index 5c9c677051..6d41913827 100644 --- a/website/justfile +++ b/website/justfile @@ -2,4 +2,4 @@ zola: zola serve --open tailwind: - fnm exec --using latest npx @tailwindcss/cli -i input.css -o static/main.css + fnm exec --using latest npx @tailwindcss/cli -w -i input.css -o static/main.css diff --git a/website/templates/404.html b/website/templates/404.html new file mode 100644 index 0000000000..ecee207de9 --- /dev/null +++ b/website/templates/404.html @@ -0,0 +1,16 @@ +{% extends "base.html" %} + +{% import "macros.html" as macros %} + +{% block content %} +
+

DON'T PANIC!

+

404: Page not found!

+ + + + {{ macros::btn(link=get_url(path="/") , content="Back to the homepage") }} +
+{% endblock %} diff --git a/website/templates/anchor-link.html b/website/templates/anchor-link.html new file mode 100644 index 0000000000..c8644d96f7 --- /dev/null +++ b/website/templates/anchor-link.html @@ -0,0 +1,2 @@ + diff --git a/website/templates/base.html b/website/templates/base.html new file mode 100644 index 0000000000..64beaab3e7 --- /dev/null +++ b/website/templates/base.html @@ -0,0 +1,83 @@ + + + + + + + {%- set timestamp = now(timestamp=true) -%} + + {%- if page.title -%} + {% set_global title = page.title %} + {%- elif section.title -%} + {% set_global title = section.title %} + {%- else -%} + {% set_global title = config.title %} + {%- endif -%} + + {%- if page.description -%} + {% set_global description = page.description %} + {%- elif section.description -%} + {% set_global description = section.description %} + {%- else -%} + {% set_global description = config.description %} + {%- endif -%} + + {%- if page.permalink -%} + {% set_global permalink = page.permalink %} + {%- elif section.permalink -%} + {% set_global permalink = section.permalink %} + {%- endif %} + + {%- block title -%}{{- title -}}{%- endblock -%} + + + + + + + + + + + {% if permalink %}{% endif %} + + + +
+ + + +
+ +
+ {% block content %}{% endblock %} +
+ + + + diff --git a/website/templates/index.html b/website/templates/index.html new file mode 100644 index 0000000000..5877765154 --- /dev/null +++ b/website/templates/index.html @@ -0,0 +1,11 @@ +{% extends "base.html" %} + +{% import "macros.html" as macros %} + +{% block content %} +
+

Rustlings

+ + {{ section.content | replace(from="", to=macros::toc() ) | safe }} +
+{% endblock %} diff --git a/website/templates/macros.html b/website/templates/macros.html new file mode 100644 index 0000000000..c40abe53b1 --- /dev/null +++ b/website/templates/macros.html @@ -0,0 +1,46 @@ +{% macro toc() %} +

Landscape mode recommended on mobile devices

+ + {%- if page.toc -%} + {% set_global toc = page.toc %} + {%- else -%} + {% set_global toc = section.toc %} + {%- endif -%} + + {% if toc %} +
+ +
+ {% endif %} +{% endmacro %} + +{% macro btn(link, content) %} + {{ content | safe }} +{% endmacro %} diff --git a/website/templates/page.html b/website/templates/page.html new file mode 100644 index 0000000000..90b269df5e --- /dev/null +++ b/website/templates/page.html @@ -0,0 +1,11 @@ +{% extends "base.html" %} + +{% import "macros.html" as macros %} + +{% block content %} +
+

{{ page.title }}

+ + {{ page.content | replace(from="", to=macros::toc() ) | safe }} +
+{% endblock %} From fda18e8895a162f484245b8a6a2eb0921632d0c7 Mon Sep 17 00:00:00 2001 From: mo8it Date: Sat, 17 May 2025 12:24:27 +0200 Subject: [PATCH 06/32] Add Ferris SVGs --- website/static/images/happy_ferris.svg | 33 ++++++++++++ website/static/images/panic.svg | 70 ++++++++++++++++++++++++++ 2 files changed, 103 insertions(+) create mode 100644 website/static/images/happy_ferris.svg create mode 100644 website/static/images/panic.svg diff --git a/website/static/images/happy_ferris.svg b/website/static/images/happy_ferris.svg new file mode 100644 index 0000000000..c7f240dd97 --- /dev/null +++ b/website/static/images/happy_ferris.svg @@ -0,0 +1,33 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/website/static/images/panic.svg b/website/static/images/panic.svg new file mode 100644 index 0000000000..be55f5e09b --- /dev/null +++ b/website/static/images/panic.svg @@ -0,0 +1,70 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + From 61c17cb349b649223e943b6db0786feacabc8ca5 Mon Sep 17 00:00:00 2001 From: mo8it Date: Sat, 17 May 2025 12:24:44 +0200 Subject: [PATCH 07/32] Change syntax highlighting theme --- website/config.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/website/config.toml b/website/config.toml index 6a9114a95b..906bb8bca4 100644 --- a/website/config.toml +++ b/website/config.toml @@ -7,7 +7,7 @@ build_search_index = false [markdown] highlight_code = true -highlight_theme = "ayu-mirage" +highlight_theme = "dracula" insert_anchor_links = "heading" From 7e26418952afa7d25d1958ee0e4d810955acf94a Mon Sep 17 00:00:00 2001 From: mo8it Date: Sat, 17 May 2025 12:25:08 +0200 Subject: [PATCH 08/32] Remove the third-party exercises file --- THIRD_PARTY_EXERCISES.md | 53 ---------------------------------------- 1 file changed, 53 deletions(-) delete mode 100644 THIRD_PARTY_EXERCISES.md diff --git a/THIRD_PARTY_EXERCISES.md b/THIRD_PARTY_EXERCISES.md deleted file mode 100644 index 62646c5bed..0000000000 --- a/THIRD_PARTY_EXERCISES.md +++ /dev/null @@ -1,53 +0,0 @@ -# Third-Party Exercises - -The support of Rustlings for third-party exercises allows you to create your own set of Rustlings exercises to focus on some specific topic. -You could also offer a translation of the original Rustlings exercises as third-party exercises. - -## Getting started - -To create third-party exercises, install Rustlings and run `rustlings dev new PROJECT_NAME`. -This command will, similar to `cargo new PROJECT_NAME`, create a template directory called `PROJECT_NAME` with all what you need to get started. - -Read the comments in the generated `info.toml` file to understand its format. -It allows you to set a custom welcome and final message and specify the metadata of every exercise. - -## Create an exercise - -Here is an example of the metadata of one file: - -```toml -[[exercises]] -name = "intro1" -hint = """ -To finish this exercise, you need to … -This link might help you …""" -``` - -After entering this in `info.toml`, create the file `intro1.rs` in the `exercises/` directory. -The exercise needs to contain a `main` function, but it can be empty. -Adding tests is recommended. -Look at the official Rustlings exercises for inspiration. - -You can optionally add a solution file `intro1.rs` to the `solutions/` directory. - -Now, run `rustlings dev check`. -It will tell you about any issues with your exercises. -For example, it will tell you to run `rustlings dev update` to update the `Cargo.toml` file to include the new exercise `intro1`. - -`rustlings dev check` will also run your solutions (if you have any) to make sure that they run successfully. - -That's it! -You finished your first exercise πŸŽ‰ - -## Publish - -Now, add more exercises and publish them as a Git repository. - -Users just have to clone that repository and run `rustlings` in it to start working on your set of exercises just like the official ones. - -One difference to the official exercises is that the solution files will not be hidden until the user finishes an exercise. -But you can trust the users to not look at the solution too early πŸ˜‰ - -## Share - -After publishing your set of exercises, open an issue or a pull request in the official Rustlings repository to link to your project in the README πŸ˜ƒ From b9d1e636a46ee6bc8ffa5dd889137229d76976ce Mon Sep 17 00:00:00 2001 From: mo8it Date: Sat, 17 May 2025 12:25:32 +0200 Subject: [PATCH 09/32] Reduce the README to the website link --- README.md | 160 +----------------------------------------------------- 1 file changed, 1 insertion(+), 159 deletions(-) diff --git a/README.md b/README.md index 8480b1a3d7..bb3fe212ae 100644 --- a/README.md +++ b/README.md @@ -1,161 +1,3 @@ # Rustlings πŸ¦€β€οΈ -Greetings and welcome to Rustlings. -This project contains small exercises to get you used to reading and writing Rust code. -This includes reading and responding to compiler messages! - -It is recommended to do the Rustlings exercises in parallel to reading [the official Rust book](https://doc.rust-lang.org/book/), the most comprehensive resource for learning Rust πŸ“šοΈ - -[Rust By Example](https://doc.rust-lang.org/rust-by-example/) is another recommended resource that you might find helpful. -It contains code examples and exercises similar to Rustlings, but online. - -## Getting Started - -### Installing Rust - -Before installing Rustlings, you need to have the **latest version of Rust** installed. -Visit [www.rust-lang.org/tools/install](https://www.rust-lang.org/tools/install) for further instructions on installing Rust. -This will also install _Cargo_, Rust's package/project manager. - -> 🐧 If you are on Linux, make sure you have installed `gcc` (for a linker). -> -> Deb: `sudo apt install gcc` -> -> Dnf: `sudo dnf install gcc` - -> 🍎 If you are on MacOS, make sure you have installed Xcode and its developer tools by running `xcode-select --install`. - -### Installing Rustlings - -The following command will download and compile Rustlings: - -```bash -cargo install rustlings -``` - -
-If the installation fails… (click to expand) - -- Make sure you have the latest Rust version by running `rustup update` -- Try adding the `--locked` flag: `cargo install rustlings --locked` -- Otherwise, please [report the issue](https://github.com/rust-lang/rustlings/issues/new) - -
- -### Initialization - -After installing Rustlings, run the following command to initialize the `rustlings/` directory: - -```bash -rustlings init -``` - -
-If the command rustlings can't be found… (click to expand) - -You are probably using Linux and installed Rust using your package manager. - -Cargo installs binaries to the directory `~/.cargo/bin`. -Sadly, package managers often don't add `~/.cargo/bin` to your `PATH` environment variable. - -The solution is to … - -- either add `~/.cargo/bin` manually to `PATH` -- or to uninstall Rust from the package manager and install it using the official way with `rustup`: https://www.rust-lang.org/tools/install - -
- -Now, go into the newly initialized directory and launch Rustlings for further instructions on getting started with the exercises: - -```bash -cd rustlings/ -rustlings -``` - -## Working environment - -### Editor - -Our general recommendation is [VS Code](https://code.visualstudio.com/) with the [rust-analyzer plugin](https://marketplace.visualstudio.com/items?itemName=rust-lang.rust-analyzer). -But any editor that supports [rust-analyzer](https://rust-analyzer.github.io/) should be enough for working on the exercises. - -### Terminal - -While working with Rustlings, please use a modern terminal for the best user experience. -The default terminal on Linux and Mac should be sufficient. -On Windows, we recommend the [Windows Terminal](https://aka.ms/terminal). - -## Doing exercises - -The exercises are sorted by topic and can be found in the subdirectory `exercises/`. -For every topic, there is an additional `README.md` file with some resources to get you started on the topic. -We highly recommend that you have a look at them before you start πŸ“šοΈ - -Most exercises contain an error that keeps them from compiling, and it's up to you to fix it! -Some exercises contain tests that need to pass for the exercise to be done βœ… - -Search for `TODO` and `todo!()` to find out what you need to change. -Ask for hints by entering `h` in the _watch mode_ πŸ’‘ - -### Watch Mode - -After the [initialization](#initialization), Rustlings can be launched by simply running the command `rustlings`. - -This will start the _watch mode_ which walks you through the exercises in a predefined order (what we think is best for newcomers). -It will rerun the current exercise automatically every time you change the exercise's file in the `exercises/` directory. - -
-If detecting file changes in the exercises/ directory fails… (click to expand) - -> You can add the **`--manual-run`** flag (`rustlings --manual-run`) to manually rerun the current exercise by entering `r` in the watch mode. -> -> Please [report the issue](https://github.com/rust-lang/rustlings/issues/new) with some information about your operating system and whether you run Rustlings in a container or virtual machine (e.g. WSL). - -
- -### Exercise List - -In the [watch mode](#watch-mode) (after launching `rustlings`), you can enter `l` to open the interactive exercise list. - -The list allows you to… - -- See the status of all exercises (done or pending) -- `c`: Continue at another exercise (temporarily skip some exercises or go back to a previous one) -- `r`: Reset status and file of the selected exercise (you need to _reload/reopen_ its file in your editor afterwards) - -See the footer of the list for all possible keys. - -## Questions? - -If you need any help while doing the exercises and the builtin-hints aren't helpful, feel free to ask in the [_Q&A_ category of the discussions](https://github.com/rust-lang/rustlings/discussions/categories/q-a?discussions_q=) if your question wasn't asked yet πŸ’‘ - -## Third-Party Exercises - -Third-party exercises are a set of exercises maintained by the community. -You can use the same `rustlings` program that you installed with `cargo install rustlings` to run them: - -- πŸ‡―πŸ‡΅ [Japanese Rustlings](https://github.com/sotanengel/rustlings-jp):A Japanese translation of the Rustlings exercises. -- πŸ‡¨πŸ‡³ [Simplified Chinese Rustlings](https://github.com/SandmeyerX/rustlings-zh-cn): A simplified Chinese translation of the Rustlings exercises. - -Do you want to create your own set of Rustlings exercises to focus on some specific topic? -Or do you want to translate the original Rustlings exercises? -Then follow the the guide about [third-party exercises](https://github.com/rust-lang/rustlings/blob/main/THIRD_PARTY_EXERCISES.md)! - -## Continuing On - -Once you've completed Rustlings, put your new knowledge to good use! -Continue practicing your Rust skills by building your own projects, contributing to Rustlings, or finding other open-source projects to contribute to. - -## Uninstalling Rustlings - -If you want to remove Rustlings from your system, run the following command: - -```bash -cargo uninstall rustlings -``` - -## Contributing - -See [CONTRIBUTING.md](https://github.com/rust-lang/rustlings/blob/main/CONTRIBUTING.md) πŸ”— - -Thanks to [all the wonderful contributors](https://github.com/rust-lang/rustlings/graphs/contributors) ✨ +➑️ [**rustlings.rust-lang.org**](https://rustlings.rust-lang.org) ⬅️ From 6d5369d4d02092757e0a75ef55cf1ea87bfe2182 Mon Sep 17 00:00:00 2001 From: mo8it Date: Sat, 17 May 2025 12:25:55 +0200 Subject: [PATCH 10/32] Add more menu and footer items --- website/config.toml | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/website/config.toml b/website/config.toml index 906bb8bca4..5a360fbada 100644 --- a/website/config.toml +++ b/website/config.toml @@ -18,9 +18,24 @@ logo_path = "images/happy_ferris.svg" name = "Home" url = "/" [[extra.menu_items]] +name = "Setup" +url = "/setup" +[[extra.menu_items]] +name = "Usage" +url = "/usage" +[[extra.menu_items]] +name = "Q/A" +url = "https://github.com/rust-lang/rustlings/discussions/categories/q-a?discussions_q=" +[[extra.menu_items]] name = "Custom Exercises" url = "/custom-exercises" [[extra.footer_items]] name = "Repository" url = "https://github.com/rust-lang/rustlings" +[[extra.footer_items]] +name = "Changelog" +url = "https://github.com/rust-lang/rustlings/blob/main/CHANGELOG.md" +[[extra.footer_items]] +name = "MIT License" +url = "https://github.com/rust-lang/rustlings/blob/main/LICENSE" From 2673177b17eac262e70a0ac8f376346fecb636b5 Mon Sep 17 00:00:00 2001 From: mo8it Date: Sat, 17 May 2025 13:02:34 +0200 Subject: [PATCH 11/32] Update header and footer --- website/config.toml | 2 +- website/static/images/rust_logo.svg | 61 +++++++++++++++++++++++++++++ website/templates/base.html | 19 +++++---- 3 files changed, 73 insertions(+), 9 deletions(-) create mode 100644 website/static/images/rust_logo.svg diff --git a/website/config.toml b/website/config.toml index 5a360fbada..031e02886d 100644 --- a/website/config.toml +++ b/website/config.toml @@ -15,7 +15,7 @@ insert_anchor_links = "heading" logo_path = "images/happy_ferris.svg" [[extra.menu_items]] -name = "Home" +name = "Rustlings" url = "/" [[extra.menu_items]] name = "Setup" diff --git a/website/static/images/rust_logo.svg b/website/static/images/rust_logo.svg new file mode 100644 index 0000000000..3b42cfe034 --- /dev/null +++ b/website/static/images/rust_logo.svg @@ -0,0 +1,61 @@ + + + diff --git a/website/templates/base.html b/website/templates/base.html index 64beaab3e7..afe8d89153 100644 --- a/website/templates/base.html +++ b/website/templates/base.html @@ -48,16 +48,16 @@ -
+
-
From 69a9e9cafc36cc73c196e462aa7fb7d812ab1012 Mon Sep 17 00:00:00 2001 From: mo8it Date: Sat, 17 May 2025 22:05:48 +0200 Subject: [PATCH 27/32] Less top margin for blockquotes --- website/input.css | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/website/input.css b/website/input.css index b2536753dc..af0675d8b7 100644 --- a/website/input.css +++ b/website/input.css @@ -41,7 +41,7 @@ @apply md:w-3/4 lg:w-3/5; } blockquote { - @apply px-3 pt-2 pb-0.5 my-4 border-s-4 border-white/80 bg-white/7 rounded-sm; + @apply px-3 pt-2 pb-0.5 mb-4 mt-2 border-s-4 border-white/80 bg-white/7 rounded-sm; } pre { From 512ded81c4e6075e1bcfdf4f2675814d556588bc Mon Sep 17 00:00:00 2001 From: mo8it Date: Sat, 17 May 2025 22:05:57 +0200 Subject: [PATCH 28/32] Done community exercises page --- website/content/community-exercises/index.md | 40 ++++++++++++-------- 1 file changed, 24 insertions(+), 16 deletions(-) diff --git a/website/content/community-exercises/index.md b/website/content/community-exercises/index.md index 1c8cd5773b..0f713d7cc7 100644 --- a/website/content/community-exercises/index.md +++ b/website/content/community-exercises/index.md @@ -2,37 +2,36 @@ title = "Community Exercises" +++ -Do you want to create your own set of Rustlings exercises to focus on some specific topic? -Or do you want to translate the original Rustlings exercises? - ## List of Community Exercises - πŸ‡―πŸ‡΅ [Japanese Rustlings](https://github.com/sotanengel/rustlings-jp):A Japanese translation of the Rustlings exercises. - πŸ‡¨πŸ‡³ [Simplified Chinese Rustlings](https://github.com/SandmeyerX/rustlings-zh-cn): A simplified Chinese translation of the Rustlings exercises. -You can use the same `rustlings` program that you installed with `cargo install rustlings` to run them +> You can use the same `rustlings` program that you installed with `cargo install rustlings` to run community exercises. + +## Creating Community Exercises -The support of Rustlings for community exercises allows you to create your own set of Rustlings exercises to focus on some specific topic. +Rustling's support for community exercises allows you to create your own exercises to focus on some specific topic. You could also offer a translation of the original Rustlings exercises as community exercises. -## Getting started +### Getting Started To create community exercises, install Rustlings and run `rustlings dev new PROJECT_NAME`. -This command will, similar to `cargo new PROJECT_NAME`, create a template directory called `PROJECT_NAME` with all what you need to get started. +This command will, similar to `cargo new PROJECT_NAME`, create the template directory `PROJECT_NAME` with all what you need to get started. -Read the comments in the generated `info.toml` file to understand its format. +_Read the comments_ in the generated `info.toml` file to understand its format. It allows you to set a custom welcome and final message and specify the metadata of every exercise. -## Create an exercise +### Creating an Exercise -Here is an example of the metadata of one file: +Here is an example of the metadata of one exercise: ```toml [[exercises]] name = "intro1" hint = """ To finish this exercise, you need to … -This link might help you …""" +These links might help you …""" ``` After entering this in `info.toml`, create the file `intro1.rs` in the `exercises/` directory. @@ -51,15 +50,24 @@ For example, it will tell you to run `rustlings dev update` to update the `Cargo That's it! You finished your first exercise πŸŽ‰ -## Publish +### Cargo.toml + +Except of the `bin` list, you can modify the `Cargo.toml` file as you want. + +> The `bin` list is automatically updated by running `rustlings dev update` + +- You can add dependencies in the `[dependencies]` table. +- You might want to [configure some lints](https://doc.rust-lang.org/cargo/reference/manifest.html#the-lints-section) for all exercises. You can do so in the `[lints.rust]` and `[lints.clippy]` tables. + +### Publishing Now, add more exercises and publish them as a Git repository. -Users just have to clone that repository and run `rustlings` in it to start working on your set of exercises just like the official ones. +Users just have to clone that repository and run `rustlings` in it to start working on your exercises (just like the official ones). One difference to the official exercises is that the solution files will not be hidden until the user finishes an exercise. -But you can trust the users to not look at the solution too early πŸ˜‰ +But you can trust your users to not open the solution too early πŸ˜‰ -## Share +### Sharing -After publishing your set of exercises, open an issue or a pull request in the official Rustlings repository to link to your project in the README πŸ˜ƒ +After publishing your community exercises, open an issue or a pull request in the [official Rustlings repository](https://github.com/rust-lang/rustlings) to add your project to the [list of community exercises](#list-of-community-exercises) πŸ˜ƒ From 596e7f36cc0fc8b6b755d444b7f054da19734b8e Mon Sep 17 00:00:00 2001 From: mo8it Date: Sat, 17 May 2025 22:33:00 +0200 Subject: [PATCH 29/32] Add website CI --- .github/workflows/website.yml | 46 +++++++++++++++++++++++++++++++++++ website/package.json | 7 +++--- 2 files changed, 50 insertions(+), 3 deletions(-) create mode 100644 .github/workflows/website.yml diff --git a/.github/workflows/website.yml b/.github/workflows/website.yml new file mode 100644 index 0000000000..355d40bd45 --- /dev/null +++ b/.github/workflows/website.yml @@ -0,0 +1,46 @@ +name: Website + +on: + push: + branches: [main] + +jobs: + # Build & upload the static files as an artifact + build: + defaults: + run: + working-directory: website + + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Install Zola + run: sudo snap install zola + - name: Install TailwindCSS + run: npm install @tailwindcss/cli + - name: Build CSS + - run: npx @tailwindcss/cli -m -i input.css -o static/main.css + - name: Build site + run: zola build + - name: Upload static files as artifact + uses: actions/upload-pages-artifact@v3 + with: + path: public/ + + deploy: + needs: build + + # Grant GITHUB_TOKEN the permissions required to make a Pages deployment + permissions: + pages: write # to deploy to Pages + id-token: write # to verify the deployment originates from an appropriate source + + # Deploy to the github-pages environment + environment: + name: github-pages + url: ${{ steps.deployment.outputs.page_url }} + + runs-on: ubuntu-latest + steps: + - name: Deploy to GitHub Pages + uses: actions/deploy-pages@v4 diff --git a/website/package.json b/website/package.json index ee8a1c8812..f502431748 100644 --- a/website/package.json +++ b/website/package.json @@ -1,7 +1,8 @@ { - "devDependencies": { - "rustywind": "^0.24", - "tailwindcss": "^4.1", + "dependencies": { "@tailwindcss/cli": "^4.1" + }, + "devDependencies": { + "rustywind": "^0.24" } } From 47e490a997c37cb28ab4022c04155049b0b26f32 Mon Sep 17 00:00:00 2001 From: mo8it Date: Sat, 17 May 2025 22:33:17 +0200 Subject: [PATCH 30/32] Run rustywind --- website/templates/404.html | 2 +- website/templates/base.html | 10 +++++----- website/templates/page.html | 2 +- website/templates/shortcodes/details.html | 2 +- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/website/templates/404.html b/website/templates/404.html index 234eb46f41..eb9d4691a7 100644 --- a/website/templates/404.html +++ b/website/templates/404.html @@ -5,7 +5,7 @@

DON'T PANIC!

404: Page not found!

- diff --git a/website/templates/base.html b/website/templates/base.html index 91b6cee8ca..1a55aebf67 100644 --- a/website/templates/base.html +++ b/website/templates/base.html @@ -47,8 +47,8 @@ {% if permalink %}{% endif %} - -
+ +