Skip to content

Commit

Permalink
Resolving conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
mrzapp committed Jan 14, 2020
2 parents 730c604 + ff95bba commit 2cf4c4b
Show file tree
Hide file tree
Showing 47 changed files with 611 additions and 431 deletions.
6 changes: 4 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@
*.swp
*.swo
.idea
node_modules/*
package-lock.json
/node_modules/*
/npm-debug.log
/package-lock.json
.sass-cache/*
/docker/db/*
/docker/remote
Expand All @@ -26,3 +27,4 @@ package-lock.json
!/public/js/setup.js
!/public/js/test.js
!/public/js/browser-check.js
/tmp/*
40 changes: 31 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
# HashBrown CMS
A free and open-source headless CMS built with Node.js and MongoDB

## NOTICE: Updating to v1.2
- The `/db` folder for the `mongodb` docker volume has been moved, along with all other docker related files, to the `/docker` folder. After you pull the latest changes, make sure to manually move your `/db` folder to `/docker/db` before you restart the container.
- The `/plugins` folder has been unversioned, so please remove all content in this directory (except for custom plugins you want to keep, of course)
## Getting started
- [Guides](http://hashbrowncms.org/guides)
- [API documentation](http://hashbrowncms.org/docs/api/)
- [Developer documentation](http://hashbrowncms.org/docs/src/)

## Installing HashBrown
First make sure you have these dependencies met:
Expand All @@ -16,7 +17,7 @@ First make sure you have these dependencies met:

Then clone the code and install the dependencies:
```
git clone https://github.com/HashBrownCMS/hashbrown-cms.git -b stable --single-branch --recursive
git clone https://github.com/HashBrownCMS/hashbrown-cms.git --recursive
cd ./hashbrown-cms
npm install
```
Expand All @@ -36,6 +37,7 @@ npm run watch:frontend
Using Docker:
```
npm run start:docker
npm run restart:docker
npm run watch:docker
npm run stop:docker
```
Expand All @@ -60,7 +62,7 @@ npm install
webpack
```

Remember to restart the server after updating (see "Running HashBrown" above)
Remember to stop and restart the server afterwards.

## Configuring MongoDB
Using environment variables:
Expand All @@ -86,9 +88,29 @@ Using `/config/database.cfg`
}
```

## Getting started
- [Guides](http://hashbrown.rocks/guides)
- [Documentation](http://hashbrown.rocks/docs)
## Plugins
The folder structure for plugins is like this:

```
/plugins
/[plugin-name]
package.json
/src
/Client
/index.js
/Server
/index.js
/template
/schema
/content
/field
```

Plugins follow the same file and namespace structure as the main codebase.

When developing plugins, use `npm run watch:frontend` to compile client-side code and `npm run watch:nodemon` or `npm run watch:docker` for server-side code.

When using Docker, issue the command `touch package.json` to reload the daemon (you might have to exit and re-enter the `npm run watch:docker` command depending on your OS).

## Contribute
If you'd like to contribute to HashBrown development, you can make a pull request to [our repo](https://github.com/HashBrownCMS/hashbrown-cms) or contact us about becoming a collaborator
Expand All @@ -97,4 +119,4 @@ If you'd like to contribute to HashBrown development, you can make a pull reques
Matrix: #hashbrowncms:matrix.org

## Report issues
If you have questions, bug reports or anything else of the sort, please use the [issue tracker](https://github.com/Putaitu/hashbrown-cms/issues)
If you have questions, bug reports or anything else of the sort, please use the [issue tracker](https://github.com/HashBrownCMS/hashbrown-cms/issues)
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "hashbrown-cms",
"repository": "https://github.com/HashBrownCMS/hashbrown-cms.git",
"version": "1.3.3",
"version": "1.3.4",
"description": "A free and open-source headless CMS",
"main": "hashbrown.js",
"scripts": {
Expand Down
9 changes: 9 additions & 0 deletions src/Client/Entity/View/DeployerEditor/DeployerEditorBase.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,15 @@ class DeployerEditorBase extends HashBrown.Entity.View.ViewBase {
this.def(Function, 'customTemplate', null);
}

/**
* Gets the placeholder
*
* @return {HTMLElement} Placeholder
*/
getPlaceholder(_, model, state) {
return _.div({class: 'deployer-editor loading'});
}

/**
* Fetch
*/
Expand Down
12 changes: 7 additions & 5 deletions src/Client/Entity/View/Field/FieldBase.js
Original file line number Diff line number Diff line change
Expand Up @@ -158,11 +158,13 @@ class FieldBase extends HashBrown.Entity.View.ViewBase {
*
* @return {HTMLElement} Placeholder
*/
getPlaceholder() {
let element = document.createElement('div');
element.className = 'field loading';

return element;
getPlaceholder(_, model, state) {
return _.div({class: 'field field--resource-reference-editor loading'},
_.div({class: 'field__key'},
_.div({class: 'field__key__label'}, model.label),
_.div({class: 'field__key__description'}, model.description)
)
);
}

/**
Expand Down
11 changes: 2 additions & 9 deletions src/Client/Entity/View/ListItem/PanelItem.js
Original file line number Diff line number Diff line change
Expand Up @@ -187,15 +187,8 @@ class PanelItem extends HashBrown.Entity.View.ListItem.ListItemBase {
*
* @return {HTMLElement} Placeholder
*/
getPlaceholder() {
let element = document.createElement('div');
element.className = 'list-item--panel-item loading';

let inner = document.createElement('div');
inner.className = 'list-item--panel-item__inner';


return element;
getPlaceholder(_, model, state) {
return _.div({class: 'list-item--panel-item loading'});
}
}

Expand Down
14 changes: 10 additions & 4 deletions src/Client/Entity/View/Modal/ContentPublishingSettings.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,17 @@ class ContentPublishingSettings extends HashBrown.Entity.View.Modal.ModalBase {
* Event: Click OK
*/
async onClickOK() {
await HashBrown.Service.ResourceService.set('content', this.model.id, this.model);

HashBrown.Service.EventService.trigger('settings', this.model.id);
try {
await HashBrown.Service.ResourceService.set('content', this.model.id, this.model);

HashBrown.Service.EventService.trigger('settings', this.model.id);

this.close();
this.close();

} catch(e) {
this.setErrorState(e);

}
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/Client/Entity/View/Navigation/ResourceBrowser.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ class ResourceBrowser extends HashBrown.Entity.View.Navigation.NavigationBase {

for(let panel of Object.values(HashBrown.Entity.View.Panel)) {
if(panel === HashBrown.Entity.View.Panel.PanelBase) { continue; }
if(!HashBrown.Context.user.hasScope(HashBrown.Context.projecId, panel.category)) { continue; }
if(!HashBrown.Context.user.hasScope(HashBrown.Context.projectId, panel.category)) { continue; }

this.state.panels.push(panel);

Expand Down
7 changes: 2 additions & 5 deletions src/Client/Entity/View/Panel/PanelBase.js
Original file line number Diff line number Diff line change
Expand Up @@ -457,11 +457,8 @@ class PanelBase extends HashBrown.Entity.View.ViewBase {
*
* @return {HTMLElement} Placeholder
*/
getPlaceholder() {
let element = document.createElement('div');
element.className = 'panel loading';

return element;
getPlaceholder(_, model, state) {
return _.div({class: 'panel loading'});
}
}

Expand Down
9 changes: 9 additions & 0 deletions src/Client/Entity/View/ProcessorEditor/ProcessorEditorBase.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,15 @@ class ProcessorEditorBase extends HashBrown.Entity.View.ViewBase {

this.def(Function, 'customTemplate', null);
}

/**
* Gets the placeholder
*
* @return {HTMLElement} Placeholder
*/
getPlaceholder(_, model, state) {
return _.div({class: 'processor-editor loading'});
}

/**
* Fetch
Expand Down
27 changes: 9 additions & 18 deletions src/Client/Entity/View/ResourceEditor/ResourceEditorBase.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,23 +29,12 @@ class ResourceEditorBase extends HashBrown.Entity.View.ViewBase {
*
* @return {HTMLElement} Placeholder
*/
getPlaceholder() {
let element = document.createElement('div');
element.className = 'resource-editor loading';

let header = document.createElement('div');
header.className = 'resource-editor__header';
element.appendChild(header);

let body = document.createElement('div');
body.className = 'resource-editor__body';
element.appendChild(body);

let footer = document.createElement('div');
footer.className = 'resource-editor__footer';
element.appendChild(footer);

return element;
getPlaceholder(_, model, state) {
return _.div({class: 'resource-editor loading'},
_.div({class: 'resource-editor__header'}),
_.div({class: 'resource-editor__body'}),
_.div({class: 'resource-editor__footer'})
);
}

/**
Expand Down Expand Up @@ -163,7 +152,9 @@ class ResourceEditorBase extends HashBrown.Entity.View.ViewBase {
await HashBrown.Service.ResourceService.heartbeat(this.model);

} catch(e) {
UI.error(e);
if(e && e.message) {
debug.error(e, this, true);
}

} finally {
setTimeout(() => {
Expand Down
2 changes: 1 addition & 1 deletion src/Client/Entity/View/ViewBase.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class ViewBase extends require('Common/Entity/View/ViewBase') {
* Initialise
*/
async init() {
this.element = this.getPlaceholder();
this.element = this.getPlaceholder(this.scope(), this.model || {}, this.state || {});

await this.update();

Expand Down
7 changes: 2 additions & 5 deletions src/Client/Entity/View/Widget/Media.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,8 @@ class Media extends HashBrown.Entity.View.Widget.WidgetBase {
*
* @return {HTMLElement} Placeholder
*/
getPlaceholder() {
let element = document.createElement('div');
element.className = 'widget--media__placeholder';

return element;
getPlaceholder(_, model, state) {
return _.div({class: 'widget--media__placeholder'});
}

/**
Expand Down
6 changes: 2 additions & 4 deletions src/Common/Entity/Resource/User.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ class User extends HashBrown.Entity.Resource.ResourceBase {
* @returns {Boolean} hasScope
*/
hasScope(project, scope) {
if(this.isAdmin || scope === 'content' || scope === 'media') { return true; }
if(this.isAdmin) { return true; }

if(!project) { return false; }
if(!scope && !this.scopes[project]) { return false; }
Expand All @@ -77,9 +77,7 @@ class User extends HashBrown.Entity.Resource.ResourceBase {
this.scopes[project] = [];
}

if(!scope) {
return true;
}
if(!scope || scope === 'content' || scope === 'media') { return true; }

return this.scopes[project].indexOf(scope) > -1;
}
Expand Down
6 changes: 6 additions & 0 deletions src/Common/Service/DebugService.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@ class DebugService {
* @param {String} type
*/
static onLog(dateString, senderString, message, type) {
if(!message) {
if(!type) { return; }

message = 'An unexpected ' + type + ' happened.';
}

if(type) {
message = '[' + type.toUpperCase() + '] ' + message;
}
Expand Down
19 changes: 18 additions & 1 deletion src/Common/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,13 @@ base.namespace = function namespace(query) {
});

let add = (module) => {
current[module.name] = module;
if(current[module.name]) {
debug.error(new Error(`A module with name "${module.name}" already exists within the "${query}" namespace, skipping load`), module, true);

} else {
current[module.name] = module;

}

return { add: add };
};
Expand Down Expand Up @@ -76,3 +82,14 @@ base.checkParam = (value, name, type, notNull = false) => {
console.trace();
throw new TypeError('Parameter "' + name + '" is of type "' + valueTypeName + '", should be "' + type.name + '". Value was: ' + (valueTypeName === 'Object' ? JSON.stringify(value) : value.toString()));
}

/**
* Waits for N seconds
*
* @param {Number} seconds
*/
base.waitForSeconds = (seconds) => {
return new Promise((resolve) => {
setTimeout(resolve, seconds * 1000);
});
}
9 changes: 7 additions & 2 deletions src/Server/Controller/ApiController.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,15 +68,20 @@ class ApiController extends HashBrown.Controller.ControllerBase {

// Using authentication
if(settings.authenticate !== false) {
req.user = await this.authenticate(token, req.project, settings.scope, settings.needsAdmin);
req.user = await this.authenticate(token);
}

// Disregarding project parameter, but using authentication
} else if(settings.authenticate !== false) {
req.user = await this.authenticate(token, null, settings.scope, settings.needsAdmin);

}


// If a user is specified, authorise it
if(req.user) {
this.authorize(req.user, req.project, settings.scope, settings.needsAdmin);
}

next();

} catch(e) {
Expand Down
Loading

0 comments on commit 2cf4c4b

Please sign in to comment.