From 2858dc422357763c47cf4f0f9755b441b830757b Mon Sep 17 00:00:00 2001 From: tima101 Date: Mon, 29 Nov 2021 21:06:05 -0800 Subject: [PATCH] #459 updated builderbook/builderbook; README --- README.md | 18 +- book/9-begin/.ebextensions/environment.config | 3 - book/9-begin/.ebextensions/git.config | 3 - builderbook/.ebextensions/environment.config | 3 - builderbook/.ebextensions/git.config | 3 - builderbook/.elasticbeanstalk/config.yml | 11 +- builderbook/.eslintrc.js | 1 - builderbook/components/Header.jsx | 18 +- builderbook/components/MenuWithAvatar.jsx | 4 +- builderbook/components/Notifier.jsx | 2 +- builderbook/components/SharedStyles.js | 12 - builderbook/components/admin/EditBook.jsx | 11 +- builderbook/components/customer/BuyButton.jsx | 8 +- builderbook/lib/api/getRootUrl.js | 4 +- builderbook/lib/theme.js | 6 +- builderbook/lib/withAuth.jsx | 17 - builderbook/next.config.js | 11 +- builderbook/package.json | 76 +- builderbook/pages/_app.jsx | 56 +- builderbook/pages/_document.jsx | 89 +- builderbook/pages/admin/book-detail.jsx | 2 +- builderbook/pages/admin/index.jsx | 2 +- builderbook/pages/public/login.jsx | 2 +- builderbook/pages/public/read-chapter-f.jsx | 379 ++ builderbook/pages/public/read-chapter.jsx | 6 +- builderbook/public/fonts/cdn.css | 4 +- builderbook/public/fonts/server.css | 4 +- builderbook/server/logger.js | 4 +- builderbook/server/models/EmailTemplate.js | 19 - builderbook/server/routesWithSlug.js | 5 + builderbook/server/server.js | 1 + builderbook/server/stripe.js | 2 +- builderbook/yarn.lock | 4322 ++++++++--------- 33 files changed, 2608 insertions(+), 2500 deletions(-) delete mode 100644 book/9-begin/.ebextensions/environment.config delete mode 100644 book/9-begin/.ebextensions/git.config delete mode 100644 builderbook/.ebextensions/environment.config delete mode 100644 builderbook/.ebextensions/git.config create mode 100644 builderbook/pages/public/read-chapter-f.jsx diff --git a/README.md b/README.md index 9805b9908..9905a65c3 100644 --- a/README.md +++ b/README.md @@ -92,8 +92,8 @@ The main use cases for this project, besides learning, are: SESSION_SECRET= # Used in lib/getRootUrl.js - URL_APP= - PRODUCTION_URL_APP= + NEXT_PUBLIC_URL_APP= + NEXT_PUBLIC_PRODUCTION_URL_APP="https://heroku.builderbook.org" # Used in server/google.js GOOGLE_CLIENTID= @@ -117,8 +117,8 @@ The main use cases for this project, besides learning, are: GITHUB_LIVE_SECRETKEY= # Used in server/stripe.js - STRIPE_TEST_PUBLISHABLEKEY= - STRIPE_LIVE_PUBLISHABLEKEY= + NEXT_PUBLIC_STRIPE_TEST_PUBLISHABLEKEY= + NEXT_PUBLIC_STRIPE_LIVE_PUBLISHABLEKEY= STRIPE_TEST_SECRETKEY= STRIPE_LIVE_SECRETKEY= STRIPE_TEST_DEMO_BOOK_PRICE_ID= @@ -133,15 +133,17 @@ The main use cases for this project, besides learning, are: MAILCHIMP_SIGNEDUP_LIST_ID= # Used in pages/_document.js and pages/_app.js - GA_MEASUREMENT_ID= - COOKIE_DOMAIN= + NEXT_PUBLIC_GA_MEASUREMENT_ID= + COOKIE_DOMAIN=".builderbook.org" ``` + Add your value (domain that you own) for `COOKIE_DOMAIN` and `NEXT_PUBLIC_PRODUCTION_URL_APP`. + - Start the app with `yarn dev`. - - To get `GA_MEASUREMENT_ID`, set up Google Analytics and follow [these instructions](https://support.google.com/analytics/answer/1008080?hl=en) to find your tracking ID. + - To get `NEXT_PUBLIC_GA_MEASUREMENT_ID`, set up Google Analytics and follow [these instructions](https://support.google.com/analytics/answer/1008080?hl=en) to find your tracking ID. - To get Stripe-related API keys, set up or log into your Stripe account and find your key [here](https://dashboard.stripe.com/account/apikeys). -- Env keys `GA_MEASUREMENT_ID` and `STRIPE_TEST_PUBLISHABLEKEY`/`STRIPE_LIVE_PUBLISHABLEKEY` are universally available (client and server). Env keys inside `.env` file are used in server code only. To make env vars universally available, add them to `next.config.js` file. +- Env keys `NEXT_PUBLIC_GA_MEASUREMENT_ID` and `NEXT_PUBLIC_STRIPE_TEST_PUBLISHABLEKEY`/`NEXT_PUBLIC_STRIPE_LIVE_PUBLISHABLEKEY` are universally available (client and server). Env keys inside `.env` file are used in server code only unless they have `NEXT_PUBLIC_` prepended to their name. In that case, they are universally available. - To make user a book's owner, set `"isAdmin": true` on corresponding MongoDB document in your database (default value is `false` for any new user). **Important: if you don't add values for environmental variables to `.env` file, corresponding functionality will not work. For example, login with Google account, purchasing book, getting repo information via GitHub API and other third-party API infrastructures.** diff --git a/book/9-begin/.ebextensions/environment.config b/book/9-begin/.ebextensions/environment.config deleted file mode 100644 index cd9da5f04..000000000 --- a/book/9-begin/.ebextensions/environment.config +++ /dev/null @@ -1,3 +0,0 @@ -option_settings: - - option_name: NODE_ENV - value: production \ No newline at end of file diff --git a/book/9-begin/.ebextensions/git.config b/book/9-begin/.ebextensions/git.config deleted file mode 100644 index 1efdaaab2..000000000 --- a/book/9-begin/.ebextensions/git.config +++ /dev/null @@ -1,3 +0,0 @@ -packages: - yum: - git: [] \ No newline at end of file diff --git a/builderbook/.ebextensions/environment.config b/builderbook/.ebextensions/environment.config deleted file mode 100644 index cd9da5f04..000000000 --- a/builderbook/.ebextensions/environment.config +++ /dev/null @@ -1,3 +0,0 @@ -option_settings: - - option_name: NODE_ENV - value: production \ No newline at end of file diff --git a/builderbook/.ebextensions/git.config b/builderbook/.ebextensions/git.config deleted file mode 100644 index 1efdaaab2..000000000 --- a/builderbook/.ebextensions/git.config +++ /dev/null @@ -1,3 +0,0 @@ -packages: - yum: - git: [] \ No newline at end of file diff --git a/builderbook/.elasticbeanstalk/config.yml b/builderbook/.elasticbeanstalk/config.yml index dfc51725d..096217f0d 100644 --- a/builderbook/.elasticbeanstalk/config.yml +++ b/builderbook/.elasticbeanstalk/config.yml @@ -1,17 +1,14 @@ branch-defaults: default: - environment: builderbook-public + environment: builderbook-9-end-env environment-defaults: - async-github1-env: - branch: null - repository: null - builderbook-app: + builderbook-9-end-env: branch: null repository: null global: - application_name: book + application_name: builderbook-9-end-app default_ec2_keyname: null - default_platform: Node.js + default_platform: Node.js 14 running on 64bit Amazon Linux 2 default_region: us-east-1 include_git_submodules: true instance_profile: null diff --git a/builderbook/.eslintrc.js b/builderbook/.eslintrc.js index 9c063614f..455032557 100644 --- a/builderbook/.eslintrc.js +++ b/builderbook/.eslintrc.js @@ -4,7 +4,6 @@ module.exports = { env: { browser: true, jest: true, - es6: true, }, plugins: ['react', 'jsx-a11y', 'import', 'prettier'], rules: { diff --git a/builderbook/components/Header.jsx b/builderbook/components/Header.jsx index bd926a23c..76f0ee426 100644 --- a/builderbook/components/Header.jsx +++ b/builderbook/components/Header.jsx @@ -1,10 +1,10 @@ import PropTypes from 'prop-types'; import Link from 'next/link'; -import Toolbar from '@material-ui/core/Toolbar'; -import Grid from '@material-ui/core/Grid'; -import Hidden from '@material-ui/core/Hidden'; -import Button from '@material-ui/core/Button'; -import Avatar from '@material-ui/core/Avatar'; +import Toolbar from '@mui/material/Toolbar'; +import Grid from '@mui/material/Grid'; +import Hidden from '@mui/material/Hidden'; +import Button from '@mui/material/Button'; +import Avatar from '@mui/material/Avatar'; import MenuWithAvatar from './MenuWithAvatar'; @@ -61,9 +61,9 @@ function Header({ user, hideHeader, redirectUrl }) { }} > - + - {!user ? ( + {user ? null : ( - ) : null} + )} {user && user.isAdmin && !user.isGithubConnected ? ( - +