Marvin Live developer guide - export plugins

Marvin Live export plugins add new report file format or report storage locations. These plugins are NodeJS modules, stored in a folder set by Marvin Live’s configuration file.

Prerequisites

  • an instance of Marvin Live available for development purposes, i.e.: the ability to stop and start it, to try different configuration options

  • familiarity with JavaScript, NodeJS and its module system

  • good understanding of Promises

Export plugins

This plugin type is intended to save important information from a discussion room, to files such as a powerpoint document saved to the local machine.

Life-cycle

Marvin Live scans the services directory to find all export plugins and generates a GUI element to execute them. There is 1 instance of a plugin per domain.

images/download/attachments/49831602/developer_guide_-_export_plugins.png

Specification

Export plugins are NodeJS modules , denoted by their filename: *.export.js and the location in the services directory as configured during installation.

An export plugin exports the following required properties:

Name

Type

Description

generate

function

The main function of the plugin, called when the sketcher is used, once for each change. The function must return a Promise of the results. The results are broadcasted by the application.

Arguments:

  • meetingData (Object) data structure containing structures and comments. See specification below.

  • this includes domain and roomName for the current call

Return value: Promise

The fulfillment value of the promise must be a String when returnType is set to message, and it must be a Buffer, Stream or String when returnType equals file.

name

string

Unique identifier of the plugin, used by Marvin Live for identification and internal communication. If multiple plugins use the same identifier, the last one to be loaded overrides the others.

label

string

Human readable name of the plugin, used by Marvin Live to display GUI elements related to this plugin.

domains

array of strings

List of domains where this plugin may be used, when authentication is enabled in Marvin Live. Use * to allow any domain. If no authentication is setup, this option has no effect. To query the configured domains, send a GET request to /domains or open /domains in your browser.

returnType

string

Configures the application to expect a file or a text message when the generate() promise is resolved. Files are downloaded to the client browser, text messages are displayed in a dialog.

Values: file or message

Required: no

Default: file

fileName

string

Suggested file name when the download prompt appears in the browser. Only used when returnType is set to file . It’s possible to use variables that are replaced automatically when creating the file.

%roomName% - name of the discussion room
%domain% - name of the authentication domain
%downloadDate% - current date formatted as YYYY-mm-dd
%roomCreateDate% - room creation date formatted as YYYY-mm-dd
%lastActivityDate% - date of last activity in the room, formatted as YYYY-mm-dd
%serviceName% - name of this plugin

Default: mlreport-%roomName%.%serviceName%

Meeting data specification

Below is an example of the meeting data object, with inline description of the individual attributes for structures and comments.

{
 //Array of objects of all structures drawn in this room
 "structures": [
   {
     //String, mrv source of the chemical structure
     "structure": "<cml><MDocument>...</MDocument></cml>",
     //String, base64 encoded PNG image at 500x400
     "image": "data:image/png;base64,iVBORw0KG...5CYII=",
     //String, display name of the author of this structure
     "author": "Susan",
     //boolean, indicates whether this structure is a snapshot
     "snapshot": true,
     //Number, millisecond resolution UNIX timestamp of the authoring
     //of this structure
     "timestamp": 1436786661609,
     //String, uploaded or drawn, indicates the source of this item
     "type": "uploaded",
     //String, action item given when making this snapshot
     //undefined for non-snapshots
     "task": "check IP by Friday",
     //Array of objects, comments assigned to this snapshot
     //undefined for non-snapshots
     "comments": [
       {
         "message": "this looks like an interesting compound",
         "author": "Wilhelm",
         "timestamp": 1436879124086
       },
       ...
     ],
     //Object, key-value data returned by real time plugins for "reports"
     "data": {
       //key: String, label of real time plugin
       //value: Object, key-value pairs of data returned
       "Calculated Properties": {
         "Mass": 344.43,
         "cLogP": 1.74
       }
     }
   },
   ...
 ],
 //Array of objects, all comments made in this room
 "comments": [
   {
     //String, text content of this message
     "message": "this looks like an interesting compound",
     //String, display name of the author of this message
     "author": "Michael",
     //Number, millisecond resolution UNIX timestamp of this message
     "timestamp": 1436879124086
   },
   ...
 ]
}