From 6b6e05ca1147f5d58ea646651529bf926bd12aca Mon Sep 17 00:00:00 2001 From: Victor Losada Hernandez Date: Fri, 20 Jan 2023 23:14:25 +0100 Subject: [PATCH 1/7] Readme update, installation text improved --- README.md | 34 ++++++++++++++++++++++++++++------ 1 file changed, 28 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 35f0150d1..a78292808 100644 --- a/README.md +++ b/README.md @@ -21,24 +21,30 @@ below. First, install three programs that The Homebrewery requires to run and retrieve updates: -1. install [node](https://nodejs.org/en/) +1. install [node](https://nodejs.org/en/), any version is supported. 1. install [mongodb](https://www.mongodb.com/try/download/community) (Community version) For the easiest installation, follow these steps: 1. In the installer, uncheck the option to run as a service. 1. You can install MongoDB Compass if you want a GUI to view your database documents. + 1. If you install any version over 6.0, you will have to install [MongoDB Shell](https://www.mongodb.com/try/download/shell). 1. Go to the C:\ drive and create a folder called "data". 1. Inside the "data" folder, create a new folder called "db". - 1. Open a command prompt or other terminal and navigate to your MongoDB install folder (C:\Program Files\Mongo\Server\4.4\bin). + 1. Open a command prompt or other terminal and navigate to your MongoDB install folder (C:\Program Files\Mongo\Server\6.0\bin). 1. In the command prompt, run "mongod", which will start up your local database server. 1. While MongoD is running, open a second command prompt and navigate to the MongoDB install folder. - 1. In the second command prompt, run "mongo", which allows you to edit the database. - 1. Type `use homebrewery` to create The Homebrewery database. You should see `switched to db homebrewery`. - 1. Type `db.brews.insert({"title":"test"})` to create a blank document. You should see `WriteResult({ "nInserted" : 1 })`. 1. Search in Windows for "Advanced system settings" and open it. 1. Click "Environment variables", find the "path" variable, and double-click to open it. 1. Click "New" and paste in the path to the MongoDB "bin" folder. 1. Click "OK" three times to close all the windows. + 1. In the second command prompt, run "mongo", which allows you to edit the database. + 1. Type `use homebrewery` to create The Homebrewery database. You should see `switched to db homebrewery`. + 1. Type `db.brews.insert({"title":"test"})` to create a blank document. You should see `WriteResult({ "nInserted" : 1 })`. + 1. If you use any version older than 6.0, use `db.brews.insertOne({"title":"test"})` instead. You should see `{ +acknowledged: true, +insertedId: ObjectId("63c2fce9e5ac5a94fe2410cf") +}` + 1. install [git](https://git-scm.com/downloads) (select the option that allows Git to run from the command prompt). Checkout the repo ([documentation][github-clone-repo-docs-url]): @@ -51,11 +57,19 @@ git clone https://github.com/naturalcrit/homebrewery.git Second, you will need to add the environment variable `NODE_ENV=local` to allow the project to run locally. -You can set this temporarily in your shell of choice: +You can set this **temporarily** in your shell of choice: * Windows Powershell: `$env:NODE_ENV="local"` * Windows CMD: `set NODE_ENV=local` * Linux / macOS: `export NODE_ENV=local` +If you want to add this variable **permanently** the steps are as follows: + 1. Search in Windows for "Advanced system settings" and open it. + 1. Click "Environment variables". + 1. In System Variables, click "New" + 1. Click "New" and write `NODE_ENV` as a name and `local` as the value. + 1. Click "OK" three times to close all the windows. + This can be undone at any time if needed. + Third, you will need to install the Node dependencies, compile the app, and run it using the two commands: @@ -65,6 +79,14 @@ it using the two commands: You should now be able to go to [http://localhost:8000](http://localhost:8000) in your browser and use The Homebrewery offline. +If you had any issue at all, here are some links that may be useful: +- [Course](https://learn.mongodb.com/courses/m103-basic-cluster-administration) on cluster administration, in the mongodb web, useful for begginners +- [Mongo community forums](https://www.mongodb.com/community/forums/) +- After mongodb 6.0, which i reccomend, to run mongo commands, users will have to install MongoDB Shell [from this link](https://www.mongodb.com/try/download/shell). +- Useful Stack Overflow links for your most probable errors: [1](https://stackoverflow.com/questions/44962540/mongod-and-mongo-commands-not-working-on-windows-10), [2](https://stackoverflow.com/questions/15053893/mongo-command-not-recognized-when-trying-to-connect-to-a-mongodb-server/41507803#41507803), [3](https://stackoverflow.com/questions/51224959/mongo-is-not-recognized-as-an-internal-or-external-command-operable-program-o) + +If you still have problems, post in [Our Subreddit](https://www.reddit.com/r/homebrewery/) and we will help you. + ### Running the application via Docker Please see the docs here: [README.DOCKER.md](./README.DOCKER.md) From 0c68e5870b395908f347d8ff8a679096cda87a60 Mon Sep 17 00:00:00 2001 From: Victor Losada Hernandez Date: Sun, 22 Jan 2023 15:52:28 +0100 Subject: [PATCH 2/7] admin privileges detail readme --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index a78292808..4165534cc 100644 --- a/README.md +++ b/README.md @@ -57,7 +57,7 @@ git clone https://github.com/naturalcrit/homebrewery.git Second, you will need to add the environment variable `NODE_ENV=local` to allow the project to run locally. -You can set this **temporarily** in your shell of choice: +You can set this **temporarily** in your shell of choice with admin privileges: * Windows Powershell: `$env:NODE_ENV="local"` * Windows CMD: `set NODE_ENV=local` * Linux / macOS: `export NODE_ENV=local` From 541109e7b1b3d9a51d8c7e3ca3deb0c17d23a815 Mon Sep 17 00:00:00 2001 From: Victor Losada Hernandez Date: Sat, 28 Jan 2023 11:47:26 +0100 Subject: [PATCH 3/7] fix created, updated published last viewed --- server/app.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/server/app.js b/server/app.js index 61dbbc21a..9f4550778 100644 --- a/server/app.js +++ b/server/app.js @@ -294,7 +294,12 @@ app.get('/edit/:id', asyncHandler(getBrew('edit')), (req, res, next)=>{ app.get('/new/:id', asyncHandler(getBrew('share')), (req, res, next)=>{ sanitizeBrew(req.brew, 'share'); splitTextStyleAndMetadata(req.brew); - req.brew.views = 0; + req.brew.published = false; + req.brew.createdAt = clock.now; + req.brew.updatedAt = clock.now; + req.brew.views = 1; + req.brew.lastViewed = clock.now; + req.brew.title = `CLONE - ${req.brew.title}`; req.ogMeta = { ...defaultMetaTags, From 91fc8a1a5e0ab4cdc570028443658e71c21a88fd Mon Sep 17 00:00:00 2001 From: Victor Losada Hernandez Date: Mon, 30 Jan 2023 20:30:43 +0100 Subject: [PATCH 4/7] Suggested changes --- README.md | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 4165534cc..af7ea1d72 100644 --- a/README.md +++ b/README.md @@ -21,7 +21,7 @@ below. First, install three programs that The Homebrewery requires to run and retrieve updates: -1. install [node](https://nodejs.org/en/), any version is supported. +1. install [node](https://nodejs.org/en/), version v16 or higher. 1. install [mongodb](https://www.mongodb.com/try/download/community) (Community version) For the easiest installation, follow these steps: @@ -39,8 +39,7 @@ updates: 1. Click "OK" three times to close all the windows. 1. In the second command prompt, run "mongo", which allows you to edit the database. 1. Type `use homebrewery` to create The Homebrewery database. You should see `switched to db homebrewery`. - 1. Type `db.brews.insert({"title":"test"})` to create a blank document. You should see `WriteResult({ "nInserted" : 1 })`. - 1. If you use any version older than 6.0, use `db.brews.insertOne({"title":"test"})` instead. You should see `{ + 1. Type `db.brews.insertOne({"title":"test"})` to create a blank document. You should see `{ acknowledged: true, insertedId: ObjectId("63c2fce9e5ac5a94fe2410cf") }` @@ -57,7 +56,7 @@ git clone https://github.com/naturalcrit/homebrewery.git Second, you will need to add the environment variable `NODE_ENV=local` to allow the project to run locally. -You can set this **temporarily** in your shell of choice with admin privileges: +You can set this **temporarily** (until you close the terminal) in your shell of choice with admin privileges: * Windows Powershell: `$env:NODE_ENV="local"` * Windows CMD: `set NODE_ENV=local` * Linux / macOS: `export NODE_ENV=local` @@ -80,9 +79,8 @@ You should now be able to go to [http://localhost:8000](http://localhost:8000) in your browser and use The Homebrewery offline. If you had any issue at all, here are some links that may be useful: -- [Course](https://learn.mongodb.com/courses/m103-basic-cluster-administration) on cluster administration, in the mongodb web, useful for begginners +- [Course](https://learn.mongodb.com/courses/m103-basic-cluster-administration) on cluster administration, useful for begginners - [Mongo community forums](https://www.mongodb.com/community/forums/) -- After mongodb 6.0, which i reccomend, to run mongo commands, users will have to install MongoDB Shell [from this link](https://www.mongodb.com/try/download/shell). - Useful Stack Overflow links for your most probable errors: [1](https://stackoverflow.com/questions/44962540/mongod-and-mongo-commands-not-working-on-windows-10), [2](https://stackoverflow.com/questions/15053893/mongo-command-not-recognized-when-trying-to-connect-to-a-mongodb-server/41507803#41507803), [3](https://stackoverflow.com/questions/51224959/mongo-is-not-recognized-as-an-internal-or-external-command-operable-program-o) If you still have problems, post in [Our Subreddit](https://www.reddit.com/r/homebrewery/) and we will help you. From 4668d36a5222623edbc8591820fefe994531316d Mon Sep 17 00:00:00 2001 From: Trevor Buckner Date: Mon, 30 Jan 2023 14:40:13 -0500 Subject: [PATCH 5/7] typo --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index af7ea1d72..df7f41503 100644 --- a/README.md +++ b/README.md @@ -79,7 +79,7 @@ You should now be able to go to [http://localhost:8000](http://localhost:8000) in your browser and use The Homebrewery offline. If you had any issue at all, here are some links that may be useful: -- [Course](https://learn.mongodb.com/courses/m103-basic-cluster-administration) on cluster administration, useful for begginners +- [Course](https://learn.mongodb.com/courses/m103-basic-cluster-administration) on cluster administration, useful for beginners - [Mongo community forums](https://www.mongodb.com/community/forums/) - Useful Stack Overflow links for your most probable errors: [1](https://stackoverflow.com/questions/44962540/mongod-and-mongo-commands-not-working-on-windows-10), [2](https://stackoverflow.com/questions/15053893/mongo-command-not-recognized-when-trying-to-connect-to-a-mongodb-server/41507803#41507803), [3](https://stackoverflow.com/questions/51224959/mongo-is-not-recognized-as-an-internal-or-external-command-operable-program-o) From f628e1a5aea855fbcb27e60023ff0ae15c1953c9 Mon Sep 17 00:00:00 2001 From: Trevor Buckner Date: Mon, 30 Jan 2023 17:08:19 -0500 Subject: [PATCH 6/7] Use DEFAULT_BREW values instead of setting them here --- server/app.js | 16 +++++++++------- server/brewDefaults.js | 1 + 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/server/app.js b/server/app.js index 9f4550778..59aac2d9b 100644 --- a/server/app.js +++ b/server/app.js @@ -294,13 +294,15 @@ app.get('/edit/:id', asyncHandler(getBrew('edit')), (req, res, next)=>{ app.get('/new/:id', asyncHandler(getBrew('share')), (req, res, next)=>{ sanitizeBrew(req.brew, 'share'); splitTextStyleAndMetadata(req.brew); - req.brew.published = false; - req.brew.createdAt = clock.now; - req.brew.updatedAt = clock.now; - req.brew.views = 1; - req.brew.lastViewed = clock.now; - - req.brew.title = `CLONE - ${req.brew.title}`; + const brew = { + shareId : req.brew.shareId, + title : `CLONE - ${req.brew.title}`, + text : req.brew.text, + style : req.brew.style, + renderer : req.brew.renderer, + theme : req.brew.theme + }; + req.brew = _.defaults(brew, DEFAULT_BREW); req.ogMeta = { ...defaultMetaTags, title : 'New', diff --git a/server/brewDefaults.js b/server/brewDefaults.js index 092f7070a..30798cea7 100644 --- a/server/brewDefaults.js +++ b/server/brewDefaults.js @@ -16,6 +16,7 @@ const DEFAULT_BREW = { tags : [], systems : [], thumbnail : '', + views : 0, published : false, pageCount : 1, gDrive : false, From 4260f5197c392149a34eb39b911a990232a5ee2b Mon Sep 17 00:00:00 2001 From: Trevor Buckner Date: Mon, 30 Jan 2023 17:15:33 -0500 Subject: [PATCH 7/7] Update specs to expect a `views` prop from default brew --- server/homebrew.api.spec.js | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/server/homebrew.api.spec.js b/server/homebrew.api.spec.js index 71d9bdcc7..22f80155c 100644 --- a/server/homebrew.api.spec.js +++ b/server/homebrew.api.spec.js @@ -71,7 +71,8 @@ describe('Tests for api', ()=>{ lastViewed : new Date(), version : 1, pageCount : 1, - textBin : '' + textBin : '', + views : 0 }; googleBrew = { ...hbBrew, @@ -261,7 +262,8 @@ If you believe you should have access to this brew, ask the file owner to invite gDrive : false, style : undefined, trashed : false, - updatedAt : undefined + updatedAt : undefined, + views : 0 }); expect(next).toHaveBeenCalled(); expect(api.getId).toHaveBeenCalledWith(req); @@ -452,7 +454,8 @@ brew`); thumbnail : '', title : 'asdf', trashed : false, - updatedAt : undefined + updatedAt : undefined, + views : 0 }); }); @@ -510,7 +513,8 @@ brew`); thumbnail : '', title : 'asdf', trashed : false, - updatedAt : undefined + updatedAt : undefined, + views : 0 }); });