Skip to content

Commit

Permalink
Use admonitions in several pages (expressjs#1595)
Browse files Browse the repository at this point in the history
  • Loading branch information
bjohansebas authored and Chris Del committed Nov 3, 2024
1 parent c6715d4 commit 34be25f
Show file tree
Hide file tree
Showing 29 changed files with 72 additions and 63 deletions.
6 changes: 2 additions & 4 deletions _includes/api/en/4x/app-listen.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,6 @@ app.listen = function () {
}
```

<div class="doc-box doc-info" markdown="1">
NOTE: All the forms of Node's
{% include admonitions/note.html content="All the forms of Node's
[http.Server.listen()](https://nodejs.org/api/http.html#http_server_listen)
method are in fact actually supported.
</div>
method are in fact actually supported." %}
6 changes: 4 additions & 2 deletions _includes/api/en/4x/express.static.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@
This is a built-in middleware function in Express.
It serves static files and is based on [serve-static](/resources/middleware/serve-static.html).

<div class="doc-box doc-info" markdown="1">NOTE: For best results, [use a reverse proxy](/{{page.lang}}/advanced/best-practice-performance.html#use-a-reverse-proxy) cache to improve performance of serving static assets.
</div>
{% capture alert_content %}
For best results, [use a reverse proxy](/{{page.lang}}/advanced/best-practice-performance.html#use-a-reverse-proxy) cache to improve performance of serving static assets.
{% endcapture %}
{% include admonitions/note.html content=alert_content %}

The `root` argument specifies the root directory from which to serve static assets.
The function determines the file to serve by combining `req.url` with the provided `root` directory.
Expand Down
4 changes: 1 addition & 3 deletions _includes/api/en/4x/req-params.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,4 @@ If you need to make changes to a key in `req.params`, use the [app.param](/{{ pa

Any changes made to the `req.params` object in a middleware or route handler will be reset.

<div class="doc-box doc-info" markdown="1">
NOTE: Express automatically decodes the values in `req.params` (using `decodeURIComponent`).
</div>
{% include admonitions/note.html content="Express automatically decodes the values in `req.params` (using `decodeURIComponent`)." %}
7 changes: 2 additions & 5 deletions _includes/api/en/4x/res-append.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
<h3 id='res.append'>res.append(field [, value])</h3>

<div class="doc-box doc-info" markdown="1">
`res.append()` is supported by Express v4.11.0+
</div>

{% include admonitions/note.html content="`res.append()` is supported by Express v4.11.0+" %}
Appends the specified `value` to the HTTP response header `field`. If the header is not already set,
it creates the header with the specified value. The `value` parameter can be a string or an array.

Note: calling `res.set()` after `res.append()` will reset the previously-set header value.
{% include admonitions/note.html content="calling `res.set()` after `res.append()` will reset the previously-set header value." %}

```js
res.append('Link', ['<http://localhost/>', '<http://localhost:3000/>'])
Expand Down
4 changes: 1 addition & 3 deletions _includes/api/en/4x/router-route.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,4 @@ router.route('/users/:user_id')
This approach re-uses the single `/users/:user_id` path and adds handlers for
various HTTP methods.

<div class="doc-box doc-info" markdown="1">
NOTE: When you use `router.route()`, middleware ordering is based on when the _route_ is created, not when method handlers are added to the route. For this purpose, you can consider method handlers to belong to the route to which they were added.
</div>
{% include admonitions/note.html content="When you use `router.route()`, middleware ordering is based on when the _route_ is created, not when method handlers are added to the route. For this purpose, you can consider method handlers to belong to the route to which they were added." %}
6 changes: 1 addition & 5 deletions _includes/api/en/5x/app-listen.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,4 @@ app.listen = function () {
}
```

<div class="doc-box doc-info" markdown="1">
NOTE: All the forms of Node's
[http.Server.listen()](https://nodejs.org/api/http.html#http_server_listen)
method are in fact actually supported.
</div>
{% include admonitions/note.html content="All the forms of Node's [http.Server.listen()](https://nodejs.org/api/http.html#http_server_listen) method are in fact actually supported." %}
4 changes: 1 addition & 3 deletions _includes/api/en/5x/req-params.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,4 @@ If you need to make changes to a key in `req.params`, use the [app.param](/{{ pa

Any changes made to the `req.params` object in a middleware or route handler will be reset.

<div class="doc-box doc-info" markdown="1">
NOTE: Express automatically decodes the values in `req.params` (using `decodeURIComponent`).
</div>
{% include admonitions/note.html content="Express automatically decodes the values in `req.params` (using `decodeURIComponent`)." %}
2 changes: 1 addition & 1 deletion _includes/api/en/5x/res-append.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
Appends the specified `value` to the HTTP response header `field`. If the header is not already set,
it creates the header with the specified value. The `value` parameter can be a string or an array.

Note: calling `res.set()` after `res.append()` will reset the previously-set header value.
{% include admonitions/note.html content="calling `res.set()` after `res.append()` will reset the previously-set header value." %}

```js
res.append('Link', ['<http://localhost/>', '<http://localhost:3000/>'])
Expand Down
8 changes: 3 additions & 5 deletions _includes/api/en/5x/res-render.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,10 @@ The `view` argument is a string that is the file path of the view file to render

For more information, see [Using template engines with Express](/{{page.lang}}/guide/using-template-engines.html).

**NOTE:** The `view` argument performs file system operations like reading a file from disk and evaluating Node.js modules, and as so for security reasons should not contain input from the end-user.
{% include admonitions/note.html content="The `view` argument performs file system operations like reading a file from disk and evaluating Node.js modules, and as so for security reasons should not contain input from the end-user." %}

<div class="doc-box doc-notice" markdown="1">
The local variable `cache` enables view caching. Set it to `true`,
to cache the view during development; view caching is enabled in production by default.
</div>
{% include admonitions/caution.html content="The local variable `cache` enables view caching. Set it to `true`,
to cache the view during development; view caching is enabled in production by default." %}

```js
// send the rendered view to the client
Expand Down
4 changes: 1 addition & 3 deletions _includes/api/en/5x/router-route.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,4 @@ router.route('/users/:user_id')
This approach re-uses the single `/users/:user_id` path and adds handlers for
various HTTP methods.

<div class="doc-box doc-info" markdown="1">
NOTE: When you use `router.route()`, middleware ordering is based on when the _route_ is created, not when method handlers are added to the route. For this purpose, you can consider method handlers to belong to the route to which they were added.
</div>
{% include admonitions/note.html content="When you use `router.route()`, middleware ordering is based on when the _route_ is created, not when method handlers are added to the route. For this purpose, you can consider method handlers to belong to the route to which they were added." %}
12 changes: 7 additions & 5 deletions _layouts/middleware.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,15 @@
{{content}}

{% elsif page.module %}
<div class="alert alert-info" role="alert"><i class="fa fa-info-circle"></i>
<b>Note:</b> This page was generated from the
<a target="_blank" href="https://github.com/expressjs/{{page.module}}">{{page.module}} README</a>.
</div>
{% capture note-middleware %}
This page was generated from the <a target="_blank" href="https://github.com/expressjs/{{page.module}}">{{page.module}} README</a>.
{% endcapture %}

{% include admonitions/note.html content=note-middleware %}

{% capture included-readme %}{% include readmes/{{page.module}}.md %}{% endcapture %}
{{ included-readme | markdownify }}

{{ included-readme | markdownify }}

{% else %}
<h3>ERROR: No source specified for README {{page.module}}</h3>
Expand Down
6 changes: 4 additions & 2 deletions en/advanced/best-practice-performance.md
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,7 @@ respawn
respawn limit 10 10
```

NOTE: This script requires Upstart 1.4 or newer, supported on Ubuntu 12.04-14.10.
{% include admonitions/note.html content="This script requires Upstart 1.4 or newer, supported on Ubuntu 12.04-14.10." %}

Since the job is configured to run when the system starts, your app will be started along with the operating system, and automatically restarted if the app crashes or the system goes down.

Expand Down Expand Up @@ -375,7 +375,9 @@ Then run the service with:
$ sudo /sbin/initctl start strong-pm
```

NOTE: On systems that don't support Upstart 1.4, the commands are slightly different. See [Setting up a production host (StrongLoop documentation)](https://docs.strongloop.com/display/SLC/Setting+up+a+production+host#Settingupaproductionhost-RHELLinux5and6,Ubuntu10.04-.10,11.04-.10) for more information.
{% include admonitions/note.html content="On systems that don't support Upstart 1.4, the commands are slightly different. See [Setting up a production host (StrongLoop documentation)](https://docs.strongloop.com/display/SLC/Setting+up+a+production+host#Settingupaproductionhost-RHELLinux5and6,Ubuntu10.04-.10,11.04-.10) for more information." %}



### Run your app in a cluster

Expand Down
4 changes: 3 additions & 1 deletion en/changelog/4x.md
Original file line number Diff line number Diff line change
Expand Up @@ -488,7 +488,9 @@ The 4.14.0 minor release includes bug fixes, security update, performance improv
</li>

<li markdown="1" class="changelog-item">
The [jshttp/cookie module](https://www.npmjs.com/package/cookie) (in addition to a number of other improvements) has been updated and now the [`res.cookie()` method](/{{ page.lang }}/4x/api.html#res.cookie) supports the `sameSite` option to let you specify the [SameSite cookie attribute](https://tools.ietf.org/html/draft-west-first-party-cookies-07). NOTE: This attribute has not yet been fully standardized, may change in the future, and many clients may ignore it.
The [jshttp/cookie module](https://www.npmjs.com/package/cookie) (in addition to a number of other improvements) has been updated and now the [`res.cookie()` method](/{{ page.lang }}/4x/api.html#res.cookie) supports the `sameSite` option to let you specify the [SameSite cookie attribute](https://tools.ietf.org/html/draft-west-first-party-cookies-07).

{% include admonitions/note.html content="This attribute has not yet been fully standardized, may change in the future, and many clients may ignore it." %}

The possible value for the `sameSite` option are:

Expand Down
5 changes: 3 additions & 2 deletions en/guide/debugging.md
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,9 @@ When running through Node.js, you can set a few environment variables that will
| `DEBUG_FD` | File descriptor to write debug output to. |
| `DEBUG_SHOW_HIDDEN` | Shows hidden properties on inspected objects. |

__Note:__ The environment variables beginning with `DEBUG_` end up being
{% include admonitions/note.html content="The environment variables beginning with `DEBUG_` end up being
converted into an Options object that gets used with `%o`/`%O` formatters.
See the Node.js documentation for
[`util.inspect()`](https://nodejs.org/api/util.html#util_util_inspect_object_options)
for the complete list.
for the complete list." %}

3 changes: 2 additions & 1 deletion en/guide/using-middleware.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,8 @@ app.get('/user/:id', (req, res, next) => {
```

To skip the rest of the middleware functions from a router middleware stack, call `next('route')` to pass control to the next route.
**NOTE**: `next('route')` will work only in middleware functions that were loaded by using the `app.METHOD()` or `router.METHOD()` functions.

{% include admonitions/note.html content="`next('route')` will work only in middleware functions that were loaded by using the `app.METHOD()` or `router.METHOD()` functions." %}

This example shows a middleware sub-stack that handles GET requests to the `/user/:id` path.

Expand Down
4 changes: 3 additions & 1 deletion en/resources/glossary.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,9 @@ A software platform that is used to build scalable network applications. Node.js

### open-source, open source

When used as an adjective, hyphenate; for example: "This is open-source software." See [Open-source software on Wikipedia](http://en.wikipedia.org/wiki/Open-source_software). Note: Although it is common not to hyphenate this term, we are using the standard English rules for hyphenating a compound adjective.
When used as an adjective, hyphenate; for example: "This is open-source software." See [Open-source software on Wikipedia](http://en.wikipedia.org/wiki/Open-source_software).

{% include admonitions/note.html content="Although it is common not to hyphenate this term, we are using the standard English rules for hyphenating a compound adjective." %}

### request

Expand Down
6 changes: 4 additions & 2 deletions en/starter/static-files.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,10 @@ app.use(express.static('files'))

Express looks up the files in the order in which you set the static directories with the `express.static` middleware function.

<div class="doc-box doc-info" markdown="1">NOTE: For best results, [use a reverse proxy](/{{page.lang}}/advanced/best-practice-performance.html#use-a-reverse-proxy) cache to improve performance of serving static assets.
</div>
{% capture alert_content %}
For best results, [use a reverse proxy](/{{page.lang}}/advanced/best-practice-performance.html#use-a-reverse-proxy) cache to improve performance of serving static assets.
{% endcapture %}
{% include admonitions/note.html content=alert_content %}

To create a virtual path prefix (where the path does not actually exist in the file system) for files that are served by the `express.static` function, [specify a mount path](/{{ page.lang }}/4x/api.html#app.use) for the static directory, as shown below:

Expand Down
4 changes: 2 additions & 2 deletions id/advanced/best-practice-performance.md
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,7 @@ respawn
respawn limit 10 10
```

NOTE: This script requires Upstart 1.4 or newer, supported on Ubuntu 12.04-14.10.
{% include admonitions/note.html content="This script requires Upstart 1.4 or newer, supported on Ubuntu 12.04-14.10." %}

Since the job is configured to run when the system starts, your app will be started along with the operating system, and automatically restarted if the app crashes or the system goes down.

Expand Down Expand Up @@ -374,7 +374,7 @@ Then run the service with:
$ sudo /sbin/initctl start strong-pm
```

NOTE: On systems that don't support Upstart 1.4, the commands are slightly different. See [Setting up a production host (StrongLoop documentation)](https://docs.strongloop.com/display/SLC/Setting+up+a+production+host#Settingupaproductionhost-RHELLinux5and6,Ubuntu10.04-.10,11.04-.10) for more information.
{% include admonitions/note.html content="On systems that don't support Upstart 1.4, the commands are slightly different. See [Setting up a production host (StrongLoop documentation)](https://docs.strongloop.com/display/SLC/Setting+up+a+production+host#Settingupaproductionhost-RHELLinux5and6,Ubuntu10.04-.10,11.04-.10) for more information." %}

### Run your app in a cluster

Expand Down
2 changes: 1 addition & 1 deletion id/guide/using-template-engines.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ app.get('/', (req, res) => {

When you make a request to the home page, the `index.pug` file will be rendered as HTML.

Note: The view engine cache does not cache the contents of the template's output, only the underlying template itself. The view is still re-rendered with every request even when the cache is on.
{% include admonitions/note.html content="The view engine cache does not cache the contents of the template's output, only the underlying template itself. The view is still re-rendered with every request even when the cache is on."%}

To learn more about how template engines work in Express, see:
["Developing template engines for Express"](/{{ page.lang }}/advanced/developing-template-engines.html).
4 changes: 3 additions & 1 deletion id/resources/glossary.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,9 @@ A software platform that is used to build scalable network applications. Node.js

### open-source, open source

When used as an adjective, hyphenate; for example: "This is open-source software." See [Open-source software on Wikipedia](http://en.wikipedia.org/wiki/Open-source_software). Note: Although it is common not to hyphenate this term, we are using the standard English rules for hyphenating a compound adjective.
When used as an adjective, hyphenate; for example: "This is open-source software." See [Open-source software on Wikipedia](http://en.wikipedia.org/wiki/Open-source_software).

{% include admonitions/note.html content="Although it is common not to hyphenate this term, we are using the standard English rules for hyphenating a compound adjective." %}

### request

Expand Down
4 changes: 2 additions & 2 deletions th/advanced/best-practice-performance.md
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,7 @@ respawn
respawn limit 10 10
```

NOTE: This script requires Upstart 1.4 or newer, supported on Ubuntu 12.04-14.10.
{% include admonitions/note.html content="This script requires Upstart 1.4 or newer, supported on Ubuntu 12.04-14.10."%}

Since the job is configured to run when the system starts, your app will be started along with the operating system, and automatically restarted if the app crashes or the system goes down.

Expand Down Expand Up @@ -373,7 +373,7 @@ Then run the service with:
$ sudo /sbin/initctl start strong-pm
```

NOTE: On systems that don't support Upstart 1.4, the commands are slightly different. See [Setting up a production host (StrongLoop documentation)](https://docs.strongloop.com/display/SLC/Setting+up+a+production+host#Settingupaproductionhost-RHELLinux5and6,Ubuntu10.04-.10,11.04-.10) for more information.
{% include admonitions/note.html content="On systems that don't support Upstart 1.4, the commands are slightly different. See [Setting up a production host (StrongLoop documentation)](https://docs.strongloop.com/display/SLC/Setting+up+a+production+host#Settingupaproductionhost-RHELLinux5and6,Ubuntu10.04-.10,11.04-.10) for more information." %}

### Run your app in a cluster

Expand Down
2 changes: 1 addition & 1 deletion th/guide/using-template-engines.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ app.get('/', (req, res) => {

When you make a request to the home page, the `index.pug` file will be rendered as HTML.

Note: The view engine cache does not cache the contents of the template's output, only the underlying template itself. The view is still re-rendered with every request even when the cache is on.
{% include admonitions/note.html content="The view engine cache does not cache the contents of the template's output, only the underlying template itself. The view is still re-rendered with every request even when the cache is on." %}

To learn more about how template engines work in Express, see:
["Developing template engines for Express"](/{{ page.lang }}/advanced/developing-template-engines.html).
4 changes: 3 additions & 1 deletion th/resources/glossary.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,9 @@ A software platform that is used to build scalable network applications. Node.js

### open-source, open source

When used as an adjective, hyphenate; for example: "This is open-source software." See [Open-source software on Wikipedia](http://en.wikipedia.org/wiki/Open-source_software). Note: Although it is common not to hyphenate this term, we are using the standard English rules for hyphenating a compound adjective.
When used as an adjective, hyphenate; for example: "This is open-source software." See [Open-source software on Wikipedia](http://en.wikipedia.org/wiki/Open-source_software).

{% include admonitions/note.html content="Although it is common not to hyphenate this term, we are using the standard English rules for hyphenating a compound adjective." %}

### request

Expand Down
4 changes: 3 additions & 1 deletion tr/changelog/4x.md
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,9 @@ The 4.14.0 minor release includes bug fixes, security update, performance improv
</li>

<li markdown="1" class="changelog-item">
The [jshttp/cookie module](https://www.npmjs.com/package/cookie) (in addition to a number of other improvements) has been updated and now the [`res.cookie()` method](/{{ page.lang }}/4x/api.html#res.cookie) supports the `sameSite` option to let you specify the [SameSite cookie attribute](https://tools.ietf.org/html/draft-west-first-party-cookies-07). NOTE: This attribute has not yet been fully standardized, may change in the future, and many clients may ignore it.
The [jshttp/cookie module](https://www.npmjs.com/package/cookie) (in addition to a number of other improvements) has been updated and now the [`res.cookie()` method](/{{ page.lang }}/4x/api.html#res.cookie) supports the `sameSite` option to let you specify the [SameSite cookie attribute](https://tools.ietf.org/html/draft-west-first-party-cookies-07).

{% include admonitions/note.html content="This attribute has not yet been fully standardized, may change in the future, and many clients may ignore it."%}

The possible value for the `sameSite` option are:

Expand Down
Loading

0 comments on commit 34be25f

Please sign in to comment.