Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added documentation regarding the static middleware #4518 #4736

Merged

Conversation

BhardwajAditya-github
Copy link
Member

Added documentation of static middleware

Added documentation of static middleware
@netlify
Copy link

netlify bot commented May 4, 2023

Deploy Preview for volto ready!

Name Link
🔨 Latest commit 812ee52
🔍 Latest deploy log https://app.netlify.com/sites/volto/deploys/6457e811ae3d770008dc96ed
😎 Deploy Preview https://deploy-preview-4736--volto.netlify.app/recipes/express.html
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

Copy link
Collaborator

@stevepiercy stevepiercy left a comment

Choose a reason for hiding this comment

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

Thank you! This looks good.

My suggestions and questions pertain only to English and MyST grammar, formatting, syntax, and style.

A core contributor should also review the content for accuracy.

docs/source/recipes/express.md Outdated Show resolved Hide resolved
docs/source/recipes/express.md Outdated Show resolved Hide resolved
@@ -42,6 +42,41 @@ if (__SERVER__) {
}
```

## Static Middleware

The `staticMiddleware` is for serving static files (such as stylesheets and client-side JavaScript files) in the `BUILD_DIR/PUBLIC` or `PUBLIC_DIR` directory. It uses the `express.static()` function to serve static files and the `setHeaders()` function to add response headers to the files that it serves.
Copy link
Collaborator

Choose a reason for hiding this comment

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

One sentence per line.

Suggested change
The `staticMiddleware` is for serving static files (such as stylesheets and client-side JavaScript files) in the `BUILD_DIR/PUBLIC` or `PUBLIC_DIR` directory. It uses the `express.static()` function to serve static files and the `setHeaders()` function to add response headers to the files that it serves.
The `staticMiddleware` is for serving static files such as style sheets and client-side JavaScript files from the `BUILD_DIR/PUBLIC` or `PUBLIC_DIR` directory.
It uses the `express.static()` function to serve static files, and the `setHeaders()` function to add response headers to the files that it serves.

For staticMiddleware, is that a setting? Perhaps it should be the following?

To add new middleware, use the `settings. staticMiddleware ` configuration key.
[What are valid values for this key?]

Also a code example would be helpful.

Copy link
Member Author

Choose a reason for hiding this comment

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

import { settings as defaultSettings } from '@plone/volto/config';
import express from 'express';

const settings = { ...defaultSettings };

if (__SERVER__) {
    const customStaticMiddleware = express.static('test/static/files');

    function setCustomHeaders(req, res, next) {
        res.setHeader('Cache-Control', 'public, max-age=3600');
        next();
    }

    customStaticMiddleware.setHeaders = setCustomHeaders;
    customStaticMiddleware.id = 'custom-static-middleware';

    settings.expressMiddleware = [
        ...defaultSettings.expressMiddleware,
        customStaticMiddleware,
    ];
}

I am not sure if this is correct. Please confirm

Copy link
Collaborator

Choose a reason for hiding this comment

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

@sneridagh @nileshgulia1 @ksuess or any other qualified person could we get a review of this Express middleware code example?

Copy link
Member

Choose a reason for hiding this comment

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

LGTM, maybe we can add this piece of code to the docs too.

docs/source/recipes/express.md Outdated Show resolved Hide resolved
docs/source/recipes/express.md Outdated Show resolved Hide resolved
docs/source/recipes/express.md Outdated Show resolved Hide resolved
docs/source/recipes/express.md Show resolved Hide resolved
docs/source/recipes/express.md Outdated Show resolved Hide resolved
```js

settings.staticFiles = [
...,{
Copy link
Collaborator

Choose a reason for hiding this comment

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

This code example should be run through whatever JavaScript linter Volto uses. I think this example would be reformatted.

docs/source/recipes/express.md Outdated Show resolved Hide resolved
BhardwajAditya-github and others added 2 commits May 5, 2023 18:20
made syntax and formatting changes for static middleware documentation
Co-authored-by: Steve Piercy <web@stevepiercy.com>
Copy link
Collaborator

@stevepiercy stevepiercy left a comment

Choose a reason for hiding this comment

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

Thanks for making the changes. I approve the English and MyST syntax and style fixes.

We need a maintainer or other qualified person to review the code example and the rest of the content for accuracy, and then we can merge it.

@stevepiercy
Copy link
Collaborator

Oops, this PR needs a towncrier entry. See https://6.docs.plone.org/contributing/index.html#change-log-entry

news/4518.documentation Outdated Show resolved Hide resolved
Co-authored-by: Steve Piercy <web@stevepiercy.com>
Copy link
Member

@sneridagh sneridagh left a comment

Choose a reason for hiding this comment

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

LGTM overall, let's add the code sample to the docs as well and it's mergeable.

@sneridagh sneridagh merged commit 166e269 into plone:master May 9, 2023
sneridagh added a commit that referenced this pull request May 10, 2023
* master: (83 commits)
  Apply suggestion from browser for password field (#4524)
  (fix):Object.normaliseMail: Cannot read properties of null (#4558)
  Fix link in Volto, remove from linkcheck ignore in Documentation v6.0 (#4742)
  added documentation regarding the static middleware #4518 (#4736)
  Closes issue #4567 (#4570)
  Fix whitespace in locales created by the generator (#4737)
  Tidy up from synch with 16.x.x (#4728)
  Release notes from 16.20.2, 16.20.3, 16.20.4 (#4729)
  Use new URL 6.docs.plone.org (#4726)
  Security upgrade for momentjs (#4715)
  Don't decode querystring while adding apiExpanders (#4719)
  (Synchronize redundant block id in listing block on pasting) Fix duplicating listing block (#4239)
  Translate add-on control panel (cleaned up PR) (#4620)
  Fix Move to top of folder ordering in folder content view by searchin… (#4709)
  Fix robot.txt - the sitemap link should respect x-forwarded headers (#4704)
  Refactor faulty reorder elements in ObjectBrowserList widget (#4703)
  Release changelog notes for 16.20.1
  Release 17.0.0-alpha.5
  Generate a split sitemap (also fix robots.txt) (#4639)
  Fix search block in edit mode re-queries multiple blocks with an empty search text (#4694)
  ...
sneridagh added a commit that referenced this pull request May 11, 2023
* master: (185 commits)
  fix: unresponsive add page (#4507)
  Apply suggestion from browser for password field (#4524)
  (fix):Object.normaliseMail: Cannot read properties of null (#4558)
  Fix link in Volto, remove from linkcheck ignore in Documentation v6.0 (#4742)
  added documentation regarding the static middleware #4518 (#4736)
  Closes issue #4567 (#4570)
  Fix whitespace in locales created by the generator (#4737)
  Tidy up from synch with 16.x.x (#4728)
  Release notes from 16.20.2, 16.20.3, 16.20.4 (#4729)
  Use new URL 6.docs.plone.org (#4726)
  Security upgrade for momentjs (#4715)
  Don't decode querystring while adding apiExpanders (#4719)
  (Synchronize redundant block id in listing block on pasting) Fix duplicating listing block (#4239)
  Translate add-on control panel (cleaned up PR) (#4620)
  Fix Move to top of folder ordering in folder content view by searchin… (#4709)
  Fix robot.txt - the sitemap link should respect x-forwarded headers (#4704)
  Refactor faulty reorder elements in ObjectBrowserList widget (#4703)
  Release changelog notes for 16.20.1
  Release 17.0.0-alpha.5
  Generate a split sitemap (also fix robots.txt) (#4639)
  ...
sneridagh pushed a commit that referenced this pull request May 12, 2023
Co-authored-by: Steve Piercy <web@stevepiercy.com>
sneridagh added a commit that referenced this pull request May 12, 2023
)

Co-authored-by: Aditya Bhardwaj <74232587+BhardwajAditya-github@users.noreply.github.com>
Co-authored-by: Steve Piercy <web@stevepiercy.com>
sneridagh added a commit to ninanoleto/volto that referenced this pull request May 20, 2023
* master: (29 commits)
  Remove max_line_length from .editorconfig (plone#4776)
  Fix bug showing logs at the browsers when richtext widget is use (plone#4780)
  Show expired and future content in contents view (plone#4764)
  Fix reducing expanders loaded in a subrequest (plone#4761)
  Update release notes for 16.20.5 and 16.20.6 (plone#4759)
  Release 17.0.0-alpha.7
  Try to sort out volto's use of language codes (plone#4741)
  Improve .npmignore to not include not needed files/folders (plone#4746)
  Release 17.0.0-alpha.6
  Control panel list SSR (plone#3749)
  Open all accordion'd content in InlineForm by default, allow arbitrarily close any number of them (plone#4178)
  Upgrade to Plone 6.0.4 (plone#4743)
  fix: unresponsive add page (plone#4507)
  Apply suggestion from browser for password field (plone#4524)
  (fix):Object.normaliseMail: Cannot read properties of null (plone#4558)
  Fix link in Volto, remove from linkcheck ignore in Documentation v6.0 (plone#4742)
  added documentation regarding the static middleware plone#4518 (plone#4736)
  Closes issue plone#4567 (plone#4570)
  Fix whitespace in locales created by the generator (plone#4737)
  Tidy up from synch with 16.x.x (plone#4728)
  ...
sneridagh added a commit that referenced this pull request May 20, 2023
* master: (29 commits)
  Remove max_line_length from .editorconfig (#4776)
  Fix bug showing logs at the browsers when richtext widget is use (#4780)
  Show expired and future content in contents view (#4764)
  Fix reducing expanders loaded in a subrequest (#4761)
  Update release notes for 16.20.5 and 16.20.6 (#4759)
  Release 17.0.0-alpha.7
  Try to sort out volto's use of language codes (#4741)
  Improve .npmignore to not include not needed files/folders (#4746)
  Release 17.0.0-alpha.6
  Control panel list SSR (#3749)
  Open all accordion'd content in InlineForm by default, allow arbitrarily close any number of them (#4178)
  Upgrade to Plone 6.0.4 (#4743)
  fix: unresponsive add page (#4507)
  Apply suggestion from browser for password field (#4524)
  (fix):Object.normaliseMail: Cannot read properties of null (#4558)
  Fix link in Volto, remove from linkcheck ignore in Documentation v6.0 (#4742)
  added documentation regarding the static middleware #4518 (#4736)
  Closes issue #4567 (#4570)
  Fix whitespace in locales created by the generator (#4737)
  Tidy up from synch with 16.x.x (#4728)
  ...
sneridagh added a commit to ninanoleto/volto that referenced this pull request May 20, 2023
* typescript-support-in-core: (29 commits)
  Remove max_line_length from .editorconfig (plone#4776)
  Fix bug showing logs at the browsers when richtext widget is use (plone#4780)
  Show expired and future content in contents view (plone#4764)
  Fix reducing expanders loaded in a subrequest (plone#4761)
  Update release notes for 16.20.5 and 16.20.6 (plone#4759)
  Release 17.0.0-alpha.7
  Try to sort out volto's use of language codes (plone#4741)
  Improve .npmignore to not include not needed files/folders (plone#4746)
  Release 17.0.0-alpha.6
  Control panel list SSR (plone#3749)
  Open all accordion'd content in InlineForm by default, allow arbitrarily close any number of them (plone#4178)
  Upgrade to Plone 6.0.4 (plone#4743)
  fix: unresponsive add page (plone#4507)
  Apply suggestion from browser for password field (plone#4524)
  (fix):Object.normaliseMail: Cannot read properties of null (plone#4558)
  Fix link in Volto, remove from linkcheck ignore in Documentation v6.0 (plone#4742)
  added documentation regarding the static middleware plone#4518 (plone#4736)
  Closes issue plone#4567 (plone#4570)
  Fix whitespace in locales created by the generator (plone#4737)
  Tidy up from synch with 16.x.x (plone#4728)
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants