Skip to content

Commit

Permalink
Changing file and image save path to Docker container persistant /pub…
Browse files Browse the repository at this point in the history
…lic folder.
  • Loading branch information
christroutner committed Aug 10, 2017
1 parent f556ece commit f1f0566
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 14 deletions.
22 changes: 10 additions & 12 deletions keystone-files/keystone.js
Expand Up @@ -18,9 +18,9 @@ keystone.init({
'name': 'keystone4',
'brand': 'ConnextCMS',

'less': '../public',
'static': '../public',
'favicon': '../public/favicon.ico',
'less': 'public',
'static': 'public',
'favicon': 'public/favicon.ico',
'views': 'templates/views',
'view engine': 'hbs',
'port': 3000,
Expand All @@ -37,7 +37,8 @@ keystone.init({
'session': true,
'auth': true,
'user model': 'User',
'file limit': '50MB'
'file limit': '50MB',
'mongo': 'mongodb://172.17.0.1:3500/connextcms'
});

// Load your project's Models
Expand Down Expand Up @@ -73,35 +74,32 @@ keystone.set('nav', {
//Admins can access the API and only the ConnextCMS Dashboard.
//keystone.set('superusers', ['57c88289144da4ea0dc979db']);
//keystone.set('admins', ['57c88289144da4ea0dc979db']);

//This function reads in the publicsettings.json file and sets the list of admins and superusers.
fs.readFile('../public/js/publicsettings.json', 'utf8', function(err, data) {
fs.readFile('public/js/publicsettings.json', 'utf8', function(err, data) {
//debugger;

if(err) {
console.log('Error in keystone.js while trying to read publicsettings.json file.');
console.log(err);
} else {

var publicSettings = JSON.parse(data);

if(typeof(publicSettings.superUsers) == "string") {
keystone.set('superusers', [publicSettings.superUsers]);
} else {
keystone.set('superusers', publicSettings.superUsers);
}

if(typeof(publicSettings.adminUsers) == "string") {
keystone.set('admins', [publicSettings.adminUsers]);
} else {
keystone.set('admins', publicSettings.adminUsers);
}

// Start Keystone to connect to your database and initialise the web server
// Need to be inside the readFile function handler.
keystone.start();
}
});



2 changes: 1 addition & 1 deletion public/js/app/views/fileLibraryView.js
Expand Up @@ -248,7 +248,7 @@ define([
//debugger;
$('#control-sidebar-home-tab').empty();

var wrapperHeight = $('.content-wrapper').height();
//var wrapperHeight = $('.content-wrapper').height();

console.log($('.wrapper').height());
$('#control-sidebar-home-tab').css('overflow-y', 'scroll');
Expand Down
12 changes: 11 additions & 1 deletion routes/api/imageupload.js
Expand Up @@ -116,6 +116,16 @@ exports.create = function(req, res) {

if (err) return res.apiError('error', err);

//Copy the file to the local public directory
exec('cp ../public'+item.url+' public/uploads/images/', function(err, stdout, stderr) {
if (err) {
console.log('child process exited with error code ' + err.code);
console.log('Warning: Could not copy image to local public directory. Issue with routes/api/imageupload.js/create().')
return;
}
console.log(stdout);
});

res.apiResponse({
image_upload: item
});
Expand Down Expand Up @@ -165,7 +175,7 @@ exports.remove = function(req, res) {
exec('rm ../public'+item.url, function(err, stdout, stderr) {
if (err) {
console.log('child process exited with error code ' + err.code);
console.log('Warning: Could not delete image from hard drive. Issue with routes/api/imageupload.js.')
console.log('Warning: Could not delete image from hard drive. Issue with routes/api/imageupload.js/remove().')
return;
}
console.log(stdout);
Expand Down

0 comments on commit f1f0566

Please sign in to comment.