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 / async await

    {info} NodeJS introduction material: https://www.youtube.com/watch?v=_l96hPlqzcI (78m), https://www.youtube.com/watch?v=hKQr2DGJjUQ (19m), https://www.youtube.com/watch?v=cJVXP1bU68Y (48m)

    NodeJS module description: https://nodejs.org/api/modules.htmlPromise introduction: https://www.html5rocks.com/en/tutorials/es6/promises/#toc-async, https://github.com/kriskowal/q#readme

    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/20424051/developer_guide_-_export_plugins.png

    Specification

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

    An export plugin exports the following required properties:

    Name Type Description
    generate async 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 / be declared as an async function. The results are broadcasted by the application.Arguments: meetingData (Object) data structure containing structures and comments. See specification below. thisincludes domain and roomName for the current callReturn value: PromiseThe fulfillment value of the promise 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 GETrequest 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 messageRequired: noDefault: 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 pluginDefault: mlreport-%roomName%.%serviceName%
    templateFile string Relative path to an HTML template, when returnType equals message. The template is injected into the room’s interface as a dialog. The templating language is Angular JS, which should allow interpolating formatted numbers or easily enumerating a list. The result of the generate call is made available as the client variable inside the template fragment.

    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 snapshots saved in this room
     "snapshots": [
       {
         //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",
         //Number, millisecond resolution UNIX timestamp of the authoring
         //of this structure
         "timestamp": 1436786661609,
         //Object, key-value data provided by users for the configured "snapshotFields"
         "additionalFields": {
           "Task": "check IP by Friday",
           "Status": "On hold"
         },
         //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
       },
       ...
     ]
    }

    Examples

    You can find a brief selection of plugins in our Github repository: CSV exporter, SMILES, SDF v3000 and IDBS E-workbook exporter