<commit_before>/***** BEGIN LICENSE BLOCK ***** {{{
 *
 * Mozilla Public License Notice
 *
 * The contents of this file are subject to the Mozilla Public License
 * Version 1.1  (the "License"); you may  not use this  file except in
 * compliance with the  License. You may obtain a  copy of the License
 * at http://www.mozilla.org/MPL/
 *
 * Software distributed under the License is distributed on an "AS IS"
 * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
 * the  License  for  the   specific  language  governing  rights  and
 * limitations under the License.
 *
}}} ***** END LICENSE BLOCK *****/

// command names taken from:
// http://developer.mozilla.org/en/docs/Editor_Embedding_Guide

function Editor() //{{{
{
    function getController()
    {
        var el = window.document.commandDispatcher.focusedElement;
        if (!el || !el.controllers)
            return null;

        return el.controllers.getControllerAt(0);
    }

    this.unselectText = function()
    {
        var elt = window.document.commandDispatcher.focusedElement;
        elt.selectionEnd = elt.selectionStart;
        return true;
    }

    this.pasteClipboard = function()
    {
        var elt = window.document.commandDispatcher.focusedElement;

        if (elt.setSelectionRange && readFromClipboard())
            // readFromClipboard would return 'undefined' if not checked
            // dunno about .setSelectionRange
        {
            var rangeStart = elt.selectionStart; // caret position
            var rangeEnd = elt.selectionEnd;
            var tempStr1 = elt.value.substring(0,rangeStart);
            var tempStr2 = readFromClipboard();
            var tempStr3 = elt.value.substring(rangeEnd);
            elt.value = tempStr1 + tempStr2  + tempStr3;
            elt.selectionStart = rangeStart + tempStr2.length;
            elt.selectionEnd = elt.selectionStart;
        }
    }

    // count is optional, defaults to 1
    this.executeCommand = function(cmd, count)
    {
        var controller = getController();
        var el = window.document.commandDispatcher.focusedElement;
        if (!controller || !el)
            return false;

        if (!controller.supportsCommand(cmd) || !controller.isCommandEnabled(cmd))
        {
            vimperator.beep();
            return false;
        }

        if (typeof count != "number" || count < 1)
            count = 1;

        var did_command = false;
        while(count--)
        {
            // some commands need this try/catch workaround, because a cmd_charPrevious triggered
            // at the beginning of the textarea, would hang the doCommand()
            // good thing is, we need this code anyway for proper beeping
            try
            {
                controller.doCommand(cmd);
                did_command = true;
            }
            catch(e)
            {
                if (!did_command)
                    vimperator.beep();
                return false;
            }
        }

        return true;
    }

    // cmd = y, d, c
    // motion = b, 0, gg, G, etc.
    this.executeCommandWithMotion = function(cmd, motion)
    {

    }
} //}}}

// vim: set fdm=marker sw=4 ts=4 et:
<commit_msg>quick'n dirty block cursor, VERY BUGGY, stay in insert mode of textareas for now<commit_after>/***** BEGIN LICENSE BLOCK ***** {{{
 *
 * Mozilla Public License Notice
 *
 * The contents of this file are subject to the Mozilla Public License
 * Version 1.1  (the "License"); you may  not use this  file except in
 * compliance with the  License. You may obtain a  copy of the License
 * at http://www.mozilla.org/MPL/
 *
 * Software distributed under the License is distributed on an "AS IS"
 * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
 * the  License  for  the   specific  language  governing  rights  and
 * limitations under the License.
 *
}}} ***** END LICENSE BLOCK *****/

// command names taken from:
// http://developer.mozilla.org/en/docs/Editor_Embedding_Guide

function Editor() //{{{
{
    function editor()
    {
        return window.document.commandDispatcher.focusedElement;
    }

    function getController()
    {
        var el = window.document.commandDispatcher.focusedElement;
        if (!el || !el.controllers)
            return null;

        return el.controllers.getControllerAt(0);
    }

    this.unselectText = function()
    {
        var elt = window.document.commandDispatcher.focusedElement;
        elt.selectionEnd = elt.selectionStart;
        return true;
    }

    this.pasteClipboard = function()
    {
        var elt = window.document.commandDispatcher.focusedElement;

        if (elt.setSelectionRange && readFromClipboard())
            // readFromClipboard would return 'undefined' if not checked
            // dunno about .setSelectionRange
        {
            var rangeStart = elt.selectionStart; // caret position
            var rangeEnd = elt.selectionEnd;
            var tempStr1 = elt.value.substring(0,rangeStart);
            var tempStr2 = readFromClipboard();
            var tempStr3 = elt.value.substring(rangeEnd);
            elt.value = tempStr1 + tempStr2  + tempStr3;
            elt.selectionStart = rangeStart + tempStr2.length;
            elt.selectionEnd = elt.selectionStart;
        }
    }

    // count is optional, defaults to 1
    this.executeCommand = function(cmd, count)
    {
        var controller = getController();
        var el = window.document.commandDispatcher.focusedElement;
        if (!controller || !el)
            return false;

        if (!controller.supportsCommand(cmd) || !controller.isCommandEnabled(cmd))
        {
            vimperator.beep();
            return false;
        }

        if (typeof count != "number" || count < 1)
            count = 1;

        var did_command = false;
        while(count--)
        {
            // some commands need this try/catch workaround, because a cmd_charPrevious triggered
            // at the beginning of the textarea, would hang the doCommand()
            // good thing is, we need this code anyway for proper beeping
            try
            {
                controller.doCommand(cmd);
                did_command = true;

                if (vimperator.hasMode(vimperator.modes.TEXTAREA))
                    this.moveCaret();
            }
            catch(e)
            {
                if (!did_command)
                    vimperator.beep();
                return false;
            }
        }

        return true;
    }

    // very rudimentary testing code
    this.moveCaret = function(pos)
    {
        if (!pos)
            pos = editor().selectionStart - 1;

        editor().setSelectionRange(pos, pos+1);
    }

    // cmd = y, d, c
    // motion = b, 0, gg, G, etc.
    this.executeCommandWithMotion = function(cmd, motion)
    {

    }
} //}}}

// vim: set fdm=marker sw=4 ts=4 et:
<|endoftext|>


<commit_before>Package.describe({
  "summary": "Subscriptions Manager for Meteor",
  "version": "1.4.0",
  "git": "https://github.com/meteorhacks/subs-manager.git",
  "name": "meteorhacks:subs-manager"
});

Package.on_use(function(api) {
  configurePackage(api);
  api.export(['SubsManager']);
});

Package.on_test(function(api) {
  configurePackage(api);

  api.use(['tinytest', 'mongo-livedata'], ['client', 'server']);
  api.add_files([
    'tests/init.js',
  ], ['server', 'client']);

  api.add_files([
    'tests/options.js',
    'tests/core.js',
    'tests/error.js'
  ], ['client']);
});

function configurePackage(api) {
  if(api.versionsFrom) {
    api.versionsFrom('METEOR@0.9.0');
  }

  api.use(['deps', 'underscore', 'ejson'], ['client', 'server']);
  api.use('meteorhacks:fast-render@2.6.0', 'client', {weak: true});

  api.add_files([
    'lib/sub_manager.js',
  ], ['client', 'server']);
}
<commit_msg>v1.5.0<commit_after>Package.describe({
  "summary": "Subscriptions Manager for Meteor",
  "version": "1.5.0",
  "git": "https://github.com/meteorhacks/subs-manager.git",
  "name": "meteorhacks:subs-manager"
});

Package.on_use(function(api) {
  configurePackage(api);
  api.export(['SubsManager']);
});

Package.on_test(function(api) {
  configurePackage(api);

  api.use(['tinytest', 'mongo-livedata'], ['client', 'server']);
  api.add_files([
    'tests/init.js',
  ], ['server', 'client']);

  api.add_files([
    'tests/options.js',
    'tests/core.js',
    'tests/error.js'
  ], ['client']);
});

function configurePackage(api) {
  if(api.versionsFrom) {
    api.versionsFrom('METEOR@0.9.0');
  }

  api.use(['deps', 'underscore', 'ejson'], ['client', 'server']);
  api.use('meteorhacks:fast-render@2.6.0', 'client', {weak: true});

  api.add_files([
    'lib/sub_manager.js',
  ], ['client', 'server']);
}
<|endoftext|>


<commit_before>"use strict";

Package.describe({
  name: 'brettle:accounts-add-service',
  version: '0.3.4',
  summary: 'Allow users to add login services to their accounts',
  git: 'https://github.com/brettle/meteor-accounts-add-service.git',
  documentation: 'README.md'
});

Package.onUse(function(api) {
  api.versionsFrom('1.0.4');
  api.use('underscore');
  api.use('brettle:workaround-issue-4331@0.0.1');
  api.use('brettle:workaround-issue-4970@0.0.1');
  api.use('brettle:workaround-issue-5110@0.0.1');
  api.use('brettle:accounts-multiple@0.3.1', 'server');
  api.export('AccountsAddService');
  api.addFiles('accounts-add-service-common.js');
  api.addFiles('accounts-add-service-client.js', 'client');
  api.addFiles('accounts-add-service-server.js', 'server');
});

Package.onTest(function(api) {
  api.versionsFrom('1.0.4');
  api.use('tinytest');
  api.use('ddp');
  api.use('accounts-base');
  api.use('accounts-password');
  api.use('brettle:accounts-add-service@0.3.3');
  api.use('brettle:accounts-testing-support@0.4.1');
  api.use('brettle:accounts-multiple@0.3.1', 'server');
  api.addFiles('accounts-add-service-server-tests.js', 'server');
});
<commit_msg>Make tests use latest brettle:accounts-testing-support.<commit_after>"use strict";

Package.describe({
  name: 'brettle:accounts-add-service',
  version: '0.3.4',
  summary: 'Allow users to add login services to their accounts',
  git: 'https://github.com/brettle/meteor-accounts-add-service.git',
  documentation: 'README.md'
});

Package.onUse(function(api) {
  api.versionsFrom('1.0.4');
  api.use('underscore');
  api.use('brettle:workaround-issue-4331@0.0.1');
  api.use('brettle:workaround-issue-4970@0.0.1');
  api.use('brettle:workaround-issue-5110@0.0.1');
  api.use('brettle:accounts-multiple@0.3.1', 'server');
  api.export('AccountsAddService');
  api.addFiles('accounts-add-service-common.js');
  api.addFiles('accounts-add-service-client.js', 'client');
  api.addFiles('accounts-add-service-server.js', 'server');
});

Package.onTest(function(api) {
  api.versionsFrom('1.0.4');
  api.use('tinytest');
  api.use('ddp');
  api.use('accounts-base');
  api.use('accounts-password');
  api.use('brettle:accounts-add-service@0.3.3');
  api.use('brettle:accounts-testing-support@0.4.3');
  api.use('brettle:accounts-multiple@0.3.1', 'server');
  api.addFiles('accounts-add-service-server-tests.js', 'server');
});
<|endoftext|>


<commit_before>Package.describe({
  name: "aldeed:autoform",
  summary: "Easily create forms with automatic insert and update, and automatic reactive validation.",
  git: "https://github.com/aldeed/meteor-autoform.git",
  version: "5.5.1"
});

Package.onUse(function(api) {
  // Dependencies
  api.versionsFrom(['METEOR@0.9.3', 'METEOR@0.9.4', 'METEOR@1.0']);
  // common
  api.use('aldeed:simple-schema@1.1.0');
  api.use('check');
  // client
  api.use(['livedata', 'underscore', 'deps', 'templating', 'ui', 'blaze', 'ejson', 'reactive-var', 'reactive-dict', 'random', 'jquery'], 'client');
  api.use('momentjs:moment@2.10.6', 'client');
  api.use('mrt:moment-timezone@0.2.1', 'client', {weak: true});
  api.use('aldeed:moment-timezone@0.4.0', 'client', {weak: true});
  api.use(['aldeed:collection2@2.0.0', 'reload'], 'client', {weak: true});

  // Imply SS to make sure SimpleSchema object is available to app
  api.imply('aldeed:simple-schema');

  // Exports
  api.export('AutoForm', 'client');
  api.export('Utility', 'client', {testOnly: true});

  // Common Files
  api.addFiles(['autoform-common.js']);

  // Client Files
  api.addFiles([
    // utilities and general init
    'utility.js',
    'form-preserve.js',
    'autoform-hooks.js',
    'autoform-formdata.js',
    'autoform-arrays.js',
    'autoform.js',
    // global helpers
    'autoform-helpers.js',
    // validation
    'autoform-validation.js',
    // inputs
    'autoform-inputs.js',
    // public API
    'autoform-api.js',
    // form types
    'formTypes/insert.js',
    'formTypes/update.js',
    'formTypes/update-pushArray.js',
    'formTypes/method.js',
    'formTypes/method-update.js',
    'formTypes/normal.js',
    'formTypes/readonly.js',
    'formTypes/disabled.js',
    // input types
    'inputTypes/value-converters.js',
    'inputTypes/boolean-checkbox/boolean-checkbox.html',
    'inputTypes/boolean-checkbox/boolean-checkbox.js',
    'inputTypes/boolean-radios/boolean-radios.html',
    'inputTypes/boolean-radios/boolean-radios.js',
    'inputTypes/boolean-select/boolean-select.html',
    'inputTypes/boolean-select/boolean-select.js',
    'inputTypes/button/button.html',
    'inputTypes/button/button.js',
    'inputTypes/color/color.html',
    'inputTypes/color/color.js',
    'inputTypes/contenteditable/contenteditable.html',
    'inputTypes/contenteditable/contenteditable.js',
    'inputTypes/date/date.html',
    'inputTypes/date/date.js',
    'inputTypes/datetime/datetime.html',
    'inputTypes/datetime/datetime.js',
    'inputTypes/datetime-local/datetime-local.html',
    'inputTypes/datetime-local/datetime-local.js',
    'inputTypes/email/email.html',
    'inputTypes/email/email.js',
    'inputTypes/file/file.html',
    'inputTypes/file/file.js',
    'inputTypes/hidden/hidden.html',
    'inputTypes/hidden/hidden.js',
    'inputTypes/image/image.html',
    'inputTypes/image/image.js',
    'inputTypes/month/month.html',
    'inputTypes/month/month.js',
    'inputTypes/number/number.html',
    'inputTypes/number/number.js',
    'inputTypes/password/password.html',
    'inputTypes/password/password.js',
    'inputTypes/radio/radio.html',
    'inputTypes/radio/radio.js',
    'inputTypes/range/range.html',
    'inputTypes/range/range.js',
    'inputTypes/reset/reset.html',
    'inputTypes/reset/reset.js',
    'inputTypes/search/search.html',
    'inputTypes/search/search.js',
    'inputTypes/select/select.html',
    'inputTypes/select/select.js',
    'inputTypes/select-checkbox/select-checkbox.html',
    'inputTypes/select-checkbox/select-checkbox.js',
    'inputTypes/select-checkbox-inline/select-checkbox-inline.html',
    'inputTypes/select-checkbox-inline/select-checkbox-inline.js',
    'inputTypes/select-multiple/select-multiple.html',
    'inputTypes/select-multiple/select-multiple.js',
    'inputTypes/select-radio/select-radio.html',
    'inputTypes/select-radio/select-radio.js',
    'inputTypes/select-radio-inline/select-radio-inline.html',
    'inputTypes/select-radio-inline/select-radio-inline.js',
    'inputTypes/submit/submit.html',
    'inputTypes/submit/submit.js',
    'inputTypes/tel/tel.html',
    'inputTypes/tel/tel.js',
    'inputTypes/text/text.html',
    'inputTypes/text/text.js',
    'inputTypes/textarea/textarea.html',
    'inputTypes/textarea/textarea.js',
    'inputTypes/time/time.html',
    'inputTypes/time/time.js',
    'inputTypes/url/url.html',
    'inputTypes/url/url.js',
    'inputTypes/week/week.html',
    'inputTypes/week/week.js',
    // components that render a form
    'components/autoForm/autoForm.html',
    'components/autoForm/autoForm.js',
    'components/quickForm/quickForm.html',
    'components/quickForm/quickForm.js',
    // components that render controls within a form
    'components/afArrayField/afArrayField.html',
    'components/afArrayField/afArrayField.js',
    'components/afEachArrayItem/afEachArrayItem.html',
    'components/afEachArrayItem/afEachArrayItem.js',
    'components/afFieldInput/afFieldInput.html',
    'components/afFieldInput/afFieldInput.js',
    'components/afFormGroup/afFormGroup.html',
    'components/afFormGroup/afFormGroup.js',
    'components/afObjectField/afObjectField.html',
    'components/afObjectField/afObjectField.js',
    'components/afQuickField/afQuickField.html',
    'components/afQuickField/afQuickField.js',
    'components/afQuickFields/afQuickFields.html',
    'components/afQuickFields/afQuickFields.js',
    // event handling
    'autoform-events.js',
    // bootstrap3 Template - General
    'templates/bootstrap3/bootstrap3.js',
    // bootstrap3 Template - Components
    'templates/bootstrap3/components/quickForm/quickForm.html',
    'templates/bootstrap3/components/quickForm/quickForm.js',
    'templates/bootstrap3/components/afArrayField/afArrayField.html',
    'templates/bootstrap3/components/afArrayField/afArrayField.css',
    'templates/bootstrap3/components/afFormGroup/afFormGroup.html',
    'templates/bootstrap3/components/afFormGroup/afFormGroup.js',
    'templates/bootstrap3/components/afObjectField/afObjectField.html',
    'templates/bootstrap3/components/afObjectField/afObjectField.js',
    // bootstrap3 Template - Input Types
    'templates/bootstrap3/inputTypes/boolean-checkbox/boolean-checkbox.html',
    'templates/bootstrap3/inputTypes/boolean-radios/boolean-radios.html',
    'templates/bootstrap3/inputTypes/boolean-radios/boolean-radios.js',
    'templates/bootstrap3/inputTypes/boolean-select/boolean-select.html',
    'templates/bootstrap3/inputTypes/button/button.html',
    'templates/bootstrap3/inputTypes/color/color.html',
    'templates/bootstrap3/inputTypes/date/date.html',
    'templates/bootstrap3/inputTypes/datetime/datetime.html',
    'templates/bootstrap3/inputTypes/datetime-local/datetime-local.html',
    'templates/bootstrap3/inputTypes/email/email.html',
    'templates/bootstrap3/inputTypes/month/month.html',
    'templates/bootstrap3/inputTypes/number/number.html',
    'templates/bootstrap3/inputTypes/password/password.html',
    'templates/bootstrap3/inputTypes/radio/radio.html',
    'templates/bootstrap3/inputTypes/radio/radio.js',
    'templates/bootstrap3/inputTypes/range/range.html',
    'templates/bootstrap3/inputTypes/reset/reset.html',
    'templates/bootstrap3/inputTypes/search/search.html',
    'templates/bootstrap3/inputTypes/select/select.html',
    'templates/bootstrap3/inputTypes/select-checkbox/select-checkbox.html',
    'templates/bootstrap3/inputTypes/select-checkbox/select-checkbox.js',
    'templates/bootstrap3/inputTypes/select-checkbox-inline/select-checkbox-inline.html',
    'templates/bootstrap3/inputTypes/select-checkbox-inline/select-checkbox-inline.js',
    'templates/bootstrap3/inputTypes/select-checkbox-inline/select-checkbox-inline.css',
    'templates/bootstrap3/inputTypes/select-multiple/select-multiple.html',
    'templates/bootstrap3/inputTypes/select-radio/select-radio.html',
    'templates/bootstrap3/inputTypes/select-radio/select-radio.js',
    'templates/bootstrap3/inputTypes/select-radio-inline/select-radio-inline.html',
    'templates/bootstrap3/inputTypes/select-radio-inline/select-radio-inline.js',
    'templates/bootstrap3/inputTypes/select-radio-inline/select-radio-inline.css',
    'templates/bootstrap3/inputTypes/submit/submit.html',
    'templates/bootstrap3/inputTypes/tel/tel.html',
    'templates/bootstrap3/inputTypes/text/text.html',
    'templates/bootstrap3/inputTypes/textarea/textarea.html',
    'templates/bootstrap3/inputTypes/time/time.html',
    'templates/bootstrap3/inputTypes/url/url.html',
    'templates/bootstrap3/inputTypes/week/week.html',
    // bootstrap3-horizontal Template - General
    'templates/bootstrap3-horizontal/bootstrap3-horizontal.css',
    // bootstrap3-horizontal Template - Components
    'templates/bootstrap3-horizontal/components/quickForm/quickForm.html',
    'templates/bootstrap3-horizontal/components/quickForm/quickForm.js',
    'templates/bootstrap3-horizontal/components/afArrayField/afArrayField.html',
    'templates/bootstrap3-horizontal/components/afArrayField/afArrayField.js',
    'templates/bootstrap3-horizontal/components/afFormGroup/afFormGroup.html',
    'templates/bootstrap3-horizontal/components/afFormGroup/afFormGroup.js',
    'templates/bootstrap3-horizontal/components/afObjectField/afObjectField.html',
    'templates/bootstrap3-horizontal/components/afObjectField/afObjectField.js',
    // bootstrap3-horizontal Template - Input Types
    'templates/bootstrap3-horizontal/inputTypes/boolean-checkbox/boolean-checkbox.html',
    'templates/bootstrap3-horizontal/inputTypes/boolean-checkbox/boolean-checkbox.js',
    // bootstrap3-inline Template
    'templates/bootstrap3-inline/bootstrap3-inline.html',
    'templates/bootstrap3-inline/bootstrap3-inline.js',
    'templates/bootstrap3-inline/bootstrap3-inline.css',
    // plain Template
    'templates/plain/components/quickForm/quickForm.html',
    'templates/plain/components/quickForm/quickForm.js',
    'templates/plain/components/afArrayField/afArrayField.html',
    'templates/plain/components/afFormGroup/afFormGroup.html',
    'templates/plain/components/afObjectField/afObjectField.html',
    'templates/plain/components/afObjectField/afObjectField.js',
    // plain-fieldset Template
    'templates/plain-fieldset/plain-fieldset.html',
    'templates/plain-fieldset/plain-fieldset.js',
  ], 'client');
});

Package.onTest(function (api) {
  api.use(['aldeed:autoform', 'tinytest', 'underscore']);
  api.use('momentjs:moment', 'client');
  api.addFiles(['tests/utility-tests.js', 'tests/autoform-tests.js']);
});
<commit_msg>fix cleanNulls test<commit_after>Package.describe({
  name: "aldeed:autoform",
  summary: "Easily create forms with automatic insert and update, and automatic reactive validation.",
  git: "https://github.com/aldeed/meteor-autoform.git",
  version: "5.5.1"
});

Package.onUse(function(api) {
  // Dependencies
  api.versionsFrom(['METEOR@0.9.3', 'METEOR@0.9.4', 'METEOR@1.0']);
  // common
  api.use('aldeed:simple-schema@1.1.0');
  api.use('check');
  // client
  api.use(['livedata', 'underscore', 'deps', 'templating', 'ui', 'blaze', 'ejson', 'reactive-var', 'reactive-dict', 'random', 'jquery'], 'client');
  api.use('momentjs:moment@2.10.6', 'client');
  api.use('mrt:moment-timezone@0.2.1', 'client', {weak: true});
  api.use('aldeed:moment-timezone@0.4.0', 'client', {weak: true});
  api.use(['aldeed:collection2@2.0.0', 'reload'], 'client', {weak: true});

  // Imply SS to make sure SimpleSchema object is available to app
  api.imply('aldeed:simple-schema');

  // Exports
  api.export('AutoForm', 'client');
  api.export('Utility', 'client', {testOnly: true});

  // Common Files
  api.addFiles(['autoform-common.js']);

  // Client Files
  api.addFiles([
    // utilities and general init
    'utility.js',
    'form-preserve.js',
    'autoform-hooks.js',
    'autoform-formdata.js',
    'autoform-arrays.js',
    'autoform.js',
    // global helpers
    'autoform-helpers.js',
    // validation
    'autoform-validation.js',
    // inputs
    'autoform-inputs.js',
    // public API
    'autoform-api.js',
    // form types
    'formTypes/insert.js',
    'formTypes/update.js',
    'formTypes/update-pushArray.js',
    'formTypes/method.js',
    'formTypes/method-update.js',
    'formTypes/normal.js',
    'formTypes/readonly.js',
    'formTypes/disabled.js',
    // input types
    'inputTypes/value-converters.js',
    'inputTypes/boolean-checkbox/boolean-checkbox.html',
    'inputTypes/boolean-checkbox/boolean-checkbox.js',
    'inputTypes/boolean-radios/boolean-radios.html',
    'inputTypes/boolean-radios/boolean-radios.js',
    'inputTypes/boolean-select/boolean-select.html',
    'inputTypes/boolean-select/boolean-select.js',
    'inputTypes/button/button.html',
    'inputTypes/button/button.js',
    'inputTypes/color/color.html',
    'inputTypes/color/color.js',
    'inputTypes/contenteditable/contenteditable.html',
    'inputTypes/contenteditable/contenteditable.js',
    'inputTypes/date/date.html',
    'inputTypes/date/date.js',
    'inputTypes/datetime/datetime.html',
    'inputTypes/datetime/datetime.js',
    'inputTypes/datetime-local/datetime-local.html',
    'inputTypes/datetime-local/datetime-local.js',
    'inputTypes/email/email.html',
    'inputTypes/email/email.js',
    'inputTypes/file/file.html',
    'inputTypes/file/file.js',
    'inputTypes/hidden/hidden.html',
    'inputTypes/hidden/hidden.js',
    'inputTypes/image/image.html',
    'inputTypes/image/image.js',
    'inputTypes/month/month.html',
    'inputTypes/month/month.js',
    'inputTypes/number/number.html',
    'inputTypes/number/number.js',
    'inputTypes/password/password.html',
    'inputTypes/password/password.js',
    'inputTypes/radio/radio.html',
    'inputTypes/radio/radio.js',
    'inputTypes/range/range.html',
    'inputTypes/range/range.js',
    'inputTypes/reset/reset.html',
    'inputTypes/reset/reset.js',
    'inputTypes/search/search.html',
    'inputTypes/search/search.js',
    'inputTypes/select/select.html',
    'inputTypes/select/select.js',
    'inputTypes/select-checkbox/select-checkbox.html',
    'inputTypes/select-checkbox/select-checkbox.js',
    'inputTypes/select-checkbox-inline/select-checkbox-inline.html',
    'inputTypes/select-checkbox-inline/select-checkbox-inline.js',
    'inputTypes/select-multiple/select-multiple.html',
    'inputTypes/select-multiple/select-multiple.js',
    'inputTypes/select-radio/select-radio.html',
    'inputTypes/select-radio/select-radio.js',
    'inputTypes/select-radio-inline/select-radio-inline.html',
    'inputTypes/select-radio-inline/select-radio-inline.js',
    'inputTypes/submit/submit.html',
    'inputTypes/submit/submit.js',
    'inputTypes/tel/tel.html',
    'inputTypes/tel/tel.js',
    'inputTypes/text/text.html',
    'inputTypes/text/text.js',
    'inputTypes/textarea/textarea.html',
    'inputTypes/textarea/textarea.js',
    'inputTypes/time/time.html',
    'inputTypes/time/time.js',
    'inputTypes/url/url.html',
    'inputTypes/url/url.js',
    'inputTypes/week/week.html',
    'inputTypes/week/week.js',
    // components that render a form
    'components/autoForm/autoForm.html',
    'components/autoForm/autoForm.js',
    'components/quickForm/quickForm.html',
    'components/quickForm/quickForm.js',
    // components that render controls within a form
    'components/afArrayField/afArrayField.html',
    'components/afArrayField/afArrayField.js',
    'components/afEachArrayItem/afEachArrayItem.html',
    'components/afEachArrayItem/afEachArrayItem.js',
    'components/afFieldInput/afFieldInput.html',
    'components/afFieldInput/afFieldInput.js',
    'components/afFormGroup/afFormGroup.html',
    'components/afFormGroup/afFormGroup.js',
    'components/afObjectField/afObjectField.html',
    'components/afObjectField/afObjectField.js',
    'components/afQuickField/afQuickField.html',
    'components/afQuickField/afQuickField.js',
    'components/afQuickFields/afQuickFields.html',
    'components/afQuickFields/afQuickFields.js',
    // event handling
    'autoform-events.js',
    // bootstrap3 Template - General
    'templates/bootstrap3/bootstrap3.js',
    // bootstrap3 Template - Components
    'templates/bootstrap3/components/quickForm/quickForm.html',
    'templates/bootstrap3/components/quickForm/quickForm.js',
    'templates/bootstrap3/components/afArrayField/afArrayField.html',
    'templates/bootstrap3/components/afArrayField/afArrayField.css',
    'templates/bootstrap3/components/afFormGroup/afFormGroup.html',
    'templates/bootstrap3/components/afFormGroup/afFormGroup.js',
    'templates/bootstrap3/components/afObjectField/afObjectField.html',
    'templates/bootstrap3/components/afObjectField/afObjectField.js',
    // bootstrap3 Template - Input Types
    'templates/bootstrap3/inputTypes/boolean-checkbox/boolean-checkbox.html',
    'templates/bootstrap3/inputTypes/boolean-radios/boolean-radios.html',
    'templates/bootstrap3/inputTypes/boolean-radios/boolean-radios.js',
    'templates/bootstrap3/inputTypes/boolean-select/boolean-select.html',
    'templates/bootstrap3/inputTypes/button/button.html',
    'templates/bootstrap3/inputTypes/color/color.html',
    'templates/bootstrap3/inputTypes/date/date.html',
    'templates/bootstrap3/inputTypes/datetime/datetime.html',
    'templates/bootstrap3/inputTypes/datetime-local/datetime-local.html',
    'templates/bootstrap3/inputTypes/email/email.html',
    'templates/bootstrap3/inputTypes/month/month.html',
    'templates/bootstrap3/inputTypes/number/number.html',
    'templates/bootstrap3/inputTypes/password/password.html',
    'templates/bootstrap3/inputTypes/radio/radio.html',
    'templates/bootstrap3/inputTypes/radio/radio.js',
    'templates/bootstrap3/inputTypes/range/range.html',
    'templates/bootstrap3/inputTypes/reset/reset.html',
    'templates/bootstrap3/inputTypes/search/search.html',
    'templates/bootstrap3/inputTypes/select/select.html',
    'templates/bootstrap3/inputTypes/select-checkbox/select-checkbox.html',
    'templates/bootstrap3/inputTypes/select-checkbox/select-checkbox.js',
    'templates/bootstrap3/inputTypes/select-checkbox-inline/select-checkbox-inline.html',
    'templates/bootstrap3/inputTypes/select-checkbox-inline/select-checkbox-inline.js',
    'templates/bootstrap3/inputTypes/select-checkbox-inline/select-checkbox-inline.css',
    'templates/bootstrap3/inputTypes/select-multiple/select-multiple.html',
    'templates/bootstrap3/inputTypes/select-radio/select-radio.html',
    'templates/bootstrap3/inputTypes/select-radio/select-radio.js',
    'templates/bootstrap3/inputTypes/select-radio-inline/select-radio-inline.html',
    'templates/bootstrap3/inputTypes/select-radio-inline/select-radio-inline.js',
    'templates/bootstrap3/inputTypes/select-radio-inline/select-radio-inline.css',
    'templates/bootstrap3/inputTypes/submit/submit.html',
    'templates/bootstrap3/inputTypes/tel/tel.html',
    'templates/bootstrap3/inputTypes/text/text.html',
    'templates/bootstrap3/inputTypes/textarea/textarea.html',
    'templates/bootstrap3/inputTypes/time/time.html',
    'templates/bootstrap3/inputTypes/url/url.html',
    'templates/bootstrap3/inputTypes/week/week.html',
    // bootstrap3-horizontal Template - General
    'templates/bootstrap3-horizontal/bootstrap3-horizontal.css',
    // bootstrap3-horizontal Template - Components
    'templates/bootstrap3-horizontal/components/quickForm/quickForm.html',
    'templates/bootstrap3-horizontal/components/quickForm/quickForm.js',
    'templates/bootstrap3-horizontal/components/afArrayField/afArrayField.html',
    'templates/bootstrap3-horizontal/components/afArrayField/afArrayField.js',
    'templates/bootstrap3-horizontal/components/afFormGroup/afFormGroup.html',
    'templates/bootstrap3-horizontal/components/afFormGroup/afFormGroup.js',
    'templates/bootstrap3-horizontal/components/afObjectField/afObjectField.html',
    'templates/bootstrap3-horizontal/components/afObjectField/afObjectField.js',
    // bootstrap3-horizontal Template - Input Types
    'templates/bootstrap3-horizontal/inputTypes/boolean-checkbox/boolean-checkbox.html',
    'templates/bootstrap3-horizontal/inputTypes/boolean-checkbox/boolean-checkbox.js',
    // bootstrap3-inline Template
    'templates/bootstrap3-inline/bootstrap3-inline.html',
    'templates/bootstrap3-inline/bootstrap3-inline.js',
    'templates/bootstrap3-inline/bootstrap3-inline.css',
    // plain Template
    'templates/plain/components/quickForm/quickForm.html',
    'templates/plain/components/quickForm/quickForm.js',
    'templates/plain/components/afArrayField/afArrayField.html',
    'templates/plain/components/afFormGroup/afFormGroup.html',
    'templates/plain/components/afObjectField/afObjectField.html',
    'templates/plain/components/afObjectField/afObjectField.js',
    // plain-fieldset Template
    'templates/plain-fieldset/plain-fieldset.html',
    'templates/plain-fieldset/plain-fieldset.js',
  ], 'client');
});

Package.onTest(function (api) {
  api.use(['aldeed:autoform', 'tinytest', 'underscore', 'mongo']);
  api.use('momentjs:moment', 'client');
  api.addFiles(['tests/utility-tests.js', 'tests/autoform-tests.js']);
});
<|endoftext|>


<commit_before>/*jslint bitwise: false, evil: true*/
/*global NoiseOverlay: true, Components: false, dump: false, gBrowser: false, toggleSidebar: true, gFindBar: true*/
if (!NoiseOverlay) {
  var NoiseOverlay = {};
}
Components.utils.import("resource://noise/noise.jsm");

NoiseOverlay = {
  player: null,
  enabled: false,

  init: function () {
    Noise.patchWindow(window);
    this.player = Noise.player;
    this.prefs = Noise.prefs;
    this.enabled = Noise.enabled;
    Noise.addEventHandlers(window);
  },

  uninit: function () {
    Noise.undoPatchWindow(window);
    Noise.removeEventHandlers(window);
    this.player = null;
  },

  reset: function (newMappings) {
    this.enabled = this.prefs.getBoolPref("extensions.noise.enabled");
    Noise.removeEventHandlers(window);
    Noise.addEventHandlers(window, newMappings);
  },

  toggle: function () {
    Noise.toggle();
  },

  play: function () {
    Noise.play.apply(Noise, arguments);
  },

  log: function (aMessage) {
    Noise.log(aMessage);
  }
};

window.addEventListener("load", function () {
  NoiseOverlay.init();
}, false);

window.addEventListener("unload", function () {
  NoiseOverlay.uninit();
}, false);
<commit_msg>Remove unused dummy functions in NoiseOverlay<commit_after>/*jslint bitwise: false, evil: true*/
/*global NoiseOverlay: true, Components: false, dump: false, gBrowser: false, toggleSidebar: true, gFindBar: true*/
if (!NoiseOverlay) {
  var NoiseOverlay = {};
}
Components.utils.import("resource://noise/noise.jsm");

NoiseOverlay = {
  init: function () {
    Noise.patchWindow(window);
    Noise.addEventHandlers(window);
  },

  uninit: function () {
    Noise.undoPatchWindow(window);
    Noise.removeEventHandlers(window);
  },

  reset: function (newMappings) {
    Noise.removeEventHandlers(window);
    Noise.addEventHandlers(window, newMappings);
  }
};

window.addEventListener("load", function () {
  NoiseOverlay.init();
}, false);

window.addEventListener("unload", function () {
  NoiseOverlay.uninit();
}, false);
<|endoftext|>


<commit_before>Package.describe({
  summary: "Automatically add visitor as anonymous guest with userId",
  version: "0.1.8",
  git: "https://github.com/Wenape/meteor-accounts-guest.git",
  name: "wenape:accounts-guest"
});

Package.onUse(function (api) {
  api.versionsFrom('0.9.0');

  api.use('accounts-base', ['client','server']);

  api.add_files('accounts-guest-client.js', ['client','server']);
  api.add_files('accounts-guest-server.js', 'server');

  api.export && api.export('Guests', ['client']);
});
<commit_msg>fix api.export<commit_after>Package.describe({
  summary: "Automatically add visitor as anonymous guest with userId",
  version: "0.1.8",
  git: "https://github.com/Wenape/meteor-accounts-guest.git",
  name: "wenape:accounts-guest"
});

Package.onUse(function (api) {
  api.versionsFrom('0.9.0');

  api.use('accounts-base', ['client','server']);

  api.add_files('accounts-guest-client.js', ['client','server']);
  api.add_files('accounts-guest-server.js', 'server');

  api.export('Guests', ['client']);
});
<|endoftext|>


<commit_before>"use strict";

var controllers = require('./lib/controllers'),
	meta = module.parent.require('./meta'),
	request = module.parent.require('request'),
	async = module.parent.require('async'),
	nconf = module.parent.require('nconf'),
	winston = module.parent.require('winston'),
	templates = module.parent.require('templates.js'),

	postCache = module.parent.require('./posts/cache'),
	LRU = require('lru-cache'),
	url = require('url'),
	escapeHtml = require('escape-html'),

	iframely = {
		config: undefined,
		apiBase: 'http://nodebb.iframe.ly/api',
		apiBaseWithKey: 'https://iframe.ly/api',
		cache: LRU({
			maxAge: 1000*60*60*24	// one day
		}),
		htmlRegex: /(.*?)<\/a>/g
	},
	app;

iframely.init = function(params, callback) {
	var router = params.router,
		hostMiddleware = params.middleware,
		hostControllers = params.controllers;

	app = params.app;

	router.get('/admin/plugins/iframely', hostMiddleware.admin.buildHeader, controllers.renderAdminPage);
	router.get('/api/admin/plugins/iframely', controllers.renderAdminPage);

	meta.settings.get('iframely', function(err, config) {
		config.blacklist = (config.blacklist && config.blacklist.split(',')) || [];
		iframely.config = config;
	});

	callback();
};

iframely.updateConfig = function(data) {
	if (data.plugin === 'iframely') {
		winston.verbose('[plugin/iframely] Config updated');
		postCache.reset();
		data.settings.blacklist = data.settings.blacklist.split(',');
		iframely.config = data.settings;
	}
};

iframely.addAdminNavigation = function(header, callback) {
	header.plugins.push({
		route: '/plugins/iframely',
		icon: 'fa-link',
		name: 'Iframely'
	});

	callback(null, header);
};

iframely.replace = function(raw, options, callback) {

	if (typeof options === 'function') {
		callback = options;
	}

	if (raw && typeof raw !== 'string' && raw.hasOwnProperty('postData') && raw.postData.hasOwnProperty('content')) {

		/**
		 *	If a post object is received (`filter:post.parse`),
		 *	instead of a plain string, call self.
		 */
		iframely.replace(raw.postData.content, {
			votes: parseInt(raw.postData.votes)
		}, function(err, html) {
			raw.postData.content = html;
			return callback(err, raw);
		});
	} else {
		var urls = [],
			match;

		// Isolate matches
		while(match = iframely.htmlRegex.exec(raw)) {
			// Only match if it is a naked link (no anchor text)

			var target = url.parse(match[1]),
				text = url.parse(match[2]);

			if (((match[1] === match[2]) || (target.host + target.path === match[2])) && !hostInBlacklist(target.host)) {
				urls.push(match[1]);
			}
		}

		// Eliminate duplicates and internal links
		urls = urls.filter(function(url, idx) {
			return urls.indexOf(url) === idx && url.indexOf(nconf.get('url')) !== 0;
		});

		async.waterfall([
			// Query urls from iFramely, in batches of 10
			async.apply(async.mapLimit, urls, 10, iframely.query),

			// Replace post text as necessary
			function(embeds, next) {
				async.reduce(embeds.filter(Boolean), raw, function(html, embed, next) {

					var replaceRegex = new RegExp('.*?', 'g');

					if (embed.rel.indexOf('summary') > -1 && embed.rel.indexOf('app') === -1) {
						// Skip summary cards.
						var image = getImage(embed);
						if (image) {
							embed.html = '';
						} else {
							app.render('partials/iframely-link-title', {embed: embed}, function(err, parsed) {

								if (err) {
									winston.error('[plugin/iframely] Could not parse embed! ' + err.message);
									return next(null, html);
								}

								next(null, html.replace(replaceRegex, parsed));
							});
						}
					}

					// Start detect collapsed.

					var collapseWidget = iframely.config.mode === 'alwaysCollapse';

					if (alwaysCollapseDomain(embed.url)) {
						collapseWidget = true;
					} else if (alwaysExpandDomain(embed.url)) {
						collapseWidget = false;
					}

					if (options && typeof options.votes === 'number') {

						if (iframely.config.collapseOnVotes === 'on') {
							if (options.votes <= getIntValue(iframely.config.collapseOnVotesCount, -1)) {
								collapseWidget = true;
							}
						}

						if (iframely.config.expandOnVotes === 'on') {
							if (options.votes >= getIntValue(iframely.config.expandOnVotesCount, 1)) {
								collapseWidget = false;
							}
						}
					}

					// End detect collapsed.

					var context = {};

					context.domain = getDomain(embed);
					context.description = shortenText(embed.meta.description, 300);

					if (embed.rel.indexOf('player') > -1) {
						context.show_label = 'show player';
						context.hide_label = 'hide player';
						context.more_label = 'play on';

					} else if (embed.rel.indexOf('image') > -1) {
						context.show_label = 'show image';
						context.hide_label = 'hide image';
						context.more_label = 'view on';

					} else if (embed.rel.indexOf('file') > -1) {
						context.show_label = 'see file';
						context.hide_label = 'hide file';

					} else {
						context.show_label = 'show details';
						context.hide_label = 'hide details';

						if (embed.meta.media == 'reader') {
							// TODO: check usage.
							context.more_label = 'read on';
						} else if (!embed.html) {
							// TODO: check usage.
							context.more_label = 'visit';
						}
					}

					// Format meta info.
					var meta = [];

					if (embed.meta.author) {
						meta.push(embed.meta.author);
					}

					var date = getDate(embed.meta.date);
					if (date) {
						meta.push(date);
					}

					var currency = embed.meta.currency_code || embed.meta.currency;
					var price = embed.meta.price ? (embed.meta.price + (currency ? (' ' + currency) : '')) : null;
					if (price) {
						meta.push(price);
					}

					var duration = getDuration(embed.meta.duration);
					if (duration) {
						meta.push(duration);
					}

					var views = getViews(embed.meta.views);
					if (views) {
						meta.push(views);
					}

					if (embed.meta.category) {
						meta.push(embed.meta.category);
					}

					context.meta = meta.join('  /  ');

					// END Format meta info.

					context.embed = embed;

					function renderWidgetWrapper(err, embed_widget) {

						if (err) {
							winston.error('[plugin/iframely] Could not parse embed! ' + err.message);
							return next(null, html);
						}

						if (collapseWidget) {
							context.escaped_html = escapeHtml(embed_widget);
							context.toggle_label = context.show_label;
							context.widget_html = '';
						} else {
							context.escaped_html = '';
							context.toggle_label = context.hide_label;
							context.widget_html = embed_widget;
						}

						app.render('partials/iframely-widget-wrapper', context, function(err, parsed) {
							if (err) {
								winston.error('[plugin/iframely] Could not parse embed! ' + err.message);
								return next(null, html);
							}

							next(null, html.replace(replaceRegex, parsed));
						});
					}

					if (embed.rel.indexOf('app') > -1 || embed.rel.indexOf('reader') > -1 || embed.rel.indexOf('survey') > -1) {
						renderWidgetWrapper(null, embed.html);
					} else {
						app.render('partials/iframely-widget-card', context, renderWidgetWrapper);
					}

				}, next);
			}
		], callback);
	}
};

iframely.query = function(url, callback) {
	if (iframely.cache.has(url)) {
		winston.verbose('[plugin/iframely] Retrieving \'' + url + '\' from cache...');
		setImmediate(function() {
			callback(null, iframely.cache.get(url));
		});
	} else {
		winston.verbose('[plugin/iframely] Querying \'' + url + '\' via iFramely...')
		request({
			url: iframely[iframely.config.key ? 'apiBaseWithKey' : 'apiBase'] + '/iframely?url=' + url + (iframely.config.key ? '?api_key=' + iframely.config.key : ''),
			json: true
		}, function(err, res, body) {
			if (err) {
				winston.error('[plugin/iframely] Encountered error querying iFramely API: ' + err.message);
				return callback();
			} else {
				if (res.statusCode === 200 && body) {
					iframely.cache.set(url, body);
					return callback(null, body);
				} else {
					return callback();
				}
			}
		});
	}
};

function hostInBlacklist(host) {
	if (iframely.config.enableBlacklist === 'on') {
		return iframely.config.blacklist.indexOf(host) > -1;
	} else {
		return false;
	}
}

function alwaysExpandDomain(urlToCheck) {
	var parsed = url.parse(urlToCheck);
	return iframely.config.expandDomains && iframely.config.expandDomains.indexOf(parsed.host) > -1;
}

function alwaysCollapseDomain(urlToCheck) {
	var parsed = url.parse(urlToCheck);
	return iframely.config.collapseDomains && iframely.config.collapseDomains.indexOf(parsed.host) > -1;
}

function getIntValue(value, defaultValue) {
	value = parseInt(value);
	if (typeof value === 'number' && !isNaN(value)) {
		return value;
	} else {
		return defaultValue;
	}
}

function shortenText(value, maxlength) {

	if (!value) {
		return '';
	}

	maxlength = maxlength || 130;

	value = '' + value;

	if (value.length <= maxlength) {
		return value;
	} else {

		value = value.substr(0, maxlength);

		var m = value.match(/(.*)[\. ,\/-]/);

		if (m) {
			value = m[1]
			return m[1] + '...';
		}

		return value + '...';
	}
}

function getDuration(duration) {
	if (duration) {
		var seconds = duration % 60;
		var minutes = Math.floor((duration - seconds) / 60);
		var hours = Math.floor(minutes / 60);
		minutes = minutes % 60;

		if (seconds < 10) {
			seconds = '0' + seconds;
		}

		if (minutes < 10) {
			minutes = '0' + minutes;
		}

		return (hours ? (hours + ':') : '') + minutes + ':' + seconds;
	}
}

function numberWithCommas(x) {
	var parts = x.toString().split(".");
	parts[0] = parts[0].replace(/\B(?=(\d{3})+(?!\d))/g, "'");
	return parts.join(".");
}

function getViews(views) {
	if (views) {
		if (views > 1000000) {
			return numberWithCommas((views / 1000000).toFixed(1)) + 'Mln';
		} else if (views > 1000) {
			return numberWithCommas((views / 1000).toFixed(1)) + 'K';
		} else {
			return numberWithCommas(views);
		}
	}
}

function getDomain(embed) {
	var domain = embed.meta && embed.meta.site;
	if (!domain) {
		var url = embed.meta && embed.meta.canonical || embed.url;
		var m = url.match(/(?:https?:\/\/)?(?:www\.)?([^\/]+)/i);
		if (m) {
			domain = m[1];
		} else {
			domain = url;
		}
	}
	return domain;
}

function getDate(date) {

	var months = [
		"Jan",
		"Feb",
		"March",
		"April",
		"May",
		"June",
		"July",
		"Aug",
		"Sept",
		"Oct",
		"Nov",
		"Dec"
	];

	var onDate = '';
	if (date) {
		date = new Date(date);
		if (date && !isNaN(date.getTime())) {
			onDate = months[date.getMonth()] + ' ' + date.getDate();
			if (date.getFullYear() !== new Date().getFullYear()) {
				onDate = onDate + ', ' + date.getFullYear();
			}
		}
	}

	return onDate;
}

function getImage(embed) {
	var image = (embed.links.thumbnail && embed.links.thumbnail[0]) || (embed.links.image && embed.links.image[0]);
	return image && image.href;
}

module.exports = iframely;<commit_msg>simplify show/hide labels<commit_after>"use strict";

var controllers = require('./lib/controllers'),
	meta = module.parent.require('./meta'),
	request = module.parent.require('request'),
	async = module.parent.require('async'),
	nconf = module.parent.require('nconf'),
	winston = module.parent.require('winston'),
	templates = module.parent.require('templates.js'),

	postCache = module.parent.require('./posts/cache'),
	LRU = require('lru-cache'),
	url = require('url'),
	escapeHtml = require('escape-html'),

	iframely = {
		config: undefined,
		apiBase: 'http://nodebb.iframe.ly/api',
		apiBaseWithKey: 'https://iframe.ly/api',
		cache: LRU({
			maxAge: 1000*60*60*24	// one day
		}),
		htmlRegex: /(.*?)<\/a>/g
	},
	app;

iframely.init = function(params, callback) {
	var router = params.router,
		hostMiddleware = params.middleware,
		hostControllers = params.controllers;

	app = params.app;

	router.get('/admin/plugins/iframely', hostMiddleware.admin.buildHeader, controllers.renderAdminPage);
	router.get('/api/admin/plugins/iframely', controllers.renderAdminPage);

	meta.settings.get('iframely', function(err, config) {
		config.blacklist = (config.blacklist && config.blacklist.split(',')) || [];
		iframely.config = config;
	});

	callback();
};

iframely.updateConfig = function(data) {
	if (data.plugin === 'iframely') {
		winston.verbose('[plugin/iframely] Config updated');
		postCache.reset();
		data.settings.blacklist = data.settings.blacklist.split(',');
		iframely.config = data.settings;
	}
};

iframely.addAdminNavigation = function(header, callback) {
	header.plugins.push({
		route: '/plugins/iframely',
		icon: 'fa-link',
		name: 'Iframely'
	});

	callback(null, header);
};

iframely.replace = function(raw, options, callback) {

	if (typeof options === 'function') {
		callback = options;
	}

	if (raw && typeof raw !== 'string' && raw.hasOwnProperty('postData') && raw.postData.hasOwnProperty('content')) {

		/**
		 *	If a post object is received (`filter:post.parse`),
		 *	instead of a plain string, call self.
		 */
		iframely.replace(raw.postData.content, {
			votes: parseInt(raw.postData.votes)
		}, function(err, html) {
			raw.postData.content = html;
			return callback(err, raw);
		});
	} else {
		var urls = [],
			match;

		// Isolate matches
		while(match = iframely.htmlRegex.exec(raw)) {
			// Only match if it is a naked link (no anchor text)

			var target = url.parse(match[1]),
				text = url.parse(match[2]);

			if (((match[1] === match[2]) || (target.host + target.path === match[2])) && !hostInBlacklist(target.host)) {
				urls.push(match[1]);
			}
		}

		// Eliminate duplicates and internal links
		urls = urls.filter(function(url, idx) {
			return urls.indexOf(url) === idx && url.indexOf(nconf.get('url')) !== 0;
		});

		async.waterfall([
			// Query urls from iFramely, in batches of 10
			async.apply(async.mapLimit, urls, 10, iframely.query),

			// Replace post text as necessary
			function(embeds, next) {
				async.reduce(embeds.filter(Boolean), raw, function(html, embed, next) {

					var replaceRegex = new RegExp('.*?', 'g');

					if (embed.rel.indexOf('summary') > -1 && embed.rel.indexOf('app') === -1) {
						// Skip summary cards.
						var image = getImage(embed);
						if (image) {
							embed.html = '';
						} else {
							app.render('partials/iframely-link-title', {embed: embed}, function(err, parsed) {

								if (err) {
									winston.error('[plugin/iframely] Could not parse embed! ' + err.message);
									return next(null, html);
								}

								next(null, html.replace(replaceRegex, parsed));
							});
						}
					}

					// Start detect collapsed.

					var collapseWidget = iframely.config.mode === 'alwaysCollapse';

					if (alwaysCollapseDomain(embed.url)) {
						collapseWidget = true;
					} else if (alwaysExpandDomain(embed.url)) {
						collapseWidget = false;
					}

					if (options && typeof options.votes === 'number') {

						if (iframely.config.collapseOnVotes === 'on') {
							if (options.votes <= getIntValue(iframely.config.collapseOnVotesCount, -1)) {
								collapseWidget = true;
							}
						}

						if (iframely.config.expandOnVotes === 'on') {
							if (options.votes >= getIntValue(iframely.config.expandOnVotesCount, 1)) {
								collapseWidget = false;
							}
						}
					}

					// End detect collapsed.

					var context = {};

					context.domain = getDomain(embed);
					context.description = shortenText(embed.meta.description, 300);

					if (embed.rel.indexOf('player') > -1 || embed.rel.indexOf('gifv') > -1) {
						context.show_label = 'view media';
						context.hide_label = 'hide media';
						context.more_label = 'view on';

					} else if (embed.rel.indexOf('image') > -1) {
						context.show_label = 'view image';
						context.hide_label = 'hide image';
						context.more_label = 'view on';

					} else if (embed.rel.indexOf('file') > -1) {
						context.show_label = 'view file';
						context.hide_label = 'hide file';

					} else if (embed.rel.indexOf('app') > -1 || embed.rel.indexOf('reader') > -1) {
						context.show_label = 'view it';
						context.hide_label = 'hide it';

					} else {
						context.show_label = 'view details';
						context.hide_label = 'hide details';

						if (embed.meta.media == 'reader') {
							// TODO: check usage.
							context.more_label = 'read on';
						} else if (!embed.html) {
							// TODO: check usage.
							context.more_label = 'visit';
						}
					}

					// Format meta info.
					var meta = [];

					if (embed.meta.author) {
						meta.push(embed.meta.author);
					}

					var date = getDate(embed.meta.date);
					if (date) {
						meta.push(date);
					}

					var currency = embed.meta.currency_code || embed.meta.currency;
					var price = embed.meta.price ? (embed.meta.price + (currency ? (' ' + currency) : '')) : null;
					if (price) {
						meta.push(price);
					}

					var duration = getDuration(embed.meta.duration);
					if (duration) {
						meta.push(duration);
					}

					var views = getViews(embed.meta.views);
					if (views) {
						meta.push(views);
					}

					if (embed.meta.category) {
						meta.push(embed.meta.category);
					}

					context.meta = meta.join('  /  ');

					// END Format meta info.

					context.embed = embed;

					function renderWidgetWrapper(err, embed_widget) {

						if (err) {
							winston.error('[plugin/iframely] Could not parse embed! ' + err.message);
							return next(null, html);
						}

						if (collapseWidget) {
							context.escaped_html = escapeHtml(embed_widget);
							context.toggle_label = context.show_label;
							context.widget_html = '';
						} else {
							context.escaped_html = '';
							context.toggle_label = context.hide_label;
							context.widget_html = embed_widget;
						}

						app.render('partials/iframely-widget-wrapper', context, function(err, parsed) {
							if (err) {
								winston.error('[plugin/iframely] Could not parse embed! ' + err.message);
								return next(null, html);
							}

							next(null, html.replace(replaceRegex, parsed));
						});
					}

					if (embed.rel.indexOf('app') > -1 || embed.rel.indexOf('reader') > -1 || embed.rel.indexOf('survey') > -1) {
						renderWidgetWrapper(null, embed.html);
					} else {
						app.render('partials/iframely-widget-card', context, renderWidgetWrapper);
					}

				}, next);
			}
		], callback);
	}
};

iframely.query = function(url, callback) {
	if (iframely.cache.has(url)) {
		winston.verbose('[plugin/iframely] Retrieving \'' + url + '\' from cache...');
		setImmediate(function() {
			callback(null, iframely.cache.get(url));
		});
	} else {
		winston.verbose('[plugin/iframely] Querying \'' + url + '\' via iFramely...')
		request({
			url: iframely[iframely.config.key ? 'apiBaseWithKey' : 'apiBase'] + '/iframely?url=' + url + (iframely.config.key ? '?api_key=' + iframely.config.key : ''),
			json: true
		}, function(err, res, body) {
			if (err) {
				winston.error('[plugin/iframely] Encountered error querying iFramely API: ' + err.message);
				return callback();
			} else {
				if (res.statusCode === 200 && body) {
					iframely.cache.set(url, body);
					return callback(null, body);
				} else {
					return callback();
				}
			}
		});
	}
};

function hostInBlacklist(host) {
	if (iframely.config.enableBlacklist === 'on') {
		return iframely.config.blacklist.indexOf(host) > -1;
	} else {
		return false;
	}
}

function alwaysExpandDomain(urlToCheck) {
	var parsed = url.parse(urlToCheck);
	return iframely.config.expandDomains && iframely.config.expandDomains.indexOf(parsed.host) > -1;
}

function alwaysCollapseDomain(urlToCheck) {
	var parsed = url.parse(urlToCheck);
	return iframely.config.collapseDomains && iframely.config.collapseDomains.indexOf(parsed.host) > -1;
}

function getIntValue(value, defaultValue) {
	value = parseInt(value);
	if (typeof value === 'number' && !isNaN(value)) {
		return value;
	} else {
		return defaultValue;
	}
}

function shortenText(value, maxlength) {

	if (!value) {
		return '';
	}

	maxlength = maxlength || 130;

	value = '' + value;

	if (value.length <= maxlength) {
		return value;
	} else {

		value = value.substr(0, maxlength);

		var m = value.match(/(.*)[\. ,\/-]/);

		if (m) {
			value = m[1]
			return m[1] + '...';
		}

		return value + '...';
	}
}

function getDuration(duration) {
	if (duration) {
		var seconds = duration % 60;
		var minutes = Math.floor((duration - seconds) / 60);
		var hours = Math.floor(minutes / 60);
		minutes = minutes % 60;

		if (seconds < 10) {
			seconds = '0' + seconds;
		}

		if (minutes < 10) {
			minutes = '0' + minutes;
		}

		return (hours ? (hours + ':') : '') + minutes + ':' + seconds;
	}
}

function numberWithCommas(x) {
	var parts = x.toString().split(".");
	parts[0] = parts[0].replace(/\B(?=(\d{3})+(?!\d))/g, "'");
	return parts.join(".");
}

function getViews(views) {
	if (views) {
		if (views > 1000000) {
			return numberWithCommas((views / 1000000).toFixed(1)) + 'Mln';
		} else if (views > 1000) {
			return numberWithCommas((views / 1000).toFixed(1)) + 'K';
		} else {
			return numberWithCommas(views);
		}
	}
}

function getDomain(embed) {
	var domain = embed.meta && embed.meta.site;
	if (!domain) {
		var url = embed.meta && embed.meta.canonical || embed.url;
		var m = url.match(/(?:https?:\/\/)?(?:www\.)?([^\/]+)/i);
		if (m) {
			domain = m[1];
		} else {
			domain = url;
		}
	}
	return domain;
}

function getDate(date) {

	var months = [
		"Jan",
		"Feb",
		"March",
		"April",
		"May",
		"June",
		"July",
		"Aug",
		"Sept",
		"Oct",
		"Nov",
		"Dec"
	];

	var onDate = '';
	if (date) {
		date = new Date(date);
		if (date && !isNaN(date.getTime())) {
			onDate = months[date.getMonth()] + ' ' + date.getDate();
			if (date.getFullYear() !== new Date().getFullYear()) {
				onDate = onDate + ', ' + date.getFullYear();
			}
		}
	}

	return onDate;
}

function getImage(embed) {
	var image = (embed.links.thumbnail && embed.links.thumbnail[0]) || (embed.links.image && embed.links.image[0]);
	return image && image.href;
}

module.exports = iframely;<|endoftext|>


<commit_before>Package.describe({
  name: 'adain:meteor-https',
  version: '1.0.1',
  summary: 'Simple https proxy server package for meteor using npm http-proxy',
  git: 'https://github.com/ADAIN/meteor-https.git',
  documentation: 'README.md'
});

Npm.depends({'http-proxy' : '1.9.0'});

Package.onUse(function(api) {
  api.versionsFrom('1.0.1');
  api.addFiles('https.js');
});

Package.onTest(function(api) {
  api.use('tinytest');
  api.use('adain:meteor-https');
  api.addFiles('https-tests.js');
});
<commit_msg>update version to 1.0.2<commit_after>Package.describe({
  name: 'adain:meteor-https',
  version: '1.0.2',
  summary: 'Simple https proxy server package for meteor using npm http-proxy',
  git: 'https://github.com/ADAIN/meteor-https.git',
  documentation: 'README.md'
});

Npm.depends({'http-proxy' : '1.9.0'});

Package.onUse(function(api) {
  api.versionsFrom('1.0.2');
  api.addFiles('https.js');
});

Package.onTest(function(api) {
  api.use('tinytest');
  api.use('adain:meteor-https');
  api.addFiles('https-tests.js');
});
<|endoftext|>


<commit_before>/*jshint bitwise:true, indent:2, curly:true eqeqeq:true, immed:true, latedef:true, newcap:true, noarg:true,
regexp:true, undef:true, strict:true, trailing:true white:true*/
/*global XT:true, enyo:true, Globalize:true */

(function () {
  "use strict";

  enyo.kind({
    name: "XT.AccountInfoList",
    kind: "XT.InfoList",
    rowClass: "XT.AccountInfoCollectionRow"
  });

  enyo.kind({
    name: "XT.AccountInfoCollectionRow",
    kind: "XT.InfoListRow",
    leftColumn: [
      [
        { width: 160 },
        { name: "number", classes: "cell-key account-number" },
        { name: "name", classes: "account-name", emptyText: "_noJobTitle".loc() }
      ],
      [
        { width: 160 },
        { name: "primaryContact.phone", classes: "cell-align-right account-primaryContact-phone" },
        { name: "primaryContact.primaryEmail", classes: "cell-align-right account-primaryContact-primaryEmail" }
      ]
    ],
    rightColumn: [
      [
        { width: 320 },
        { name: "primaryContact.name", classes: "cell-italic account-primaryContact-name", emptyText: "_noContact".loc() },
        { name: "primaryContact.address.formatShort", classes: "account-primaryContact-address" }
      ]
    ]
  });

}());
<commit_msg>reverted another file<commit_after>/*jshint bitwise:true, indent:2, curly:true eqeqeq:true, immed:true, latedef:true, newcap:true, noarg:true,
regexp:true, undef:true, strict:true, trailing:true white:true*/
/*global XT:true, enyo:true, Globalize:true */

(function () {
  "use strict";

  enyo.kind({
    name: "XT.AccountInfoList",
    kind: "XT.InfoList",
    rowClass: "XT.AccountInfoCollectionRow"
  });

  enyo.kind({
    name: "XT.AccountInfoCollectionRow",
    kind: "XT.InfoListRow",
    leftColumn: [
      [
        { width: 160 },
        { name: "number", classes: "cell-key account-number" },
        { name: "name", classes: "account-name", emptyText: "_noJobTitle".loc() }
      ],
      [
        { width: 160 },
        { name: "primaryContact.phone", classes: "cell-align-right account-primaryContact-phone" },
        { name: "primaryContact.primaryEmail", classes: "cell-align-right account-primaryContact-primaryEmail" }
      ]
    ],
    rightColumn: [
      [
        { width: 320 },
        { name: "primaryContact.name", classes: "cell-italic account-primaryContact-name", emptyText: "_noContact".loc() },
        { name: "primaryContact.address.formatShort", classes: "account-primaryContact-address" }
      ]
    ]
  });

}());<|endoftext|>


<commit_before>(function(module) {
	"use strict";

	var User = module.parent.require('./user'),
		meta = module.parent.require('./meta'),
		db = module.parent.require('../src/database'),
		passport = module.parent.require('passport'),
  		passportGoogle = require('passport-google-oauth').OAuth2Strategy,
  		fs = module.parent.require('fs'),
  		path = module.parent.require('path'),
  		nconf = module.parent.require('nconf');

	var constants = Object.freeze({
		'name': "Google",
		'admin': {
			'route': '/plugins/sso-google',
			'icon': 'fa-google-plus-square'
		}
	});

	var Google = {};

	Google.init = function(app, middleware, controllers, callback) {
		function render(req, res, next) {
			res.render('admin/plugins/sso-google', {});
		}

		app.get('/admin/plugins/sso-google', middleware.admin.buildHeader, render);
		app.get('/api/admin/plugins/sso-google', render);

		callback();
	}

	Google.getStrategy = function(strategies, callback) {
		meta.settings.get('sso-google', function(err, settings) {
			if (!err && settings['id'] && settings['secret']) {
				passport.use(new passportGoogle({
					clientID: settings['id'],
					clientSecret: settings['secret'],
					callbackURL: nconf.get('url') + '/auth/google/callback'
				}, function(accessToken, refreshToken, profile, done) {
					Google.login(profile.id, profile.displayName, profile.emails[0].value, function(err, user) {
						if (err) {
							return done(err);
						}
						done(null, user);
					});
				}));

				strategies.push({
					name: 'google',
					url: '/auth/google',
					callbackURL: '/auth/google/callback',
					icon: 'fa-google-plus-square',
					scope: 'https://www.googleapis.com/auth/userinfo.profile https://www.googleapis.com/auth/userinfo.email'
				});
			}

			callback(null, strategies);
		});
	};

	Google.login = function(gplusid, handle, email, callback) {
		Google.getUidByGoogleId(gplusid, function(err, uid) {
			if(err) {
				return callback(err);
			}

			if (uid !== null) {
				// Existing User
				callback(null, {
					uid: uid
				});
			} else {
				// New User
				var success = function(uid) {
					// Save google-specific information to the user
					User.setUserField(uid, 'gplusid', gplusid);
					db.setObjectField('gplusid:uid', gplusid, uid);
					callback(null, {
						uid: uid
					});
				};

				User.getUidByEmail(email, function(err, uid) {
					if(err) {
						return callback(err);
					}

					if (!uid) {
						User.create({username: handle, email: email}, function(err, uid) {
							if(err) {
								return callback(err);
							}

							success(uid);
						});
					} else {
						success(uid); // Existing account -- merge
					}
				});
			}
		});
	};

	Google.getUidByGoogleId = function(gplusid, callback) {
		db.getObjectField('gplusid:uid', gplusid, function(err, uid) {
			if (err) {
				return callback(err);
			}
			callback(null, uid);
		});
	};

	Google.addMenuItem = function(custom_header, callback) {
		custom_header.authentication.push({
			"route": constants.admin.route,
			"icon": constants.admin.icon,
			"name": constants.name
		});

		callback(null, custom_header);
	}

	module.exports = Google;
}(module));<commit_msg>Add google picture<commit_after>(function(module) {
	"use strict";

	var User = module.parent.require('./user'),
		meta = module.parent.require('./meta'),
		db = module.parent.require('../src/database'),
		passport = module.parent.require('passport'),
  		passportGoogle = require('passport-google-oauth').OAuth2Strategy,
  		fs = module.parent.require('fs'),
  		path = module.parent.require('path'),
  		nconf = module.parent.require('nconf');

	var constants = Object.freeze({
		'name': "Google",
		'admin': {
			'route': '/plugins/sso-google',
			'icon': 'fa-google-plus-square'
		}
	});

	var Google = {};

	Google.init = function(app, middleware, controllers, callback) {
		function render(req, res, next) {
			res.render('admin/plugins/sso-google', {});
		}

		app.get('/admin/plugins/sso-google', middleware.admin.buildHeader, render);
		app.get('/api/admin/plugins/sso-google', render);

		callback();
	}

	Google.getStrategy = function(strategies, callback) {
		meta.settings.get('sso-google', function(err, settings) {
			if (!err && settings['id'] && settings['secret']) {
				passport.use(new passportGoogle({
					clientID: settings['id'],
					clientSecret: settings['secret'],
					callbackURL: nconf.get('url') + '/auth/google/callback'
				}, function(accessToken, refreshToken, profile, done) {
					Google.login(profile.id, profile.displayName, profile.emails[0].value, profile._json.picture, function(err, user) {
						if (err) {
							return done(err);
						}
						done(null, user);
					});
				}));

				strategies.push({
					name: 'google',
					url: '/auth/google',
					callbackURL: '/auth/google/callback',
					icon: 'fa-google-plus-square',
					scope: 'https://www.googleapis.com/auth/userinfo.profile https://www.googleapis.com/auth/userinfo.email'
				});
			}

			callback(null, strategies);
		});
	};

	Google.login = function(gplusid, handle, email, picture, callback) {
		Google.getUidByGoogleId(gplusid, function(err, uid) {
			if(err) {
				return callback(err);
			}

			if (uid !== null) {
				// Existing User
				callback(null, {
					uid: uid
				});
			} else {
				// New User
				var success = function(uid) {
					// Save google-specific information to the user
					User.setUserField(uid, 'gplusid', gplusid);
					db.setObjectField('gplusid:uid', gplusid, uid);

					// Save their photo, if present
					if (picture) {
						User.setUserField(uid, 'uploadedpicture', picture);
						User.setUserField(uid, 'picture', picture);
					}

					callback(null, {
						uid: uid
					});
				};

				User.getUidByEmail(email, function(err, uid) {
					if(err) {
						return callback(err);
					}

					if (!uid) {
						User.create({username: handle, email: email}, function(err, uid) {
							if(err) {
								return callback(err);
							}

							success(uid);
						});
					} else {
						success(uid); // Existing account -- merge
					}
				});
			}
		});
	};

	Google.getUidByGoogleId = function(gplusid, callback) {
		db.getObjectField('gplusid:uid', gplusid, function(err, uid) {
			if (err) {
				return callback(err);
			}
			callback(null, uid);
		});
	};

	Google.addMenuItem = function(custom_header, callback) {
		custom_header.authentication.push({
			"route": constants.admin.route,
			"icon": constants.admin.icon,
			"name": constants.name
		});

		callback(null, custom_header);
	}

	module.exports = Google;
}(module));<|endoftext|>


<commit_before>Package.describe({
  name: 'saucecode:rollbar',
  version: '0.0.7',
  summary: 'Rollbar error reporting integrations for Meteor',
  documentation: 'README.md'
});

Package.onUse(function(api) {
  api.versionsFrom('METEOR@1.0');

  Npm.depends({
    'rollbar': '0.5.4'
  });

  api.use('check', 'server');

  api.addFiles('lib/server/rollbar-server.js', 'server');
  api.addFiles('lib/client/rollbar-client.js', 'client');
  api.addFiles('lib/private/client-head.html', 'server', { isAsset: true });

  api.export([
    'throwError',
    'handleError'
  ], 'client');

  api.export([
    'rollbar',
    'throwError',
    'handleError'
  ], 'server');
});

<commit_msg>rolling version number<commit_after>Package.describe({
  name: 'saucecode:rollbar',
  version: '0.0.8',
  summary: 'Rollbar error reporting integrations for Meteor',
  documentation: 'README.md'
});

Package.onUse(function(api) {
  api.versionsFrom('METEOR@1.0');

  Npm.depends({
    rollbar: '0.5.4'
  });

  api.use('check', 'server');

  api.addFiles('lib/server/rollbar-server.js', 'server');
  api.addFiles('lib/client/rollbar-client.js', 'client');
  api.addFiles('lib/private/client-head.html', 'server', { isAsset: true });

  api.export([
    'throwError',
    'handleError'
  ], 'client');

  api.export([
    'rollbar',
    'throwError',
    'handleError'
  ], 'server');
});
<|endoftext|>


<commit_before>function qs(selector){
	return 'bla';
};
<commit_msg>Delete library.js<commit_after><|endoftext|>


<commit_before>function Characteristic(options, onUpdate) {
	if (!(this instanceof Characteristic))  {
		return new Characteristic(options);
	}

	this.instanceID = 0;
	this.accessoryID = 0;
	this.type = options.type;
	this.value = options.initialValue;
	this.perms = options.perms;
	this.format = options.format;
	this.supportEvents = options.supportEvents;
	this.supportBonjour = options.supportBonjour;
	this.manfDescription = options.manfDescription;
	this.designedMaxLength = options.designedMaxLength;

	this.eventEnabled = false;
	this.bonjourEnabled = false;

	this.subscribedPeers = {};

	this.onUpdate = onUpdate;
}

Characteristic.prototype = {
	updateCharacteristicValue: function updateCharacteristicValue(value, peer) {
		this.value = value;
		this.updateValue(value, peer);
		if (this.onUpdate !== undefined) {
			this.onUpdate(value);
		} else {
			console.log("Update:",value);
		}
	},
	updateCharacteristicEvent: function updateCharacteristicEvent(event, peer) {
		console.log("Enable Event:",event);
		this.subscribedPeers[peer] = event;
		this.eventEnabled = event;
	},
	objectPresentation: function objectPresentation() {
		var object = {
			iid: this.instanceID,
			type: this.type,
			perms: this.perms,
			format: this.format,
			value: this.value,
			events: this.eventEnabled,
			bonjour: this.bonjourEnabled,
			description: this.manfDescription,
			maxLen: this.designedMaxLength,
		};
		return object;
	},
	updateValue: function updateValue(value, peer) {
		this.value = value;
		if(this.eventEnabled) {
			if (this.accessoryController !== undefined) {
				var eventDict = {
					characteristics: [
						{
							aid: this.accessoryID,
							iid: this.instanceID,
							value: this.value
						}
					]
				}
				var eventJSON = JSON.stringify(eventDict);
				this.accessoryController.broadcastEvent(eventJSON, this.subscribedPeers, peer);
			}
		}
	},
	valueForUpdate: function valueForUpdate() {
		return this.value;
	}
}

module.exports = {
	Characteristic: Characteristic
};<commit_msg>Fix onUpdate function check<commit_after>function Characteristic(options, onUpdate) {
	if (!(this instanceof Characteristic))  {
		return new Characteristic(options);
	}

	this.instanceID = 0;
	this.accessoryID = 0;
	this.type = options.type;
	this.value = options.initialValue;
	this.perms = options.perms;
	this.format = options.format;
	this.supportEvents = options.supportEvents;
	this.supportBonjour = options.supportBonjour;
	this.manfDescription = options.manfDescription;
	this.designedMaxLength = options.designedMaxLength;

	this.eventEnabled = false;
	this.bonjourEnabled = false;

	this.subscribedPeers = {};

	this.onUpdate = onUpdate;
}

Characteristic.prototype = {
	updateCharacteristicValue: function updateCharacteristicValue(value, peer) {
		this.value = value;
		this.updateValue(value, peer);
		if (this.onUpdate !== null) {
			this.onUpdate(value);
		} else {
			console.log("Update:",value);
		}
	},
	updateCharacteristicEvent: function updateCharacteristicEvent(event, peer) {
		console.log("Enable Event:",event);
		this.subscribedPeers[peer] = event;
		this.eventEnabled = event;
	},
	objectPresentation: function objectPresentation() {
		var object = {
			iid: this.instanceID,
			type: this.type,
			perms: this.perms,
			format: this.format,
			value: this.value,
			events: this.eventEnabled,
			bonjour: this.bonjourEnabled,
			description: this.manfDescription,
			maxLen: this.designedMaxLength,
		};
		return object;
	},
	updateValue: function updateValue(value, peer) {
		this.value = value;
		if(this.eventEnabled) {
			if (this.accessoryController !== undefined) {
				var eventDict = {
					characteristics: [
						{
							aid: this.accessoryID,
							iid: this.instanceID,
							value: this.value
						}
					]
				}
				var eventJSON = JSON.stringify(eventDict);
				this.accessoryController.broadcastEvent(eventJSON, this.subscribedPeers, peer);
			}
		}
	},
	valueForUpdate: function valueForUpdate() {
		return this.value;
	}
}

module.exports = {
	Characteristic: Characteristic
};<|endoftext|>


<commit_before>Package.describe({
  name: 'babrahams:constellation',
  version: '0.1.6',
  summary: 'A curated set of packages for Constellation',
  git: 'https://github.com/JackAdams/constellation-distro.git',
  documentation: 'README.md',
  debugOnly: true
});

Package.onUse(function(api) {

  api.versionsFrom('1.1');

  api.use('constellation:console@1.2.1');
  api.use('babrahams:temple@0.3.2');
  api.use('constellation:subscriptions@0.3.1');
  api.use('constellation:session@0.3.2');
  api.use('constellation:autopublish@0.3.4');
  api.use('constellation:tiny@0.3.1');
  api.use('constellation:position@0.3.2');
  api.use('lai:ddp-inspector@1.1.6');

  api.imply('constellation:console');

});

Package.onTest(function(api) {
  api.use('tinytest');
});
<commit_msg>Bump DDP Inspector version<commit_after>Package.describe({
  name: 'babrahams:constellation',
  version: '0.1.6',
  summary: 'A curated set of packages for Constellation',
  git: 'https://github.com/JackAdams/constellation-distro.git',
  documentation: 'README.md',
  debugOnly: true
});

Package.onUse(function(api) {

  api.versionsFrom('1.1');

  api.use('constellation:console@1.2.1');
  api.use('babrahams:temple@0.3.2');
  api.use('constellation:subscriptions@0.3.1');
  api.use('constellation:session@0.3.2');
  api.use('constellation:autopublish@0.3.4');
  api.use('constellation:tiny@0.3.1');
  api.use('constellation:position@0.3.2');
  api.use('lai:ddp-inspector@1.1.7');

  api.imply('constellation:console');

});

Package.onTest(function(api) {
  api.use('tinytest');
});
<|endoftext|>


<commit_before>Package.describe({
  name: 'gfk:notifications',
  summary: 'Notifications - Add reactive notifications to any meteor template',
  version: '1.1.2',
  git: 'https://github.com/gfk-ba/meteor-notifications'
});

Package.onUse(function(api) {
  api.versionsFrom('METEOR@1.0');

  api.use([
    'templating',
    'underscore',
    'less',
    'mongo@1.0.4'
  ], 'client');

  api.addFiles([
    'globals.js',
    'notifications.less',
    'notifications.html',
    'notifications.js',
    'notification.html',
    'notification.js',
  ], 'client');

  api.export && api.export('Notifications', 'client');
});

Package.onTest(function(api) {
  api.use([
    'tinytest',
    'underscore',
    'gfk:notifications'
  ], 'client');

  api.use(['spacejamio:munit@2.1.0'], 'client');

  api.addFiles('notifications_tests.js', 'client');
});
<commit_msg>Version bump<commit_after>Package.describe({
  name: 'gfk:notifications',
  summary: 'Notifications - Add reactive notifications to any meteor template',
  version: '1.1.3',
  git: 'https://github.com/gfk-ba/meteor-notifications'
});

Package.onUse(function(api) {
  api.versionsFrom('METEOR@1.0');

  api.use([
    'templating',
    'underscore',
    'less',
    'mongo@1.0.4'
  ], 'client');

  api.addFiles([
    'globals.js',
    'notifications.less',
    'notifications.html',
    'notifications.js',
    'notification.html',
    'notification.js',
  ], 'client');

  api.export && api.export('Notifications', 'client');
});

Package.onTest(function(api) {
  api.use([
    'tinytest',
    'underscore',
    'gfk:notifications'
  ], 'client');

  api.use(['spacejamio:munit@2.1.0'], 'client');

  api.addFiles('notifications_tests.js', 'client');
});
<|endoftext|>


<commit_before>Package.describe({
	summary: "A paypal package that helps make restful API calls to Paypal",
	version: "1.2.0",
	name: "limemakers:paypal",
	git: "https://github.com/LimeMakers/meteor-paypal.git"
});

Npm.depends({
	"paypal-rest-sdk": "1.5.1"
});

Package.on_use(function(api) {
	api.versionsFrom("1.0");
	api.use(["meteorhacks:npm"], "server");
	api.use(["templating"], "client");
	api.add_files("paypal.js", ["client", "server"]);
	api.add_files(["paypal_credit_card_form.html", "paypal_credit_card_form.js"], "client");
});

Package.on_test(function(api) {
	//need to add some tests
});
<commit_msg>Revert "fixed depending"<commit_after>Package.describe({
  name: 'liberation:accounts-paypal',
  summary: 'Login service for PayPal accounts',
  version: '1.0.3',
  git: 'https://github.com/dolgarev/meteor-accounts-paypal'
});

Package.onUse(function(api) {
  api.versionsFrom('1.0.2');
  api.use('accounts-base', ['client', 'server']);
  api.imply('accounts-base', ['client', 'server']);
  api.use('accounts-oauth', ['client', 'server']);
  api.use('liberation:paypal-login@1.0.3', ['client', 'server']);

  api.export('PaypalLogin')

  api.addFiles('paypal_login_button.css', 'client');
  api.addFiles("paypal.js");
});
<|endoftext|>


<commit_before>Package.describe({
  name: 'meteoric:ionic-sass',
  summary: "Ionic's CSS Framework in SASS and bundled for Meteor.",
  version: '0.1.0',
  git: 'https://github.com/meteoric/ionic-sass'
});

Package.onUse(function(api) {
  api.versionsFrom('1.0');
  api.use('stevezhu:sass@1.3.2');
  api.addFiles('sass_include_paths.json', 'server');
});
<commit_msg>version bump<commit_after>Package.describe({
  name: 'meteoric:ionic-sass',
  summary: "Ionic's CSS Framework in SASS and bundled for Meteor.",
  version: '0.1.1',
  git: 'https://github.com/meteoric/ionic-sass'
});

Package.onUse(function(api) {
  api.versionsFrom('1.0');
  api.use('stevezhu:sass@1.3.2');
  api.addFiles('sass_include_paths.json', 'server');
});
<|endoftext|>


<commit_before>Package.describe({
  name: 'packaging:autopublish-test',
  summary: 'Dummy package to test auto-publish with TravisCI. DO NOT USE!',
  version: '0.1.5',
  git: 'https://github.com/MeteorPackaging/autopublish-test.git'
});

Package.onUse(function(api) {
  "use strict";

  api.versionsFrom('1.0.1');
  api.addFiles('lib/main.js');
});

Package.onTest(function(api) {
  "use strict";

  api.use('tinytest');
  api.use('packaging:autopublish-test');
  api.addFiles('tests/main.js');
});
<commit_msg>Bump to version 0.1.6<commit_after>Package.describe({
  name: 'packaging:autopublish-test',
  summary: 'Dummy package to test auto-publish with TravisCI. DO NOT USE!',
  version: '0.1.6',
  git: 'https://github.com/MeteorPackaging/autopublish-test.git'
});

Package.onUse(function(api) {
  "use strict";

  api.versionsFrom('1.0.1');
  api.addFiles('lib/main.js');
});

Package.onTest(function(api) {
  "use strict";

  api.use('tinytest');
  api.use('packaging:autopublish-test');
  api.addFiles('tests/main.js');
});
<|endoftext|>


<commit_before>import ShadowComponent from './ShadowComponent';

class ModalComponent extends ShadowComponent {

	constructor () {
		super();

		this.state = {
			open: false
		};
	}

	onStateUpdate (property, oldValue, newValue) {
		if (property === 'open') {
			this.classList.toggle ('modal--active');
		}
		return Promise.resolve ();
	}

	render () {
		return `

					<slot></slot>

		`;
	}
}

export { ModalComponent };<commit_msg>Remove unused component template<commit_after><|endoftext|>


<commit_before>Package.describe({
  name: 'babrahams:editable-text-wysiwyg',
  summary: 'Extends the babrahams:editable-text package to include a wysiwyg editor',
  version: '0.2.2',
  git: 'https://github.com/jackadams/meteor-editable-text-wysiwyg.git'
});

Package.onUse(function(api) {

  api.versionsFrom('1.0');

  api.use('babrahams:editable-text@0.5.5', 'client');
  api.use('babrahams:editable-text-wysiwyg-base@0.1.0', 'client');
  api.use('templating', 'client');
  api.use('blaze', 'client');
  api.use('spacebars', 'client');
  api.use('jquery', 'client');
  api.use('ian:bootstrap-3', 'client');
  api.use('fortawesome:fontawesome@4.2.0', 'client');

  api.add_files('lib/editable_text_wysiwyg_bootstrap_wysiwyg.css', 'client');
  api.add_files('lib/editable_text_wysiwyg_bootstrap_wysiwyg.html', 'client');
  api.add_files('lib/editable_text_wysiwyg_bootstrap_wysiwyg.js', 'client');

});

Package.onTest(function(api) {
  api.use('tinytest');
  api.use('babrahams:editable-text-wysiwyg');
  api.addFiles('editable-text-wysiwyg-tests.js');
});<commit_msg>Updated package.js<commit_after>Package.describe({
  name: 'babrahams:editable-text-wysiwyg-bootstrap-3',
  summary: 'Extends the babrahams:editable-text package to include a wysiwyg editor that uses bootstrap-3',
  version: '0.1.0',
  git: 'https://github.com/jackadams/meteor-editable-text-wysiwyg-bootstrap-3.git'
});

Package.onUse(function(api) {

  api.versionsFrom('1.0');

  api.use('babrahams:editable-text@0.5.5', 'client');
  api.use('babrahams:editable-text-wysiwyg-base@0.1.0', 'client');
  api.use('templating', 'client');
  api.use('blaze', 'client');
  api.use('spacebars', 'client');
  api.use('jquery', 'client');
  api.use('ian:bootstrap-3', 'client');
  api.use('fortawesome:fontawesome@4.2.0', 'client');

  api.add_files('lib/editable_text_wysiwyg_bootstrap_wysiwyg.css', 'client');
  api.add_files('lib/editable_text_wysiwyg_bootstrap_wysiwyg.html', 'client');
  api.add_files('lib/editable_text_wysiwyg_bootstrap_wysiwyg.js', 'client');

});

Package.onTest(function(api) {
  api.use('tinytest');
  api.use('babrahams:editable-text-wysiwyg');
  api.addFiles('editable-text-wysiwyg-tests.js');
});<|endoftext|>


<commit_before>Package.describe({
    name: 'fullhdpixel:authenticator',
    summary: 'Google authenticator methods for quick integration',
    version: '0.0.1',
    git: 'https://github.com/fullhdpixel/Meteor-Google-Authenticator'
});

Package.onUse(function(api) {
    Npm.depends({
        "notp": "2.0.3",
        "thirty-two": "0.0.2"
    });

    api.addFiles(['authenticator.js']);
    api.addFiles(['server/authenticator.js'], 'server');
    api.export('Authenticator');
});
<commit_msg>0.0.2 release<commit_after>Package.describe({
    name: 'fullhdpixel:authenticator',
    summary: 'Google authenticator methods for quick integration',
    version: '0.0.2',
    git: 'https://github.com/fullhdpixel/Google-Authenticator'
});

Package.onUse(function(api) {
    Npm.depends({
        "notp": "2.0.3",
        "thirty-two": "0.0.2"
    });

    api.addFiles(['authenticator.js']);
    api.addFiles(['server/authenticator.js'], 'server');
    api.export('Authenticator');
});
<|endoftext|>


<commit_before>window.qd.plotScatterPlot = function(divId, correlateEvents) {
	var margin = {
			top: 20,
			right: 20,
			bottom: 30,
			left: 40
		},
		width = $(divId).width() - margin.left - margin.right,
		height = (width/ 1.61) - margin.top - margin.bottom;

	/*
	 * value accessor - returns the value to encode for a given data object.
	 * scale - maps value to a visual display encoding, such as a pixel position.
	 * map function - maps from data value to display value
	 * axis - sets up axis
	 */
	var _groupCorrelateEvents = function(events) {
		return _.map(events, function(event) {
			return {
				x: event.activeTimeInMinutes,
				y: event.githubPushEventCount
			};
		});
	};

	// setup x
	var xValue = function(d) {
			return d.x;
		}, // data -> value
		xScale = d3.scale.linear().range([0, width]), // value -> display
		xMap = function(d) {
			return xScale(xValue(d));
		}, // data -> display
		xAxis = d3.svg.axis().scale(xScale).orient("bottom");

	// setup y
	var yValue = function(d) {
			return d.y;
		}, // data -> value
		yScale = d3.scale.linear().range([height, 0]), // value -> display
		yMap = function(d) {
			return yScale(yValue(d));
		}, // data -> display
		yAxis = d3.svg.axis().scale(yScale).orient("left");

	// setup fill color
	var cValue = function(d) {
			return d.x;
		},
		color = d3.scale.category10();

	// add the graph canvas to the body of the webpage
	var svg = d3.select(divId).append("svg")
		.attr("width", width + margin.left + margin.right)
		.attr("height", height + margin.top + margin.bottom)
		.append("g")
		.attr("transform", "translate(" + margin.left + "," + margin.top + ")");

	// add the tooltip area to the webpage
	var tooltip = d3.select("body").append("div")
		.attr("class", "tooltip")
		.style("opacity", 0);

	// load data
	var _plotGraph = function() {
		var data = _groupCorrelateEvents(correlateEvents);
		// don't want dots overlapping axis, so add in buffer to data domain
		xScale.domain([d3.min(data, xValue) - 1, d3.max(data, xValue) + 1]);
		yScale.domain([d3.min(data, yValue) - 1, d3.max(data, yValue) + 1]);

		// x-axis
		svg.append("g")
			.attr("class", "x axis")
			.attr("transform", "translate(0," + height + ")")
			.call(xAxis)
			.append("text")
			.attr("class", "label")
			.attr("x", width)
			.attr("y", -6)
			.style("text-anchor", "end")
			.text("IDE ACtivity In Minutes");

		// y-axis
		svg.append("g")
			.attr("class", "y axis")
			.call(yAxis)
			.append("text")
			.attr("class", "label")
			.attr("transform", "rotate(-90)")
			.attr("y", 6)
			.attr("dy", ".71em")
			.style("text-anchor", "end")
			.text("Github Push Count");

		// draw dots
		svg.selectAll(".dot")
			.data(data)
			.enter().append("circle")
			.attr("class", "dot")
			.attr("r", 3.5)
			.attr("cx", xMap)
			.attr("cy", yMap)
			.style("fill", function(d) {
				return color(cValue(d));
			})
			.on("mouseover", function(d) {
				tooltip.transition()
					.duration(200)
					.style("opacity", .9);
				tooltip.html("
 (" + xValue(d) + ", " + yValue(d) + ")")
					.style("left", (d3.event.pageX + 5) + "px")
					.style("top", (d3.event.pageY - 28) + "px");
			})
			.on("mouseout", function(d) {
				tooltip.transition()
					.duration(500)
					.style("opacity", 0);
			});

		// draw legend
		var legend = svg.selectAll(".legend")
			.data(color.domain())
			.enter().append("g")
			.attr("class", "legend")
			.attr("transform", function(d, i) {
				return "translate(0," + i * 20 + ")";
			});

		// draw legend colored rectangles
		legend.append("rect")
			.attr("x", width - 18)
			.attr("width", 18)
			.attr("height", 18)
			.style("fill", color);

		// draw legend text
		legend.append("text")
			.attr("x", width - 24)
			.attr("y", 9)
			.attr("dy", ".35em")
			.style("text-anchor", "end")
			.text(function(d) {
				return d;
			})
	};
	_plotGraph();
};<commit_msg>-- Removed the different colors for the plot dots<commit_after>window.qd.plotScatterPlot = function(divId, correlateEvents) {
	var margin = {
			top: 20,
			right: 20,
			bottom: 30,
			left: 40
		},
		width = $(divId).width() - margin.left - margin.right,
		height = (width / 1.61) - margin.top - margin.bottom;

	var _groupCorrelateEvents = function(events) {
		return _.map(events, function(event) {
			return {
				x: event.activeTimeInMinutes,
				y: event.githubPushEventCount
			};
		});
	};

	var xValue = function(d) {
			return d.x;
		},
		xScale = d3.scale.linear().range([0, width]),
		xMap = function(d) {
			return xScale(xValue(d));
		},
		xAxis = d3.svg.axis().scale(xScale).orient("bottom");

	var yValue = function(d) {
			return d.y;
		},
		yScale = d3.scale.linear().range([height, 0]),
		yMap = function(d) {
			return yScale(yValue(d));
		},
		yAxis = d3.svg.axis().scale(yScale).orient("left");

	/*var cValue = function(d) {
			return d.x;
		},
		color = d3.scale.category10();*/

	var svg = d3.select(divId).append("svg")
		.attr("width", width + margin.left + margin.right)
		.attr("height", height + margin.top + margin.bottom)
		.append("g")
		.attr("transform", "translate(" + margin.left + "," + margin.top + ")");

	var tooltip = d3.select("body").append("div")
		.attr("class", "tooltip")
		.style("opacity", 0);

	var _plotGraph = function() {
		var data = _groupCorrelateEvents(correlateEvents);
		// don't want dots overlapping axis, so add in buffer to data domain
		xScale.domain([d3.min(data, xValue) - 1, d3.max(data, xValue) + 1]);
		yScale.domain([d3.min(data, yValue) - 1, d3.max(data, yValue) + 1]);

		// x-axis
		svg.append("g")
			.attr("class", "x axis")
			.attr("transform", "translate(0," + height + ")")
			.call(xAxis)
			.append("text")
			.attr("class", "label")
			.attr("x", width)
			.attr("y", -6)
			.style("text-anchor", "end")
			.text("IDE Activity In Minutes");

		// y-axis
		svg.append("g")
			.attr("class", "y axis")
			.call(yAxis)
			.append("text")
			.attr("class", "label")
			.attr("transform", "rotate(-90)")
			.attr("y", 6)
			.attr("dy", ".71em")
			.style("text-anchor", "end")
			.text("Github Push Count");

		// draw dots
		svg.selectAll(".dot")
			.data(data)
			.enter().append("circle")
			.attr("class", "dot")
			.attr("r", 3.5)
			.attr("cx", xMap)
			.attr("cy", yMap)
			.style("fill", "blue")
		/*.style("fill", function(d) {
				return color(cValue(d));
			})*/
		.on("mouseover", function(d) {
			tooltip.transition()
				.duration(200)
				.style("opacity", .9);
			tooltip.html("
 (" + xValue(d) + ", " + yValue(d) + ")")
				.style("left", (d3.event.pageX + 5) + "px")
				.style("top", (d3.event.pageY - 28) + "px");
		})
			.on("mouseout", function(d) {
				tooltip.transition()
					.duration(500)
					.style("opacity", 0);
			});

		/*// draw legend
		var legend = svg.selectAll(".legend")
			.data(color.domain())
			.enter().append("g")
			.attr("class", "legend")
			.attr("transform", function(d, i) {
				return "translate(0," + i * 20 + ")";
			});

		// draw legend colored rectangles
		legend.append("rect")
			.attr("x", width - 18)
			.attr("width", 18)
			.attr("height", 18)
			.style("fill", color);

		// draw legend text
		legend.append("text")
			.attr("x", width - 24)
			.attr("y", 9)
			.attr("dy", ".35em")
			.style("text-anchor", "end")
			.text(function(d) {
				return d;
			})*/
	};
	_plotGraph();
};<|endoftext|>


<commit_before>import React from 'react';
import { Link } from 'react-router';
import './contest-navigator.css';
import { logout } from './Login/actions/authActions';
import { connect } from 'react-redux';
import { getContestInfo } from './ContestActions';

class ContestNavigator extends React.Component {

  constructor(props) {
    super(props);
    this.state = { name: ''};
  }

  logout(e) {
    this.props.logout();
  }

  /**
   * get contest name for home link
   */
  componentDidMount() {
    if(this.props.contestId != 'wont be used') {
      getContestInfo(this.props.contestId).then(res => {
        if (res.name) {
          this.setState({name: res.name});
        }
      });
    }
  }

  render() {
    const { contestId, page, teamId, username, userRole } = this.props;

    let navLinks = null;
    if ('admin' === userRole) {
      navLinks = (

            <Link
              className='nav-link'
              to={`/contest/${contestId}/home`}
            >{this.state.name}</Link>

            <Link
              className='nav-link'
              to={`/contest/${contestId}/problems/add`}
            >Problems</Link>

            <Link
              className='nav-link'
              to={`/contest/${contestId}/scoreboard`}
            >ScoreBoard</Link>

            <Link
              className='nav-link'
              to={`/contest/${contestId}/submissions`}
            >Submissions</Link>

      );
    } else if ('participant' === userRole) {
      navLinks = (

            <Link
              className='nav-link'
              to={`/contest/${contestId}/home`}
            >{contestName}</Link>

            <Link
              className='nav-link'
              to={`/contest/${contestId}/problems/${teamId}/1`}
            >Problems</Link>

            <Link
              className='nav-link'
              to={`/contest/${contestId}/scoreboard/${teamId}`}
            >ScoreBoard</Link>

            <Link
              className='nav-link'
              to={`/contest/${contestId}/submissions/${teamId}`}
            >Submissions</Link>

      );
    }
    return (

          {navLinks}

              <Link to={'/profile'} className='nav-link'>
                {username}
              </Link>

              <Link to={'/'} className='nav-link' onClick={this.logout.bind(this)}>
                Logout
              </Link>

    );
  }
}

ContestNavigator.propTypes = {
  contestId: React.PropTypes.string.isRequired,
  page: React.PropTypes.oneOf([
    'home', 'problems', 'scoreboard', 'submissions', 'none',
  ]).isRequired,
  teamId: React.PropTypes.string,
  username: React.PropTypes.string.isRequired,
  userRole: React.PropTypes.oneOf(['admin', 'participant', 'none']).isRequired,
};

function mapStateToProps(state) {
  return {
    auth: state.auth,
  };
}

export default connect(mapStateToProps, { logout })(ContestNavigator);
<commit_msg>fixed navigation for participant<commit_after>import React from 'react';
import { Link } from 'react-router';
import './contest-navigator.css';
import { logout } from './Login/actions/authActions';
import { connect } from 'react-redux';
import { getContestInfo } from './ContestActions';

class ContestNavigator extends React.Component {

  constructor(props) {
    super(props);
    this.state = { name: ''};
  }

  logout(e) {
    this.props.logout();
  }

  /**
   * get contest name for home link
   */
  componentDidMount() {
    if(this.props.contestId != 'wont be used') {
      getContestInfo(this.props.contestId).then(res => {
        if (res.name) {
          this.setState({name: res.name});
        }
      });
    }
  }

  render() {
    const { contestId, page, teamId, username, userRole } = this.props;

    let navLinks = null;
    if ('admin' === userRole) {
      navLinks = (

            <Link
              className='nav-link'
              to={`/contest/${contestId}/home`}
            >{this.state.name}</Link>

            <Link
              className='nav-link'
              to={`/contest/${contestId}/problems/add`}
            >Problems</Link>

            <Link
              className='nav-link'
              to={`/contest/${contestId}/scoreboard`}
            >ScoreBoard</Link>

            <Link
              className='nav-link'
              to={`/contest/${contestId}/submissions`}
            >Submissions</Link>

      );
    } else if ('participant' === userRole) {
      navLinks = (

            <Link
              className='nav-link'
              to={`/contest/${contestId}/home`}
            >{this.state.name}</Link>

            <Link
              className='nav-link'
              to={`/contest/${contestId}/problems/${teamId}/1`}
            >Problems</Link>

            <Link
              className='nav-link'
              to={`/contest/${contestId}/scoreboard/${teamId}`}
            >ScoreBoard</Link>

            <Link
              className='nav-link'
              to={`/contest/${contestId}/submissions/${teamId}`}
            >Submissions</Link>

      );
    }
    return (

          {navLinks}

              <Link to={'/profile'} className='nav-link'>
                {username}
              </Link>

              <Link to={'/'} className='nav-link' onClick={this.logout.bind(this)}>
                Logout
              </Link>

    );
  }
}

ContestNavigator.propTypes = {
  contestId: React.PropTypes.string.isRequired,
  page: React.PropTypes.oneOf([
    'home', 'problems', 'scoreboard', 'submissions', 'none',
  ]).isRequired,
  teamId: React.PropTypes.string,
  username: React.PropTypes.string.isRequired,
  userRole: React.PropTypes.oneOf(['admin', 'participant', 'none']).isRequired,
};

function mapStateToProps(state) {
  return {
    auth: state.auth,
  };
}

export default connect(mapStateToProps, { logout })(ContestNavigator);
<|endoftext|>