Spaces:
Running
Running
neon_arch
commited on
Commit
Β·
493696f
1
Parent(s):
2b41fb9
π docs: update the project structure and the associated explaination (#439)
Browse files- docs/developing.md +57 -45
docs/developing.md
CHANGED
@@ -12,7 +12,7 @@ This page of the docs outlines how to get **Websurfx** up and running in a devel
|
|
12 |
- [NixOS Dev Shell using Nix Flake](#nixos-dev-shell-using-nix-flake-)
|
13 |
- [Local Development with Docker Compose](#local-development-with-docker-compose-)
|
14 |
- [Project Commands](#project-commands)
|
15 |
-
|
16 |
- [Git Strategy](#git-strategy)
|
17 |
- [Flow](#git-flow)
|
18 |
- [Branches](#git-branch-naming)
|
@@ -57,7 +57,7 @@ $ npm i -g stylelint
|
|
57 |
$ npm i -g stylelint stylelint-config-standard postcss-lit
|
58 |
```
|
59 |
|
60 |
-
>
|
61 |
> In the above command the dollar sign(**$**) refers to running the command in privileged mode by using utilities `sudo`, `doas`, `pkgexec`, or any other privileged access methods.
|
62 |
|
63 |
- `Cargo-watch` installed on your system which will allow you to auto-build the project when any checks occur in the source code files in the codebase (`websurfx` directory). Before you install `cargo-watch` on your system, make sure you have `cargo` installed on your system. To install `cargo-watch` run the following command:
|
@@ -69,7 +69,7 @@ cargo install cargo-watch
|
|
69 |
- `Git` installed on your system. The installation instructions for this can be found [here](https://git-scm.com/book/en/v2/Getting-Started-Installing-Git).
|
70 |
- Finally, The latest version of `Docker` is installed on your system which will be used to avoid introducing unexpected issues when working on the project. The installation instructions for this can be found [here](https://docs.docker.com/engine/install/).
|
71 |
|
72 |
-
>
|
73 |
> For **rolling release Linux distributions (distros)**, the above-mentioned required packages except for `stylelint` and `cargo-watch` can also be installed via the distro-specific package manager.
|
74 |
>
|
75 |
> **For Example:**
|
@@ -149,7 +149,7 @@ Once you have finished running the above command, Websurfx should now be served
|
|
149 |
|
150 |
This section covers how to use and set up the Gitpod development environment for working on the project.
|
151 |
|
152 |
-
>
|
153 |
> By default the project only supports the Vscode **IDE/Editor** for Gitpod.
|
154 |
|
155 |
#### Launching Gitpod
|
@@ -310,13 +310,13 @@ Before you start working on the project. You will need the following packages in
|
|
310 |
$ npm i -g stylelint
|
311 |
```
|
312 |
|
313 |
-
>
|
314 |
> In the above command the dollar sign(**$**) refers to running the command in privileged mode by using utilities `sudo`, `doas`, `pkgexec`, or any other privileged access methods.
|
315 |
|
316 |
- `Git` installed on your system. The installation instructions for this can be found [here](https://git-scm.com/book/en/v2/Getting-Started-Installing-Git).
|
317 |
- Finally, The latest version of `Docker` is installed on your system which will be used to avoid introducing unexpected issues when working on the project. The installation instructions for this can be found [here](https://docs.docker.com/engine/install/).
|
318 |
|
319 |
-
>
|
320 |
> For **rolling release Linux distributions (distros)**, the above-mentioned all required packages can also be installed via the distro-specific package manager.
|
321 |
>
|
322 |
> **For Example:**
|
@@ -355,7 +355,7 @@ If you have followed the above section then you should have a cloned repository
|
|
355 |
$ docker compose -f dev.docker-compose.yml up
|
356 |
```
|
357 |
|
358 |
-
>
|
359 |
> In the above command the dollar sign(**$**) refers to running the command in privileged mode by using utilities `sudo`, `doas`, `pkgexec`, or any other privileged access methods.
|
360 |
|
361 |
Once you have finished running the above command, Websurfx should now be served on the address http://127.0.0.1:8080. Hot reload is enabled, so making changes to any of the files will trigger the project to be rebuilt.
|
@@ -366,13 +366,12 @@ Once you have finished running the above command, Websurfx should now be served
|
|
366 |
|
367 |
- `cargo build`: Builds the project.
|
368 |
|
369 |
-
>
|
370 |
> When you build the project first time with the above command it will require the app to compile every dependency in the project which will then be cached on your system. So when you compile the app next time it will only compile for the new changes.
|
371 |
|
372 |
-
|
373 |
|
374 |
-
|
375 |
-
> **Important**
|
376 |
> You must run the build command first.
|
377 |
|
378 |
#### Development
|
@@ -458,10 +457,10 @@ When you submit your pull request, include the required info, by filling out the
|
|
458 |
- If any dependencies were added, explain why it was needed, and state the cost. associated, and confirm it does not introduce any security, privacy, or speed issues
|
459 |
- Optionally, provide a checklist of all the changes that were included in the pull request.
|
460 |
|
461 |
-
>
|
462 |
> Make sure to fill all the required/mandatory sections of the pull request as filling them helps us distinguish between spam pull requests and legitimate pull requests.
|
463 |
|
464 |
-
>
|
465 |
> The pull request template contains comments in the following form `<!-- -->` which are used to provide a guide on what should be provided under each heading of the template. These comments are never rendered when the pull request is either created or updated and hence anything provided in such comments is never displayed.
|
466 |
|
467 |
## Resources for Beginners
|
@@ -498,7 +497,7 @@ For Rust, CSS, JS, HTML, Git, and Docker- you'll need an IDE (e.g. [VSCode](http
|
|
498 |
|
499 |
Linting is done using [Cargo Clippy](https://doc.rust-lang.org/clippy/) and [StyleLint](https://stylelint.io/) or [ESLint](https://eslint.org/). Also, linting is run as a git pre-commit hook.
|
500 |
|
501 |
-
>
|
502 |
> All lint checks must pass before any PR can be merged.
|
503 |
|
504 |
Styleguides to follow:
|
@@ -509,7 +508,7 @@ Styleguides to follow:
|
|
509 |
|
510 |
## Application Structure
|
511 |
|
512 |
-
>
|
513 |
> We follow the Unix style naming conventions for all the files and folders in the project (except for all files under the `themes` and `colorschemes` folder in the frontend's source code which requires that the names of the files and folders should be in lowercase and the words be separated with a hyphen.) which includes the name of the files and folders should be in lowercase and every word should be separated with an underscore.
|
514 |
|
515 |
**Files in the root of the codebase:** `./`
|
@@ -541,30 +540,42 @@ Styleguides to follow:
|
|
541 |
./public/
|
542 |
βββ robots.txt # Robots file for the Website.
|
543 |
βββ images # Images for the Website.
|
544 |
-
|
545 |
-
|
546 |
-
|
547 |
-
|
548 |
-
|
549 |
-
|
550 |
-
|
551 |
-
|
552 |
-
|
553 |
-
|
554 |
-
|
555 |
-
|
556 |
-
|
557 |
-
|
558 |
-
|
559 |
-
|
560 |
-
|
561 |
-
|
562 |
-
|
563 |
-
|
564 |
-
|
565 |
-
|
566 |
-
|
567 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
568 |
```
|
569 |
|
570 |
**Backend Source:** `./src/`
|
@@ -601,12 +612,13 @@ Styleguides to follow:
|
|
601 |
β βββ aggregator.rs # Provides code aggregate and fetches results from the upstream engines.
|
602 |
β βββ mod.rs # A module file for the rust project.
|
603 |
β βββ user_agent.rs # Provides a helper function to allow random user agents to pass in the server request code to improve user privacy and avoiding detected as a bot.
|
604 |
-
|
605 |
-
|
606 |
-
|
607 |
-
|
608 |
-
|
609 |
-
|
|
|
610 |
```
|
611 |
|
612 |
## Development Tools
|
|
|
12 |
- [NixOS Dev Shell using Nix Flake](#nixos-dev-shell-using-nix-flake-)
|
13 |
- [Local Development with Docker Compose](#local-development-with-docker-compose-)
|
14 |
- [Project Commands](#project-commands)
|
15 |
+
- [Environment Variables](#environment-variables)
|
16 |
- [Git Strategy](#git-strategy)
|
17 |
- [Flow](#git-flow)
|
18 |
- [Branches](#git-branch-naming)
|
|
|
57 |
$ npm i -g stylelint stylelint-config-standard postcss-lit
|
58 |
```
|
59 |
|
60 |
+
> [!Note]
|
61 |
> In the above command the dollar sign(**$**) refers to running the command in privileged mode by using utilities `sudo`, `doas`, `pkgexec`, or any other privileged access methods.
|
62 |
|
63 |
- `Cargo-watch` installed on your system which will allow you to auto-build the project when any checks occur in the source code files in the codebase (`websurfx` directory). Before you install `cargo-watch` on your system, make sure you have `cargo` installed on your system. To install `cargo-watch` run the following command:
|
|
|
69 |
- `Git` installed on your system. The installation instructions for this can be found [here](https://git-scm.com/book/en/v2/Getting-Started-Installing-Git).
|
70 |
- Finally, The latest version of `Docker` is installed on your system which will be used to avoid introducing unexpected issues when working on the project. The installation instructions for this can be found [here](https://docs.docker.com/engine/install/).
|
71 |
|
72 |
+
> [!Note]
|
73 |
> For **rolling release Linux distributions (distros)**, the above-mentioned required packages except for `stylelint` and `cargo-watch` can also be installed via the distro-specific package manager.
|
74 |
>
|
75 |
> **For Example:**
|
|
|
149 |
|
150 |
This section covers how to use and set up the Gitpod development environment for working on the project.
|
151 |
|
152 |
+
> [!Note]
|
153 |
> By default the project only supports the Vscode **IDE/Editor** for Gitpod.
|
154 |
|
155 |
#### Launching Gitpod
|
|
|
310 |
$ npm i -g stylelint
|
311 |
```
|
312 |
|
313 |
+
> [!Note]
|
314 |
> In the above command the dollar sign(**$**) refers to running the command in privileged mode by using utilities `sudo`, `doas`, `pkgexec`, or any other privileged access methods.
|
315 |
|
316 |
- `Git` installed on your system. The installation instructions for this can be found [here](https://git-scm.com/book/en/v2/Getting-Started-Installing-Git).
|
317 |
- Finally, The latest version of `Docker` is installed on your system which will be used to avoid introducing unexpected issues when working on the project. The installation instructions for this can be found [here](https://docs.docker.com/engine/install/).
|
318 |
|
319 |
+
> [!Note]
|
320 |
> For **rolling release Linux distributions (distros)**, the above-mentioned all required packages can also be installed via the distro-specific package manager.
|
321 |
>
|
322 |
> **For Example:**
|
|
|
355 |
$ docker compose -f dev.docker-compose.yml up
|
356 |
```
|
357 |
|
358 |
+
> [!Note]
|
359 |
> In the above command the dollar sign(**$**) refers to running the command in privileged mode by using utilities `sudo`, `doas`, `pkgexec`, or any other privileged access methods.
|
360 |
|
361 |
Once you have finished running the above command, Websurfx should now be served on the address http://127.0.0.1:8080. Hot reload is enabled, so making changes to any of the files will trigger the project to be rebuilt.
|
|
|
366 |
|
367 |
- `cargo build`: Builds the project.
|
368 |
|
369 |
+
> [!Note]
|
370 |
> When you build the project first time with the above command it will require the app to compile every dependency in the project which will then be cached on your system. So when you compile the app next time it will only compile for the new changes.
|
371 |
|
372 |
+
- `cargo run`: Starts the app and serves the project on http://127.0.0.1:8080.
|
373 |
|
374 |
+
> [!Important]
|
|
|
375 |
> You must run the build command first.
|
376 |
|
377 |
#### Development
|
|
|
457 |
- If any dependencies were added, explain why it was needed, and state the cost. associated, and confirm it does not introduce any security, privacy, or speed issues
|
458 |
- Optionally, provide a checklist of all the changes that were included in the pull request.
|
459 |
|
460 |
+
> [!Important]
|
461 |
> Make sure to fill all the required/mandatory sections of the pull request as filling them helps us distinguish between spam pull requests and legitimate pull requests.
|
462 |
|
463 |
+
> [!Note]
|
464 |
> The pull request template contains comments in the following form `<!-- -->` which are used to provide a guide on what should be provided under each heading of the template. These comments are never rendered when the pull request is either created or updated and hence anything provided in such comments is never displayed.
|
465 |
|
466 |
## Resources for Beginners
|
|
|
497 |
|
498 |
Linting is done using [Cargo Clippy](https://doc.rust-lang.org/clippy/) and [StyleLint](https://stylelint.io/) or [ESLint](https://eslint.org/). Also, linting is run as a git pre-commit hook.
|
499 |
|
500 |
+
> [!Important]
|
501 |
> All lint checks must pass before any PR can be merged.
|
502 |
|
503 |
Styleguides to follow:
|
|
|
508 |
|
509 |
## Application Structure
|
510 |
|
511 |
+
> [!Important]
|
512 |
> We follow the Unix style naming conventions for all the files and folders in the project (except for all files under the `themes` and `colorschemes` folder in the frontend's source code which requires that the names of the files and folders should be in lowercase and the words be separated with a hyphen.) which includes the name of the files and folders should be in lowercase and every word should be separated with an underscore.
|
513 |
|
514 |
**Files in the root of the codebase:** `./`
|
|
|
540 |
./public/
|
541 |
βββ robots.txt # Robots file for the Website.
|
542 |
βββ images # Images for the Website.
|
543 |
+
βββ static # The directory containing all the UI handlers.
|
544 |
+
βββ cookies.js # Handles the loading of saved cookies.
|
545 |
+
βββ error_box.js # Handles the toggling functionality of the error box on the search page.
|
546 |
+
βββ index.js # Functions to handle the search functionality of the search bar.
|
547 |
+
βββ pagination.js # Functions to handle the navigation between the previous and next page in the search page.
|
548 |
+
βββ search_area_options.js # Changes the search options under the search bar in the search page according to the safe search level set using the URL safesearch parameter.
|
549 |
+
βββ settings.js # Handles the settings and saving of all the settings page options as a cookie.
|
550 |
+
βββ colorschemes # A folder containing all the popular colorscheme files as CSS files.
|
551 |
+
βββ themes # A folder containing all the popular theme files as CSS files.
|
552 |
+
```
|
553 |
+
|
554 |
+
**Fronted Maud HTML Framework Source:** `./src/templates/`
|
555 |
+
|
556 |
+
```
|
557 |
+
./src/templates/
|
558 |
+
βββ mod.rs # A module file for the rust project.
|
559 |
+
βββ partials # A folder containing the code for partials for the views.
|
560 |
+
β βββ bar.rs # Provides partial code for the search bar.
|
561 |
+
β βββ footer.rs # Provides partial code for the footer section.
|
562 |
+
β βββ header.rs # Provides partial code for the header section.
|
563 |
+
β βββ mod.rs # A module file for the rust project.
|
564 |
+
β βββ navbar.rs # Provides partial code for the navbar inside the header section.
|
565 |
+
β βββ search_bar.rs # Provides partial code for the search bar present in the search page.
|
566 |
+
β βββ settings_tabs # A folder containing all the partials for the settings page tabs.
|
567 |
+
β βββ cookies.rs # Provides partial code for the cookies tab.
|
568 |
+
β βββ engines.rs # Provides partial code for the engines tab.
|
569 |
+
β βββ general.rs # Provides partial code for the general tab.
|
570 |
+
β βββ mod.rs # A module file for the rust project.
|
571 |
+
β βββ user_interface.rs # Provides partial code for the user interface tab.
|
572 |
+
βββ views # A folder containing the code for the views.
|
573 |
+
βββ about.rs # Provides code for the about page view.
|
574 |
+
βββ index.rs # Provides code for the homepage view.
|
575 |
+
βββ mod.rs # A module file for the rust project.
|
576 |
+
βββ not_found.rs # Provides code for the 404 page view.
|
577 |
+
βββ search.rs # Provides code for the search page view.
|
578 |
+
βββ settings.rs # Provides code for the settings page view.
|
579 |
```
|
580 |
|
581 |
**Backend Source:** `./src/`
|
|
|
612 |
β βββ aggregator.rs # Provides code aggregate and fetches results from the upstream engines.
|
613 |
β βββ mod.rs # A module file for the rust project.
|
614 |
β βββ user_agent.rs # Provides a helper function to allow random user agents to pass in the server request code to improve user privacy and avoiding detected as a bot.
|
615 |
+
βββ server # A folder that holds code to handle the routes for the search engine website.
|
616 |
+
β βββ mod.rs # A module file for the rust project.
|
617 |
+
β βββ router.rs # Provides functions to handle the different routes on the website.
|
618 |
+
β βββ routes # A folder that contains code to handle the bigger route for the website.
|
619 |
+
β βββ mod.rs # A module file for the rust project.
|
620 |
+
β βββ search.rs # Provides the function to handle the search route.
|
621 |
+
βββ templates # A module that provides and handles Maud HTML framework source code for the search engine website (subfolders and files are explained in the above frontend section.)
|
622 |
```
|
623 |
|
624 |
## Development Tools
|