From 43ab322e5c614289553375df2e5d44ac128492d9 Mon Sep 17 00:00:00 2001 From: Dimitrie Stefanescu Date: Thu, 20 Dec 2018 19:47:01 +0000 Subject: [PATCH] adds a "serveSource" optional parameter for plugins (ie, specify a relative directory from which to source the plugin inside its root dir, such as 'dist') --- app/api/streams/StreamDuplicate.js | 2 +- models/DataStream.js | 6 +++++- plugins.js | 6 ++++-- server.js | 2 +- 4 files changed, 11 insertions(+), 5 deletions(-) diff --git a/app/api/streams/StreamDuplicate.js b/app/api/streams/StreamDuplicate.js index 0cecaac6..fb913a71 100644 --- a/app/api/streams/StreamDuplicate.js +++ b/app/api/streams/StreamDuplicate.js @@ -23,7 +23,7 @@ module.exports = ( req, res ) => { clone.streamId = shortId.generate() clone.parent = stream.streamId clone.children = [ ] - clone.name += ' Clone' + clone.name = req.body.name ? req.body.name : clone.name + ' (clone)' clone.createdAt = new Date() clone.updatedAt = new Date() clone.private = stream.private diff --git a/models/DataStream.js b/models/DataStream.js index e7bce991..31f66c34 100644 --- a/models/DataStream.js +++ b/models/DataStream.js @@ -16,6 +16,7 @@ var dataStreamSchema = mongoose.Schema( { name: { type: String, default: 'Speckle Stream' }, description: { type: String, default: 'This is a simple speckle stream.' }, + commitMessage: { type: String }, tags: [ { type: String } ], baseProperties: { type: Object, default: {} }, @@ -35,8 +36,11 @@ var dataStreamSchema = mongoose.Schema( { children: { type: Array, default: [ ] }, ancestors: { type: Array, default: [ ] }, - deleted: { type: Boolean, default: false } + deleted: { type: Boolean, default: false }, + // keeps track wether this stream can be edited from the online ui or not. + // it's set by default to NOPE + onlineEditable: { type: Boolean, default: false } }, { timestamps: true, strict: false } ) module.exports = mongoose.model( 'DataStream', dataStreamSchema ) diff --git a/plugins.js b/plugins.js index 395e4f64..fe04a150 100644 --- a/plugins.js +++ b/plugins.js @@ -20,19 +20,21 @@ module.exports = ( ) => { } ) // read in manifest files - let plugins = [] + let plugins = [ ] pluginDirs.forEach( dir => { let file = path.normalize( `${dir}//speckle-plugin-manifest.json` ) if ( fs.existsSync( file ) ) { let obj = JSON.parse( fs.readFileSync( file, 'utf8' ) ) obj.sourceDir = dir + if ( obj.serveSource ) + obj.serveSource = path.normalize( `${dir}//${obj.serveSource}` ) plugins.push( obj ) } else winston.warn( `No plugin manifest file found in ${dir}.` ) } ) // check for conflicts - let serveLocations = [] + let serveLocations = [ ] plugins.forEach( pl => { if ( serveLocations.indexOf( pl.serveFrom ) < 0 ) serveLocations.push( pl.serveFrom ) diff --git a/server.js b/server.js index 2d96f827..24e1a886 100644 --- a/server.js +++ b/server.js @@ -100,7 +100,7 @@ if ( cluster.isMaster ) { // register plugins with express plugins.forEach( plugin => { - app.use( plugin.serveFrom, express.static( path.join( __dirname, plugin.sourceDir ) ) ) + app.use( plugin.serveFrom, express.static( path.join( __dirname, plugin.serveSource ? plugin.serveSource : plugin.sourceDir ) ) ) } ) // expose an api