Skip to content

Commit

Permalink
Merge branch 'master' into addUserInfo-naturalcrit#1908
Browse files Browse the repository at this point in the history
  • Loading branch information
G-Ambatte committed Feb 19, 2023
2 parents d62fb1e + fe5e91c commit 52e475d
Show file tree
Hide file tree
Showing 50 changed files with 5,300 additions and 4,367 deletions.
6 changes: 6 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,15 @@ jobs:
at: .

# run tests!
- run:
name: Test - API Unit Tests
command: npm run test:api-unit
- run:
name: Test - Basic
command: npm run test:basic
- run:
name: Test - Coverage
command: npm run test:coverage
- run:
name: Test - Mustache Spans
command: npm run test:mustache-span
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,5 @@ todo.md
startDB.bat
startMViewer.bat
.vscode

coverage
32 changes: 26 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,24 +21,29 @@ 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/), version v16 or higher.
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.insertOne({"title":"test"})` to create a blank document. 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]):
Expand All @@ -51,11 +56,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** (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`

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:

Expand All @@ -65,6 +78,13 @@ 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, 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)

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)
Expand Down
53 changes: 38 additions & 15 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,42 +52,65 @@ pre {
font-family: 'Open Sans';
font-size: 0.9em;
}

.page {
padding-bottom: 1.5cm;
}
```

## changelog
For a full record of development, visit our [Github Page](https://github.com/naturalcrit/homebrewery).

### Friday 23/12/2022 - v3.5.0
### Saturday 18/02/2023 - v3.6.1
{{taskList
##### G-Ambatte

##### Jeddai

* [x] Only brew owners or invited authors can edit a brew

- Visiting an `/edit` page of a brew that does not list you as an author will result in an error page. Authors can be added to any brew by opening its {{fa,fa-info-circle}} **Properties** menu and typing the author's username (case-sensitive) into the **Invited Authors** bubble.
- Warn user if a newer brew version has been saved on another device
* [x] Fix users not being removed from Authors list correctly

Fixes issues [#1987](https://github.com/naturalcrit/homebrewery/issues/1987)
Fixes issues [#2674](https://github.com/naturalcrit/homebrewery/issues/2674)
}}

\page

### Monday 05/12/2022 - v3.4.1
### Friday 23/01/2023 - v3.6.0
{{taskList
##### calculuschild

* [x] Fix Google Drive brews sometimes duplicating

Fixes issues [#2603](https://github.com/naturalcrit/homebrewery/issues/2603)

##### Jeddai

* [x] Add unit tests with full coverage for the Homebrewery API

* [x] Add message to refresh the browser if the user is missing an update to the Homebrewery

Fixes issues [#2583](https://github.com/naturalcrit/homebrewery/issues/2583)

##### G-Ambatte

* [x] Fix Account page incorrect last login time
* [x] Auto-compile Themes CSS on development server

Fixes issues [#2521](https://github.com/naturalcrit/homebrewery/issues/2521)
##### 5e-Cleric

##### Gazook
* [x] Fix cloned brews inheriting the parent view count
}}

* [x] Fix crashing on iOS and Safari browsers
### Friday 23/12/2022 - v3.5.0
{{taskList

Fixes issues [#2531](https://github.com/naturalcrit/homebrewery/issues/2531)
##### Jeddai

* [x] Only brew owners or invited authors can edit a brew

- Visiting an `/edit` page of a brew that does not list you as an author will result in an error page. Authors can be added to any brew by opening its {{fa,fa-info-circle}} **Properties** menu and typing the author's username (case-sensitive) into the **Invited Authors** bubble.
- Warn user if a newer brew version has been saved on another device

Fixes issues [#1987](https://github.com/naturalcrit/homebrewery/issues/1987)
}}

\page

### Saturday 10/12/2022 - v3.4.2
{{taskList

Expand Down
2 changes: 1 addition & 1 deletion client/homebrew/brewRenderer/brewRenderer.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ const BrewRenderer = createClass({

renderStyle : function() {
if(!this.props.style) return;
return <div style={{ display: 'none' }} dangerouslySetInnerHTML={{ __html: `<style> ${this.props.style} </style>` }} />;
return <div style={{ display: 'none' }} dangerouslySetInnerHTML={{ __html: `<style>@layer styleTab {\n${this.props.style}\n} </style>` }} />;
},

renderPage : function(pageText, index){
Expand Down
4 changes: 3 additions & 1 deletion client/homebrew/editor/editor.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ const Editor = createClass({
onTextChange : ()=>{},
onStyleChange : ()=>{},
onMetaChange : ()=>{},
reportError : ()=>{},

renderer : 'legacy'
};
Expand Down Expand Up @@ -291,7 +292,8 @@ const Editor = createClass({
rerenderParent={this.rerenderParent} />
<MetadataEditor
metadata={this.props.brew}
onChange={this.props.onMetaChange} />
onChange={this.props.onMetaChange}
reportError={this.props.reportError}/>
</>;
}
},
Expand Down
21 changes: 15 additions & 6 deletions client/homebrew/editor/metadataEditor/metadataEditor.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const React = require('react');
const createClass = require('create-react-class');
const _ = require('lodash');
const cx = require('classnames');
const request = require('superagent');
const request = require('../../utils/request-middleware.js');
const Nav = require('naturalcrit/nav/nav.jsx');
const StringArrayEditor = require('../stringArrayEditor/stringArrayEditor.jsx');

Expand Down Expand Up @@ -37,7 +37,8 @@ const MetadataEditor = createClass({
renderer : 'legacy',
theme : '5ePHB'
},
onChange : ()=>{}
onChange : ()=>{},
reportError : ()=>{}
};
},

Expand Down Expand Up @@ -121,8 +122,12 @@ const MetadataEditor = createClass({

request.delete(`/api/${this.props.metadata.googleId ?? ''}${this.props.metadata.editId}`)
.send()
.end(function(err, res){
window.location.href = '/';
.end((err, res)=>{
if(err) {
this.props.reportError(err);
} else {
window.location.href = '/';
}
});
},

Expand Down Expand Up @@ -184,6 +189,10 @@ const MetadataEditor = createClass({
return <div className='item' key={''} onClick={()=>this.handleTheme(theme)} title={''}>
{`${theme.renderer} : ${theme.name}`}
<img src={`/themes/${theme.renderer}/${theme.path}/dropdownTexture.png`}/>
<div className='preview'>
<h6>{`${theme.name}`} preview</h6>
<img src={`/themes/${theme.renderer}/${theme.path}/dropdownPreview.png`}/>
</div>
</div>;
});
};
Expand All @@ -193,14 +202,14 @@ const MetadataEditor = createClass({

if(this.props.metadata.renderer == 'legacy') {
dropdown =
<Nav.dropdown className='disabled' trigger='disabled'>
<Nav.dropdown className='disabled value' trigger='disabled'>
<div>
{`Themes are not supported in the Legacy Renderer`} <i className='fas fa-caret-down'></i>
</div>
</Nav.dropdown>;
} else {
dropdown =
<Nav.dropdown trigger='click'>
<Nav.dropdown className='value' trigger='click'>
<div>
{`${_.upperFirst(currentTheme.renderer)} : ${currentTheme.name}`} <i className='fas fa-caret-down'></i>
</div>
Expand Down
53 changes: 39 additions & 14 deletions client/homebrew/editor/metadataEditor/metadataEditor.less
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
flex-direction: column;
flex: 5 0 200px;
gap: 10px;

}
.field{
display : flex;
Expand Down Expand Up @@ -159,7 +158,6 @@
font-size : 13.33px;
.navDropdownContainer {
background-color : white;
width : 100%;
position : relative;
z-index : 500;
&.disabled {
Expand All @@ -182,24 +180,51 @@
}
.navDropdown {
box-shadow : 0px 5px 10px rgba(0, 0, 0, 0.3);
position : absolute;
width : 100%;
position : absolute;
width : 100%;
.item {
padding : 3px 3px;
border-top : 1px solid rgb(118, 118, 118);
position : relative;
overflow : hidden;
padding : 3px 3px;
border-top : 1px solid rgb(118, 118, 118);
position : relative;
overflow : visible;
background-color : white;
.preview {
display : flex;
flex-direction: column;
background : #ccc;
border-radius : 5px;
box-shadow : 0 0 5px black;
width : 200px;
color :black;
position : absolute;
top : 0;
right : 0;
opacity : 0;
transition : opacity 250ms ease;
z-index : 1;
overflow :hidden;
h6 {
font-weight : 900;
padding-inline:1em;
padding-block :.5em;
border-bottom :2px solid hsl(0,0%,40%);
}
}
&:hover {
background-color : @blue;
color : white;
color : white;
}
&:hover > .preview {
opacity: 1;
}
img {
mask-image : linear-gradient(90deg, transparent, black 20%);
>img {
mask-image : linear-gradient(90deg, transparent, black 20%);
-webkit-mask-image : linear-gradient(90deg, transparent, black 20%);
position : absolute;
left : ~"max(100px, 100% - 300px)";
top : 0px;
position : absolute;
right : 0;
top : 0px;
width : 50%;
height : 100%;
}
}
}
Expand Down
17 changes: 12 additions & 5 deletions client/homebrew/editor/snippetbar/snippetbar.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -163,15 +163,22 @@ const SnippetGroup = createClass({
onSnippetClick : function(){},
};
},
handleSnippetClick : function(snippet){
handleSnippetClick : function(e, snippet){
e.stopPropagation();
this.props.onSnippetClick(execute(snippet.gen, this.props.brew));
},
renderSnippets : function(){
return _.map(this.props.snippets, (snippet)=>{
return <div className='snippet' key={snippet.name} onClick={()=>this.handleSnippetClick(snippet)}>
renderSnippets : function(snippets){
return _.map(snippets, (snippet)=>{
return <div className='snippet' key={snippet.name} onClick={(e)=>this.handleSnippetClick(e, snippet)}>
<i className={snippet.icon} />
{snippet.name}
{snippet.subsnippets && <>
<i className='fas fa-caret-right'></i>
<div className='dropdown side'>
{this.renderSnippets(snippet.subsnippets)}
</div></>}
</div>;

});
},

Expand All @@ -182,7 +189,7 @@ const SnippetGroup = createClass({
<span className='groupName'>{this.props.groupName}</span>
</div>
<div className='dropdown'>
{this.renderSnippets()}
{this.renderSnippets(this.props.snippets)}
</div>
</div>;
},
Expand Down
Loading

0 comments on commit 52e475d

Please sign in to comment.