From 2aacdf2f70fe7eb5d0b1a03adbfafbc62d3d0969 Mon Sep 17 00:00:00 2001 From: Hichem Fantar Date: Mon, 27 May 2024 21:55:31 +0100 Subject: [PATCH] Add extension recommendations, fix linting warnings, improve accessibility (#378) * chore: add VS Code extension recommendations * Update image URLs in README and documentation files * chore: disable no-inline-html rule * chore: use standard md/mdx syntax, and use .jsx for react components * chore: fix email links in Code of Conduct The commit message suggests fixing the email links in the Code of Conduct file to use the correct `mailto:` syntax. * chore: update actix-web error helper links Update the links to the `actix-web` error helper traits in the `databases.md` and `errors.md` files to use the correct URLs. * chore: restore unused actix-web error helper links * Update src/pages/community/coc.md Co-authored-by: Rob Ede * Update docs/getting-started.md Co-authored-by: Rob Ede --------- Co-authored-by: Rob Ede --- .vscode/extensions.json | 7 +++++++ .vscode/settings.json | 14 +++++++------- README.md | 3 +-- docs/application.md | 2 +- docs/conn_lifecycle.md | 8 ++++---- docs/databases.md | 12 ++++++------ docs/errors.md | 6 +++--- docs/extractors.md | 2 +- docs/getting-started.md | 2 +- docs/handlers.md | 2 +- docs/http2.md | 2 +- docs/http_server_init.md | 2 +- docs/middleware.md | 4 ++-- docs/request.md | 2 +- docs/response.md | 2 +- docs/server.md | 5 ++--- docs/shuttle.md | 4 ++-- docs/static-files.md | 2 +- docs/testing.md | 2 +- docs/url-dispatch.md | 6 +++--- docs/websockets.md | 2 +- .../{code_block.js => code_block.jsx} | 0 src/pages/community/coc.md | 18 ++++++++++-------- src/pages/{index.js => index.jsx} | 4 ++-- 24 files changed, 60 insertions(+), 53 deletions(-) create mode 100644 .vscode/extensions.json rename src/components/{code_block.js => code_block.jsx} (100%) rename src/pages/{index.js => index.jsx} (98%) diff --git a/.vscode/extensions.json b/.vscode/extensions.json new file mode 100644 index 0000000..a4f79e5 --- /dev/null +++ b/.vscode/extensions.json @@ -0,0 +1,7 @@ +{ + "recommendations": [ + "esbenp.prettier-vscode", + "davidanson.vscode-markdownlint", + "unifiedjs.vscode-mdx" + ] +} diff --git a/.vscode/settings.json b/.vscode/settings.json index c43ec64..ee310ec 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,9 +1,9 @@ { - "cSpell.words": [ - "actix", - "deserialization", - "rustls", - "serde", - "struct" - ] + "cSpell.words": ["actix", "deserialization", "rustls", "serde", "struct"], + "markdownlint.config": { + "no-inline-html": false, + "link-image-reference-definitions": false, + "commands-show-output": false, + "fenced-code-language": false + } } diff --git a/README.md b/README.md index e9d19a9..1562951 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,7 @@ npm install # or yarn install npm start # or yarn start ``` -Then visit http://localhost:3000. +Then visit . ## Updating diagrams @@ -37,4 +37,3 @@ This site is licensed under either of [docusaurus]: https://docusaurus.io/ [mermaid_cli]: https://github.com/mermaidjs/mermaid.cli - diff --git a/docs/application.md b/docs/application.md index 221c3a9..5c500b5 100644 --- a/docs/application.md +++ b/docs/application.md @@ -2,7 +2,7 @@ title: Application --- -import CodeBlock from "@site/src/components/code_block.js"; +import CodeBlock from "@site/src/components/code_block"; # Writing an Application diff --git a/docs/conn_lifecycle.md b/docs/conn_lifecycle.md index 3f29cbd..0189957 100644 --- a/docs/conn_lifecycle.md +++ b/docs/conn_lifecycle.md @@ -10,23 +10,23 @@ Once connection accepted Application level protocol processing happens in a prot Please note, below diagrams are outlining happy-path scenarios only. -![](/img/diagrams/connection_overview.svg) +![Connection Overview](/img/diagrams/connection_overview.svg) ## Accept loop in more detail -![](/img/diagrams/connection_accept.svg) +![Connection Accept](/img/diagrams/connection_accept.svg "Connection Accept") Most of code implementation resides in [`actix-server`][server] crate for struct [`Accept`][accept]. ## Worker loop in more detail -![](/img/diagrams/connection_worker.svg) +![Connection Worker](/img/diagrams/connection_worker.svg "Connection Worker") Most of code implementation resides in [`actix-server`][server] crate for struct [`Worker`][worker]. ## Request loop roughly -![](/img/diagrams/connection_request.svg) +![Connection Request](/img/diagrams/connection_request.svg "Connection Request") Most of code implementation for request loop resides in [`actix-web`][web] and [`actix-http`][http] crates. diff --git a/docs/databases.md b/docs/databases.md index 53b84d0..1a9080e 100644 --- a/docs/databases.md +++ b/docs/databases.md @@ -2,15 +2,15 @@ title: Databases --- -import CodeBlock from "@site/src/components/code_block.js"; +import CodeBlock from "@site/src/components/code_block"; # Async Options We have several example projects showing use of async database adapters: -- Postgres: https://github.com/actix/examples/tree/master/databases/postgres -- SQLite: https://github.com/actix/examples/tree/master/databases/sqlite -- MongoDB: https://github.com/actix/examples/tree/master/databases/mongodb +- [Postgres](https://github.com/actix/examples/tree/master/databases/postgres) +- [SQLite](https://github.com/actix/examples/tree/master/databases/sqlite) +- [MongoDB](https://github.com/actix/examples/tree/master/databases/mongodb) # Diesel @@ -30,7 +30,7 @@ This example also maps the error to an `HttpResponse` before using the `?` opera -That's it! See the full example here: https://github.com/actix/examples/tree/master/databases/diesel +That's it! See the full example [here](https://github.com/actix/examples/tree/master/databases/diesel). [web-block]: https://docs.rs/actix-web/4/actix_web/web/fn.block.html -[response-error]: https://docs.rs/actix-web/4/actix_web/trait.ResponseError.html +[response-error]: https://docs.rs/actix-web/4/actix_web/error/trait.ResponseError.html diff --git a/docs/errors.md b/docs/errors.md index fcf44f1..41b00e9 100644 --- a/docs/errors.md +++ b/docs/errors.md @@ -2,7 +2,7 @@ title: Errors --- -import CodeBlock from "@site/src/components/code_block.js"; +import CodeBlock from "@site/src/components/code_block"; # Errors @@ -62,7 +62,7 @@ See the [API documentation for actix-web's `error` module][actixerror] for a ful Actix logs all errors at the `WARN` log level. If an application's log level is set to `DEBUG` and `RUST_BACKTRACE` is enabled, the backtrace is also logged. These are configurable with environmental variables: -``` +```sh >> RUST_BACKTRACE=1 RUST_LOG=actix_web=debug cargo run ``` @@ -99,7 +99,7 @@ log = "0.4" [actixerror]: https://docs.rs/actix-web/4/actix_web/error/struct.Error.html -[errorhelpers]: https://docs.rs/actix-web/4/actix_web/trait.ResponseError.html +[errorhelpers]: https://docs.rs/actix-web/4/actix_web/error/trait.ResponseError.html [derive_more]: https://crates.io/crates/derive_more [responseerror]: https://docs.rs/actix-web/4/actix_web/error/trait.ResponseError.html [responseerrorimpls]: https://docs.rs/actix-web/4/actix_web/error/trait.ResponseError.html#foreign-impls diff --git a/docs/extractors.md b/docs/extractors.md index 3605b59..2398cb3 100644 --- a/docs/extractors.md +++ b/docs/extractors.md @@ -2,7 +2,7 @@ title: Extractors --- -import CodeBlock from "@site/src/components/code_block.js"; +import CodeBlock from "@site/src/components/code_block"; # Type-safe information extraction diff --git a/docs/getting-started.md b/docs/getting-started.md index e25be7f..c1c38f3 100644 --- a/docs/getting-started.md +++ b/docs/getting-started.md @@ -2,7 +2,7 @@ title: Getting Started --- -import RenderCodeBlock from '@theme/CodeBlock'; import CodeBlock from "@site/src/components/code_block.js"; import { rustVersion, actixWebMajorVersion } from "@site/vars"; +import RenderCodeBlock from '@theme/CodeBlock'; import CodeBlock from "@site/src/components/code_block"; import { rustVersion, actixWebMajorVersion } from "@site/vars"; ## Installing Rust diff --git a/docs/handlers.md b/docs/handlers.md index 0906372..8f003b9 100644 --- a/docs/handlers.md +++ b/docs/handlers.md @@ -2,7 +2,7 @@ title: Handlers --- -import CodeBlock from "@site/src/components/code_block.js"; +import CodeBlock from "@site/src/components/code_block"; # Request Handlers diff --git a/docs/http2.md b/docs/http2.md index f0c7142..6e087aa 100644 --- a/docs/http2.md +++ b/docs/http2.md @@ -2,7 +2,7 @@ title: HTTP/2 --- -import RenderCodeBlock from '@theme/CodeBlock'; import CodeBlock from '@site/src/components/code_block.js'; import { actixWebMajorVersion } from "@site/vars"; +import RenderCodeBlock from '@theme/CodeBlock'; import CodeBlock from '@site/src/components/code_block'; import { actixWebMajorVersion } from "@site/vars"; `actix-web` automatically upgrades connections to _HTTP/2_ if possible. diff --git a/docs/http_server_init.md b/docs/http_server_init.md index 81830a2..125ea53 100644 --- a/docs/http_server_init.md +++ b/docs/http_server_init.md @@ -19,4 +19,4 @@ async fn main() -> std::io::Result<()> { } ``` -![](/img/diagrams/http_server.svg) +![HTTP Server Diagram](/img/diagrams/http_server.svg) diff --git a/docs/middleware.md b/docs/middleware.md index ce54e74..e98273c 100644 --- a/docs/middleware.md +++ b/docs/middleware.md @@ -2,7 +2,7 @@ title: Middleware --- -import CodeBlock from "@site/src/components/code_block.js"; +import CodeBlock from "@site/src/components/code_block"; # Middleware @@ -49,7 +49,7 @@ Create `Logger` middleware with the specified `format`. Default `Logger` can be The following is an example of the default logging format: -``` +```log INFO:actix_web::middleware::logger: 127.0.0.1:59934 [02/Dec/2017:00:21:43 -0800] "GET / HTTP/1.1" 302 0 "-" "curl/7.54.0" 0.000397 INFO:actix_web::middleware::logger: 127.0.0.1:59947 [02/Dec/2017:00:22:40 -0800] "GET /index.html HTTP/1.1" 200 0 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.13; rv:57.0) Gecko/20100101 Firefox/57.0" 0.000646 ``` diff --git a/docs/request.md b/docs/request.md index 8eaccb2..2169ac4 100644 --- a/docs/request.md +++ b/docs/request.md @@ -2,7 +2,7 @@ title: Requests --- -import CodeBlock from "@site/src/components/code_block.js"; +import CodeBlock from "@site/src/components/code_block"; # JSON Request diff --git a/docs/response.md b/docs/response.md index aeeb096..adaac55 100644 --- a/docs/response.md +++ b/docs/response.md @@ -2,7 +2,7 @@ title: Responses --- -import CodeBlock from "@site/src/components/code_block.js"; +import CodeBlock from "@site/src/components/code_block"; # Response diff --git a/docs/server.md b/docs/server.md index da3676b..0336551 100644 --- a/docs/server.md +++ b/docs/server.md @@ -2,7 +2,7 @@ title: Server --- -import RenderCodeBlock from '@theme/CodeBlock'; import CodeBlock from '@site/src/components/code_block.js'; import { actixWebMajorVersion } from "@site/vars"; +import RenderCodeBlock from '@theme/CodeBlock'; import CodeBlock from '@site/src/components/code_block'; import { actixWebMajorVersion } from "@site/vars"; # The HTTP Server @@ -70,8 +70,7 @@ openssl = { version = "0.10" } To create the key.pem and cert.pem use the command. **Fill in your own subject** ```bash -$ openssl req -x509 -newkey rsa:4096 -keyout key.pem -out cert.pem \ - -days 365 -sha256 -subj "/C=CN/ST=Fujian/L=Xiamen/O=TVlinux/OU=Org/CN=muro.lxd" +$ openssl req -x509 -newkey rsa:4096 -keyout key.pem -out cert.pem -days 365 -sha256 -subj "/C=CN/ST=Fujian/L=Xiamen/O=TVlinux/OU=Org/CN=muro.lxd" ``` To remove the password, then copy nopass.pem to key.pem diff --git a/docs/shuttle.md b/docs/shuttle.md index 0518f32..02103b8 100644 --- a/docs/shuttle.md +++ b/docs/shuttle.md @@ -2,11 +2,11 @@ title: Hosting on Shuttle --- -import CodeBlock from '@site/src/components/code_block.js'; +import CodeBlock from '@site/src/components/code_block'; # Hosting on Shuttle - +Shuttle Logo > [**Shuttle**](https://www.shuttle.rs) is a Rust-native cloud development platform that lets you deploy your Rust apps for free. diff --git a/docs/static-files.md b/docs/static-files.md index 7522985..ec5992d 100644 --- a/docs/static-files.md +++ b/docs/static-files.md @@ -2,7 +2,7 @@ title: Static Files --- -import CodeBlock from "@site/src/components/code_block.js"; +import CodeBlock from "@site/src/components/code_block"; # Individual file diff --git a/docs/testing.md b/docs/testing.md index fb7627f..353b78d 100644 --- a/docs/testing.md +++ b/docs/testing.md @@ -2,7 +2,7 @@ title: Testing --- -import CodeBlock from "@site/src/components/code_block.js"; +import CodeBlock from "@site/src/components/code_block"; # Testing diff --git a/docs/url-dispatch.md b/docs/url-dispatch.md index 185176c..5897ef7 100644 --- a/docs/url-dispatch.md +++ b/docs/url-dispatch.md @@ -2,7 +2,7 @@ title: URL Dispatch --- -import CodeBlock from "@site/src/components/code_block.js"; +import CodeBlock from "@site/src/components/code_block"; # URL Dispatch @@ -12,7 +12,7 @@ URL dispatch provides a simple way for mapping URLs to handler code using a simp ## Resource configuration -Resource configuration is the act of adding a new resources to an application. A resource has a name, which acts as an identifier to be used for URL generation. The name also allows developers to add routes to existing resources. A resource also has a pattern, meant to match against the _PATH_ portion of a _URL_ (the portion following the scheme and port, e.g. _/foo/bar_ in the _URL_ _http://localhost:8080/foo/bar?q=value_). It does not match against the _QUERY_ portion (the portion that follows _?_, e.g. _q=value_ in _http://localhost:8080/foo/bar?q=value_). +Resource configuration is the act of adding a new resources to an application. A resource has a name, which acts as an identifier to be used for URL generation. The name also allows developers to add routes to existing resources. A resource also has a pattern, meant to match against the _PATH_ portion of a _URL_ (the portion following the scheme and port, e.g. _/foo/bar_ in the _URL_ _`http://localhost:8080/foo/bar?q=value`_). It does not match against the _QUERY_ portion (the portion that follows _?_, e.g. _q=value_ in _`http://localhost:8080/foo/bar?q=value`_). The [_App::route()_][approute] method provides simple way of registering routes. This method adds a single route to application routing table. This method accepts a _path pattern_, _HTTP method_ and a handler function. `route()` method could be called multiple times for the same path, in that case, multiple routes register for the same resource path. @@ -206,7 +206,7 @@ Use the [_HttpRequest.url_for()_][urlfor] method to generate URLs based on resou -This would return something like the string `http://example.com/test/1/2/3` (at least if the current protocol and hostname implied http://example.com). `url_for()` method returns [_Url object_][urlobj] so you can modify this url (add query parameters, anchor, etc). `url_for()` could be called only for _named_ resources otherwise error get returned. +This would return something like the string `http://example.com/test/1/2/3` (at least if the current protocol and hostname implied `http://example.com`). `url_for()` method returns [_Url object_][urlobj] so you can modify this url (add query parameters, anchor, etc). `url_for()` could be called only for _named_ resources otherwise error get returned. ## External resources diff --git a/docs/websockets.md b/docs/websockets.md index 97a902c..f70368e 100644 --- a/docs/websockets.md +++ b/docs/websockets.md @@ -2,7 +2,7 @@ title: Websockets --- -import CodeBlock from "@site/src/components/code_block.js"; +import CodeBlock from "@site/src/components/code_block"; # Websockets diff --git a/src/components/code_block.js b/src/components/code_block.jsx similarity index 100% rename from src/components/code_block.js rename to src/components/code_block.jsx diff --git a/src/pages/community/coc.md b/src/pages/community/coc.md index 9ab27e8..1ac3418 100644 --- a/src/pages/community/coc.md +++ b/src/pages/community/coc.md @@ -3,11 +3,13 @@ title: Contributor Covenant Code of Conduct description: The code of conduct --- -# Our Pledge +# Code of Conduct + +## Our Pledge In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, gender identity and expression, level of experience, nationality, personal appearance, race, religion, or sexual identity and orientation. -# Our Standards +## Our Standards Examples of behavior that contributes to creating a positive environment include: @@ -25,28 +27,28 @@ Examples of unacceptable behavior by participants include: - Publishing others' private information, such as a physical or electronic address, without explicit permission - Other conduct which could reasonably be considered inappropriate in a professional setting -# Our Responsibilities +## Our Responsibilities Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior. Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful. -# Scope +## Scope This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers. -# Enforcement +## Enforcement -Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at robjtede@icloud.com ([@robjtede]) or jtitor@2k36.org ([@JohnTitor]). The project team will review and investigate all complaints, and will respond in a way that it deems appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately. +Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at [robjtede@icloud.com](mailto:robjtede@icloud.com) ([@robjtede]) or [jtitor@2k36.org](mailto:jtitor@2k36.org) ([@JohnTitor]). The project team will review and investigate all complaints, and will respond in a way that it deems appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately. Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership. [@robjtede]: https://github.com/robjtede [@JohnTitor]: https://github.com/JohnTitor -# Attribution +## Attribution -This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, available at [http://contributor-covenant.org/version/1/4][version] +This Code of Conduct is adapted from the [Contributor Covenant][homepage], [Version 1.4][version]. [homepage]: http://contributor-covenant.org [version]: http://contributor-covenant.org/version/1/4/ diff --git a/src/pages/index.js b/src/pages/index.jsx similarity index 98% rename from src/pages/index.js rename to src/pages/index.jsx index 889d9e3..f0e129a 100644 --- a/src/pages/index.js +++ b/src/pages/index.jsx @@ -2,7 +2,7 @@ import clsx from "clsx"; import React from "react"; import Link from "@docusaurus/Link"; import Layout from "@theme/Layout"; -import CodeBlock from "../components/code_block.js"; +import CodeBlock from "@site/src/components/code_block"; import useDocusaurusContext from "@docusaurus/useDocusaurusContext"; import useBaseUrl from "@docusaurus/useBaseUrl"; import styles from "./styles.module.scss"; @@ -15,7 +15,7 @@ import { } from "@fortawesome/free-solid-svg-icons"; const Home = () => { - const {siteConfig} = useDocusaurusContext(); + const { siteConfig } = useDocusaurusContext(); return (