Skip to content

Commit

Permalink
Merge branch 'master' into stable
Browse files Browse the repository at this point in the history
  • Loading branch information
jz committed May 2, 2018
2 parents 04dd938 + 84887c6 commit 5cd49b9
Show file tree
Hide file tree
Showing 6 changed files with 55 additions and 37 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ First make sure you have these dependencies met:

Then checkout and run HashBrown:
```
git clone https://github.com/Putaitu/hashbrown-cms.git -b stable --single-branch --recursive
git clone https://github.com/HashBrownCMS/hashbrown-cms.git -b stable --single-branch --recursive
cd ./hashbrown-cms
npm install --production
node hashbrown.js
Expand All @@ -31,7 +31,7 @@ npm install --production
- [Documentation](http://hashbrown.rocks/docs)

## Contribute
If you'd like to contribute to HashBrown development, you can make a pull request to [our repo](https://github.com/Putaitu/hashbrown-cms) or contact us about becoming a collaborator
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

## Ask a question
Here: [/r/HashBrownCMS/](https://www.reddit.com/r/HashBrownCMS/)
Expand Down
41 changes: 41 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
####################
# A docker compose config for HashBrown CMS
#
# For this to work, please create a database.cfg file in the /config/ directory
# The contents of the file should look like this: { "url": "mongodb" }
####################

version: "3.4"

volumes:
v-hashbrown-mongodb: ~
v-hashbrown-storage: ~

networks:
n-hashbrown: ~

services:
node:
image: node:alpine
ports:
- "8080:8080"
depends_on:
- mongodb
networks:
- n-hashbrown
restart: unless-stopped
command: "node /opt/hashbrown-cms"
volumes:
- "./:/opt/hashbrown-cms"
- "v-hashbrown-storage:/opt/hashbrown-cms/storage"
- "/etc/localtime:/etc/localtime:ro"

mongodb:
image: mongo
networks:
- n-hashbrown
restart: unless-stopped
volumes:
- "v-hashbrown-mongodb:/data/db"
- "v-hashbrown-storage:/opt/hashbrown-cms/storage"
- "/etc/localtime:/etc/localtime:ro"
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/Putaitu/hashbrown-cms.git",
"version": "1.0.5",
"version": "1.0.6",
"description": "The pluggable CMS",
"main": "hashbrown.js",
"scripts": {
Expand Down
33 changes: 4 additions & 29 deletions src/Server/Controllers/ViewController.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,38 +63,13 @@ class ViewController extends Controller {

// First time setup
app.get('/setup/:step', (req, res) => {
let check = () => {
switch(parseInt(req.params.step)) {
case 1:
return ConfigHelper.exists('database')
.then((exists) => {
if(!exists) {
return Promise.resolve();
}

return Promise.reject(new Error('Database config exists already'));
});

case 2:
return UserHelper.getAllUsers()
.then((users) => {
if(!users || users.length < 1) {
return Promise.resolve();
}

return Promise.reject(new Error('Cannot create first admin, users already exist. If you lost your credentials, please assign the the admin from the commandline.'));
});
return UserHelper.getAllUsers()
.then((users) => {
if(users && users.length > 0) {
return res.status(400).render('error', { message: 'Cannot create first admin, users already exist. If you lost your credentials, please assign the the admin from the commandline.' });
}

return Promise.reject(new Error('No such step "' + req.params.step + '"'));
};

check()
.then(() => {
res.render('setup', { step: req.params.step });
})
.catch((e) => {
res.status(400).render('error', { message: e.message });
});
});

Expand Down
4 changes: 4 additions & 0 deletions src/Server/Helpers/DatabaseHelper.js
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,8 @@ class DatabaseHelper {

args.push('--archive=' + dumpPath + '/' + timestamp + '.hba');

debug.log('Dumping database "' + databaseName + '" to ' + dumpPath + '/' + timestamp + '.hba...', this);

let mongodump = Spawn('mongodump', args);

mongodump.stdout.on('data', (data) => {
Expand All @@ -183,9 +185,11 @@ class DatabaseHelper {

mongodump.on('exit', (code) => {
if(code != 0) {
debug.log('Dumping database failed!', this);
reject(new Error('mongodump exited with status code ' + code));

} else {
debug.log('Dumping database succeeded!', this);
resolve(timestamp);

}
Expand Down
8 changes: 3 additions & 5 deletions src/Server/Views/setup.pug
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,10 @@ html

form(class='page--setup__step page--setup__step-' + step, data-step=step, action='/api/user/first')
.page--setup__step__heading
if(step == 1)
h2 Create your first admin account
h2 Create your first admin account
.page--setup__step__body
if(step == 1)
input.widget.widget--input.tall.expanded.text(required=true, title='Your username', type='text', name='username', placeholder='Username')
input.widget.widget--input.tall.expanded.text(required=true, title='Your password', type='password', name='password', placeholder='Password')
input.widget.widget--input.tall.expanded.text(required=true, title='Your username', type='text', name='username', placeholder='Username')
input.widget.widget--input.tall.expanded.text(required=true, title='Your password', type='password', name='password', placeholder='Password')

input.widget.widget--button.expanded(type='submit', value='Next')

Expand Down

0 comments on commit 5cd49b9

Please sign in to comment.