<commit_before>'use strict'

function LoginWorld() {
    this.__init__()
}

LoginWorld.prototype = {

    scene: null,

    player: null,

    username_label: null,
    username_field: null,
    password_label: null,
    password_field: null,

    set_player_look_at: null,

    __init__: function() {
        // Create the scene.
        this.scene = new THREE.Scene()

        // Going to try to create a plane here.
        var plane_geometry = new THREE.PlaneGeometry(2000, 2000, 100, 100)
        plane_geometry.applyMatrix(new THREE.Matrix4().makeRotationX(- Math.PI / 2))
        //var plane_material = new THREE.MeshBasicMaterial({color: 0x0000ff})
        var plane_material = new THREE.MeshLambertMaterial({color: 0xccffcc, side: THREE.FrontSide, wireframe: true})
        var plane_mesh     = new THREE.Mesh(plane_geometry, plane_material)
        this.add_to_scene(plane_mesh)

        // Add lights.
        /*
        var color1 = '#b9ffd2'
        var color2 = '#090920'
        var light = new THREE.HemisphereLight(color1, color2, .5)
        this.add_to_scene(light)
        */

        var light3 = new THREE.PointLight(0xccffcc, .8, 0)
        light3.position.set(5, 100, 5)
        this.add_to_scene(light3)

        // Add the text.

        this.username_label = new Floating2DText(50, 20, 'Username :')
        this.username_label.create(this.scene)
        this.username_field = new Floating2DText(100, 20, '')
        this.username_field.create(this.scene)

        this.password_label = new Floating2DText(50, 20, 'Password :')
        this.password_label.create(this.scene)
        this.password_field = new Floating2DText(100, 20, '')
        this.password_field.create(this.scene)

        this.login_button = new Floating2DText(50, 20, 'Login')
        this.login_button.create(this.scene)

        var username_position0 = new THREE.Vector3(0, 70, 45)
        var username_position1 = new THREE.Vector3(75, 70, 45)

        var password_position0 = new THREE.Vector3(0, 40, 45)
        var password_position1 = new THREE.Vector3(75, 40, 45)

        this.username_label.update_position_and_look_at(username_position0, new THREE.Vector3(0, 70, 55))
        this.username_field.update_position_and_look_at(username_position1, new THREE.Vector3(75, 70, 55))

        this.password_label.update_position_and_look_at(password_position0, new THREE.Vector3(0, 40, 55))
        this.password_field.update_position_and_look_at(password_position1, new THREE.Vector3(75, 40, 55))

        this.login_button.update_position_and_look_at(new THREE.Vector3(0, 10, 45), new THREE.Vector3(0, 10, 55))

        // Handle key press events.
        document.addEventListener('keypress', this.on_key_press.bind(this), false)

        this.set_player_look_at = false
    },

    add_to_scene: function(object) {
        this.scene.add(object)
    },

    update: function() {

        if (this.set_player_look_at) {
            this.player.look_at(new THREE.Vector3(0, 70, 45))
            this.set_player_look_at = false
        }

        var position = this.player.fps_controls.get_position()
        var direction = this.player.fps_controls.get_direction()

        var raycaster = new THREE.Raycaster(position, direction)

        /*
        var intersects = raycaster.intersectObjects(this.scene.children)
        if (intersects.length > 1) {
            console.log('There are ' + intersects.length + ' intersections!')
        }*/

        this.username_label.being_looked_at = false
        this.password_label.being_looked_at = false
        this.username_field.being_looked_at = false
        this.password_field.being_looked_at = false

        var aa = raycaster.intersectObject(this.username_label.object3d, true)
        var bb = raycaster.intersectObject(this.username_field.object3d, true)
        var cc = raycaster.intersectObject(this.password_label.object3d, true)
        var dd = raycaster.intersectObject(this.password_field.object3d, true)

        if (aa.length > 0) {
            console.log('AA')
            this.username_label.being_looked_at = true
        } else if (bb.length > 0) {
            console.log('BB')
            this.username_field.being_looked_at = true
        } else if (cc.length > 0) {
            console.log('CC')
            this.password_label.being_looked_at = true
        } else if (dd.length > 0) {
            console.log('DD')
            this.password_field.being_looked_at = true
        }
    },

    on_key_press: function(event) {

        console.log('Key pressed:')
        console.log(event.keyCode)
        console.log(event)

        switch(event.keyCode) {
        case 101: // e
            if (this.username_field.being_looked_at) {
                console.log('ENGAGE USERNAME FIELD')
                this.username_field.engage()
                this.player.engage()
            } else if (this.password_field.being_looked_at) {
                console.log('ENGAGE PASSWORD FIELD')
                this.password_field.engage()
                this.player.engage()
            }
            break
        case 92: // backslash
            if (this.player.is_engaged()) {
                this.player.disengage()
                if (this.username_field.being_looked_at) {
                    this.username_field.disengage()
                } else if (this.password_field.being_looked_at) {
                    this.password_field.disengage()
                }
            }
            break
        }

        if (this.username_field.is_engaged()) {
            this.username_field.parse_keycode(event)
        } else if (this.password_field.is_engaged()) {
            this.password_field.parse_keycode(event)
        }
    },

    enter_world: function() {
        if (this.player == null) {
            this.set_player_look_at = true
        } else {
            this.player.look_at(new THREE.Vector3(0, 70, 45))
        }
    },

    exit_world: function() {

    }
}<commit_msg>General updating 08.<commit_after>'use strict'

function LoginWorld() {
    this.__init__()
}

LoginWorld.prototype = {

    scene: null,

    player: null,

    username_label: null,
    username_field: null,
    password_label: null,
    password_field: null,

    set_player_look_at: null,

    __init__: function() {
        // Create the scene.
        this.scene = new THREE.Scene()

        // Going to try to create a plane here.
        var plane_geometry = new THREE.PlaneGeometry(2000, 2000, 100, 100)
        plane_geometry.applyMatrix(new THREE.Matrix4().makeRotationX(- Math.PI / 2))
        //var plane_material = new THREE.MeshBasicMaterial({color: 0x0000ff})
        var plane_material = new THREE.MeshLambertMaterial({color: 0xccffcc, side: THREE.FrontSide, wireframe: true})
        var plane_mesh     = new THREE.Mesh(plane_geometry, plane_material)
        this.add_to_scene(plane_mesh)

        // Add lights.
        /*
        var color1 = '#b9ffd2'
        var color2 = '#090920'
        var light = new THREE.HemisphereLight(color1, color2, .5)
        this.add_to_scene(light)
        */

        var light3 = new THREE.PointLight(0xccffcc, .8, 0)
        light3.position.set(5, 100, 5)
        this.add_to_scene(light3)

        // Add the text.

        this.username_label = new Floating2DText(50, 20, 'Username :')
        this.username_label.create(this.scene)
        this.username_field = new Floating2DText(100, 20, '')
        this.username_field.create(this.scene)

        this.password_label = new Floating2DText(50, 20, 'Password :')
        this.password_label.create(this.scene)
        this.password_field = new Floating2DText(100, 20, '')
        this.password_field.create(this.scene)

        this.login_button = new Floating2DText(50, 20, 'Login')
        this.login_button.create(this.scene)

        var username_position0 = new THREE.Vector3(0, 70, 45)
        var username_position1 = new THREE.Vector3(75, 70, 45)

        var password_position0 = new THREE.Vector3(0, 40, 45)
        var password_position1 = new THREE.Vector3(75, 40, 45)

        this.username_label.update_position_and_look_at(username_position0, new THREE.Vector3(0, 70, 55))
        this.username_field.update_position_and_look_at(username_position1, new THREE.Vector3(75, 70, 55))

        this.password_label.update_position_and_look_at(password_position0, new THREE.Vector3(0, 40, 55))
        this.password_field.update_position_and_look_at(password_position1, new THREE.Vector3(75, 40, 55))

        this.login_button.update_position_and_look_at(new THREE.Vector3(0, 10, 45), new THREE.Vector3(0, 10, 55))

        // Handle key press events.
        document.addEventListener('keypress', this.on_key_press.bind(this), false)

        this.set_player_look_at = false
    },

    add_to_scene: function(object) {
        this.scene.add(object)
    },

    update: function() {

        if (this.set_player_look_at) {
            this.player.look_at(new THREE.Vector3(0, 70, 45))
            this.set_player_look_at = false
        }

        var position = this.player.fps_controls.get_position()
        var direction = this.player.fps_controls.get_direction()

        var raycaster = new THREE.Raycaster(position, direction)

        /*
        var intersects = raycaster.intersectObjects(this.scene.children)
        if (intersects.length > 1) {
            console.log('There are ' + intersects.length + ' intersections!')
        }*/

        this.username_label.being_looked_at = false
        this.password_label.being_looked_at = false
        this.username_field.being_looked_at = false
        this.password_field.being_looked_at = false

        var aa = raycaster.intersectObject(this.username_label.object3d, true)
        var bb = raycaster.intersectObject(this.username_field.object3d, true)
        var cc = raycaster.intersectObject(this.password_label.object3d, true)
        var dd = raycaster.intersectObject(this.password_field.object3d, true)

        if (aa.length > 0) {
            console.log('AA')
            this.username_label.being_looked_at = true
        } else if (bb.length > 0) {
            console.log('BB')
            this.username_field.being_looked_at = true
        } else if (cc.length > 0) {
            console.log('CC')
            this.password_label.being_looked_at = true
        } else if (dd.length > 0) {
            console.log('DD')
            this.password_field.being_looked_at = true
        }
    },

    on_key_press: function(event) {
        switch(event.keyCode) {
        case 101: // e
            if (this.username_field.being_looked_at) {
                this.username_field.engage()
                this.player.engage()
            } else if (this.password_field.being_looked_at) {
                this.password_field.engage()
                this.player.engage()
            }
            break
        case 92: // backslash
            if (this.player.is_engaged()) {
                this.player.disengage()
                if (this.username_field.being_looked_at) {
                    this.username_field.disengage()
                } else if (this.password_field.being_looked_at) {
                    this.password_field.disengage()
                }
            }
            break
        }

        if (this.username_field.is_engaged()) {
            this.username_field.parse_keycode(event)
        } else if (this.password_field.is_engaged()) {
            this.password_field.parse_keycode(event)
        }
    },

    enter_world: function() {
        if (this.player == null) {
            this.set_player_look_at = true
        } else {
            this.player.look_at(new THREE.Vector3(0, 70, 45))
        }
    },

    exit_world: function() {

    }
}<|endoftext|>


<commit_before>/*globals $*/
import Ember from 'ember';
import layout from '../templates/components/crud-table';

var CustomField = Ember.Object.extend({
    Field: null,
    Value: null,
    Type: null,
    listener: function () {}.observes('Value')
});

var regenerateView = function (cmp) {
    var ComplexModel = [];
    if (cmp.value) {
        cmp.value.forEach(function (row) {
            var CustomProperties = [];
            cmp.fields.forEach(function (field) {
                var data = row.get ? row.get(field) : row[field];
                var cfield = CustomField.create({
                    Field: field,
                    Value: data,
                    Type: typeof (data),
                    listener: function () {
                        row.set(this.get('Field'), this.get('Value'));
                    }.observes('Value')
                });
                CustomProperties.pushObject(cfield);
            });
            CustomProperties.RoutedRecord = row;
            ComplexModel.pushObject(CustomProperties);
        });
    }
    cmp.set('ComplexModel', ComplexModel);

};
var showmodal = function () {
    $("#CrudTableDeleteRecordModal").modal('show');
};

var hidemodal = function () {
    $("#CrudTableDeleteRecordModal").modal('hide');
};

export default Ember.Component.extend({

    attributeBindings: ['style'],
    style: function () {
        return 'color: ' + this.get('name') + ';';
    }.property('name'),
    stripped: false,
    hover: false,
    createRecord: 'create',
    updateRecord: 'update',
    deleteRecord: 'delete',
    cancelRecord: 'cancel',
    searchRecord: 'FetchData',
    currentRecord: null,
    getRecord: 'getRecord',
    isLoading: true,
    SearchTerm: "",
    SearchField: "",
    actions: {
        internal_search: function () {
            var field = $("#SearchField").val();
            var query = {};
            var that = this;
            query[field] = this.get('SearchTerm');
            var deferred = Ember.RSVP.defer('crud-table#createRecord');
            that.set('isLoading', true);
            this.sendAction('searchRecord', query, deferred);
            deferred.promise.then(function (records) {
                that.set('value', records);
                regenerateView(that);
                that.set('isLoading', false);
            }, function (data) {
                alert(data.message);
                that.set('isLoading', false);
            });
        },
        confirm: function () {
            var that = this;
            var deferred;
            if (this.get('newRecord')) {
                deferred = Ember.RSVP.defer('crud-table#createRecord');
                this.sendAction('createRecord', this.get('currentRecord').RoutedRecord, deferred);
            } else {
                if (this.get('isDeleting')) {
                    deferred = Ember.RSVP.defer('crud-table#deleteRecord');
                    this.sendAction('deleteRecord', this.get('currentRecord').RoutedRecord, deferred);
                } else {
                    deferred = Ember.RSVP.defer('crud-table#updateRecord');
                    this.sendAction('updateRecord', this.get('currentRecord').RoutedRecord, deferred);
                }
            }
            deferred.promise.then(function () {
                regenerateView(that);
                hidemodal();
            }, function (data) {
                alert(data.message);
            });
        },
        internal_create: function () {
            var that = this;
            that.set('newRecord', true);
            var deferred = Ember.RSVP.defer('crud-table#newRecord');
            this.sendAction('getRecord', deferred);
            deferred.promise.then(function ( /*record*/ ) {
                regenerateView(that);
                that.set('currentRecord', that.get('ComplexModel').get('lastObject'));
                showmodal();
            }, function ( /*data*/ ) {
                alert('Something went wrong');
            });
        },
        internal_edit: function (record) {
            this.set('isDeleting', false);
            this.set('currentRecord', record);
            //$("#CrudTableDeleteRecordModal .modal-title").html("Updating");
            showmodal();
        },
        internal_delete: function (record) {
            this.set('newRecord', false);
            this.set('isDeleting', true);
            this.set('currentRecord', record);
            showmodal();
            //this.get('delete')();
        }
    },
    layout: layout,
    class: "",
    value: [],
    fields: "id",
    init: function () {
        var that = this;
        this._super();
        this.set('fields', this.fields.split(','));
        this.set('editdelete', this.deleteRecord != null || this.updateRecord != null);
        this.init = function () {
            that._super();
        }.on('willInsertElement');
    }.on('willInsertElement'),
    setup: function () {
        var that = this;
        var deferred = Ember.RSVP.defer('crud-table#createRecord');
        that.set('isLoading', true);
        this.sendAction('searchRecord', query, deferred);
        deferred.promise.then(function (records) {
            that.set('value', records);
            regenerateView(that);
            that.set('isLoading', false);
        }, function (data) {
            alert(data.message);
            that.set('isLoading', false);
        });
        //regenerateView(that);
        //Ember.addObserver('value',that,function(){
        //    regenerateView(that);
        //});
        $("#CrudTableDeleteRecordModal").modal('hide');
        $('#CrudTableDeleteRecordModal').on('hidden.bs.modal', function () {
            var deferred = Ember.RSVP.defer('crud-table#cancelRecord');
            var template = Ember.RSVP.defer('crud-table#RenderTemplate');
            that.sendAction('cancelRecord', that.get('currentRecord').RoutedRecord, deferred);
            deferred.promise.then(function () {
                regenerateView(that);
                that.set('newRecord', false);
                that.set('isDeleting', false);
                that.set('currentRecord', null);
                template.resolve(true);
            }, function (data) {
                alert(data);
            });

        });

    }.on('didInsertElement'),
    teardown: function () {
        //this._drop.destroy();
    }.on('willDestroyElement'),
});
<commit_msg>Load Content with a nice spinner!<commit_after>/*globals $*/
import Ember from 'ember';
import layout from '../templates/components/crud-table';

var CustomField = Ember.Object.extend({
    Field: null,
    Value: null,
    Type: null,
    listener: function () {}.observes('Value')
});

var regenerateView = function (cmp) {
    var ComplexModel = [];
    if (cmp.value) {
        cmp.value.forEach(function (row) {
            var CustomProperties = [];
            cmp.fields.forEach(function (field) {
                var data = row.get ? row.get(field) : row[field];
                var cfield = CustomField.create({
                    Field: field,
                    Value: data,
                    Type: typeof (data),
                    listener: function () {
                        row.set(this.get('Field'), this.get('Value'));
                    }.observes('Value')
                });
                CustomProperties.pushObject(cfield);
            });
            CustomProperties.RoutedRecord = row;
            ComplexModel.pushObject(CustomProperties);
        });
    }
    cmp.set('ComplexModel', ComplexModel);

};
var showmodal = function () {
    $("#CrudTableDeleteRecordModal").modal('show');
};

var hidemodal = function () {
    $("#CrudTableDeleteRecordModal").modal('hide');
};

export default Ember.Component.extend({

    attributeBindings: ['style'],
    style: function () {
        return 'color: ' + this.get('name') + ';';
    }.property('name'),
    stripped: false,
    hover: false,
    createRecord: 'create',
    updateRecord: 'update',
    deleteRecord: 'delete',
    cancelRecord: 'cancel',
    searchRecord: 'FetchData',
    currentRecord: null,
    getRecord: 'getRecord',
    isLoading: true,
    SearchTerm: "",
    SearchField: "",
    actions: {
        internal_search: function () {
            var field = $("#SearchField").val();
            var query = {};
            var that = this;
            query[field] = this.get('SearchTerm');
            var deferred = Ember.RSVP.defer('crud-table#createRecord');
            that.set('isLoading', true);
            this.sendAction('searchRecord', query, deferred);
            deferred.promise.then(function (records) {
                that.set('value', records);
                regenerateView(that);
                that.set('isLoading', false);
            }, function (data) {
                alert(data.message);
                that.set('isLoading', false);
            });
        },
        confirm: function () {
            var that = this;
            var deferred;
            if (this.get('newRecord')) {
                deferred = Ember.RSVP.defer('crud-table#createRecord');
                this.sendAction('createRecord', this.get('currentRecord').RoutedRecord, deferred);
            } else {
                if (this.get('isDeleting')) {
                    deferred = Ember.RSVP.defer('crud-table#deleteRecord');
                    this.sendAction('deleteRecord', this.get('currentRecord').RoutedRecord, deferred);
                } else {
                    deferred = Ember.RSVP.defer('crud-table#updateRecord');
                    this.sendAction('updateRecord', this.get('currentRecord').RoutedRecord, deferred);
                }
            }
            deferred.promise.then(function () {
                regenerateView(that);
                hidemodal();
            }, function (data) {
                alert(data.message);
            });
        },
        internal_create: function () {
            var that = this;
            that.set('newRecord', true);
            var deferred = Ember.RSVP.defer('crud-table#newRecord');
            this.sendAction('getRecord', deferred);
            deferred.promise.then(function ( /*record*/ ) {
                regenerateView(that);
                that.set('currentRecord', that.get('ComplexModel').get('lastObject'));
                showmodal();
            }, function ( /*data*/ ) {
                alert('Something went wrong');
            });
        },
        internal_edit: function (record) {
            this.set('isDeleting', false);
            this.set('currentRecord', record);
            //$("#CrudTableDeleteRecordModal .modal-title").html("Updating");
            showmodal();
        },
        internal_delete: function (record) {
            this.set('newRecord', false);
            this.set('isDeleting', true);
            this.set('currentRecord', record);
            showmodal();
            //this.get('delete')();
        }
    },
    layout: layout,
    class: "",
    value: [],
    fields: "id",
    init: function () {
        var that = this;
        this._super();
        this.set('fields', this.fields.split(','));
        this.set('editdelete', this.deleteRecord != null || this.updateRecord != null);
        this.init = function () {
            that._super();
        }.on('willInsertElement');
    }.on('willInsertElement'),
    setup: function () {
        var that = this;
        var deferred = Ember.RSVP.defer('crud-table#createRecord');
        that.set('isLoading', true);
        this.sendAction('searchRecord', {}, deferred);
        deferred.promise.then(function (records) {
            that.set('value', records);
            regenerateView(that);
            that.set('isLoading', false);
        }, function (data) {
            alert(data.message);
            that.set('isLoading', false);
        });
        //regenerateView(that);
        //Ember.addObserver('value',that,function(){
        //    regenerateView(that);
        //});
        $("#CrudTableDeleteRecordModal").modal('hide');
        $('#CrudTableDeleteRecordModal').on('hidden.bs.modal', function () {
            var deferred = Ember.RSVP.defer('crud-table#cancelRecord');
            var template = Ember.RSVP.defer('crud-table#RenderTemplate');
            that.sendAction('cancelRecord', that.get('currentRecord').RoutedRecord, deferred);
            deferred.promise.then(function () {
                regenerateView(that);
                that.set('newRecord', false);
                that.set('isDeleting', false);
                that.set('currentRecord', null);
                template.resolve(true);
            }, function (data) {
                alert(data);
            });

        });

    }.on('didInsertElement'),
    teardown: function () {
        //this._drop.destroy();
    }.on('willDestroyElement'),
});
<|endoftext|>


<commit_before>#! /usr/bin/env node
const shell = require('shelljs');
const chalk = require('chalk');
// SET SILENT TRUE SO THAT DEFAULT OUTPUT IS NOT PRINTED ON CONSOLE
shell.config.silent = true;
// get command line argument for commit message
module.exports = (branchName, args, callback) => {
  // remove \n from the end
  let command = 'git push';
  switch (args.length) {
    case 0:
      command += ` origin ${branchName}`;
      break;
    case 1:
      command += ` origin ${args[0]}`;
      break;
    case 2:
      command += ` ${args[0]} ${args[1]}`;
      break;
    default:
      callback(chalk.redBright('Invalid arguments'));
      return;
  }
  shell.exec(command, (code, stdout, stderr) => {
    // console.log(121, { code, stdout, stderr });
    if (stderr) {
      console.log(2);
      const commitLine = stderr.substr(stderr.indexOf('..') + 2).substr(0, stderr.indexOf('  '));
      console.log({ commitLine });
      callback(chalk.redBright(stderr));
      return;
    }
    callback(chalk.greenBright(stdout));
  });
};
<commit_msg>invalid arg removed from data<commit_after>#! /usr/bin/env node
const shell = require('shelljs');
const chalk = require('chalk');
// SET SILENT TRUE SO THAT DEFAULT OUTPUT IS NOT PRINTED ON CONSOLE
shell.config.silent = true;
// get command line argument for commit message
module.exports = (branchName, args, callback) => {
  // remove \n from the end
  let command = 'git push';
  switch (args.length) {
    case 0:
      command += ` origin ${branchName}`;
      break;
    case 1:
      command += ` origin ${args[0]}`;
      break;
    case 2:
      command += ` ${args[0]} ${args[1]}`;
      break;
    default:
      callback(chalk.redBright('Invalid arguments'));
      return;
  }
  shell.exec(command, (code, stdout, stderr) => {
    // console.log(121, { code, stdout, stderr });
    if (stderr) {
      const commitLine = stderr.substr(stderr.indexOf('..') + 2).substr(0, stderr.indexOf('  '));
      console.log({ commitLine });
      callback(chalk.redBright(stderr));
      return;
    }
    callback(chalk.greenBright(stdout));
  });
};
<|endoftext|>


<commit_before>#!/usr/bin/env node

/*!
 * mqtt-ws: a node.js MQTT/WebSocket bridge
 * Copyright(c) 2013 M2M Connections, Inc <info@m2mconnectionsinc.com>
 * MIT Licensed
 */

var optimist = require('optimist'),
    myArgs = optimist
    .usage('MQTT/WebSocket Bridge\nUsage: $0')
    .alias({
        'p': 'port',
        'h': 'host',
        'l': 'listen',
        'c': 'configFile',
    })
    .describe({
        'p': 'MQTT port to connect to',
        'h': 'Hostname of MQTT server',
        'l': 'WebSocket port to listen on',
        'c': 'Configuration file',
        'help': 'Show this help'
    })
    .argv,
    url = require('url'),
    util = require('util'),
    errno = require('errno'),
    log4js = require('log4js'),
    logger = log4js.getLogger(),
    mqttws = require('../lib/mqtt-ws');

if (myArgs.help) {
    optimist.showHelp();
    process.exit(0);
}

// If we are given a config file, parse that,
// otherwise just parse command line
if (myArgs.c || myArgs.configFile) {
    var configFile = myArgs.c || myArgs.configFile;
    logger.info("Reading configuration from %s", configFile);
    require('fs').readFile(configFile, 'utf8', function(err, data) {
        if (err) {
            logger.info("Error reading config file %s: %s", configFile, err);
            process.exit(-1);
        }
        config = JSON.parse(data);
        run(parseCommandLine(myArgs, config));
    });
} else {
    run(parseCommandLine(myArgs, {mqtt: {}, websocket: {}}));
}

// Parse the command line
function parseCommandLine(args, config) {
    if (args.p || args.port) {
        config.mqtt.port = args.p || args.port;
    }
    if (args.h || args.host) {
        config.mqtt.host = args.h || args.host;
    }
    if (args.l || args.listen) {
        config.websocket.port = args.l || args.listen;
    }

    return config;
}

function getErrnoDescription(err) {
    if (!err.errno) return undefined;
    var e;
    if (typeof err.errno == 'number') {
        e = errno.errno[err.errno];
        if (e) {
            return e.description;
        } else {
            return undefined;
        }
    } else if (typeof err.errno == 'string') {
        for (e in errno.errno) {
            if (errno.errno[e].code == err.code) {
                return errno.errno[e].description;
            }
        }
        return undefined;
    }
}

function logError(err, message) {
    if (err.syscall) {
        var description = getErrnoDescription(err) || err.code;
        logger.error("%s on %s: %s", message, err.syscall, description);
    } else {
        logger.error("%s: %s", message, err);
    }
}

// Start the bridge
function run(config) {
    if (config.log4js) {
        log4js.configure(config.log4js);
    }

    // Create our bridge
    bridge = mqttws.createBridge(config);
    logger.info("Listening for incoming WebSocket connections on port %d",
        bridge.port);

    // Set up error handling
    bridge.on('error', function(err) {
        logError(err, "WebSocket Error");
    });

    // Handle incoming WS connection
    bridge.on('connection', function(ws) {
        // URL-decode the URL, and use the URI part as the subscription topic
        logger.info("WebSocket connection from %s received", ws.connectString);

        var self = this;

        ws.on('error', function(err) {
            logError(err, util.format("WebSocket error in client %s", ws.connectString));
        });

        // Parse the URL
        var parsed = url.parse(ws.upgradeReq.url, true);
        // Connect to the MQTT server using the URL query as options
        var mqtt = bridge.connectMqtt(parsed.query);
        mqtt.topic = decodeURIComponent(parsed.pathname.substring(1));

        ws.on('close', function() {
            logger.info("WebSocket client %s closed", ws.connectString);
            mqtt.end();
        });

        ws.on('message', function(message) {
            message = new Buffer(message);
            var char = " ";
            var topic = "";
            var offset = 0;
            while(char != "|" && offset < message.length){
                topic += char;
                char = String.fromCharCode(message.readUInt16LE(offset));
                offset += 2;
            }
            topic = topic.substring(1);
            logger.info("WebSocket client %s publishing to %s", ws.connectString, topic);
            mqtt.publish(topic, message.slice(offset), mqtt.options);
        });

        mqtt.on('error', function(err) {
            logError(err, "MQTT error");
        });

        mqtt.on('connect', function() {
            logger.info("Connected to MQTT server at %s:%d", mqtt.host, mqtt.port);
            logger.info("WebSocket client %s subscribing to '%s'", ws.connectString, mqtt.topic);
            mqtt.subscribe(mqtt.topic);
        });

        mqtt.on('close', function() {
            logger.info("MQTT connection for client %s closed",
                ws.connectString);
            ws.terminate();
        });

        mqtt.on('message', function(topic, message, packet) {
            ws.send(Buffer.concat([new Buffer(topic + "|", "utf16le"), new Buffer(message)]), {binary: true, mask: true});
        });
    });
}

<commit_msg>Don't mask packages<commit_after>#!/usr/bin/env node

/*!
 * mqtt-ws: a node.js MQTT/WebSocket bridge
 * Copyright(c) 2013 M2M Connections, Inc <info@m2mconnectionsinc.com>
 * MIT Licensed
 */

var optimist = require('optimist'),
    myArgs = optimist
    .usage('MQTT/WebSocket Bridge\nUsage: $0')
    .alias({
        'p': 'port',
        'h': 'host',
        'l': 'listen',
        'c': 'configFile',
    })
    .describe({
        'p': 'MQTT port to connect to',
        'h': 'Hostname of MQTT server',
        'l': 'WebSocket port to listen on',
        'c': 'Configuration file',
        'help': 'Show this help'
    })
    .argv,
    url = require('url'),
    util = require('util'),
    errno = require('errno'),
    log4js = require('log4js'),
    logger = log4js.getLogger(),
    mqttws = require('../lib/mqtt-ws');

if (myArgs.help) {
    optimist.showHelp();
    process.exit(0);
}

// If we are given a config file, parse that,
// otherwise just parse command line
if (myArgs.c || myArgs.configFile) {
    var configFile = myArgs.c || myArgs.configFile;
    logger.info("Reading configuration from %s", configFile);
    require('fs').readFile(configFile, 'utf8', function(err, data) {
        if (err) {
            logger.info("Error reading config file %s: %s", configFile, err);
            process.exit(-1);
        }
        config = JSON.parse(data);
        run(parseCommandLine(myArgs, config));
    });
} else {
    run(parseCommandLine(myArgs, {mqtt: {}, websocket: {}}));
}

// Parse the command line
function parseCommandLine(args, config) {
    if (args.p || args.port) {
        config.mqtt.port = args.p || args.port;
    }
    if (args.h || args.host) {
        config.mqtt.host = args.h || args.host;
    }
    if (args.l || args.listen) {
        config.websocket.port = args.l || args.listen;
    }

    return config;
}

function getErrnoDescription(err) {
    if (!err.errno) return undefined;
    var e;
    if (typeof err.errno == 'number') {
        e = errno.errno[err.errno];
        if (e) {
            return e.description;
        } else {
            return undefined;
        }
    } else if (typeof err.errno == 'string') {
        for (e in errno.errno) {
            if (errno.errno[e].code == err.code) {
                return errno.errno[e].description;
            }
        }
        return undefined;
    }
}

function logError(err, message) {
    if (err.syscall) {
        var description = getErrnoDescription(err) || err.code;
        logger.error("%s on %s: %s", message, err.syscall, description);
    } else {
        logger.error("%s: %s", message, err);
    }
}

// Start the bridge
function run(config) {
    if (config.log4js) {
        log4js.configure(config.log4js);
    }

    // Create our bridge
    bridge = mqttws.createBridge(config);
    logger.info("Listening for incoming WebSocket connections on port %d",
        bridge.port);

    // Set up error handling
    bridge.on('error', function(err) {
        logError(err, "WebSocket Error");
    });

    // Handle incoming WS connection
    bridge.on('connection', function(ws) {
        // URL-decode the URL, and use the URI part as the subscription topic
        logger.info("WebSocket connection from %s received", ws.connectString);

        var self = this;

        ws.on('error', function(err) {
            logError(err, util.format("WebSocket error in client %s", ws.connectString));
        });

        // Parse the URL
        var parsed = url.parse(ws.upgradeReq.url, true);
        // Connect to the MQTT server using the URL query as options
        var mqtt = bridge.connectMqtt(parsed.query);
        mqtt.topic = decodeURIComponent(parsed.pathname.substring(1));

        ws.on('close', function() {
            logger.info("WebSocket client %s closed", ws.connectString);
            mqtt.end();
        });

        ws.on('message', function(message) {
            message = new Buffer(message);
            var char = " ";
            var topic = "";
            var offset = 0;
            while(char != "|" && offset < message.length){
                topic += char;
                char = String.fromCharCode(message.readUInt16LE(offset));
                offset += 2;
            }
            topic = topic.substring(1);
            logger.info("WebSocket client %s publishing to %s", ws.connectString, topic);
            mqtt.publish(topic, message.slice(offset), mqtt.options);
        });

        mqtt.on('error', function(err) {
            logError(err, "MQTT error");
        });

        mqtt.on('connect', function() {
            logger.info("Connected to MQTT server at %s:%d", mqtt.host, mqtt.port);
            logger.info("WebSocket client %s subscribing to '%s'", ws.connectString, mqtt.topic);
            mqtt.subscribe(mqtt.topic);
        });

        mqtt.on('close', function() {
            logger.info("MQTT connection for client %s closed",
                ws.connectString);
            ws.terminate();
        });

        mqtt.on('message', function(topic, message, packet) {
            ws.send(Buffer.concat([new Buffer(topic + "|", "utf16le"), new Buffer(message)]), {binary: true, mask: false});
        });
    });
}

<|endoftext|>


<commit_before>import Ember from 'ember';
import { moduleFor, test, skip } from 'ember-qunit';
import config from 'ember-get-config';

moduleFor('controller:content/index', 'Unit | Controller | content/index', {
    needs: [
        'model:review-action',
        'model:file',
        'model:file-version',
        'model:comment',
        'model:node',
        'model:preprint',
        'model:preprint-provider',
        'model:institution',
        'model:contributor',
        'model:file-provider',
        'model:registration',
        'model:draft-registration',
        'model:log',
        'model:user',
        'model:citation',
        'model:license',
        'model:wiki',
        'model:taxonomy',
        'service:metrics',
        'service:theme'
    ]
});

test('Initial properties', function (assert) {
    const ctrl = this.subject();

    const expected = {
        fullScreenMFR: false,
        showLicenseText: false,
        activeFile: null,
        chosenFile: null,
    };

    const propKeys = Object.keys(expected);
    const actual = ctrl.getProperties(propKeys);

    assert.ok(propKeys.every(key => expected[key] === actual[key]));
});

test('isAdmin computed property', function (assert) {
    this.inject.service('store');

    const store = this.store;
    const ctrl = this.subject();

    Ember.run(() => {
        const node = store.createRecord('node', {
            currentUserPermissions: ['admin']
        });

        assert.strictEqual(ctrl.get('isAdmin'), false);

        ctrl.set('node', node);

        assert.strictEqual(ctrl.get('isAdmin'), true);
    });
});

test('twitterHref computed property', function (assert) {
    this.inject.service('store');

    const store = this.store;
    const ctrl = this.subject();

    Ember.run(() => {
        const node = store.createRecord('node', {
            title: 'test title'
        });

        ctrl.setProperties({node});

        const location = encodeURIComponent(window.location.href);

        assert.strictEqual(
            ctrl.get('twitterHref'),
            `https://twitter.com/intent/tweet?url=${location}&text=test%20title&via=OSFramework`
        );
    });
});

test('facebookHref computed property', function (assert) {
    const ctrl = this.subject();

    const {FB_APP_ID} = config;
    const location = encodeURIComponent(window.location.href);

    assert.strictEqual(
        ctrl.get('facebookHref'),
        `https://www.facebook.com/dialog/share?app_id=${FB_APP_ID}&display=popup&href=${location}&redirect_uri=${location}`
    );
});

test('linkedinHref computed property', function (assert) {
    this.inject.service('store');

    const store = this.store;
    const ctrl = this.subject();

    Ember.run(() => {
        const node = store.createRecord('node', {
            title: 'test title',
            description: 'test description'
        });

        ctrl.setProperties({node});

        const location = encodeURIComponent(window.location.href);

        assert.strictEqual(
            ctrl.get('linkedinHref'),
            `https://www.linkedin.com/shareArticle?url=${location}&mini=true&title=test%20title&summary=test%20description&source=Open%20Science%20Framework`
        );
    });
});

test('emailHref computed property', function (assert) {
    this.inject.service('store');

    const store = this.store;
    const ctrl = this.subject();

    Ember.run(() => {
        const node = store.createRecord('node', {
            title: 'test title'
        });

        ctrl.setProperties({node});

        const location = encodeURIComponent(window.location.href);

        assert.strictEqual(
            ctrl.get('emailHref'),
            `mailto:?subject=test%20title&body=${location}`
        );
    });
});

test('hasTag computed property', function (assert) {
    this.inject.service('store');

    const store = this.store;
    const ctrl = this.subject();

    Ember.run(() => {
        const node = store.createRecord('node', {
            tags: []
        });

        ctrl.setProperties({node});

        assert.strictEqual(
            ctrl.get('hasTag'),
            false
        );
    });

    Ember.run(() => {
        const node = store.createRecord('node', {
            tags: ['a', 'b', 'c']
        });

        ctrl.setProperties({node});

        assert.strictEqual(
            ctrl.get('hasTag'),
            true
        );
    });
});

//TODO: unskip test when loadAll() is removed/refactored.
skip('authors computed property', function (assert) {
    assert.expect(1);
    this.inject.service('store');

    const store = this.store;
    const ctrl = this.subject();

    Ember.run(() => {
        const node = store.createRecord('node', {
            id: 'abc12'
        });

        ctrl.setProperties({
            node
        });

        // TODO figure out how to test with at least one contributor
        ctrl.get('authors')
            .then(authors => {
                assert.strictEqual(authors.length, 0);
            });
    });
});

test('fullLicenseText computed property', function (assert) {
    this.inject.service('store');

    const store = this.store;
    const ctrl = this.subject();

    Ember.run(() => {
        const license = store.createRecord('license', {
            text: 'The year is {{year}} and the copyright holders are {{copyrightHolders}}.'
        });

        const model = store.createRecord('preprint', {
            license,
            licenseRecord: {
                year: '2000',
                copyright_holders: [
                    'Annie Anderson',
                    'Bobby Buckner',
                    'Charlie Carson'
                ]
            }
        });

        ctrl.setProperties({model});

        assert.strictEqual(
            ctrl.get('fullLicenseText'),
            'The year is 2000 and the copyright holders are Annie Anderson, Bobby Buckner, Charlie Carson.'
        );
    });

    Ember.run(() => {
        const license = store.createRecord('license', {
            text: 'The year is {{year}}.'
        });

        const model = store.createRecord('preprint', {
            license,
            licenseRecord: {
                year: '2000'
            }
        });

        ctrl.setProperties({model});

        assert.strictEqual(
            ctrl.get('fullLicenseText'),
            'The year is 2000.'
        );
    });
});

test('editButtonLabel computed property', function (assert) {
    this.inject.service('store');

    const store = this.store;
    const ctrl = this.subject();

    Ember.run(() => {
        const provider = store.createRecord('preprint-provider', {
            reviewsWorkflow: 'pre-moderation',
        });

        const model = store.createRecord('preprint', {
            provider,
            reviewsState: 'initial',
        });

        ctrl.setProperties({model});

        const workflowTypes = ['pre-moderation', 'post-moderation'];
        const stateTypes = ['pending', 'accepted', 'rejected'];
        for (let i = 0; i < workflowTypes.length; i++) {
            for (let j = 0; j < stateTypes.length; j++) {
                ctrl.set('model.provider.reviewsWorkflow', workflowTypes[i]);
                ctrl.set('model.reviewsState', stateTypes[j]);
                if (workflowTypes[i] == 'pre-moderation' && stateTypes[j] == 'rejected') {
                    assert.strictEqual( ctrl.get('editButtonLabel'), 'content.project_button.edit_resubmit_preprint');
                } else {
                    assert.strictEqual( ctrl.get('editButtonLabel'), 'content.project_button.edit_preprint');
                }

            }
        }
    });
});

test('hasShortenedDescription computed property', function (assert) {
    this.inject.service('store');

    const store = this.store;
    const ctrl = this.subject();

    Ember.run(() => {
        const node = store.createRecord('node', {
            description: 'Lorem ipsum'
        });

        ctrl.setProperties({node});

        assert.strictEqual(
            ctrl.get('hasShortenedDescription'),
            false
        );
    });

    Ember.run(() => {
        const node = store.createRecord('node', {
            description: 'Lorem ipsum'.repeat(35)
        });

        ctrl.setProperties({node});

        assert.strictEqual(
            ctrl.get('hasShortenedDescription'),
            true
        );
    });
});

test('useShortenedDescription computed property', function (assert) {
    const ctrl = this.subject();

    const scenarios = [
        [false, true, true],
        [true, true, false],
        [false, false, false],
        [true, false, false]
    ];

    for (const [expandedAbstract, hasShortenedDescription, expected] of scenarios) {
        ctrl.setProperties({
            expandedAbstract,
            hasShortenedDescription
        });

        assert.strictEqual(ctrl.get('useShortenedDescription'), expected);
    }
});

test('description computed property', function (assert) {
    this.inject.service('store');

    const store = this.store;
    const ctrl = this.subject();

    Ember.run(() => {
        const input = 'Lorem ipsum dolor sit amet, atqui elitr id vim, at clita facilis tibique ius, ad pro stet accusam. Laudem essent commune ea vix. Duis hendrerit complectitur usu eu, ei nam ullum accusamus inciderint, has appetere assueverit te. An pro maiorum alienum voluptatibus, mei adhuc docendi prodesset in. Ut vel mundi atomorum quaerendum, cu per autem menandri consequat, tantas dictas quodsi nec eu. Ornatus forensibus vituperatoribus id vix.';
        const expected ='Lorem ipsum dolor sit amet, atqui elitr id vim, at clita facilis tibique ius, ad pro stet accusam. Laudem essent commune ea vix. Duis hendrerit complectitur usu eu, ei nam ullum accusamus inciderint, has appetere assueverit te. An pro maiorum alienum voluptatibus, mei adhuc docendi prodesset in. Ut vel mundi atomorum quaerendum, cu per autem';

        const node = store.createRecord('node', {
            description: input
        });

        ctrl.setProperties({node});

        assert.strictEqual(
            ctrl.get('description'),
            expected
        );
    });
});

test('toggleLicenseText action', function (assert) {
    const ctrl = this.subject();
    const initialValue = ctrl.get('showLicenseText');

    ctrl.send('toggleLicenseText');
    assert.strictEqual(ctrl.get('showLicenseText'), !initialValue);

    ctrl.send('toggleLicenseText');
    assert.strictEqual(ctrl.get('showLicenseText'), initialValue);
});

test('expandMFR action', function (assert) {
    const ctrl = this.subject();
    const initialValue = ctrl.get('fullScreenMFR');

    ctrl.send('expandMFR');
    assert.strictEqual(ctrl.get('fullScreenMFR'), !initialValue);

    ctrl.send('expandMFR');
    assert.strictEqual(ctrl.get('fullScreenMFR'), initialValue);
});

test('expandAbstract action', function (assert) {
    const ctrl = this.subject();
    const initialValue = ctrl.get('expandedAbstract');

    ctrl.send('expandAbstract');
    assert.strictEqual(ctrl.get('expandedAbstract'), !initialValue);

    ctrl.send('expandAbstract');
    assert.strictEqual(ctrl.get('expandedAbstract'), initialValue);
});

test('chooseFile action', function (assert) {
    this.inject.service('store');

    const store = this.store;
    const ctrl = this.subject();

    Ember.run(() => {
        const fileItem = store.createRecord('file', {
            id: 'test1'
        });

        ctrl.send('chooseFile', fileItem);
        assert.strictEqual(ctrl.get('chosenFile'), 'test1');
        assert.strictEqual(ctrl.get('activeFile'), fileItem);
    });
});

// Don't try to test shareLink, since it includes a window.open call. No good way to test that.
<commit_msg>Add test for facebookAppId<commit_after>import Ember from 'ember';
import { moduleFor, test, skip } from 'ember-qunit';
import config from 'ember-get-config';

moduleFor('controller:content/index', 'Unit | Controller | content/index', {
    needs: [
        'model:review-action',
        'model:file',
        'model:file-version',
        'model:comment',
        'model:node',
        'model:preprint',
        'model:preprint-provider',
        'model:institution',
        'model:contributor',
        'model:file-provider',
        'model:registration',
        'model:draft-registration',
        'model:log',
        'model:user',
        'model:citation',
        'model:license',
        'model:wiki',
        'model:taxonomy',
        'service:metrics',
        'service:theme'
    ]
});

test('Initial properties', function (assert) {
    const ctrl = this.subject();

    const expected = {
        fullScreenMFR: false,
        showLicenseText: false,
        activeFile: null,
        chosenFile: null,
    };

    const propKeys = Object.keys(expected);
    const actual = ctrl.getProperties(propKeys);

    assert.ok(propKeys.every(key => expected[key] === actual[key]));
});

test('isAdmin computed property', function (assert) {
    this.inject.service('store');

    const store = this.store;
    const ctrl = this.subject();

    Ember.run(() => {
        const node = store.createRecord('node', {
            currentUserPermissions: ['admin']
        });

        assert.strictEqual(ctrl.get('isAdmin'), false);

        ctrl.set('node', node);

        assert.strictEqual(ctrl.get('isAdmin'), true);
    });
});

test('twitterHref computed property', function (assert) {
    this.inject.service('store');

    const store = this.store;
    const ctrl = this.subject();

    Ember.run(() => {
        const node = store.createRecord('node', {
            title: 'test title'
        });

        ctrl.setProperties({node});

        const location = encodeURIComponent(window.location.href);

        assert.strictEqual(
            ctrl.get('twitterHref'),
            `https://twitter.com/intent/tweet?url=${location}&text=test%20title&via=OSFramework`
        );
    });
});

test('facebookHref computed property - has facebookAppId', function (assert) {
    this.inject.service('store');

    const store = this.store;
    const ctrl = this.subject();
    const facebookAppId = 112233445566;

    Ember.run(() => {
        const provider = store.createRecord('preprint-provider', {
            facebookAppId: facebookAppId,
        });

        const model = store.createRecord('preprint', {
            provider,
        });

        ctrl.setProperties({ model });

        const location = encodeURIComponent(window.location.href);

        assert.strictEqual(
            ctrl.get('facebookHref'),
            `https://www.facebook.com/dialog/share?app_id=${facebookAppId.toString()}&display=popup&href=${location}&redirect_uri=${location}`
        );
    });
});

test('facebookHref computed property - does not have facebookAppId', function(assert) {
    this.inject.service('store');

    const store = this.store;
    const ctrl = this.subject();

    Ember.run(() => {
        const provider = store.createRecord('preprint-provider', {
            facebookAppId: '',
        });

        const model = store.createRecord('preprint', {
            provider,
        });

        ctrl.setProperties({ model });

        const { FB_APP_ID } = config;
        const location = encodeURIComponent(window.location.href);

        assert.strictEqual(
            ctrl.get('facebookHref'),
            `https://www.facebook.com/dialog/share?app_id=${FB_APP_ID}&display=popup&href=${location}&redirect_uri=${location}`
        );
    });
});

test('linkedinHref computed property', function (assert) {
    this.inject.service('store');

    const store = this.store;
    const ctrl = this.subject();

    Ember.run(() => {
        const node = store.createRecord('node', {
            title: 'test title',
            description: 'test description'
        });

        ctrl.setProperties({node});

        const location = encodeURIComponent(window.location.href);

        assert.strictEqual(
            ctrl.get('linkedinHref'),
            `https://www.linkedin.com/shareArticle?url=${location}&mini=true&title=test%20title&summary=test%20description&source=Open%20Science%20Framework`
        );
    });
});

test('emailHref computed property', function (assert) {
    this.inject.service('store');

    const store = this.store;
    const ctrl = this.subject();

    Ember.run(() => {
        const node = store.createRecord('node', {
            title: 'test title'
        });

        ctrl.setProperties({node});

        const location = encodeURIComponent(window.location.href);

        assert.strictEqual(
            ctrl.get('emailHref'),
            `mailto:?subject=test%20title&body=${location}`
        );
    });
});

test('hasTag computed property', function (assert) {
    this.inject.service('store');

    const store = this.store;
    const ctrl = this.subject();

    Ember.run(() => {
        const node = store.createRecord('node', {
            tags: []
        });

        ctrl.setProperties({node});

        assert.strictEqual(
            ctrl.get('hasTag'),
            false
        );
    });

    Ember.run(() => {
        const node = store.createRecord('node', {
            tags: ['a', 'b', 'c']
        });

        ctrl.setProperties({node});

        assert.strictEqual(
            ctrl.get('hasTag'),
            true
        );
    });
});

//TODO: unskip test when loadAll() is removed/refactored.
skip('authors computed property', function (assert) {
    assert.expect(1);
    this.inject.service('store');

    const store = this.store;
    const ctrl = this.subject();

    Ember.run(() => {
        const node = store.createRecord('node', {
            id: 'abc12'
        });

        ctrl.setProperties({
            node
        });

        // TODO figure out how to test with at least one contributor
        ctrl.get('authors')
            .then(authors => {
                assert.strictEqual(authors.length, 0);
            });
    });
});

test('fullLicenseText computed property', function (assert) {
    this.inject.service('store');

    const store = this.store;
    const ctrl = this.subject();

    Ember.run(() => {
        const license = store.createRecord('license', {
            text: 'The year is {{year}} and the copyright holders are {{copyrightHolders}}.'
        });

        const model = store.createRecord('preprint', {
            license,
            licenseRecord: {
                year: '2000',
                copyright_holders: [
                    'Annie Anderson',
                    'Bobby Buckner',
                    'Charlie Carson'
                ]
            }
        });

        ctrl.setProperties({model});

        assert.strictEqual(
            ctrl.get('fullLicenseText'),
            'The year is 2000 and the copyright holders are Annie Anderson, Bobby Buckner, Charlie Carson.'
        );
    });

    Ember.run(() => {
        const license = store.createRecord('license', {
            text: 'The year is {{year}}.'
        });

        const model = store.createRecord('preprint', {
            license,
            licenseRecord: {
                year: '2000'
            }
        });

        ctrl.setProperties({model});

        assert.strictEqual(
            ctrl.get('fullLicenseText'),
            'The year is 2000.'
        );
    });
});

test('editButtonLabel computed property', function (assert) {
    this.inject.service('store');

    const store = this.store;
    const ctrl = this.subject();

    Ember.run(() => {
        const provider = store.createRecord('preprint-provider', {
            reviewsWorkflow: 'pre-moderation',
        });

        const model = store.createRecord('preprint', {
            provider,
            reviewsState: 'initial',
        });

        ctrl.setProperties({model});

        const workflowTypes = ['pre-moderation', 'post-moderation'];
        const stateTypes = ['pending', 'accepted', 'rejected'];
        for (let i = 0; i < workflowTypes.length; i++) {
            for (let j = 0; j < stateTypes.length; j++) {
                ctrl.set('model.provider.reviewsWorkflow', workflowTypes[i]);
                ctrl.set('model.reviewsState', stateTypes[j]);
                if (workflowTypes[i] == 'pre-moderation' && stateTypes[j] == 'rejected') {
                    assert.strictEqual( ctrl.get('editButtonLabel'), 'content.project_button.edit_resubmit_preprint');
                } else {
                    assert.strictEqual( ctrl.get('editButtonLabel'), 'content.project_button.edit_preprint');
                }

            }
        }
    });
});

test('hasShortenedDescription computed property', function (assert) {
    this.inject.service('store');

    const store = this.store;
    const ctrl = this.subject();

    Ember.run(() => {
        const node = store.createRecord('node', {
            description: 'Lorem ipsum'
        });

        ctrl.setProperties({node});

        assert.strictEqual(
            ctrl.get('hasShortenedDescription'),
            false
        );
    });

    Ember.run(() => {
        const node = store.createRecord('node', {
            description: 'Lorem ipsum'.repeat(35)
        });

        ctrl.setProperties({node});

        assert.strictEqual(
            ctrl.get('hasShortenedDescription'),
            true
        );
    });
});

test('useShortenedDescription computed property', function (assert) {
    const ctrl = this.subject();

    const scenarios = [
        [false, true, true],
        [true, true, false],
        [false, false, false],
        [true, false, false]
    ];

    for (const [expandedAbstract, hasShortenedDescription, expected] of scenarios) {
        ctrl.setProperties({
            expandedAbstract,
            hasShortenedDescription
        });

        assert.strictEqual(ctrl.get('useShortenedDescription'), expected);
    }
});

test('description computed property', function (assert) {
    this.inject.service('store');

    const store = this.store;
    const ctrl = this.subject();

    Ember.run(() => {
        const input = 'Lorem ipsum dolor sit amet, atqui elitr id vim, at clita facilis tibique ius, ad pro stet accusam. Laudem essent commune ea vix. Duis hendrerit complectitur usu eu, ei nam ullum accusamus inciderint, has appetere assueverit te. An pro maiorum alienum voluptatibus, mei adhuc docendi prodesset in. Ut vel mundi atomorum quaerendum, cu per autem menandri consequat, tantas dictas quodsi nec eu. Ornatus forensibus vituperatoribus id vix.';
        const expected ='Lorem ipsum dolor sit amet, atqui elitr id vim, at clita facilis tibique ius, ad pro stet accusam. Laudem essent commune ea vix. Duis hendrerit complectitur usu eu, ei nam ullum accusamus inciderint, has appetere assueverit te. An pro maiorum alienum voluptatibus, mei adhuc docendi prodesset in. Ut vel mundi atomorum quaerendum, cu per autem';

        const node = store.createRecord('node', {
            description: input
        });

        ctrl.setProperties({node});

        assert.strictEqual(
            ctrl.get('description'),
            expected
        );
    });
});

test('toggleLicenseText action', function (assert) {
    const ctrl = this.subject();
    const initialValue = ctrl.get('showLicenseText');

    ctrl.send('toggleLicenseText');
    assert.strictEqual(ctrl.get('showLicenseText'), !initialValue);

    ctrl.send('toggleLicenseText');
    assert.strictEqual(ctrl.get('showLicenseText'), initialValue);
});

test('expandMFR action', function (assert) {
    const ctrl = this.subject();
    const initialValue = ctrl.get('fullScreenMFR');

    ctrl.send('expandMFR');
    assert.strictEqual(ctrl.get('fullScreenMFR'), !initialValue);

    ctrl.send('expandMFR');
    assert.strictEqual(ctrl.get('fullScreenMFR'), initialValue);
});

test('expandAbstract action', function (assert) {
    const ctrl = this.subject();
    const initialValue = ctrl.get('expandedAbstract');

    ctrl.send('expandAbstract');
    assert.strictEqual(ctrl.get('expandedAbstract'), !initialValue);

    ctrl.send('expandAbstract');
    assert.strictEqual(ctrl.get('expandedAbstract'), initialValue);
});

test('chooseFile action', function (assert) {
    this.inject.service('store');

    const store = this.store;
    const ctrl = this.subject();

    Ember.run(() => {
        const fileItem = store.createRecord('file', {
            id: 'test1'
        });

        ctrl.send('chooseFile', fileItem);
        assert.strictEqual(ctrl.get('chosenFile'), 'test1');
        assert.strictEqual(ctrl.get('activeFile'), fileItem);
    });
});

// Don't try to test shareLink, since it includes a window.open call. No good way to test that.
<|endoftext|>


<commit_before>// Simulate config options from your production environment by
// customising the .env file in your project's root folder.
require('dotenv').load();

// Require keystone
var keystone = require('keystone');

// Initialise Keystone with your project's configuration.
// See http://keystonejs.com/guide/config for available options
// and documentation.

keystone.init({

	'name': 'MTG Baselland',
	'brand': 'MTG Baselland',

	'host': process.env.OPENSHIFT_HAPROXY_IP || process.env.IP || '127.0.0.1',
	'port': process.env.OPENSHIFT_HAPROXY_PORT || process.env.PORT || 3000,

	'mongo': process.env.OPENSHIFT_MONGODB_DB_URL || process.env.MONGO_URI || "mongodb://localhost/mtgbl",

	'cloudinary config': process.env.CLOUDINARY_URL,
	'cloudinary secure': true,

	'sass': 'public',
	'static': 'public',
	'favicon': 'public/favicon.ico',
	'views': 'templates/views',
	'view engine': 'jade',

	'auto update': true,
	'session': true,
	'auth': true,
	'user model': 'User',

	'wysiwyg images': true,
	'wysiwyg cloudinary images': true

});

// Load your project's Models

keystone.import('models');

// Setup common locals for your templates. The following are required for the
// bundled templates and layouts. Any runtime locals (that should be set uniquely
// for each request) should be added to ./routes/middleware.js

keystone.set('locals', {
	_: require('underscore'),
	env: keystone.get('env'),
	utils: keystone.utils,
	editable: keystone.content.editable
});

// Load your project's Routes

keystone.set('routes', require('./routes'));

// Configure the navigation bar in Keystone's Admin UI

keystone.set('nav', {
	'posts': ['posts', 'post-categories'],
	'galleries': 'galleries',
	'enquiries': 'enquiries',
	'users': 'users'
});

// Start Keystone to connect to your database and initialise the web server

keystone.start();
<commit_msg>Revert "change env ip/port"<commit_after>// Simulate config options from your production environment by
// customising the .env file in your project's root folder.
require('dotenv').load();

// Require keystone
var keystone = require('keystone');

// Initialise Keystone with your project's configuration.
// See http://keystonejs.com/guide/config for available options
// and documentation.

keystone.init({

	'name': 'MTG Baselland',
	'brand': 'MTG Baselland',

	'host': process.env.OPENSHIFT_NODEJS_IP || process.env.IP || '127.0.0.1',
	'port': process.env.OPENSHIFT_NODEJS_PORT || process.env.PORT || 3000,

	'mongo': process.env.OPENSHIFT_MONGODB_DB_URL || process.env.MONGO_URI || "mongodb://localhost/mtgbl",

	'cloudinary config': process.env.CLOUDINARY_URL,
	'cloudinary secure': true,

	'sass': 'public',
	'static': 'public',
	'favicon': 'public/favicon.ico',
	'views': 'templates/views',
	'view engine': 'jade',

	'auto update': true,
	'session': true,
	'auth': true,
	'user model': 'User',

	'wysiwyg images': true,
	'wysiwyg cloudinary images': true

});

// Load your project's Models

keystone.import('models');

// Setup common locals for your templates. The following are required for the
// bundled templates and layouts. Any runtime locals (that should be set uniquely
// for each request) should be added to ./routes/middleware.js

keystone.set('locals', {
	_: require('underscore'),
	env: keystone.get('env'),
	utils: keystone.utils,
	editable: keystone.content.editable
});

// Load your project's Routes

keystone.set('routes', require('./routes'));

// Configure the navigation bar in Keystone's Admin UI

keystone.set('nav', {
	'posts': ['posts', 'post-categories'],
	'galleries': 'galleries',
	'enquiries': 'enquiries',
	'users': 'users'
});

// Start Keystone to connect to your database and initialise the web server

keystone.start();
<|endoftext|>


<commit_before>import {Duration} from './duration';
import {Formatter} from './impl/formatter';
import {Gregorian} from './impl/gregorian';
import {FixedOffsetZone} from './impl/fixedOffsetZone';
import {LocalZone} from './impl/localZone';

function isUndefined(o){
  return typeof(o) == 'undefined';
}

function now(){
  return new Date().valueOf();
}

function clone(inst, alts = {}){
  let current = {ts: inst.ts, zone: inst.zone, c: inst.c, o: inst.o};
  return new Instant(Object.assign({}, current, alts, {old: current}));
}

//seems like this might be more complicated than it appears here:
//https://github.com/v8/v8/blob/master/src/date.cc#L212
function fixOffset(ts, tz, o){
  //1. test whether the zone matches the offset for this ts
  let o2 = tz.offset(ts);
  if (o == o2){
    return [ts, o];
  }

  //2. if not, change the ts by the difference in the offset
  ts -= (o2 - o) * 60 * 1000;

  //3. check it again
  let o3 = tz.offset(ts);

  //4. if it's the same, good to go
  if (o2 == o3){
    return [ts, o2];
  }

  //5. if it's different, steal underpants
  //6. profit!
  return [ts, o];
}

function adjustTime(inst, dur){
  let tz = inst.zone,
      o = tz.offset(this.ts),
      c = Object.assign({}, inst.c, {
        year: inst.c.year + dur.years,
        month: inst.c.month + dur.months,
        day: inst.c.day + dur.days
      }),
      ts = Gregorian.objToTS(c, o);

  [ts, o] = fixOffset(ts, o);

  let millisToAdd = Duration
        .fromObject(leftovers)
        .shiftTo('milliseconds')
        .milliseconds();

  ts += millisToAdd;

  [ts, o] = fixOffset(ts, o);

  return {ts: Gregorian.tsToObj(ts, o), zone: tz};
}

function friendlyDuration(durationOrNumber, type){
  return typeof durationOrNumber === 'number' ?
    Duration.fromLength(durationOrNumber, type) :
    durationOrNumber;
}

export class Instant{

  constructor(config = {}){
    Object.defineProperty(this, 'ts', {
      value: config.ts || Instant.now(),
      enumerable: true
    });

    Object.defineProperty(this, 'zone', {
      value: config.zone || Instant.defaultZone,
      enumerable: true
    });

    Object.defineProperty(this, 'locale', {
      value: config.locale || 'en-us',
      enumerable: true
    });

    let c = (config.old && config.old.ts == this.ts && config.old.zone.equals(this.zone)) ?
          config.old.c :
          Gregorian.tsToObj(this.ts, this.zone.offset(this.ts));

    let o = (config.old && config.old.zone.equals(this.zone)) ?
          config.old.o :
          this.zone.offset(this.ts);

    Object.defineProperty(this, 'c', {value: c});
    Object.defineProperty(this, 'o', {value: o});
  }

  static get defaultZone(){
    return new LocalZone();
  }

  //create instants

  static now(){
    return new Instant({ts: now()});
  }

  static fromJSDate(date){
    return new Instant({ts: date.valueOf()});
  }

  static fromMillis(milliseconds){
    return new Instant({ts: milliseconds});
  }

  static fromUnix(seconds){
    return this.fromMillis(seconds * 1000);
  }

  static fromObject(obj, opts = {utc: false, zone: null}){
    let tsNow = now();

    let zone = opts.zone ? opts.zone : (opts.utc ? new FixedOffsetZone(0) : new LocalZone()),
        offsetProvis = zone.offset(tsNow),
        defaulted = Object.assign(Gregorian.tsToObj(tsNow, offsetProvis), {hour: 0, minute: 0, second: 0, millisecond: 0}, obj),
        tsProvis = Gregorian.objToTS(defaulted, offsetProvis),
        [tsFinal, _] = fixOffset(tsProvis, zone, offsetProvis);

    return new Instant({ts: tsFinal, zone: zone});
  }

  static fromISOString(text){
  }

  static fromString(text, fmt){
  }

  //operate on many instants
  static max(...instants){
  }

  static min(...instants){
  }

  //localization

  locale(l){
    if (isUndefined(l)){
      return this.locale;
    }
    else{
      return this.clone(this, {locale: l});
    }
  }

  //zones and offsets

  utc(){
    return this.useUTCOffset(0);
  }

  useUTCOffset(offset, opts = {keepCalendarTime: false}){
    return this.rezone(new FixedOffsetZone(offset), opts);
  }

  local(){
    return this.rezone(new LocalZone());
  }

  timezone(zone){
    return this.zone;
  }

  rezone(zone, opts = {keepCalendarTime: false}){
    if (zone.equals(this.zone)){
      return this;
    }
    else {
      //this keepCalendarTime thing probably doesn't work for variable-offset zones
      let newTS = opts.keepCalendarTime ? this.ts - this.o + zone(this.ts) : this.ts;
      return clone(this, {ts: newTS, zone: zone});
    }
  }

  timezoneName(opts = {}){
    return this.zone.name(opts);
  }

  isOffsetFixed(){
    return this.zone.universal();
  }

  //getters/setters
  get(unit){
    return this[unit]();
  }

  set(values){
    let mixed = Object.assign(this.toObject(), values);
    return this.clone(this, {ts: Gregorian.objToTS(mixed)});
  }

  year(v){
    return isUndefined(v) ? this.c.year : this.set({year: v});
  }

  month(v){
    return isUndefined(v) ? this.c.month : this.set({month: v});
  }

  day(v){
    return isUndefined(v) ? this.c.day : this.set({day: v});
  }

  hour(v){
    return isUndefined(v) ? this.c.hour : this.set({hour: v});
  }

  minute(v){
    return isUndefined(v) ? this.c.minute : this.set({minute: v});
  }

  second(v){
    return isUndefined(v) ? this.c.second : this.set({second: v});
  }

  millisecond(v){
    return isUndefined(v) ? this.c.millisecond : this.set({millsecond: v});
  }

  weekday(){
    return "Not implemented";
  }

  offset(){
    return this.zone.offset(this.ts);
  }

  //useful info

  isInLeapYear(){
    let year = this.year();
    return (year % 4 === 0 && year % 100 !== 0) || year % 400 === 0;
  }

  isDST(){
    return this.offset() > this.month(0).offset() || this.offset() > this.month(5).offset();
  }

  daysInMonth(){
    let year = this.year(),
        month = this.month();

    return Gregorian.daysInMonth(year, month);
  }

  daysInYear(){
    return Gregorian.daysInYear(this.year());
  }

  //generate strings and other values
  toFormatString(fmt, opts = {}){
    return Formatter.create(this, opts).formatFromString(this);
  }

  toLocaleString(opts = {}){
    return Formatter.create(this, opts).formatDate(this);
  }

  toISO(){
    return Formatter.create({locale: 'en'}).formatFromString(this, 'yyyy-MM-ddTHH:mm:ss.SSSZ');
  }

  toString(){
    return this.utc().toISO();
  }

  valueOf(){
    return this.ts;
  }

  toJSON(){
    return this.toISO();
  }

  toObject(opts = {}){
    return Object.assign({}, this.c);
  }

  toJSDate(){
    return new Date(this.ts);
  }

  resolvedLocaleOpts(opts = {}){
    return Formatter.create(this, opts).resolvedOptions();
  }

  //add/subtract/compare
  plus(durationOrNumber, type){
    let dur = friendlyDuration(durationOrNumber, type);
    this.clone(this, adjustTime(this, dur));
  }

  minus(durationOrNumber, type){
    let dur = friendlyDuration(durationOrNumber, type).negate();
    this.clone(this, adjustTime(this, dur));
  }

  diff(otherInstant, opts = {granularity: 'millisecond'}){
  }

  diffNow(opts = {granularity : 'millisecond'}){
  }
}
<commit_msg>tiny cleanup<commit_after>import {Duration} from './duration';
import {Formatter} from './impl/formatter';
import {Gregorian} from './impl/gregorian';
import {FixedOffsetZone} from './impl/fixedOffsetZone';
import {LocalZone} from './impl/localZone';

function isUndefined(o){
  return typeof(o) == 'undefined';
}

function now(){
  return new Date().valueOf();
}

function clone(inst, alts = {}){
  let current = {ts: inst.ts, zone: inst.zone, c: inst.c, o: inst.o};
  return new Instant(Object.assign({}, current, alts, {old: current}));
}

//seems like this might be more complicated than it appears. E.g.:
//https://github.com/v8/v8/blob/master/src/date.cc#L212
function fixOffset(ts, tz, o){
  //1. test whether the zone matches the offset for this ts
  let o2 = tz.offset(ts);
  if (o == o2){
    return [ts, o];
  }

  //2. if not, change the ts by the difference in the offset
  ts -= (o2 - o) * 60 * 1000;

  //3. check it again
  let o3 = tz.offset(ts);

  //4. if it's the same, good to go
  if (o2 == o3){
    return [ts, o2];
  }

  //5. if it's different, steal underpants
  //6. ???
  //7. profit!
  return [ts, o];
}

function adjustTime(inst, dur){
  let tz = inst.zone,
      o = tz.offset(this.ts),
      c = Object.assign({}, inst.c, {
        year: inst.c.year + dur.years,
        month: inst.c.month + dur.months,
        day: inst.c.day + dur.days
      }),
      ts = Gregorian.objToTS(c, o);

  [ts, o] = fixOffset(ts, o);

  let millisToAdd = Duration
        .fromObject(leftovers)
        .shiftTo('milliseconds')
        .milliseconds();

  ts += millisToAdd;

  [ts, o] = fixOffset(ts, o);

  return {ts: Gregorian.tsToObj(ts, o), zone: tz};
}

function friendlyDuration(durationOrNumber, type){
  return typeof durationOrNumber === 'number' ?
    Duration.fromLength(durationOrNumber, type) :
    durationOrNumber;
}

export class Instant{

  constructor(config = {}){
    Object.defineProperty(this, 'ts', {
      value: config.ts || Instant.now(),
      enumerable: true
    });

    Object.defineProperty(this, 'zone', {
      value: config.zone || Instant.defaultZone,
      enumerable: true
    });

    Object.defineProperty(this, 'locale', {
      value: config.locale || 'en-us',
      enumerable: true
    });

    let c = (config.old && config.old.ts == this.ts && config.old.zone.equals(this.zone)) ?
          config.old.c :
          Gregorian.tsToObj(this.ts, this.zone.offset(this.ts));

    let o = (config.old && config.old.zone.equals(this.zone)) ?
          config.old.o :
          this.zone.offset(this.ts);

    Object.defineProperty(this, 'c', {value: c});
    Object.defineProperty(this, 'o', {value: o});
  }

  static get defaultZone(){
    return new LocalZone();
  }

  //create instants

  static now(){
    return new Instant({ts: now()});
  }

  static fromJSDate(date){
    return new Instant({ts: date.valueOf()});
  }

  static fromMillis(milliseconds){
    return new Instant({ts: milliseconds});
  }

  static fromUnix(seconds){
    return this.fromMillis(seconds * 1000);
  }

  static fromObject(obj, opts = {utc: false, zone: null}){
    let tsNow = now();

    let zone = opts.zone ? opts.zone : (opts.utc ? new FixedOffsetZone(0) : new LocalZone()),
        offsetProvis = zone.offset(tsNow),
        defaulted = Object.assign(Gregorian.tsToObj(tsNow, offsetProvis), {hour: 0, minute: 0, second: 0, millisecond: 0}, obj),
        tsProvis = Gregorian.objToTS(defaulted, offsetProvis),
        [tsFinal, _] = fixOffset(tsProvis, zone, offsetProvis);

    return new Instant({ts: tsFinal, zone: zone});
  }

  static fromISOString(text){
  }

  static fromString(text, fmt){
  }

  //operate on many instants
  static max(...instants){
  }

  static min(...instants){
  }

  //localization

  locale(l){
    if (isUndefined(l)){
      return this.locale;
    }
    else{
      return this.clone(this, {locale: l});
    }
  }

  //zones and offsets

  utc(){
    return this.useUTCOffset(0);
  }

  useUTCOffset(offset, opts = {keepCalendarTime: false}){
    return this.rezone(new FixedOffsetZone(offset), opts);
  }

  local(){
    return this.rezone(new LocalZone());
  }

  timezone(zone){
    return this.zone;
  }

  rezone(zone, opts = {keepCalendarTime: false}){
    if (zone.equals(this.zone)){
      return this;
    }
    else {
      //this keepCalendarTime thing probably doesn't work for variable-offset zones
      let newTS = opts.keepCalendarTime ? this.ts - this.o + zone(this.ts) : this.ts;
      return clone(this, {ts: newTS, zone: zone});
    }
  }

  timezoneName(opts = {}){
    return this.zone.name(opts);
  }

  isOffsetFixed(){
    return this.zone.universal();
  }

  //getters/setters
  get(unit){
    return this[unit]();
  }

  set(values){
    let mixed = Object.assign(this.toObject(), values);
    return this.clone(this, {ts: Gregorian.objToTS(mixed)});
  }

  year(v){
    return isUndefined(v) ? this.c.year : this.set({year: v});
  }

  month(v){
    return isUndefined(v) ? this.c.month : this.set({month: v});
  }

  day(v){
    return isUndefined(v) ? this.c.day : this.set({day: v});
  }

  hour(v){
    return isUndefined(v) ? this.c.hour : this.set({hour: v});
  }

  minute(v){
    return isUndefined(v) ? this.c.minute : this.set({minute: v});
  }

  second(v){
    return isUndefined(v) ? this.c.second : this.set({second: v});
  }

  millisecond(v){
    return isUndefined(v) ? this.c.millisecond : this.set({millsecond: v});
  }

  weekday(){
    return "Not implemented";
  }

  offset(){
    return this.zone.offset(this.ts);
  }

  //useful info

  isInLeapYear(){
    let year = this.year();
    return (year % 4 === 0 && year % 100 !== 0) || year % 400 === 0;
  }

  isDST(){
    return this.offset() > this.month(0).offset() || this.offset() > this.month(5).offset();
  }

  daysInMonth(){
    return Gregorian.daysInMonth(this.month(), this.year());
  }

  daysInYear(){
    return Gregorian.daysInYear(this.year());
  }

  //generate strings and other values
  toFormatString(fmt, opts = {}){
    return Formatter.create(this, opts).formatFromString(this);
  }

  toLocaleString(opts = {}){
    return Formatter.create(this, opts).formatDate(this);
  }

  toISO(){
    return Formatter.create({locale: 'en'}).formatFromString(this, 'yyyy-MM-ddTHH:mm:ss.SSSZ');
  }

  toString(){
    return this.utc().toISO();
  }

  valueOf(){
    return this.ts;
  }

  toJSON(){
    return this.toISO();
  }

  toObject(opts = {}){
    return Object.assign({}, this.c);
  }

  toJSDate(){
    return new Date(this.ts);
  }

  resolvedLocaleOpts(opts = {}){
    return Formatter.create(this, opts).resolvedOptions();
  }

  //add/subtract/compare
  plus(durationOrNumber, type){
    let dur = friendlyDuration(durationOrNumber, type);
    this.clone(this, adjustTime(this, dur));
  }

  minus(durationOrNumber, type){
    let dur = friendlyDuration(durationOrNumber, type).negate();
    this.clone(this, adjustTime(this, dur));
  }

  diff(otherInstant, opts = {granularity: 'millisecond'}){
  }

  diffNow(opts = {granularity : 'millisecond'}){
  }
}
<|endoftext|>


<commit_before>import React, { Component } from 'react';

import Presentation from './Presentation';
import Author from './Author';

class PerformedPanel extends Component {
  render() {
    const { sessionCode, sessionName, sessionRoom, sessionStartTime, sessionEndTime,
            sessionDescription, sessionChairs, presentations, sessionType
          } = this.props;
    const timeStr = `${sessionStartTime} - ${sessionEndTime}`;

    let DescriptionEl = false;
    if (sessionDescription) {
      DescriptionEl =
        <description dangerouslySetInnerHTML={{__html: sessionDescription}} />;
    }

    return (
      <presentation>
        { sessionType }
        <sessioncode>{ sessionCode }</sessioncode>
        <sessionname>{ sessionName }</sessionname>
        <starttime>{ timeStr }</starttime>
        <sessionroom>{ sessionRoom }</sessionroom>

        { sessionChairs.map( item => (
          <Author key={item.iD} tagName="moderator" {...item} />
        ))}

        { DescriptionEl }

        { presentations.map( item => (
          <Presentation key={item.iD} {...item} />
        ))}

      </presentation>
    );
  }
}

export default PerformedPanel;

// Preformed Panel
// [Session Number (i.e. 1.1.08)] [Title of Preformed Panel]
// [time] [Location]
// [Moderator]
// [All Presenter/Author(s)]

// [Presentation 1 Title]
// [Presenter of Presentation 1] – should include their organization

// i.e.: Marianne Amoss, Gates Institute;
// [Presentation 2 Title]
// [Presenter of Presentation 2]

// - - - - -

// Individual Abstracts
// [Session Number (i.e. 1.1.08)] [Title of Session]
// [time] [Location]

// [Co-Moderator], [Co-moderator]
// [All Author(s)], [Author’s Organization] – repeat per number of co-authors

// Repeat per number of abstracts
<commit_msg>eslint<commit_after>import React, { Component } from 'react';

import Presentation from './Presentation';
import Author from './Author';

class PerformedPanel extends Component {
  render() {
    const { sessionCode, sessionName, sessionRoom, sessionStartTime, sessionEndTime,
            sessionDescription, sessionChairs, presentations, sessionType,
          } = this.props;
    const timeStr = `${sessionStartTime} - ${sessionEndTime}`;

    let DescriptionEl = false;
    if (sessionDescription) {
      DescriptionEl =
        <description dangerouslySetInnerHTML={{__html: sessionDescription}} />;
    }

    return (
      <presentation>
        { sessionType }
        <sessioncode>{ sessionCode }</sessioncode>
        <sessionname>{ sessionName }</sessionname>
        <starttime>{ timeStr }</starttime>
        <sessionroom>{ sessionRoom }</sessionroom>

        { sessionChairs.map( item => (
          <Author key={item.iD} tagName="moderator" {...item} />
        ))}

        { DescriptionEl }

        { presentations.map( item => (
          <Presentation key={item.iD} {...item} />
        ))}

      </presentation>
    );
  }
}

export default PerformedPanel;

// Preformed Panel
// [Session Number (i.e. 1.1.08)] [Title of Preformed Panel]
// [time] [Location]
// [Moderator]
// [All Presenter/Author(s)]

// [Presentation 1 Title]
// [Presenter of Presentation 1] – should include their organization

// i.e.: Marianne Amoss, Gates Institute;
// [Presentation 2 Title]
// [Presenter of Presentation 2]

// - - - - -

// Individual Abstracts
// [Session Number (i.e. 1.1.08)] [Title of Session]
// [time] [Location]

// [Co-Moderator], [Co-moderator]
// [All Author(s)], [Author’s Organization] – repeat per number of co-authors

// Repeat per number of abstracts
<|endoftext|>