<commit_before>var Promise = require('bluebird');
var TimeSeries = require('redis-timeseries');

var MAX_NEWS_ITEMS = 100;

function getUnixTimestamp() {
  return Math.floor(new Date() / 1000);
}

function getUserKey(username, optSuffix) {
  var path = ['gos', 'user', username];
  optSuffix && path.push(optSuffix);
  return path.join(':');
}

function getExpKey(id, optSuffix) {
  var path = ['gos', 'exp', id];
  optSuffix && path.push(optSuffix);
  return path.join(':');
}

function getNewsKey(optSuffix) {
  var path = ['gos', 'news'];
  optSuffix && path.push(optSuffix);
  return path.join(':');
}

function Model(config, redis) {
  this.config = config;
  this.redis = redis;
  this.timeseries = new TimeSeries(redis, 'gos:stats');
}

Model.prototype = {
  /**
   * Users
   */

  putUser: function(profile, accessToken, isVouched) {
    var writePromise = this.redis.multi()
      .set(getUserKey(profile.username, 'accessToken'), accessToken)
      .set(getUserKey(profile.username, 'isVouched'), isVouched)
      .set(getUserKey(profile.username), JSON.stringify(profile))
      .exec();

    return writePromise.then(function() {
      return {
        username: profile.username,
        profile: profile,
        isVouched: isVouched
      };
    });
  },

  getUserByUsername: function(username) {
    return Promise.props({
      username: username,
      profile: this.redis.get(getUserKey(username)).then(JSON.parse),
      isVouched: this.redis.get(getUserKey(username, 'isVouched')),
      accessToken: this.redis.get(getUserKey(username, 'accessToken'))
    });
  },

  /**
   * Experiments
   */

  putExp: function(owner, repo, branch, collaborators, title) {
    var id = this.getExpId(owner, repo, branch);
    var exp = {
      id: id,
      owner: owner,
      repo: repo,
      branch: branch,
      title: title
    };

    var transaction = this.redis.multi()
      .hmset(getExpKey(id), exp);

    collaborators.forEach(function(collaborator) {
      transaction.sadd(getUserKey(collaborator, 'exps'), id);
    });

    return transaction.exec().return(exp);
  },

  getExpId: function(owner, repo, branch) {
    return [owner, repo, branch].join(':');
  },

  haveExpById: function(id) {
    return this.redis.exists(getExpKey(id));
  },

  getExpById: function(id) {
    return this.redis.hgetall(getExpKey(id));
  },

  haveExpByUsernameId: function(username, id) {
    return this.redis.sismember(getUserKey(username, 'exps'), id);
  },

  getAllExpsWithBuilds: function() {
    return Promise.map(
      this.redis.zrevrange('gos:exps', 0, -1),
      this.getExpById.bind(this)
    );
  },

  getExpsByUsername: function(username) {
    return Promise.map(
      this.redis.smembers(getUserKey(username, 'exps')),
      this.getExpById.bind(this)
    );
  },

  /**
   * Experiments: Builds
   */

  putExpBuildLock: function(expId) {
    return this.redis.set(getExpKey(expId, 'build'), this.config.id, 'NX');
  },

  delExpBuildLock: function(expId) {
    return this.redis.del(getExpKey(expId, 'build'));
  },

  putExpBuild: function(expId, profile, commit) {
    var timestamp = getUnixTimestamp();

    return (
      this.redis.multi()
        .rpush(getExpKey(expId, 'builds'), JSON.stringify({
          profile: profile,
          commit: commit,
          timestamp: timestamp
        }))
        .zadd('gos:exps', timestamp, expId)
        .exec()
    ).then(function(results) {
      return results[0][1];
    });
  },

  getLatestExpBuildId: function(expId) {
    return this.redis.llen(getExpKey(expId, 'builds'));
  },

  getAllExpBuilds: function(expId) {
    return Promise.map(
      this.redis.lrange(getExpKey(expId, 'builds'), 0, -1),
      function(value, index) {
        return Object.assign(JSON.parse(value), {id: index+1});
      }
    );
  },

  /**
   * Experiments: Analytics
   */

  putExpEvents: function(id, events) {
    var keySet = {};

    events.forEach(function(event) {
      var key = [id, event.key].join(':');
      keySet[key] = true;
      this.timeseries.recordHit(key, event.timestamp, event.increment);
    }.bind(this));

    return Promise.join(
      Promise.promisify(this.timeseries.exec)(),
      this.redis.sadd(getExpKey(id, 'eventTypes'), Object.keys(keySet))
    ).return({
      events: events.length,
      eventTypes: Object.keys(keySet)
    });
  },

  getExpEventTypes: function(id) {
    return this.redis.smembers(getExpKey(id, 'eventTypes'));
  },

  /**
   * News Feed
   */

  putNewsItem: function(profile, details) {
    return this.redis.multi()
      .lpush(getNewsKey(), JSON.stringify({
        profile: profile,
        details: details,
        timestamp: getUnixTimestamp()
      }))
      .ltrim(getNewsKey(), 0, MAX_NEWS_ITEMS)
      .exec();
  },

  getAllNewsItems: function() {
    return Promise.map(
      this.redis.lrange(getNewsKey(), 0, -1),
      JSON.parse
    );
  },

  /**
   * My Build
   */

  putMyExp: function(username, expId) {
    return this.redis.set(getUserKey(username, 'my'), expId);
  },

  getMyExp: function(username) {
    return this.redis.get(getUserKey(username, 'my'));
  },

  getMyExpBuildId: function(username, baseUrl) {
    return this.getMyExp(username).then(function(expId) {
      if (!expId) {
        return null;
      }
      return this.getLatestExpBuildId(expId, baseUrl).then(function(buildId) {
        return [expId, buildId].join('/');
      });
    }.bind(this));
  }
};

module.exports = Model;<commit_msg>Use babel to more easily manage keys.<commit_after>var Promise = require('bluebird');
var TimeSeries = require('redis-timeseries');

var MAX_NEWS_ITEMS = 100;

function getUnixTimestamp() {
  return Math.floor(new Date() / 1000);
}

function getKey(...parts) {
  return ['gos'].concat(parts).join(':');
}

function getKeyPrefix(...parts) {
  return getKey(...parts) + ':';
}

function Model(config, redis) {
  this.config = config;
  this.redis = redis;
  this.timeseries = new TimeSeries(redis, 'gos:stats');
}

Model.prototype = {
  /**
   * Users
   */

  putUser: function(profile, accessToken, isVouched) {
    var writePromise = this.redis.multi()
      .set(getKey('user', profile.username, 'accessToken'), accessToken)
      .set(getKey('user', profile.username, 'isVouched'), isVouched)
      .set(getKey('user', profile.username), JSON.stringify(profile))
      .exec();

    return writePromise.then(function() {
      return {
        username: profile.username,
        profile: profile,
        isVouched: isVouched
      };
    });
  },

  getUserByUsername: function(username) {
    return Promise.props({
      username: username,
      profile: this.redis.get(getKey('user', username)).then(JSON.parse),
      isVouched: this.redis.get(getKey('user', username, 'isVouched')),
      accessToken: this.redis.get(getKey('user', username, 'accessToken'))
    });
  },

  /**
   * Experiments
   */

  putExp: function(owner, repo, branch, collaborators, title) {
    var id = this.getExpId(owner, repo, branch);
    var exp = {
      id: id,
      owner: owner,
      repo: repo,
      branch: branch,
      title: title
    };

    var transaction = this.redis.multi()
      .hmset(getKey('exp', id), exp);

    collaborators.forEach(function(collaborator) {
      transaction.sadd(getKey('user', collaborator, 'exps'), id);
    });

    return transaction.exec().return(exp);
  },

  getExpId: function(owner, repo, branch) {
    return [owner, repo, branch].join(':');
  },

  haveExpById: function(id) {
    return this.redis.exists(getKey('exp', id));
  },

  getExpById: function(id) {
    return this.redis.hgetall(getKey('exp', id));
  },

  haveExpByUsernameId: function(username, id) {
    return this.redis.sismember(getKey('user', username, 'exps'), id);
  },

  getAllExpsWithBuilds: function() {
    return Promise.map(
      this.redis.zrevrange('gos:exps', 0, -1),
      this.getExpById.bind(this)
    );
  },

  getExpsByUsername: function(username) {
    return Promise.map(
      this.redis.smembers(getKey('user', username, 'exps')),
      this.getExpById.bind(this)
    );
  },

  /**
   * Experiments: Builds
   */

  putExpBuildLock: function(expId) {
    return this.redis.set(getKey('exp', expId, 'build'), this.config.id, 'NX');
  },

  delExpBuildLock: function(expId) {
    return this.redis.del(getKey('exp', expId, 'build'));
  },

  putExpBuild: function(expId, profile, commit) {
    var timestamp = getUnixTimestamp();

    return (
      this.redis.multi()
        .rpush(getKey('exp', expId, 'builds'), JSON.stringify({
          profile: profile,
          commit: commit,
          timestamp: timestamp
        }))
        .zadd('gos:exps', timestamp, expId)
        .exec()
    ).then(function(results) {
      return results[0][1];
    });
  },

  getLatestExpBuildId: function(expId) {
    return this.redis.llen(getKey('exp', expId, 'builds'));
  },

  getAllExpBuilds: function(expId) {
    return Promise.map(
      this.redis.lrange(getKey('exp', expId, 'builds'), 0, -1),
      function(value, index) {
        return Object.assign(JSON.parse(value), {id: index+1});
      }
    );
  },

  /**
   * Experiments: Analytics
   */

  putExpEvents: function(id, events) {
    var keySet = {};

    events.forEach(function(event) {
      var key = [id, event.key].join(':');
      keySet[key] = true;
      this.timeseries.recordHit(key, event.timestamp, event.increment);
    }.bind(this));

    return Promise.join(
      Promise.promisify(this.timeseries.exec)(),
      this.redis.sadd(getKey('exp', id, 'eventTypes'), Object.keys(keySet))
    ).return({
      events: events.length,
      eventTypes: Object.keys(keySet)
    });
  },

  getExpEventTypes: function(id) {
    return this.redis.smembers(getKey('exp', id, 'eventTypes'));
  },

  /**
   * News Feed
   */

  putNewsItem: function(profile, details) {
    return this.redis.multi()
      .lpush(getKey('news', ), JSON.stringify({
        profile: profile,
        details: details,
        timestamp: getUnixTimestamp()
      }))
      .ltrim(getKey('news', ), 0, MAX_NEWS_ITEMS)
      .exec();
  },

  getAllNewsItems: function() {
    return Promise.map(
      this.redis.lrange(getKey('news', ), 0, -1),
      JSON.parse
    );
  },

  /**
   * My Build
   */

  putMyExp: function(username, expId) {
    return this.redis.set(getKey('user', username, 'my'), expId);
  },

  getMyExp: function(username) {
    return this.redis.get(getKey('user', username, 'my'));
  },

  getMyExpBuildId: function(username, baseUrl) {
    return this.getMyExp(username).then(function(expId) {
      if (!expId) {
        return null;
      }
      return this.getLatestExpBuildId(expId, baseUrl).then(function(buildId) {
        return [expId, buildId].join('/');
      });
    }.bind(this));
  }
};

module.exports = Model;<|endoftext|>


<commit_before>var constants = require('./constants');
var binPath = require('phantomjs').path;
var childProcess = require('child_process');
var path = require('path');
var Q = require('q');

exports.prerender = function(config, posts, callback) {

  var args = getArguments(config, posts);

  Q.all(args.map(function(arg) {
      return Q.nfcall(execPhantom, arg.pageName, arg.outputFile, arg.outputPath);
  }))
  .then(function() {
      callback(null);
  })
  .catch(function(err) {
      callback(err);
  });
};

function execPhantom(pageName, outputFile, outputPath, callback) {

  var childArgs = [
    path.join(__dirname, 'phantomjs-script.js'),
    pageName,
    outputFile,
    outputPath
  ];

  childProcess.execFile(binPath, childArgs, function(err, stdout, stderr) {
    console.log(stdout);
    callback(err);
  });
}

function getArguments(config, posts) {

  var args = [];

  posts.forEach(function(post) {

    var arg = {
      pageName: constants.STAGING_HOSTED_URL + '/' +  constants.FOLDER_POSTS.replace('\\', '') + '/' + post.url,
      outputFile: post.url,
      outputPath: config.directory + constants.FOLDER_POSTS
    };

    args.push(arg);
  });

  return args;
}
<commit_msg>Removing old prerendered files before prerendering new ones<commit_after>var constants = require('./constants');
var binPath = require('phantomjs').path;
var childProcess = require('child_process');
var fs = require('fs');
var path = require('path');
var Q = require('q');

exports.prerender = function(config, posts, callback) {

  var args = getArguments(config, posts);

  removePreviousPosts(config, function(err) {

    if (err)
      callback(err);

    Q.all(args.map(function(arg) {
        return Q.nfcall(execPhantom, arg.pageName, arg.outputFile, arg.outputPath);
    }))
    .then(function() {
        callback(null);
    })
    .catch(function(err) {
        callback(err);
    });
  });
};

function execPhantom(pageName, outputFile, outputPath, callback) {

  var childArgs = [
    path.join(__dirname, 'phantomjs-script.js'),
    pageName,
    outputFile,
    outputPath
  ];

  childProcess.execFile(binPath, childArgs, function(err, stdout, stderr) {
    console.log(stdout);
    callback(err);
  });
}

function getArguments(config, posts) {

  var args = [];

  posts.forEach(function(post) {

    var arg = {
      pageName: constants.STAGING_HOSTED_URL + '/' +  constants.FOLDER_POSTS.replace('\\', '') + '/' + post.url,
      outputFile: post.url,
      outputPath: config.directory + constants.FOLDER_POSTS
    };

    args.push(arg);
  });

  return args;
}

function removePreviousPosts(config, callback) {

  var dir = config.directory + constants.FOLDER_POSTS;

  fs.readdir(dir, function(err, files) {

    if (err)
      callback(err);

    Q.all(files.map(function(file) {

      var path = dir + '\\' + file;
      return Q.nfcall(fs.unlink, path);
    }))
    .then(function() {
      callback(null);
    })
    .catch(function(err) {
      callback(err);
    });
  });
}
<|endoftext|>


<commit_before>'use strict';
Package.describe({
  name: 'firrae:react-mediumeditor',
  summary: 'MediumEditor wrapped up in a ReactJS component.',
  version: '0.1.0',
  git: 'https://github.com/firrae/react-mediumeditor',
  documentation: 'README.md'
});

Package.onUse(function (api) {
  api.use([
    "ecmascript",
    "less",
    "jquery",
    "mediumeditor:mediumeditor",
    "react"
  ], ['client','server']);

  api.addFiles([
    'editor.jsx',
    'editor.less'
  ], 'client', 'server');

  api.export("MediumEditorComp", "client", "server");
});
<commit_msg>Increased the version number.<commit_after>'use strict';
Package.describe({
  name: 'firrae:react-mediumeditor',
  summary: 'MediumEditor wrapped up in a ReactJS component.',
  version: '0.1.1',
  git: 'https://github.com/firrae/react-mediumeditor',
  documentation: 'README.md'
});

Package.onUse(function (api) {
  api.use([
    "ecmascript",
    "less",
    "jquery",
    "mediumeditor:mediumeditor",
    "react"
  ], ['client','server']);

  api.addFiles([
    'editor.jsx',
    'editor.less'
  ], 'client', 'server');

  api.export("MediumEditorComp", "client", "server");
});
<|endoftext|>


<commit_before>Ext.namespace('ui','ui.cmp','ui.cmp._PortletLocalMail');

//------------------------------------------------------------------------------
// PortletLocalMail internals

// Store : Mailing with Informations about phpdoc-LANG mailing
ui.cmp._PortletLocalMail.store = new Ext.data.Store({
    proxy : new Ext.data.HttpProxy({
        url : './do/getLastNews'
    }),
    reader : new Ext.data.JsonReader({
        root          : 'Items',
        totalProperty : 'nbItems',
        idProperty    : 'id',
        fields        : [
            {name : 'id'},
            {name : 'title'},
            {name : 'link'},
            {name : 'description'},
            {name : 'pubDate', type : 'date',dateFormat : 'Y-m-d H:i:s' }
        ]

    })
});
ui.cmp._PortletLocalMail.store.setDefaultSort('pubDate', 'desc');

// PortletLocalMail columns definition
ui.cmp._PortletLocalMail.columns = [
    new Ext.grid.RowNumberer(), {
        id        : 'GridMailingTitle',
        header    : _('Title'),
        sortable  : true,
        dataIndex : 'title'
    }, {
        header    : _('By'),
        width     : 100,
        sortable  : true,
        dataIndex : 'description'
    }, {
        header    : _('Date'),
        width     : 100,
        sortable  : true,
        dataIndex : 'pubDate',
        renderer  : Ext.util.Format.dateRenderer(_('Y-m-d, H:i'))
    }
];

//------------------------------------------------------------------------------
// _PortletLocalMail
ui.cmp._PortletLocalMail.grid = Ext.extend(Ext.grid.GridPanel,
{
    loadMask         : true,
    autoScroll       : true,
    height           : 250,
    autoExpandColumn : 'GridMailingTitle',
    id               : 'PortletLocalMail-grid-id',
    store            : ui.cmp._PortletLocalMail.store,
    columns          : ui.cmp._PortletLocalMail.columns,
    sm               : new Ext.grid.RowSelectionModel({ singleSelect: true }),

    view             : new Ext.grid.GridView({
                           forceFit:true,
                           enableRowBody:true,
                           ignoreAdd: true,
                           emptyText: '
' + _('You must manually load this data.
Use the refresh button !') + '
',
                           deferEmptyText: false
                       }),

    onRowDblClick : function(grid, rowIndex)
    {
        var MailId    = grid.store.getAt(rowIndex).data.pubDate,
            MailUrl   = grid.store.getAt(rowIndex).data.link,
            MailTitle = grid.store.getAt(rowIndex).data.title;

        if (!Ext.getCmp('main-panel').findById('mail-' + MailId)) {

            Ext.getCmp('main-panel').add({
                xtype      : 'panel',
                id         : 'mail-' + MailId,
                title      : Ext.util.Format.substr(MailTitle, 0, 20) + '...',
                tabTip     : MailTitle,
                iconCls    : 'iconMailing',
                closable   : true,
                layout     : 'fit',
                items: [ new Ext.ux.IFrameComponent({ id: 'frame-mail-' + MailId, url: MailUrl }) ]
            });
        }
        Ext.getCmp('main-panel').setActiveTab('mail-' + MailId);
    },

    onContextClick : function(grid, rowIndex, e)
    {
        if(!this.menu) {
            this.menu = new Ext.menu.Menu({
                id    : 'submenu-mail',
                items : [{
                    scope   : this,
                    text    : ''+_('Open in a new Tab')+'',
                    iconCls : 'iconOpenInTab',
                    handler : function()
                    {
                        this.fireEvent('rowdblclick', grid, this.ctxIndex, e);
                        this.menu.hide();
                    }
                }, '-', {
                    scope   : this,
                    text    : _('Refresh this grid'),
                    iconCls : 'iconRefresh',
                    handler : function()
                    {
                        this.ctxIndex = null;
                        ui.cmp._PortletLocalMail.reloadData();
                    }
                }]
            });
        }

        this.getSelectionModel().selectRow(rowIndex);
        e.stopEvent();

        if(this.ctxIndex){
            this.ctxIndex = null;
        }

        this.ctxIndex = rowIndex;
        this.menu.showAt(e.getXY());

    },

    initComponent : function(config)
    {
        ui.cmp._PortletLocalMail.grid.superclass.initComponent.call(this);
        Ext.apply(this, config);

        this.on('rowcontextmenu', this.onContextClick, this);
        this.on('rowdblclick',    this.onRowDblClick,  this);
    }
});

ui.cmp._PortletLocalMail.reloadData = function() {
    ui.cmp._PortletLocalMail.store.reload({
        callback: function(r,o,s) {
          if( !s ) {
              Ext.getCmp('PortletLocalMail-grid-id').getView().mainBody.update('
' + _('Error when loading mails from this mailing list !') + '
');
              Ext.get('PortletLocalMail-grid-defaultMess-id').highlight();

          }
        }
    });
};

//------------------------------------------------------------------------------
// PortletLocalMail
ui.cmp.PortletLocalMail = Ext.extend(Ext.ux.Portlet,
{
    title      : '',
    iconCls    : 'iconMailing',
    id         : 'portletLocalMail',
    layout     : 'fit',
    store      : ui.cmp._PortletLocalMail.store,
    reloadData : ui.cmp._PortletLocalMail.reloadData,
    tools      : [{
        id      : 'refresh',
        qtip    : _('Refresh this grid'),
        handler : function() {
            ui.cmp._PortletLocalMail.reloadData();
        }
    }],
    listeners : {
        expand : function() {
            if( PhDOE.app.loaded ) {
                new ui.task.UpdateConfTask({
                    item  : 'portletLocalMailCollapsed',
                    value : false,
                    notify: false
                });
            }
        },
        collapse : function() {
            if( PhDOE.app.loaded ) {
                new ui.task.UpdateConfTask({
                    item  : 'portletLocalMailCollapsed',
                    value : true,
                    notify: false
                });
            }
        },
        afterrender : function(cmp) {
            if( PhDOE.user.conf.portletLocalMailCollapsed ) {
                cmp.collapse();
            } else {
                cmp.expand();
            }
        }
    },

    initComponent: function(config)
    {
        ui.cmp.PortletLocalMail.superclass.initComponent.call(this);
        Ext.apply(this, config);

        this.title = String.format(_('Mail from {0}'), 'doc-' + this.lang);
        this.add(new ui.cmp._PortletLocalMail.grid());
    }
});

// singleton
ui.cmp._PortletLocalMail.instance = null;
ui.cmp.PortletLocalMail.getInstance = function(config)
{
    if (!ui.cmp._PortletLocalMail.instance) {
        if (!config) {
            config = {};
        }
        ui.cmp._PortletLocalMail.instance = new ui.cmp.PortletLocalMail(config);
    }
    return ui.cmp._PortletLocalMail.instance;
};<commit_msg>Fix date format<commit_after>Ext.namespace('ui','ui.cmp','ui.cmp._PortletLocalMail');

//------------------------------------------------------------------------------
// PortletLocalMail internals

// Store : Mailing with Informations about phpdoc-LANG mailing
ui.cmp._PortletLocalMail.store = new Ext.data.Store({
    proxy : new Ext.data.HttpProxy({
        url : './do/getLastNews'
    }),
    reader : new Ext.data.JsonReader({
        root          : 'Items',
        totalProperty : 'nbItems',
        idProperty    : 'id',
        fields        : [
            {name : 'id'},
            {name : 'title'},
            {name : 'link'},
            {name : 'description'},
            {name : 'pubDate', type : 'date',dateFormat : 'Y/m/d H:i:s' }
        ]

    })
});
ui.cmp._PortletLocalMail.store.setDefaultSort('pubDate', 'desc');

// PortletLocalMail columns definition
ui.cmp._PortletLocalMail.columns = [
    new Ext.grid.RowNumberer(), {
        id        : 'GridMailingTitle',
        header    : _('Title'),
        sortable  : true,
        dataIndex : 'title'
    }, {
        header    : _('By'),
        width     : 100,
        sortable  : true,
        dataIndex : 'description'
    }, {
        header    : _('Date'),
        width     : 100,
        sortable  : true,
        dataIndex : 'pubDate',
        renderer  : Ext.util.Format.dateRenderer(_('Y-m-d, H:i'))
    }
];

//------------------------------------------------------------------------------
// _PortletLocalMail
ui.cmp._PortletLocalMail.grid = Ext.extend(Ext.grid.GridPanel,
{
    loadMask         : true,
    autoScroll       : true,
    height           : 250,
    autoExpandColumn : 'GridMailingTitle',
    id               : 'PortletLocalMail-grid-id',
    store            : ui.cmp._PortletLocalMail.store,
    columns          : ui.cmp._PortletLocalMail.columns,
    sm               : new Ext.grid.RowSelectionModel({ singleSelect: true }),

    view             : new Ext.grid.GridView({
                           forceFit:true,
                           enableRowBody:true,
                           ignoreAdd: true,
                           emptyText: '
' + _('You must manually load this data.
Use the refresh button !') + '
',
                           deferEmptyText: false
                       }),

    onRowDblClick : function(grid, rowIndex)
    {
        var MailId    = grid.store.getAt(rowIndex).data.pubDate,
            MailUrl   = grid.store.getAt(rowIndex).data.link,
            MailTitle = grid.store.getAt(rowIndex).data.title;

        if (!Ext.getCmp('main-panel').findById('mail-' + MailId)) {

            Ext.getCmp('main-panel').add({
                xtype      : 'panel',
                id         : 'mail-' + MailId,
                title      : Ext.util.Format.substr(MailTitle, 0, 20) + '...',
                tabTip     : MailTitle,
                iconCls    : 'iconMailing',
                closable   : true,
                layout     : 'fit',
                items: [ new Ext.ux.IFrameComponent({ id: 'frame-mail-' + MailId, url: MailUrl }) ]
            });
        }
        Ext.getCmp('main-panel').setActiveTab('mail-' + MailId);
    },

    onContextClick : function(grid, rowIndex, e)
    {
        if(!this.menu) {
            this.menu = new Ext.menu.Menu({
                id    : 'submenu-mail',
                items : [{
                    scope   : this,
                    text    : ''+_('Open in a new Tab')+'',
                    iconCls : 'iconOpenInTab',
                    handler : function()
                    {
                        this.fireEvent('rowdblclick', grid, this.ctxIndex, e);
                        this.menu.hide();
                    }
                }, '-', {
                    scope   : this,
                    text    : _('Refresh this grid'),
                    iconCls : 'iconRefresh',
                    handler : function()
                    {
                        this.ctxIndex = null;
                        ui.cmp._PortletLocalMail.reloadData();
                    }
                }]
            });
        }

        this.getSelectionModel().selectRow(rowIndex);
        e.stopEvent();

        if(this.ctxIndex){
            this.ctxIndex = null;
        }

        this.ctxIndex = rowIndex;
        this.menu.showAt(e.getXY());

    },

    initComponent : function(config)
    {
        ui.cmp._PortletLocalMail.grid.superclass.initComponent.call(this);
        Ext.apply(this, config);

        this.on('rowcontextmenu', this.onContextClick, this);
        this.on('rowdblclick',    this.onRowDblClick,  this);
    }
});

ui.cmp._PortletLocalMail.reloadData = function() {
    ui.cmp._PortletLocalMail.store.reload({
        callback: function(r,o,s) {
          if( !s ) {
              Ext.getCmp('PortletLocalMail-grid-id').getView().mainBody.update('
' + _('Error when loading mails from this mailing list !') + '
');
              Ext.get('PortletLocalMail-grid-defaultMess-id').highlight();

          }
        }
    });
};

//------------------------------------------------------------------------------
// PortletLocalMail
ui.cmp.PortletLocalMail = Ext.extend(Ext.ux.Portlet,
{
    title      : '',
    iconCls    : 'iconMailing',
    id         : 'portletLocalMail',
    layout     : 'fit',
    store      : ui.cmp._PortletLocalMail.store,
    reloadData : ui.cmp._PortletLocalMail.reloadData,
    tools      : [{
        id      : 'refresh',
        qtip    : _('Refresh this grid'),
        handler : function() {
            ui.cmp._PortletLocalMail.reloadData();
        }
    }],
    listeners : {
        expand : function() {
            if( PhDOE.app.loaded ) {
                new ui.task.UpdateConfTask({
                    item  : 'portletLocalMailCollapsed',
                    value : false,
                    notify: false
                });
            }
        },
        collapse : function() {
            if( PhDOE.app.loaded ) {
                new ui.task.UpdateConfTask({
                    item  : 'portletLocalMailCollapsed',
                    value : true,
                    notify: false
                });
            }
        },
        afterrender : function(cmp) {
            if( PhDOE.user.conf.portletLocalMailCollapsed ) {
                cmp.collapse();
            } else {
                cmp.expand();
            }
        }
    },

    initComponent: function(config)
    {
        ui.cmp.PortletLocalMail.superclass.initComponent.call(this);
        Ext.apply(this, config);

        this.title = String.format(_('Mail from {0}'), 'doc-' + this.lang);
        this.add(new ui.cmp._PortletLocalMail.grid());
    }
});

// singleton
ui.cmp._PortletLocalMail.instance = null;
ui.cmp.PortletLocalMail.getInstance = function(config)
{
    if (!ui.cmp._PortletLocalMail.instance) {
        if (!config) {
            config = {};
        }
        ui.cmp._PortletLocalMail.instance = new ui.cmp.PortletLocalMail(config);
    }
    return ui.cmp._PortletLocalMail.instance;
};<|endoftext|>


<commit_before>Package.describe({
  name: 'gcampax:accounts-box',
  summary: 'OAuth2 integration with Box cloud storage service',
  version: '1.0.1',
  git: 'https://github.com/gcampax/meteor-accounts-box'
});

Package.onUse(function(api) {
    api.versionsFrom('0.9.4');
    api.use('accounts-base', ['client', 'server']);
    // Export Accounts (etc) to packages using this one.
    api.imply('accounts-base', ['client', 'server']);
    api.use('accounts-oauth', ['client', 'server']);
    api.use('oauth2', ['client', 'server']);
    api.use('oauth', ['client', 'server']);
    api.use('http', ['server']);
    api.use(['underscore', 'service-configuration'], ['client', 'server']);
    api.use(['random', 'templating'], 'client');

    api.export('Box');

    api.addFiles(['box_configure.html', 'box_configure.js'],'client');
    api.addFiles('box_server.js', 'server');
    api.addFiles('box_client.js', 'client');
    api.addFiles('box.js', ['client', 'server']);
});

Package.onTest(function(api) {
  api.use('tinytest');
  api.use('gcampax:accounts-box');

  api.addFiles('box-tests.js');
});
<commit_msg>Bump version again<commit_after>Package.describe({
  name: 'gcampax:accounts-box',
  summary: 'OAuth2 integration with Box cloud storage service',
  version: '1.0.2',
  git: 'https://github.com/gcampax/meteor-accounts-box'
});

Package.onUse(function(api) {
    api.versionsFrom('0.9.4');
    api.use('accounts-base', ['client', 'server']);
    // Export Accounts (etc) to packages using this one.
    api.imply('accounts-base', ['client', 'server']);
    api.use('accounts-oauth', ['client', 'server']);
    api.use('oauth2', ['client', 'server']);
    api.use('oauth', ['client', 'server']);
    api.use('http', ['server']);
    api.use(['underscore', 'service-configuration'], ['client', 'server']);
    api.use(['random', 'templating'], 'client');

    api.export('Box');

    api.addFiles(['box_configure.html', 'box_configure.js'],'client');
    api.addFiles('box_server.js', 'server');
    api.addFiles('box_client.js', 'client');
    api.addFiles('box.js', ['client', 'server']);
});

Package.onTest(function(api) {
  api.use('tinytest');
  api.use('gcampax:accounts-box');

  api.addFiles('box-tests.js');
});
<|endoftext|>


<commit_before>var Backbone = require('backbone');
var _ = require('underscore');

// Model
// ---------------

// Model is an extension of `Backbone.Model` with the addition of basic features. To use it, call
// `Model.extend()` as you would with Backbone.Model.

var Model = Backbone.Model.extend({

  // Default is empty. Override this to specify a list of attributes that will automatically get
  // converted to/from Models on `parse` and `toJSON` calls. Example config for a Book class (given
  // an additional Author and Publisher model classes):
  //
  //     modelAttributes: { author: Author, publisher: Publisher }
  //
  modelAttributes: {},

  // Extends `Backbone.Model` 's `get` with support for nested attributes. Attempts a deep get when
  // passed in an `attr` string that contains the `.` delimeter. Example:
  //
  //     var attr = model.get('firstLevel.secondLevel');
  //
  // The deep `get` calls will work so long as the attributes at each level is either an instance
  // of a `Lumbar.Model` or `Backbone.Model`, or if it's a plain object map whose keys match to the
  // corresponding attributes. Returns `undefined` if an attribute is not found at any level.
  get: function(attr) {
    var fields = attr.split('.');
    var result = this;
    for (var i = 0; result && i < fields.length; i++) {
      if (result instanceof Backbone.Model) {
        result = Model.__super__.get.call(result, fields[i]);
      } else {
        result = result[fields[i]];
      }
    }
    return result;
  },

  // Extends `Backbone.Model` 's `set` with support for deep sets, but only on single
  // key/value set calls, not {} set calls. The following would attempt a nested set call:
  //
  //     model.set('attr1.attr2', value);
  //
  // But the following wouldn't and would result in value getting set on model as `attr1.attr2` :
  //
  //     model.set({ 'attr1.attr2': value });
  //
  // The deep `set` calls will work so long as the key attributes at each level is either an
  // instance of a `Lumbar.Model` or `Backbone.Model`, or if it's a plain object map whose keys
  // match the corresponding key attributes. Triggers a `lumbar:invalid:set` event and returns
  // false for invalid key calls.
  set: function(key, val, options) {

    // Proxy back to Backbone if it's not a single key/val
    if (!key || _.isObject(key)) {
      return Model.__super__.set.apply(this, arguments);
    }

    options || (options = {});

    var fields = key.split('.');
    var result = this;
    for (var i = 0; result && i < fields.length; i++) {
      var isLast = (i === fields.length - 1);
      if (result instanceof Backbone.Model) {
        if (isLast) {
          Model.__super__.set.call(result, fields[i], val, options);
        } else {
          result = result.get(fields[i]);
        }
      } else {
        if (isLast) {
          result[fields[i]] = val;
        } else {
          result = result[fields[i]];
        }
      }
    }

    // Trigger an error event if unable to evaluate nested key
    if (!result) {
      var error = 'Unable to do nested set for invalid key: ' + key;
      this.trigger('lumbar:invalid:set', this, error, _.extend(options, { setError: error }));
      return false;
    }

    return this;
  },

  // Overrides `Backbone.Model` 's default `parse` . Expands attributes as Model instances for
  // attributes configured in `modelAttributes` .
  parse: function(resp) {
    var parsed = _.clone(resp);
    _.each(this.modelAttributes, function(model, attr) {
      if (parsed[attr]) {
        parsed[attr] = new model(parsed[attr], { parse: true });
      }
    });
    return parsed;
  },

  // Extends `Backbone.Model` 's `toJSON` by also further calling toJSON on Model attributes as
  // specified in `modelAttributes`
  toJSON: function(options) {
    var json = Model.__super__.toJSON.apply(this, arguments);
    _.each(this.modelAttributes, function(Model, attrName) {
      var obj = this.get(attrName);
      if (obj && obj instanceof Model && _.isFunction(obj.toJSON)) {
        json[attrName] = obj.toJSON(options);
      }
    }, this);
    return json;
  }

});

module.exports = Model;
<commit_msg>Improve robustness of `Lumbar.Model`'s `parse`<commit_after>var Backbone = require('backbone');
var _ = require('underscore');

// Model
// ---------------

// Model is an extension of `Backbone.Model` with the addition of basic features. To use it, call
// `Model.extend()` as you would with Backbone.Model.

var Model = Backbone.Model.extend({

  // Default is empty. Override this to specify a list of attributes that will automatically get
  // converted to/from Models on `parse` and `toJSON` calls. Example config for a Book class (given
  // an additional Author and Publisher model classes):
  //
  //     modelAttributes: { author: Author, publisher: Publisher }
  //
  modelAttributes: {},

  // Extends `Backbone.Model` 's `get` with support for nested attributes. Attempts a deep get when
  // passed in an `attr` string that contains the `.` delimeter. Example:
  //
  //     var attr = model.get('firstLevel.secondLevel');
  //
  // The deep `get` calls will work so long as the attributes at each level is either an instance
  // of a `Lumbar.Model` or `Backbone.Model`, or if it's a plain object map whose keys match to the
  // corresponding attributes. Returns `undefined` if an attribute is not found at any level.
  get: function(attr) {
    var fields = attr.split('.');
    var result = this;
    for (var i = 0; result && i < fields.length; i++) {
      if (result instanceof Backbone.Model) {
        result = Model.__super__.get.call(result, fields[i]);
      } else {
        result = result[fields[i]];
      }
    }
    return result;
  },

  // Extends `Backbone.Model` 's `set` with support for deep sets, but only on single
  // key/value set calls, not {} set calls. The following would attempt a nested set call:
  //
  //     model.set('attr1.attr2', value);
  //
  // But the following wouldn't and would result in value getting set on model as `attr1.attr2` :
  //
  //     model.set({ 'attr1.attr2': value });
  //
  // The deep `set` calls will work so long as the key attributes at each level is either an
  // instance of a `Lumbar.Model` or `Backbone.Model`, or if it's a plain object map whose keys
  // match the corresponding key attributes. Triggers a `lumbar:invalid:set` event and returns
  // false for invalid key calls.
  set: function(key, val, options) {

    // Proxy back to Backbone if it's not a single key/val
    if (!key || _.isObject(key)) {
      return Model.__super__.set.apply(this, arguments);
    }

    options || (options = {});

    var fields = key.split('.');
    var result = this;
    for (var i = 0; result && i < fields.length; i++) {
      var isLast = (i === fields.length - 1);
      if (result instanceof Backbone.Model) {
        if (isLast) {
          Model.__super__.set.call(result, fields[i], val, options);
        } else {
          result = result.get(fields[i]);
        }
      } else {
        if (isLast) {
          result[fields[i]] = val;
        } else {
          result = result[fields[i]];
        }
      }
    }

    // Trigger an error event if unable to evaluate nested key
    if (!result) {
      var error = 'Unable to do nested set for invalid key: ' + key;
      this.trigger('lumbar:invalid:set', this, error, _.extend(options, { setError: error }));
      return false;
    }

    return this;
  },

  // Overrides `Backbone.Model` 's default `parse` . Expands attributes as Model instances for
  // attributes configured in `modelAttributes` .
  parse: function(resp) {
    var parsed = _.clone(resp);
    _.each(this.modelAttributes, function(Model, attrName) {
      var obj = parsed[attrName];
      if (obj && !(obj instanceof Model)) {
        parsed[attrName] = new Model(obj, { parse: true });
      }
    });
    return parsed;
  },

  // Extends `Backbone.Model` 's `toJSON` by also further calling toJSON on Model attributes as
  // specified in `modelAttributes`
  toJSON: function(options) {
    var json = Model.__super__.toJSON.apply(this, arguments);
    _.each(this.modelAttributes, function(Model, attrName) {
      var obj = this.get(attrName);
      if (obj && obj instanceof Model && _.isFunction(obj.toJSON)) {
        json[attrName] = obj.toJSON(options);
      }
    }, this);
    return json;
  }

});

module.exports = Model;
<|endoftext|>


<commit_before>Package.describe({
  name: "supaseca:guillotine",
  summary: "jQuery plugin to crop images within an area (fully responsive), allowing to drag (touch support), zoom and rotate.",
  version: "1.3.1",
  git: "https://github.com/projik/meteor-guillotine.git"
});

Package.onUse(function (api) {
  api.versionsFrom('0.9.0');
  api.use('jquery', 'client');
  api.imply('jquery', 'client');
  api.addFiles([
    'guillotine/js/jquery.guillotine.js',
    'guillotine/css/jquery.guillotine.css'
  ], 'client'
  );
});
<commit_msg>updated package info<commit_after>Package.describe({
  name: "supaseca:guillotine",
  summary: "jQuery plugin to crop images within an area (fully responsive), allowing to drag (touch support), zoom and rotate.",
  version: "1.3.1",
  git: "https://github.com/projik/meteor-guillotine.git"
});

Package.onUse(function(api) {
  api.versionsFrom('1.2.1');
  api.use('ecmascript');
  api.use('jquery', 'client');
  api.imply('jquery', 'client');
  api.addFiles([
    'guillotine/js/jquery.guillotine.js',
    'guillotine/css/jquery.guillotine.css'
  ], 'client'
  );
});

<|endoftext|>


<commit_before>'use strict';

var angular           = require('angular');
var uuid              = require('node-uuid');
var internals         = {};

module.exports = function ($q, ConvexRequest, ConvexCache, ConvexBatch, ConvexRelation, ConvexCollection) {

  internals.depth = function (string) {
    return (string.match(/\./g) || []).length;
  };

  internals.relation = function (base, relation) {
    var parent = base;
    for (var i = 0; i < relation.depth - 1; i++) {
      var child = relation.segments[i];
      parent = parent.$related(child);
    }
  };

  internals.relations = function (model, options) {
    if (options && options.expand) {
      options.expand
        .map(function (relation) {
          var segments = relation.split('.');
          return {
            accessor: relation,
            depth: segments.length + 1,
            segments: segments
          };
        })
        .sort(function ($1, $2) {
          var diff = $2.depth - $1.depth;
          if (diff === 0) return 0;
          if (diff < 0) return -1;
          if (diff > 0) return 1;
        })
        .forEach(angular.bind(null, internals.relation, model));
    }
    return model;
  };

  var ConvexModel = function (attributes, options) {
    angular.extend(this, attributes);
    internals.relations(this, options);
    if (!this.id) {
      this.$$saved = false;
      this.id = uuid.v4();
    }
    else {
      this.$$saved = true;
    }
    var cached = this.$$cache.get(this.id);
    if (cached) {
      return angular.extend(cached, attributes);
    }
    else {
      if (this.$initialize) this.$initialize();
      this.$$cache.put(this.id, this);
    }
  };

  ConvexModel.$new = function (proto, ctor) {
    var Parent = this;
    var Child = function () {
      return Parent.apply(this, arguments);
    };
    proto = proto || {};
    ctor = ctor || {};
    Child.prototype = Object.create(Parent.prototype);
    angular.extend(Child.prototype, proto);
    angular.extend(Child, Parent);
    angular.extend(Child, ctor);

    if (!proto.name) throw new Error('All models must have a name');
    Child.prototype.$name = proto.name;
    delete Child.prototype.name;
    Child.prototype.$$cache = new ConvexCache(proto.name);

    return Child;
  };

  internals.plural = function (model) {
    return model.$plural || model.$name + 's';
  };

  ConvexModel.prototype.$path = function (id) {
    var path = '/' + internals.plural(this);
    if (id) path += ('/' + id);
    return path;
  };

  ConvexModel.prototype.$reset = function () {
    for (var property in this) {
      if (this.hasOwnProperty(property)) delete this[property];
    }
    return this;
  };

  ConvexModel.prototype.toJSON = function () {
    var data = angular.copy(this, {});
    for (var relation in this.$$relations) {
      delete data[relation];
    }
    for (var key in data) {
      if (!this.hasOwnProperty(key)) delete data[key];
    }
    return data;
  };

  ConvexModel.prototype.$request = function (defaults, overrides) {
    defaults = defaults || {};
    overrides = overrides || {};
    defaults.params = defaults.params || {};
    if (overrides.expand) {
      defaults.params.expand = overrides.expand;
    }
    var config = angular.extend(defaults, overrides);
    var request = new ConvexRequest(config);
    if (config.batch) {
      config.batch.add(request);
    }
    else {
      request.send();
    }
    return request;
  };

  ConvexModel.prototype.$fetch = function (options) {
    var model = this;
    if (!this.$$saved) return $q.when(this);
    return this.$request({
      method: 'get',
      path: this.$path(this.id)
    }, options)
    .then(function (response) {
      return angular.extend(model, response);
    })
    .then(function (model) {
      return internals.relations(model, options);
    });
  };

  ConvexModel.prototype.$save = function (options) {
    var model = this;
    return this.$request({
      method: this.$$saved ? 'put' : 'post',
      path: this.$$saved ? this.$path(this.id) : this.$path(),
      data: this
    }, options)
    .then(function (response) {
      model.$$saved = true;
      return angular.extend(model, response);
    })
    .then(function (model) {
      return internals.relations(model, options);
    });
  };

  ConvexModel.prototype.$delete = function (options) {
    var model = this;
    return $q.when()
      .then(function () {
        if (model.$$saved) {
          return model.$request({
            method: 'delete',
            path: model.$path(model.id)
          }, options);
        }
      })
      .then(function () {
        model.$$cache.remove(model.id);
        model.$reset();
        model.$$saved = false;
        model.$deleted = true;
      });
  };

  ConvexModel.prototype.$batch = function (callback) {
    var batch = new ConvexBatch();
    callback.call(this, batch);
    return batch.process();
  };

  internals.query = function (Model, attributes, options) {
    return Model.prototype.$request({
      method: 'get',
      path: Model.prototype.$path(),
      params: attributes
    }, options);
  };

  internals.cast = function (Model, data) {
    return new ConvexCollection(Model).add(data);
  };

  ConvexModel.$where = function (attributes, options) {
    var Model = this;
    return internals.query(this, attributes, options)
      .then(function (data) {
        return internals.cast(Model, data);
      });
  };

  ConvexModel.$find = function (attributes, options) {
    var Model = this;
    return internals.query(this, attributes, options)
      .then(function (data) {
        return data.length ? data[0] : $q.reject('Not found');
      })
      .then(function (data) {
        return new Model(data, options);
      });
  };

  ConvexModel.$all = function (options) {
    return this.$where(null, options);
  };

  internals.relationStore = function (Model) {
    return Model.prototype.$$relations || (Model.prototype.$$relations = {});
  };

  ConvexModel.belongsTo = function (Target) {
    var relation = new ConvexRelation('belongsTo', Target);
    internals.relationStore(this)[relation.key] = relation;
    return this;
  };

  ConvexModel.hasMany = function (Target) {
    var relation = new ConvexRelation('hasMany', Target);
    internals.relationStore(this)[relation.key] = relation;
    return this;
  };

  ConvexModel.prototype.$related = function (name) {
    if (this[name] && (this[name] instanceof ConvexModel || this[name].isCollection)) {
      return this[name];
    } else {
      return (this[name] = this.$$relations[name].initialize(this));
    }
  };

  return ConvexModel;

};

module.exports.$inject = [
  '$q',
  'ConvexRequest',
  'ConvexCache',
  'ConvexBatch',
  'ConvexRelation',
  'ConvexCollection'
];
<commit_msg>Cast data using ConvexCollection<commit_after>'use strict';

var angular           = require('angular');
var uuid              = require('node-uuid');
var internals         = {};

module.exports = function ($q, ConvexRequest, ConvexCache, ConvexBatch, ConvexRelation, ConvexCollection) {

  internals.depth = function (string) {
    return (string.match(/\./g) || []).length;
  };

  internals.relation = function (base, relation) {
    var parent = base;
    for (var i = 0; i < relation.depth - 1; i++) {
      var child = relation.segments[i];
      parent = parent.$related(child);
    }
  };

  internals.relations = function (model, options) {
    if (options && options.expand) {
      options.expand
        .map(function (relation) {
          var segments = relation.split('.');
          return {
            accessor: relation,
            depth: segments.length + 1,
            segments: segments
          };
        })
        .sort(function ($1, $2) {
          var diff = $2.depth - $1.depth;
          if (diff === 0) return 0;
          if (diff < 0) return -1;
          if (diff > 0) return 1;
        })
        .forEach(angular.bind(null, internals.relation, model));
    }
    return model;
  };

  var ConvexModel = function (attributes, options) {
    angular.extend(this, attributes);
    internals.relations(this, options);
    if (!this.id) {
      this.$$saved = false;
      this.id = uuid.v4();
    }
    else {
      this.$$saved = true;
    }
    var cached = this.$$cache.get(this.id);
    if (cached) {
      return angular.extend(cached, attributes);
    }
    else {
      if (this.$initialize) this.$initialize();
      this.$$cache.put(this.id, this);
    }
  };

  ConvexModel.$new = function (proto, ctor) {
    var Parent = this;
    var Child = function () {
      return Parent.apply(this, arguments);
    };
    proto = proto || {};
    ctor = ctor || {};
    Child.prototype = Object.create(Parent.prototype);
    angular.extend(Child.prototype, proto);
    angular.extend(Child, Parent);
    angular.extend(Child, ctor);

    if (!proto.name) throw new Error('All models must have a name');
    Child.prototype.$name = proto.name;
    delete Child.prototype.name;
    Child.prototype.$$cache = new ConvexCache(proto.name);

    return Child;
  };

  internals.plural = function (model) {
    return model.$plural || model.$name + 's';
  };

  ConvexModel.prototype.$path = function (id) {
    var path = '/' + internals.plural(this);
    if (id) path += ('/' + id);
    return path;
  };

  ConvexModel.prototype.$reset = function () {
    for (var property in this) {
      if (this.hasOwnProperty(property)) delete this[property];
    }
    return this;
  };

  ConvexModel.prototype.toJSON = function () {
    var data = angular.copy(this, {});
    for (var relation in this.$$relations) {
      delete data[relation];
    }
    for (var key in data) {
      if (!this.hasOwnProperty(key)) delete data[key];
    }
    return data;
  };

  ConvexModel.prototype.$request = function (defaults, overrides) {
    defaults = defaults || {};
    overrides = overrides || {};
    defaults.params = defaults.params || {};
    if (overrides.expand) {
      defaults.params.expand = overrides.expand;
    }
    var config = angular.extend(defaults, overrides);
    var request = new ConvexRequest(config);
    if (config.batch) {
      config.batch.add(request);
    }
    else {
      request.send();
    }
    return request;
  };

  ConvexModel.prototype.$fetch = function (options) {
    var model = this;
    if (!this.$$saved) return $q.when(this);
    return this.$request({
      method: 'get',
      path: this.$path(this.id)
    }, options)
    .then(function (response) {
      return angular.extend(model, response);
    })
    .then(function (model) {
      return internals.relations(model, options);
    });
  };

  ConvexModel.prototype.$save = function (options) {
    var model = this;
    return this.$request({
      method: this.$$saved ? 'put' : 'post',
      path: this.$$saved ? this.$path(this.id) : this.$path(),
      data: this
    }, options)
    .then(function (response) {
      model.$$saved = true;
      return angular.extend(model, response);
    })
    .then(function (model) {
      return internals.relations(model, options);
    });
  };

  ConvexModel.prototype.$delete = function (options) {
    var model = this;
    return $q.when()
      .then(function () {
        if (model.$$saved) {
          return model.$request({
            method: 'delete',
            path: model.$path(model.id)
          }, options);
        }
      })
      .then(function () {
        model.$$cache.remove(model.id);
        model.$reset();
        model.$$saved = false;
        model.$deleted = true;
      });
  };

  ConvexModel.prototype.$batch = function (callback) {
    var batch = new ConvexBatch();
    callback.call(this, batch);
    return batch.process();
  };

  internals.query = function (Model, attributes, options) {
    return Model.prototype.$request({
      method: 'get',
      path: Model.prototype.$path(),
      params: attributes
    }, options);
  };

  internals.cast = function (Model, data) {
    var collection = new ConvexCollection(Model)
    collection.push.apply(collection, data);
    return collection.asArray();
  };

  ConvexModel.$where = function (attributes, options) {
    var Model = this;
    return internals.query(this, attributes, options)
      .then(function (data) {
        return internals.cast(Model, data);
      });
  };

  ConvexModel.$find = function (attributes, options) {
    var Model = this;
    return internals.query(this, attributes, options)
      .then(function (data) {
        return data.length ? data[0] : $q.reject('Not found');
      })
      .then(function (data) {
        return new Model(data, options);
      });
  };

  ConvexModel.$all = function (options) {
    return this.$where(null, options);
  };

  internals.relationStore = function (Model) {
    return Model.prototype.$$relations || (Model.prototype.$$relations = {});
  };

  ConvexModel.belongsTo = function (Target) {
    var relation = new ConvexRelation('belongsTo', Target);
    internals.relationStore(this)[relation.key] = relation;
    return this;
  };

  ConvexModel.hasMany = function (Target) {
    var relation = new ConvexRelation('hasMany', Target);
    internals.relationStore(this)[relation.key] = relation;
    return this;
  };

  ConvexModel.prototype.$related = function (name) {
    if (this[name] && (this[name] instanceof ConvexModel || this[name].isCollection)) {
      return this[name];
    } else {
      return (this[name] = this.$$relations[name].initialize(this));
    }
  };

  return ConvexModel;

};

module.exports.$inject = [
  '$q',
  'ConvexRequest',
  'ConvexCache',
  'ConvexBatch',
  'ConvexRelation',
  'ConvexCollection'
];
<|endoftext|>


<commit_before>// Package metadata for Meteor.js web platform (https://www.meteor.com/)
// This file is defined within the Meteor documentation at
//
//   http://docs.meteor.com/#/full/packagejs
//
// and it is needed to define a Meteor package
'use strict';

Package.describe({
  name: 'useraccounts:iron-routing',
  summary: 'UserAccounts package providing routes configuration capability via iron:router.',
  version: '1.11.1',
  git: 'https://github.com/meteor-useraccounts/iron-routing.git'
});

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

  api.use([
    'check',
    'iron:router',
    'underscore',
    'useraccounts:core',
  ], ['client', 'server']);

  api.imply([
    'useraccounts:core@1.11.1',
    'iron:router@1.0.7',
  ], ['client', 'server']);

  api.addFiles([
    'lib/core.js',
    'lib/server.js',
  ], ['server']);

  api.addFiles([
    'lib/core.js',
    'lib/client.js',
    'lib/templates_helpers/at_input.js',
  ], ['client']);
});
<commit_msg>udpated iron:router dependency to v1.0.9<commit_after>// Package metadata for Meteor.js web platform (https://www.meteor.com/)
// This file is defined within the Meteor documentation at
//
//   http://docs.meteor.com/#/full/packagejs
//
// and it is needed to define a Meteor package
'use strict';

Package.describe({
  name: 'useraccounts:iron-routing',
  summary: 'UserAccounts package providing routes configuration capability via iron:router.',
  version: '1.11.1',
  git: 'https://github.com/meteor-useraccounts/iron-routing.git'
});

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

  api.use([
    'check',
    'iron:router',
    'underscore',
    'useraccounts:core',
  ], ['client', 'server']);

  api.imply([
    'useraccounts:core@1.11.1',
    'iron:router@1.0.9',
  ], ['client', 'server']);

  api.addFiles([
    'lib/core.js',
    'lib/server.js',
  ], ['server']);

  api.addFiles([
    'lib/core.js',
    'lib/client.js',
    'lib/templates_helpers/at_input.js',
  ], ['client']);
});
<|endoftext|>


<commit_before>Package.describe({
    summary: "Accounts Templates unstyled.",
    version: "1.7.1",
    name: "useraccounts:unstyled",
    git: "https://github.com/meteor-useraccounts/unstyled.git",
});

Package.on_use(function(api, where) {
    api.versionsFrom("METEOR@1.0");

    api.use([
        "less",
        "templating",
    ], "client");

    api.use([
        "useraccounts:core",
    ], ["client", "server"]);

    api.imply([
        "useraccounts:core@1.7.1",
    ], ["client", "server"]);

    api.add_files([
        "lib/at_error.html",
        "lib/at_error.js",
        "lib/at_form.html",
        "lib/at_form.js",
        "lib/at_input.html",
        "lib/at_input.js",
        "lib/at_nav_button.html",
        "lib/at_nav_button.js",
        "lib/at_oauth.html",
        "lib/at_oauth.js",
        "lib/at_pwd_form.html",
        "lib/at_pwd_form.js",
        "lib/at_pwd_form_btn.html",
        "lib/at_pwd_form_btn.js",
        "lib/at_pwd_link.html",
        "lib/at_pwd_link.js",
        "lib/at_reCaptcha.html",
        "lib/at_reCaptcha.js",
        "lib/at_result.html",
        "lib/at_result.js",
        "lib/at_sep.html",
        "lib/at_sep.js",
        "lib/at_signin_link.html",
        "lib/at_signin_link.js",
        "lib/at_signup_link.html",
        "lib/at_signup_link.js",
        "lib/at_social.html",
        "lib/at_social.js",
        "lib/at_terms_link.html",
        "lib/at_terms_link.js",
        "lib/at_title.html",
        "lib/at_title.js",
        "lib/full_page_at_form.html",
        "lib/at_unstyled.css"
    ], ["client"]);
});

Package.on_test(function(api) {
    api.use([
        "useraccounts:unstyled",
        "useraccounts:core@1.7.1",
    ]);

    api.use([
        "accounts-password",
        "tinytest",
        "test-helpers"
    ], ["client", "server"]);

    api.add_files([
        "tests/tests.js"
    ], ["client", "server"]);
});
<commit_msg>minor release - Bump to version 1.8.0<commit_after>Package.describe({
    summary: "Accounts Templates unstyled.",
    version: "1.8.0",
    name: "useraccounts:unstyled",
    git: "https://github.com/meteor-useraccounts/unstyled.git",
});

Package.on_use(function(api, where) {
    api.versionsFrom("METEOR@1.0");

    api.use([
        "less",
        "templating",
    ], "client");

    api.use([
        "useraccounts:core",
    ], ["client", "server"]);

    api.imply([
        "useraccounts:core@1.8.0",
    ], ["client", "server"]);

    api.add_files([
        "lib/at_error.html",
        "lib/at_error.js",
        "lib/at_form.html",
        "lib/at_form.js",
        "lib/at_input.html",
        "lib/at_input.js",
        "lib/at_nav_button.html",
        "lib/at_nav_button.js",
        "lib/at_oauth.html",
        "lib/at_oauth.js",
        "lib/at_pwd_form.html",
        "lib/at_pwd_form.js",
        "lib/at_pwd_form_btn.html",
        "lib/at_pwd_form_btn.js",
        "lib/at_pwd_link.html",
        "lib/at_pwd_link.js",
        "lib/at_reCaptcha.html",
        "lib/at_reCaptcha.js",
        "lib/at_result.html",
        "lib/at_result.js",
        "lib/at_sep.html",
        "lib/at_sep.js",
        "lib/at_signin_link.html",
        "lib/at_signin_link.js",
        "lib/at_signup_link.html",
        "lib/at_signup_link.js",
        "lib/at_social.html",
        "lib/at_social.js",
        "lib/at_terms_link.html",
        "lib/at_terms_link.js",
        "lib/at_title.html",
        "lib/at_title.js",
        "lib/full_page_at_form.html",
        "lib/at_unstyled.css"
    ], ["client"]);
});

Package.on_test(function(api) {
    api.use([
        "useraccounts:unstyled",
        "useraccounts:core@1.8.0",
    ]);

    api.use([
        "accounts-password",
        "tinytest",
        "test-helpers"
    ], ["client", "server"]);

    api.add_files([
        "tests/tests.js"
    ], ["client", "server"]);
});
<|endoftext|>


<commit_before>Package.describe({
  name: "ground:servertime",
  version: "0.0.3",
  summary: "Adds server time on the client",
  git: "https://github.com/GroundMeteor/servertime.git"
});

Package.onUse(function (api) {

  if (api.versionsFrom) {
    api.versionsFrom('1.0');

    api.use('ground:store@0.1.0');

    // Make sure any storage adapters are loaded first
    api.use([
      'ground:localstorage@0.1.6'
    ], 'client', { weak: true });
  } else {

    api.use('ground-store');

    // Make sure any storage adapters are loaded first
    api.use([
      'ground-localstorage'
    ], 'client', { weak: true });

  }

  api.export('ServerTime');

  api.addFiles('client.js', 'client');
  api.addFiles('server.js', 'server');
});

Package.onTest(function (api) {
  if (api.versionsFrom) {
    api.use('ground:servertime', ['client', 'server']);
  } else {
    api.use('ground-servertime', ['client', 'server']);
  }
  api.use('test-helpers', 'client');
  api.use(['tinytest', 'underscore', 'ejson']);

  api.addFiles('client.tests.js', 'client');
  api.addFiles('server.tests.js', 'server');

});
<commit_msg>bump versions<commit_after>Package.describe({
  name: "ground:servertime",
  version: "0.0.3",
  summary: "Adds server time on the client",
  git: "https://github.com/GroundMeteor/servertime.git"
});

Package.onUse(function (api) {

  if (api.versionsFrom) {
    api.versionsFrom('1.0');

    api.use('ground:store@0.1.1');

    // Make sure any storage adapters are loaded first
    api.use([
      'ground:localstorage@0.1.6'
    ], 'client', { weak: true });
  } else {

    api.use('ground-store');

    // Make sure any storage adapters are loaded first
    api.use([
      'ground-localstorage'
    ], 'client', { weak: true });

  }

  api.export('ServerTime');

  api.addFiles('client.js', 'client');
  api.addFiles('server.js', 'server');
});

Package.onTest(function (api) {
  if (api.versionsFrom) {
    api.use('ground:servertime', ['client', 'server']);
  } else {
    api.use('ground-servertime', ['client', 'server']);
  }
  api.use('test-helpers', 'client');
  api.use(['tinytest', 'underscore', 'ejson']);

  api.addFiles('client.tests.js', 'client');
  api.addFiles('server.tests.js', 'server');

});
<|endoftext|>


<commit_before>Package.describe({
	name: 'useful:wizard',
	version: '0.0.4',
	summary: 'Wizard Template Mixin',
	git: 'https://github.com/usefulio/wizard',
	documentation: 'README.md'
});

Package.onUse(function(api) {

	api.versionsFrom('1.1');

	// ====== BUILT-IN PACKAGES =======

	api.use([
		'jquery'
		, 'templating'
		, 'underscore'
		, 'reactive-dict'
		, 'reactive-var'
	], 'client');

	// ====== 3RD PARTY PACKAGES =======

	// ====== BOTH =======

	// ====== SERVER =======

	// ====== CLIENT =======

	api.addFiles('client/views/wizard/wizard.js', 'client');

	// ====== EXPORTS =======

	api.export('Wizard');
});

Package.onTest(function(api) {
	api.use('tinytest');
});
<commit_msg>adding MIT license<commit_after>Package.describe({
	name: 'useful:wizard',
	version: '0.0.5',
	summary: 'Wizard Template Mixin',
	git: 'https://github.com/usefulio/wizard',
	documentation: 'README.md'
});

Package.onUse(function(api) {

	api.versionsFrom('1.1');

	// ====== BUILT-IN PACKAGES =======

	api.use([
		'jquery'
		, 'templating'
		, 'underscore'
		, 'reactive-dict'
		, 'reactive-var'
	], 'client');

	// ====== 3RD PARTY PACKAGES =======

	// ====== BOTH =======

	// ====== SERVER =======

	// ====== CLIENT =======

	api.addFiles('client/views/wizard/wizard.js', 'client');

	// ====== EXPORTS =======

	api.export('Wizard');
});

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


<commit_before>var fs = Npm.require('fs');
var path = Npm.require('path');

Package.describe({
  "summary": "Render you app even before the DDP connection comes live. - magic?",
  "version": "2.3.1",
  "git": "https://github.com/meteorhacks/fast-render",
  "name": "meteorhacks:fast-render"
});

Npm.depends({
  "connect": "2.13.0"
});

Package.onUse(function(api) {
  configure(api);
  api.export('FastRender', ['client', 'server']);
  api.export('__init_fast_render', ['client']);
});

Package.onTest(function(api) {
  configure(api);
  api.use('tinytest', ['client', 'server']);
  api.use('http', 'server');

  api.addFiles([
    'tests/utils.js'
  ], ['client', 'server']);

  api.addFiles([
    'tests/client/fast_render.js',
    'tests/client/ddp_update.js'
  ], 'client');

  api.addFiles([
    'tests/server/context.js',
    'tests/server/integration.js'
  ], 'server');
});

function configure (api) {
  api.versionsFrom('METEOR@0.9.3');
  api.use('meteorhacks:inject-data@1.2.2', ['client', 'server']);
  api.use('iron:router@0.9.0 || 1.0.0', ['client', 'server'], {weak: true});
  api.use('chuangbo:cookie@1.1.0', 'client');
  api.use('meteorhacks:picker@1.0.1', 'server');

  api.use(['minimongo', 'livedata', 'ejson', 'underscore', 'webapp', 'routepolicy', 'accounts-base'], ['server']);
  api.use(['minimongo', 'underscore', 'deps', 'ejson', 'accounts-base'], ['client']);

  api.addFiles([
    'lib/utils.js'
  ], ['client', 'server']);

  api.addFiles([
    'lib/server/namespace.js',
    'lib/server/utils.js',
    'lib/server/routes.js',
    'lib/server/publish_context.js',
    'lib/server/context.js',
    'lib/server/iron_router_support.js',
  ], 'server');

  api.addFiles([
    'lib/client/fast_render.js',
    'lib/client/debugger.js',
    'lib/client/ddp_update.js',
    'lib/client/auth.js',
    'lib/client/boot.js'
  ], 'client');

}
<commit_msg>Update inject data to 1.2.3<commit_after>var fs = Npm.require('fs');
var path = Npm.require('path');

Package.describe({
  "summary": "Render you app even before the DDP connection comes live. - magic?",
  "version": "2.3.1",
  "git": "https://github.com/meteorhacks/fast-render",
  "name": "meteorhacks:fast-render"
});

Npm.depends({
  "connect": "2.13.0"
});

Package.onUse(function(api) {
  configure(api);
  api.export('FastRender', ['client', 'server']);
  api.export('__init_fast_render', ['client']);
});

Package.onTest(function(api) {
  configure(api);
  api.use('tinytest', ['client', 'server']);
  api.use('http', 'server');

  api.addFiles([
    'tests/utils.js'
  ], ['client', 'server']);

  api.addFiles([
    'tests/client/fast_render.js',
    'tests/client/ddp_update.js'
  ], 'client');

  api.addFiles([
    'tests/server/context.js',
    'tests/server/integration.js'
  ], 'server');
});

function configure (api) {
  api.versionsFrom('METEOR@0.9.3');
  api.use('meteorhacks:inject-data@1.2.3', ['client', 'server']);
  api.use('iron:router@0.9.0 || 1.0.0', ['client', 'server'], {weak: true});
  api.use('chuangbo:cookie@1.1.0', 'client');
  api.use('meteorhacks:picker@1.0.1', 'server');

  api.use(['minimongo', 'livedata', 'ejson', 'underscore', 'webapp', 'routepolicy', 'accounts-base'], ['server']);
  api.use(['minimongo', 'underscore', 'deps', 'ejson', 'accounts-base'], ['client']);

  api.addFiles([
    'lib/utils.js'
  ], ['client', 'server']);

  api.addFiles([
    'lib/server/namespace.js',
    'lib/server/utils.js',
    'lib/server/routes.js',
    'lib/server/publish_context.js',
    'lib/server/context.js',
    'lib/server/iron_router_support.js',
  ], 'server');

  api.addFiles([
    'lib/client/fast_render.js',
    'lib/client/debugger.js',
    'lib/client/ddp_update.js',
    'lib/client/auth.js',
    'lib/client/boot.js'
  ], 'client');

}
<|endoftext|>


<commit_before>Package.describe({
  name: "uzumaxy:jstree",
  summary: "jQuery tree plugin for MeteorJS.",
  version: "3.0.9",
  git: "https://github.com/uzumaxy/meteor-jstree"
});

Package.onUse(function(api) {

  api.use([
    'jquery'
  ], 'client');

  api.addFiles([
    'uzumaxy:jstree/js/jstree.js',
    'uzumaxy:jstree/css/style.css'
  ], 'client');

  api.addFiles([
    'uzumaxy:jstree/img/32px.png',
    'uzumaxy:jstree/img/40px.png',
    'uzumaxy:jstree/img/throbber.gif'
  ], 'client', {isAsset: true});

});
<commit_msg>Specify a version constraint for package jquery.<commit_after>Package.describe({
  name: "uzumaxy:jstree",
  summary: "jQuery tree plugin for MeteorJS.",
  version: "3.0.9",
  git: "https://github.com/uzumaxy/meteor-jstree"
});

Package.onUse(function(api) {

  api.use([
    'jquery@1.11.3'
  ], 'client');

  api.addFiles([
    'uzumaxy:jstree/js/jstree.js',
    'uzumaxy:jstree/css/style.css'
  ], 'client');

  api.addFiles([
    'uzumaxy:jstree/img/32px.png',
    'uzumaxy:jstree/img/40px.png',
    'uzumaxy:jstree/img/throbber.gif'
  ], 'client', {isAsset: true});

});
<|endoftext|>


<commit_before>/**
 * Created by ivar on 21.11.15.
 */

define([
    'config/stateConfig',
    'config/global',
    'angular-ui-router',
    'angular-messages',
    'angular-sanitize',
    'ui-bootstrap',
    'angular-storage',
    'angular-animate',
    'angular-scroll',
    'angular-scroll-glue',
    'angular-ui-select',
    'angular-vertilize'
], function (stateConfig, globalConf/*etTranslations, $ocLazyLoad*/) {

    var app = angular.module('myApp', [
        'ui.router',
        'ui.bootstrap',
        'ui.select',
        'ngCookies',
        'ngResource',
        'ngStorage',
        'ngAnimate',
        'ngSanitize',
        'ngMessages',
        'duScroll',
        'angular.vertilize',
        'luegg.directives',
        'angularSpinners'
    ]);

    app.constant('config', globalConf);

    app.config(function($animateProvider) {
        $animateProvider.classNameFilter(/angular-animate/);
    });

    app.config(function(uiSelectConfig) {
        uiSelectConfig.theme = 'bootstrap';
    });

    app.config(function ($provide, $httpProvider) {

  	  // Intercept http calls.
  	  $provide.factory('MyHttpInterceptor', function ($q) {
  	    return {
  	      // On request success
  	      request: function (config) {
  	        // console.log(config); // Contains the data about the request before it is sent.
  	        // Return the config or wrap it in a promise if blank.
  	        return config || $q.when(config);
  	      },

  	      // On request failure
  	      requestError: function (rejection) {
  	        // console.log(rejection); // Contains the data about the error on the request.
  	        console.log('requestError');
  	        // Return the promise rejection.
  	        return $q.reject(rejection);
  	      },

  	      // On response success
  	      response: function (response) {
  	        // console.log(response); // Contains the data from the response.
  	        // Return the response or promise.
  	        return response || $q.when(response);
  	      },

  	      // On response failure
  	      responseError: function (rejection) {
  	        // console.log(rejection); // Contains the data about the error.
  	    	 console.log('wnwbApi responseError');

  	    	  if (rejection.status == 500){
  	    		 alert('Sorry, something went wrong.'
  	    				 + "\n" + rejection.status + ' ' + rejection.statusText
  	    				 + "\n" + rejection.config.url);
  	    	  }
  	    	  else if (rejection.status == 404){

  	    		 alert('Sorry, something went wrong.'
  	    				 + "\n" + rejection.status + ' ' + rejection.statusText
  	    				 + "\n" + rejection.config.url);
  	    	  }

  	        // Return the promise rejection.
  	        return $q.reject(rejection);
  	      }
  	    };
  	  });
  	  // Intercept http calls.

  	  // Add the interceptor to the $httpProvider.
  	  $httpProvider.interceptors.push('MyHttpInterceptor');

  	});
    var defaultResponseTransformer = function (data, headersGetter) {
        return JSON.parse(data).results;
    };

    app.factory('wnwbApi', ['config', '$resource', function(config, $resource) {
        return {
            Version: $resource(config.API_URL+'version/', {}, {}, {stripTrailingSlashes: false}),
            sensereltype: $resource(config.API_URL+'sensereltype/:id/', {}, {}, {stripTrailingSlashes: false}),
            Authorization: $resource(config.API_AUTH_URL, {}, {
                auth: {
                    method: 'POST',
                    params: {

                    }
                }
            }, {stripTrailingSlashes: false}),
            Lexicon: $resource(config.API_URL+'lexicon/:id/', {}, {
                get: {
                    method: 'GET',
                    isArray: false
                },
                query: {
                    method: 'GET',
                    transformResponse: [defaultResponseTransformer],
                    isArray: true
                }
            }, {stripTrailingSlashes: false}),
            Sense: $resource(config.API_URL+'sense/:id/', {}, {
                update: {
                    method: 'PUT'
                },
                query: {
                    method: 'GET',
                    transformResponse: [defaultResponseTransformer],
                    isArray: true
                },
                remove: {
                	method: 'DELETE'
                }
            }, {stripTrailingSlashes: false}),
            SynSet: $resource(config.API_URL+'synset/:id/', {}, {
                update: {
                    method: 'PUT'
                },
                query: {
                    method: 'GET',
                    transformResponse: [defaultResponseTransformer],
                    isArray: true
                },
                remove: {
                	method: 'DELETE'
                }
            }, {stripTrailingSlashes: false}),
            HyperonymRelTree: $resource(config.API_URL+'hypers/', {}, {
                get: {
                    method: 'GET',
                    isArray: true
                }
            }, {stripTrailingSlashes: false}),
            HyponymRelTree: $resource(config.API_URL+'hypos/', {}, {
                get: {
                    method: 'GET',
                    isArray: true
                }
            }, {stripTrailingSlashes: false}),
            SiblingRelTree: $resource(config.API_URL+'sibs/', {}, {
                get: {
                    method: 'GET',
                    isArray: true
                }
            }, {stripTrailingSlashes: false}),
            OtherRelTree: $resource(config.API_URL+'rels/', {}, {
                get: {
                    method: 'GET',
                    isArray: true
                }
            }, {stripTrailingSlashes: false}),
            Domain: $resource(config.API_URL+'domain/:id/', {}, {
                update: {
                    method: 'PUT'
                },
                query: {
                    method: 'GET',
                    transformResponse: [defaultResponseTransformer],
                    isArray: true
                }/*,
                delete: { method: 'DELETE', params: { id: 0 } }*/
            }, {stripTrailingSlashes: false}),
            SenseRel: $resource(config.API_URL+'senserel/:id/', {}, {}, {stripTrailingSlashes: false}),
            SynSetRel: $resource(config.API_URL+'synsetrel/:id/', {}, {}, {stripTrailingSlashes: false}),
            SenseRelType: $resource(config.API_URL+'sensereltype/:id/', {}, {
                update: {
                    method: 'PUT'
                },
                query: {
                    method: 'GET',
                    transformResponse: [defaultResponseTransformer],
                    isArray: true
                }
            }, {stripTrailingSlashes: false}),
            SenseStyle: $resource(config.API_URL+'refcode/:id/', {}, {
                update: {
                    method: 'PUT'
                },
                query: {
                    method: 'GET',
                    transformResponse: [defaultResponseTransformer],
                    isArray: true
                }
            }, {stripTrailingSlashes: false}),
            SynSetRelType: $resource(config.API_URL+'synsetreltype/:id/', {}, {
                update: {
                    method: 'PUT'
                },
                query: {
                    method: 'GET',
                    transformResponse: [defaultResponseTransformer],
                    isArray: true
                }
            }, {stripTrailingSlashes: false}),
            ExtRelType: $resource(config.API_URL+'extreltype/:id/', {}, {
                update: {
                    method: 'PUT'
                },
                query: {
                    method: 'GET',
                    transformResponse: [defaultResponseTransformer],
                    isArray: true
                }
            }, {stripTrailingSlashes: false}),
            ExtSystem: $resource(config.API_URL+'extsystem/:id/', {}, {
                update: {
                    method: 'PUT'
                },
                query: {
                    method: 'GET',
                    transformResponse: [defaultResponseTransformer],
                    isArray: true
                }
            }, {stripTrailingSlashes: false}),
            LexicalEntry: $resource(config.API_URL+'lexentry/', {}, {
                query: {
                    method: 'GET',
                    transformResponse: [defaultResponseTransformer],
                    isArray: true
                }
            }, {stripTrailingSlashes: false}),
            Statistics: $resource(config.API_URL+'stats/', {}, {
                query: {
                    method: 'GET',
                    isArray: true
                }
            }, {stripTrailingSlashes: false}),
            Principal: $resource(config.API_URL+'users/?principal', {}, {
                query: {
                    method: 'GET',
                    transformResponse: [defaultResponseTransformer],
                    isArray: true
                }
            }, {stripTrailingSlashes: false})
        };
    }]);

    return app;
});<commit_msg>displays "Please login first." popup on unauthorized access error.<commit_after>/**
 * Created by ivar on 21.11.15.
 */

define([
    'config/stateConfig',
    'config/global',
    'angular-ui-router',
    'angular-messages',
    'angular-sanitize',
    'ui-bootstrap',
    'angular-storage',
    'angular-animate',
    'angular-scroll',
    'angular-scroll-glue',
    'angular-ui-select',
    'angular-vertilize'
], function (stateConfig, globalConf/*etTranslations, $ocLazyLoad*/) {

    var app = angular.module('myApp', [
        'ui.router',
        'ui.bootstrap',
        'ui.select',
        'ngCookies',
        'ngResource',
        'ngStorage',
        'ngAnimate',
        'ngSanitize',
        'ngMessages',
        'duScroll',
        'angular.vertilize',
        'luegg.directives',
        'angularSpinners'
    ]);

    app.constant('config', globalConf);

    app.config(function($animateProvider) {
        $animateProvider.classNameFilter(/angular-animate/);
    });

    app.config(function(uiSelectConfig) {
        uiSelectConfig.theme = 'bootstrap';
    });

    app.config(function ($provide, $httpProvider) {

  	  // Intercept http calls.
  	  $provide.factory('MyHttpInterceptor', function ($q) {
  	    return {
  	      // On request success
  	      request: function (config) {
  	        // console.log(config); // Contains the data about the request before it is sent.
  	        // Return the config or wrap it in a promise if blank.
  	        return config || $q.when(config);
  	      },

  	      // On request failure
  	      requestError: function (rejection) {
  	        // console.log(rejection); // Contains the data about the error on the request.
  	        console.log('requestError');
  	        // Return the promise rejection.
  	        return $q.reject(rejection);
  	      },

  	      // On response success
  	      response: function (response) {
  	        // console.log(response); // Contains the data from the response.
  	        // Return the response or promise.
  	        return response || $q.when(response);
  	      },

  	      // On response failure
  	      responseError: function (rejection) {
  	        // console.log(rejection); // Contains the data about the error.
  	    	 console.log('wnwbApi responseError');

  	    	  if (rejection.status == 500){
  	    		 alert('Sorry, something went wrong.'
  	    				 + "\n" + rejection.status + ' ' + rejection.statusText
  	    				 + "\n" + rejection.config.url);
  	    	  }
  	    	 else if (rejection.status == 401){

  	    		 alert('Please login first.'
  	    				 + "\n" + rejection.status + ' ' + rejection.statusText
  	    				 + "\n" + rejection.config.url);
  	    	  }
  	    	  else if (rejection.status == 404){

  	    		 alert('Sorry, something went wrong.'
  	    				 + "\n" + rejection.status + ' ' + rejection.statusText
  	    				 + "\n" + rejection.config.url);
  	    	  }

  	        // Return the promise rejection.
  	        return $q.reject(rejection);
  	      }
  	    };
  	  });
  	  // Intercept http calls.

  	  // Add the interceptor to the $httpProvider.
  	  $httpProvider.interceptors.push('MyHttpInterceptor');

  	});
    var defaultResponseTransformer = function (data, headersGetter) {
        return JSON.parse(data).results;
    };

    app.factory('wnwbApi', ['config', '$resource', function(config, $resource) {
        return {
            Version: $resource(config.API_URL+'version/', {}, {}, {stripTrailingSlashes: false}),
            sensereltype: $resource(config.API_URL+'sensereltype/:id/', {}, {}, {stripTrailingSlashes: false}),
            Authorization: $resource(config.API_AUTH_URL, {}, {
                auth: {
                    method: 'POST',
                    params: {

                    }
                }
            }, {stripTrailingSlashes: false}),
            Lexicon: $resource(config.API_URL+'lexicon/:id/', {}, {
                get: {
                    method: 'GET',
                    isArray: false
                },
                query: {
                    method: 'GET',
                    transformResponse: [defaultResponseTransformer],
                    isArray: true
                }
            }, {stripTrailingSlashes: false}),
            Sense: $resource(config.API_URL+'sense/:id/', {}, {
                update: {
                    method: 'PUT'
                },
                query: {
                    method: 'GET',
                    transformResponse: [defaultResponseTransformer],
                    isArray: true
                },
                remove: {
                	method: 'DELETE'
                }
            }, {stripTrailingSlashes: false}),
            SynSet: $resource(config.API_URL+'synset/:id/', {}, {
                update: {
                    method: 'PUT'
                },
                query: {
                    method: 'GET',
                    transformResponse: [defaultResponseTransformer],
                    isArray: true
                },
                remove: {
                	method: 'DELETE'
                }
            }, {stripTrailingSlashes: false}),
            HyperonymRelTree: $resource(config.API_URL+'hypers/', {}, {
                get: {
                    method: 'GET',
                    isArray: true
                }
            }, {stripTrailingSlashes: false}),
            HyponymRelTree: $resource(config.API_URL+'hypos/', {}, {
                get: {
                    method: 'GET',
                    isArray: true
                }
            }, {stripTrailingSlashes: false}),
            SiblingRelTree: $resource(config.API_URL+'sibs/', {}, {
                get: {
                    method: 'GET',
                    isArray: true
                }
            }, {stripTrailingSlashes: false}),
            OtherRelTree: $resource(config.API_URL+'rels/', {}, {
                get: {
                    method: 'GET',
                    isArray: true
                }
            }, {stripTrailingSlashes: false}),
            Domain: $resource(config.API_URL+'domain/:id/', {}, {
                update: {
                    method: 'PUT'
                },
                query: {
                    method: 'GET',
                    transformResponse: [defaultResponseTransformer],
                    isArray: true
                }/*,
                delete: { method: 'DELETE', params: { id: 0 } }*/
            }, {stripTrailingSlashes: false}),
            SenseRel: $resource(config.API_URL+'senserel/:id/', {}, {}, {stripTrailingSlashes: false}),
            SynSetRel: $resource(config.API_URL+'synsetrel/:id/', {}, {}, {stripTrailingSlashes: false}),
            SenseRelType: $resource(config.API_URL+'sensereltype/:id/', {}, {
                update: {
                    method: 'PUT'
                },
                query: {
                    method: 'GET',
                    transformResponse: [defaultResponseTransformer],
                    isArray: true
                }
            }, {stripTrailingSlashes: false}),
            SenseStyle: $resource(config.API_URL+'refcode/:id/', {}, {
                update: {
                    method: 'PUT'
                },
                query: {
                    method: 'GET',
                    transformResponse: [defaultResponseTransformer],
                    isArray: true
                }
            }, {stripTrailingSlashes: false}),
            SynSetRelType: $resource(config.API_URL+'synsetreltype/:id/', {}, {
                update: {
                    method: 'PUT'
                },
                query: {
                    method: 'GET',
                    transformResponse: [defaultResponseTransformer],
                    isArray: true
                }
            }, {stripTrailingSlashes: false}),
            ExtRelType: $resource(config.API_URL+'extreltype/:id/', {}, {
                update: {
                    method: 'PUT'
                },
                query: {
                    method: 'GET',
                    transformResponse: [defaultResponseTransformer],
                    isArray: true
                }
            }, {stripTrailingSlashes: false}),
            ExtSystem: $resource(config.API_URL+'extsystem/:id/', {}, {
                update: {
                    method: 'PUT'
                },
                query: {
                    method: 'GET',
                    transformResponse: [defaultResponseTransformer],
                    isArray: true
                }
            }, {stripTrailingSlashes: false}),
            LexicalEntry: $resource(config.API_URL+'lexentry/', {}, {
                query: {
                    method: 'GET',
                    transformResponse: [defaultResponseTransformer],
                    isArray: true
                }
            }, {stripTrailingSlashes: false}),
            Statistics: $resource(config.API_URL+'stats/', {}, {
                query: {
                    method: 'GET',
                    isArray: true
                }
            }, {stripTrailingSlashes: false}),
            Principal: $resource(config.API_URL+'users/?principal', {}, {
                query: {
                    method: 'GET',
                    transformResponse: [defaultResponseTransformer],
                    isArray: true
                }
            }, {stripTrailingSlashes: false})
        };
    }]);

    return app;
});<|endoftext|>


<commit_before>Package.describe({
  summary: 'A comprehensive internationalization solution for Meteor'
});

Package.on_use(function (api) {
  api.use(["coffeescript", "underscore", "meteor"], ['server', 'client']);
  api.use(["http-methods"], 'server');
  api.use(["deps", "session", "jquery", "templating"], 'client');

  // load and init TAPi18next
  api.add_files('lib/tap_i18next/tap_i18next-1.7.3.js', 'client');
  api.export("TAPi18next");
  api.add_files('lib/tap_i18next/tap_i18next_init.js', 'client');

  // load TAPi18n
  api.add_files('lib/globals.js', ['client', 'server']);

  // We use the bare option since we need TAPi18n in the package level and
  // coffee adds vars to all (so without bare all vars are in the file level)
  api.add_files('lib/tap_i18n/tap_i18n-common.coffee', 'server');
  api.add_files('lib/tap_i18n/tap_i18n-common.coffee', 'client', {bare: true});

  api.add_files('lib/tap_i18n/tap_i18n-server.coffee', 'server');
  api.add_files('lib/tap_i18n/tap_i18n-client.coffee', 'client', {bare: true});

  api.export("TAPi18n");
});

// Register our build plugin
Package._transitional_registerBuildPlugin({
  name: "compileI18n",
  use: ["coffeescript", "meteor", "simple-schema", "check", "templating"],
  sources: [
    'lib/globals.js',
    'lib/plugin/wrench.js',
    'lib/plugin/language_names.js',
    'lib/plugin/compile-i18n.coffee'
  ]
});

<commit_msg>Add version in package.js<commit_after>Package.describe({
  summary: 'A comprehensive internationalization solution for Meteor',
  version: '0.7.0'
});

Package.on_use(function (api) {
  api.use(["coffeescript", "underscore", "meteor"], ['server', 'client']);
  api.use(["http-methods"], 'server');
  api.use(["deps", "session", "jquery", "templating"], 'client');

  // load and init TAPi18next
  api.add_files('lib/tap_i18next/tap_i18next-1.7.3.js', 'client');
  api.export("TAPi18next");
  api.add_files('lib/tap_i18next/tap_i18next_init.js', 'client');

  // load TAPi18n
  api.add_files('lib/globals.js', ['client', 'server']);

  // We use the bare option since we need TAPi18n in the package level and
  // coffee adds vars to all (so without bare all vars are in the file level)
  api.add_files('lib/tap_i18n/tap_i18n-common.coffee', 'server');
  api.add_files('lib/tap_i18n/tap_i18n-common.coffee', 'client', {bare: true});

  api.add_files('lib/tap_i18n/tap_i18n-server.coffee', 'server');
  api.add_files('lib/tap_i18n/tap_i18n-client.coffee', 'client', {bare: true});

  api.export("TAPi18n");
});

// Register our build plugin
Package._transitional_registerBuildPlugin({
  name: "compileI18n",
  use: ["coffeescript", "meteor", "simple-schema", "check", "templating"],
  sources: [
    'lib/globals.js',
    'lib/plugin/wrench.js',
    'lib/plugin/language_names.js',
    'lib/plugin/compile-i18n.coffee'
  ]
});

<|endoftext|>


<commit_before>'use strict';

Package.describe({
    name: 'vazco:universe-selectize',
    summary: 'Universe select input standalone - with the appearance as selectize. It is for use without autoform.',
    version: '0.1.14',
    git: 'https://github.com/vazco/meteor-universe-selectize.git'
});

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

    if (!api.addAssets) {
        api.addAssets = function (files, platform) {
            api.addFiles(files, platform, {isAsset: true});
        };
    }

    api.use('ecmascript');
    api.use('less');
    api.use('templating');

    api.use(['underscore', 'reactive-var'], 'client');

    api.addFiles([
        'universe-selectize.html',
        'universe-selectize.js',
        'stylesheets/selectize.default.less',
        'stylesheets/universe-selectize.less'
    ], 'client');

    api.addAssets('img/loading.gif', 'client');

    api.export(['UniSelectize']);
});
<commit_msg>fixes<commit_after>'use strict';

Package.describe({
    name: 'vazco:universe-selectize',
    summary: 'Universe select input standalone - with the appearance as selectize. It is for use without autoform.',
    version: '0.1.15',
    git: 'https://github.com/vazco/meteor-universe-selectize.git'
});

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

    if (!api.addAssets) {
        api.addAssets = function (files, platform) {
            api.addFiles(files, platform, {isAsset: true});
        };
    }

    api.use(['ecmascript', 'templating', 'underscore', 'less', 'reactive-var'], 'client');

    api.addFiles([
        'universe-selectize.html',
        'universe-selectize.js',
        'stylesheets/selectize.default.less',
        'stylesheets/universe-selectize.less'
    ], 'client');

    api.addAssets('img/loading.gif', 'client');

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


<commit_before>Package.describe({
  name: 'fafournier:eu-vat',
  version: '0.0.1',
  // Brief, one-line summary of the package.
  summary: 'This package allows to work with EU-VAT.',
  // URL to the Git repository containing the source code for this package.
  git: 'https://github.com/fafournier/eu-vat/',
  // By default, Meteor will default to using README.md for documentation.
  // To avoid submitting documentation, set this field to null.
  documentation: 'README.md'
});

Npm.depends({
  "validate-vat": "0.3.1",
  "big.js": "3.1.3",
  // "vat-moss.js": "0.10.0",
  // "require": "2.4.20",
});

Package.onUse(function(api) {
  api.versionsFrom('1.1.0.2');
  api.use('ecmascript');
  api.use( 'livedata', [ 'server' ] ) ;
  api.addFiles('eu-vat.js');
  api.addFiles('methods.js');
  api.export("VAT", 'server');
  api.export( 'methods', [ 'client', 'server' ] ) ;
});

// Package.onTest(function(api) {
//   api.use('ecmascript');
//   api.use('tinytest');
//   api.use('fafournier:eu-vat');
//   api.addFiles('eu-vat-tests.js');
// });
<commit_msg>shorter summory<commit_after>Package.describe({
  name: 'fafournier:eu-vat',
  version: '0.0.1',
  // Brief, one-line summary of the package.
  summary: 'Tools to work with EU-VAT.',
  // URL to the Git repository containing the source code for this package.
  git: 'https://github.com/fafournier/eu-vat/',
  // By default, Meteor will default to using README.md for documentation.
  // To avoid submitting documentation, set this field to null.
  documentation: 'README.md'
});

Npm.depends({
  "validate-vat": "0.3.1",
  "big.js": "3.1.3",
  // "vat-moss.js": "0.10.0",
  // "require": "2.4.20",
});

Package.onUse(function(api) {
  api.versionsFrom('1.1.0.2');
  api.use('ecmascript');
  api.use( 'livedata', [ 'server' ] ) ;
  api.addFiles('eu-vat.js');
  api.addFiles('methods.js');
  api.export("VAT", 'server');
  api.export( 'methods', [ 'client', 'server' ] ) ;
});

// Package.onTest(function(api) {
//   api.use('ecmascript');
//   api.use('tinytest');
//   api.use('fafournier:eu-vat');
//   api.addFiles('eu-vat-tests.js');
// });
<|endoftext|>


<commit_before>Package.describe({
	summary: "Adds the global variable doNothing, storing a function doing nothing.",
	version: "1.0.0",
	git: "https://github.com/PeppeL-G/doNothing.git"
})

Package.onUse(function(api){
	api.versionsFrom('METEOR@0.9.0.1')
	api.addFiles('main.js')
	api.export('doNothing')
})

Package.onTest(function(api){
	api.use('tinytest')
	api.use('peppelg:do-nothing')
	api.addFiles('tests.js')
})<commit_msg>Added the package name to the package description, so the directory can be renamed to whatever.<commit_after>Package.describe({
	summary: "Adds the global variable doNothing, storing a function doing nothing.",
	version: "1.0.0",
	name: "peppelg:do-nothing",
	git: "https://github.com/PeppeL-G/doNothing.git"
})

Package.onUse(function(api){
	api.versionsFrom('METEOR@0.9.0.1')
	api.addFiles('main.js')
	api.export('doNothing')
})

Package.onTest(function(api){
	api.use('tinytest')
	api.use('peppelg:do-nothing')
	api.addFiles('tests.js')
})<|endoftext|>


<commit_before>Package.describe({
  name: 'planifica:encryption',
  version: '0.0.4',
  // Brief, one-line summary of the package.
  summary: 'Client-Side Encryption for Mongo Collections',
  // URL to the Git repository containing the source code for this package.
  git: 'https://github.com/Planifica/encryption',
  // By default, Meteor will default to using README.md for documentation.
  // To avoid submitting documentation, set this field to null.
  documentation: 'README.md'
});

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

  api.use(['underscore', 'check'], 'client');
  api.use('u2622:persistent-session@0.4.1', 'client');
  api.use('aldeed:collection2@2.5.0');
  api.use('ongoworks:security@1.2.0');
  api.use('matb33:collection-hooks@0.7.13', 'client');
  api.use('robertlowe:persistent-reactive-dict@0.1.2', 'client');
  api.use('jparker:crypto-core@0.1.0', 'client');
  api.use('jparker:crypto-base64@0.1.0', 'client');

  api.addFiles('tweetnacl-js-master/nacl-fast.min.js', 'client');

  api.addFiles('principals.js', ['client', 'server']);
  api.addFiles('server.js', 'server');
  api.addFiles('utils.js', 'client');
  api.addFiles('EncryptionUtils.js', 'client');
  api.addFiles('CollectionEncryption.js', 'client');

  api.export('CollectionEncryption');
  api.export('EncryptionUtils');
  api.export('Principals');
});

Package.onTest(function(api) {
  api.use('tinytest');
  api.use('planifica:encryption');
});
<commit_msg>fixed collection hooks dependency<commit_after>Package.describe({
  name: 'planifica:encryption',
  version: '0.0.4',
  // Brief, one-line summary of the package.
  summary: 'Client-Side Encryption for Mongo Collections',
  // URL to the Git repository containing the source code for this package.
  git: 'https://github.com/Planifica/encryption',
  // By default, Meteor will default to using README.md for documentation.
  // To avoid submitting documentation, set this field to null.
  documentation: 'README.md'
});

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

  api.use(['underscore', 'check'], 'client');
  api.use('u2622:persistent-session@0.4.1', 'client');
  api.use('aldeed:collection2@2.5.0');
  api.use('ongoworks:security@1.2.0');
  api.use('matb33:collection-hooks@0.7.13');
  api.use('robertlowe:persistent-reactive-dict@0.1.2', 'client');
  api.use('jparker:crypto-core@0.1.0', 'client');
  api.use('jparker:crypto-base64@0.1.0', 'client');

  api.addFiles('tweetnacl-js-master/nacl-fast.min.js', 'client');

  api.addFiles('principals.js', ['client', 'server']);
  api.addFiles('server.js', 'server');
  api.addFiles('utils.js', 'client');
  api.addFiles('EncryptionUtils.js', 'client');
  api.addFiles('CollectionEncryption.js', 'client');

  api.export('CollectionEncryption');
  api.export('EncryptionUtils');
  api.export('Principals');
});

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