Skip to content
This repository has been archived by the owner on Aug 28, 2021. It is now read-only.

Commit

Permalink
adds a "serveSource" optional parameter for plugins (ie, specify a re…
Browse files Browse the repository at this point in the history
…lative directory from which to source the plugin inside its root dir, such as 'dist')
  • Loading branch information
didimitrie committed Dec 20, 2018
1 parent 95ceac9 commit 43ab322
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 5 deletions.
2 changes: 1 addition & 1 deletion app/api/streams/StreamDuplicate.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 5 additions & 1 deletion models/DataStream.js
Original file line number Diff line number Diff line change
Expand Up @@ -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: {} },
Expand All @@ -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 )
6 changes: 4 additions & 2 deletions plugins.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 )
Expand Down
2 changes: 1 addition & 1 deletion server.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 43ab322

Please sign in to comment.