<commit_before>const path = require('path');
const ExtractTextPlugin = require('extract-text-webpack-plugin');
const CleanWebpackPlugin = require('clean-webpack-plugin');
// const CopyWebpackPlugin = require('copy-webpack-plugin');
const merge = require('webpack-merge');
const autoprefixer = require('autoprefixer');

const PATHS = {
  site: [
    path.join(__dirname, 'layouts'),
    path.join(__dirname, 'components'),
    path.join(__dirname, 'pages')
  ],
  style: [
    path.join(__dirname, 'layouts'),
    path.join(__dirname, 'components'),
    path.join(__dirname, 'styles')
  ],
  packages: path.join(__dirname, '..', 'packages')
};

const commonConfig = {
  resolve: {
    // Patch webpack module resolution so that the site works with `packages`
    modules: [
      PATHS.packages
    ]
  },
  module: {
    rules: [
      {
        test: /\.jsx?$/,
        use: 'babel-loader',
        include: PATHS.site
      },
      {
        test: /\.woff$/,
        use: 'url-loader?prefix=font/&limit=5000&mimetype=application/font-woff'
      },
      {
        test: /\.ttf$|\.eot$/,
        use: 'file-loader?prefix=font/'
      },
      {
        test: /\.jpg$/,
        use: 'file-loader'
      },
      {
        test: /\.png$/,
        use: 'file-loader'
      },
      {
        test: /\.svg$/,
        use: 'raw-loader'
      },
      {
        test: /\.html$/,
        use: 'raw-loader'
      },
      {
        test: /\.json$/,
        use: 'json-loader'
      }
    ]
  }
  // XXX
  /* plugins: [
    new CopyWebpackPlugin([
      {
        from: './CNAME',
        to: './'
      }
    ])
  ]*/
};

module.exports = function (env) {
  switch (env) {
    case 'build':
      return merge(
        commonConfig,
        buildConfig(PATHS.style)
      );
    default:
    case 'start':
      return merge(
        commonConfig,
        developmentConfig(PATHS.style)
      );
  }
};

function developmentConfig(stylePaths) {
  return {
    module: {
      rules: [
        {
          test: /\.css$/,
          use: [
            'style-loader',
            'css-loader'
          ],
          include: stylePaths
        },
        {
          test: /\.scss$/,
          use: [
            'style-loader',
            'css-loader?modules&localIdentName=[local]--[hash:base64:5]',
            {
              loader: 'postcss-loader',
              options: {
                plugins: () => ([
                  autoprefixer({ browsers: ['last 2 versions'] })
                ])
              }
            },
            'sass-loader'
          ],
          include: stylePaths
        }
      ]
    }
  };
}

function buildConfig(stylePaths) {
  return {
    output: {
      // XXX: patch paths - this can be removed once there's a root domain
      publicPath: '/antwarjs.github.io/antwar'
    },
    module: {
      rules: [
        {
          test: /\.css$/,
          use: ExtractTextPlugin.extract({
            fallback: 'style-loader',
            use: 'css-loader'
          }),
          include: stylePaths
        },
        {
          test: /\.scss$/,
          loader: ExtractTextPlugin.extract({
            fallback: 'style-loader',
            use: [
              'css-loader?modules',
              {
                loader: 'postcss-loader',
                options: {
                  plugins: () => ([
                    autoprefixer({ browsers: ['last 2 versions'] })
                  ])
                }
              },
              'sass-loader'
            ]
          }),
          include: stylePaths
        }
      ]
    },
    plugins: [
      new ExtractTextPlugin({
        filename: '[name].css',
        allChunks: true
      }),
      new CleanWebpackPlugin(['build'])
    ]
  };
}
<commit_msg>Fix: Add a missing slash<commit_after>const path = require('path');
const ExtractTextPlugin = require('extract-text-webpack-plugin');
const CleanWebpackPlugin = require('clean-webpack-plugin');
// const CopyWebpackPlugin = require('copy-webpack-plugin');
const merge = require('webpack-merge');
const autoprefixer = require('autoprefixer');

const PATHS = {
  site: [
    path.join(__dirname, 'layouts'),
    path.join(__dirname, 'components'),
    path.join(__dirname, 'pages')
  ],
  style: [
    path.join(__dirname, 'layouts'),
    path.join(__dirname, 'components'),
    path.join(__dirname, 'styles')
  ],
  packages: path.join(__dirname, '..', 'packages')
};

const commonConfig = {
  resolve: {
    // Patch webpack module resolution so that the site works with `packages`
    modules: [
      PATHS.packages
    ]
  },
  module: {
    rules: [
      {
        test: /\.jsx?$/,
        use: 'babel-loader',
        include: PATHS.site
      },
      {
        test: /\.woff$/,
        use: 'url-loader?prefix=font/&limit=5000&mimetype=application/font-woff'
      },
      {
        test: /\.ttf$|\.eot$/,
        use: 'file-loader?prefix=font/'
      },
      {
        test: /\.jpg$/,
        use: 'file-loader'
      },
      {
        test: /\.png$/,
        use: 'file-loader'
      },
      {
        test: /\.svg$/,
        use: 'raw-loader'
      },
      {
        test: /\.html$/,
        use: 'raw-loader'
      },
      {
        test: /\.json$/,
        use: 'json-loader'
      }
    ]
  }
  // XXX
  /* plugins: [
    new CopyWebpackPlugin([
      {
        from: './CNAME',
        to: './'
      }
    ])
  ]*/
};

module.exports = function (env) {
  switch (env) {
    case 'build':
      return merge(
        commonConfig,
        buildConfig(PATHS.style)
      );
    default:
    case 'start':
      return merge(
        commonConfig,
        developmentConfig(PATHS.style)
      );
  }
};

function developmentConfig(stylePaths) {
  return {
    module: {
      rules: [
        {
          test: /\.css$/,
          use: [
            'style-loader',
            'css-loader'
          ],
          include: stylePaths
        },
        {
          test: /\.scss$/,
          use: [
            'style-loader',
            'css-loader?modules&localIdentName=[local]--[hash:base64:5]',
            {
              loader: 'postcss-loader',
              options: {
                plugins: () => ([
                  autoprefixer({ browsers: ['last 2 versions'] })
                ])
              }
            },
            'sass-loader'
          ],
          include: stylePaths
        }
      ]
    }
  };
}

function buildConfig(stylePaths) {
  return {
    output: {
      // XXX: patch paths - this can be removed once there's a root domain
      publicPath: '//antwarjs.github.io/antwar'
    },
    module: {
      rules: [
        {
          test: /\.css$/,
          use: ExtractTextPlugin.extract({
            fallback: 'style-loader',
            use: 'css-loader'
          }),
          include: stylePaths
        },
        {
          test: /\.scss$/,
          loader: ExtractTextPlugin.extract({
            fallback: 'style-loader',
            use: [
              'css-loader?modules',
              {
                loader: 'postcss-loader',
                options: {
                  plugins: () => ([
                    autoprefixer({ browsers: ['last 2 versions'] })
                  ])
                }
              },
              'sass-loader'
            ]
          }),
          include: stylePaths
        }
      ]
    },
    plugins: [
      new ExtractTextPlugin({
        filename: '[name].css',
        allChunks: true
      }),
      new CleanWebpackPlugin(['build'])
    ]
  };
}
<|endoftext|>


<commit_before>'use strict';

var express = require('express'),
    logger = require('../../core/Logger')('webapi'),
    JID = require('node-xmpp-core').JID,
    ApiError = require('../utils/ApiError'),
    ApiUtils = require('../utils/ApiUtils'),
    bodyParser = require('body-parser');

var routes = function (storage, settings) {

    logger.info('register room routes');

    var roomapi = express.Router();

    var domain = settings.get('domain');

    roomapi.use(bodyParser.json({ limit: '1mb' }));

    /**
     * Get room
     * restriction: only owner and members can access this information
     */
    roomapi.get('/rooms/:owner/:room', function (req, res) {

        // requester, should be member of the room
        var jid = ApiUtils.getJID(req);

        var username = req.params.owner;
        var roomname = req.params.room;

        logger.debug('Get room: ' +  username + '/' + roomname);

        var ownerjid = new JID(username + '@' + domain);

        var usr = null;
        var r = null;
        storage.findUser(jid.toString()).then(function (user) {
            usr = user;
            return storage.findUser(ownerjid.toString());
        }).then(function(owner){
            return storage.getRoom(owner, roomname);
        }).then(function(room) {
            r = room;
            return room.isMember(usr);
        }).then(function() {
            res.json(r);
        }).catch(function(err) {
            logger.error(err);
            res.status(404).json(new ApiError('not found'));
        });
    });

    /**
     * Edit room
     * restriction: only owner and members can access this information
     */
    roomapi.patch('/rooms/:owner/:room', function (req, res) {
        res.status(404).json(new ApiError('not found'));
    });

    /**
     * Delete a room (requires admin access)
     * restriction: only owner can do this
     */
    roomapi.delete('/rooms/:owner/:room', function (req, res) {
        var username = req.params.owner;
        var roomname = req.params.room;

        logger.debug('Delete room: ' +  username + '/' + roomname);

        // requester, should be member of the room
        var jid = ApiUtils.getJID(req);
        var ownerjid = new JID(username + '@' + domain);

        // verify that owner and requestor are the same
        if (!ownerjid.equals(jid)) {
            res.send(404);
            return;
        }

        // since only owner can delete rooms, we try to delete the room directly
        storage.findUser(jid.toString()).then(function (user) {
            return storage.getRoom(user, roomname);
        }).then(function(room) {
            return storage.delRoom(room);
        }).then(function() {
            res.send(204);
        }).catch(function(err) {
            logger.error(err);
            res.status(404).json(new ApiError('not found'));
        });
    });

    /**
     * List members
     * restriction: only owner and members can access this information
     */
    roomapi.get('/rooms/:owner/:room/members', function(req, res) {

        // extract parameter
        var username = req.params.owner;
        var roomname = req.params.room;

        logger.debug('Get room: ' +  username + '/' + roomname);

        // requester, should be member of the room
        var jid = ApiUtils.getJID(req);
        var ownerjid = new JID(username + '@' + domain);

        var usr = null;
        var r = null;
        storage.findUser(jid.toString()).then(function (user) {
            usr = user;
            return storage.findUser(ownerjid.toString());
        }).then(function(owner){
            return storage.getRoom(owner, roomname);
        }).then(function(room) {
            r = room;
            return room.isMember(usr);
        }).then(function() {
            return r.getMembers();
        }).then(function(members) {
            res.json(ApiUtils.exportJSON(members));
        }).catch(function(err) {
            logger.error(err);
            res.status(404).json(new ApiError('not found'));
        });
    });

    /**
     * Check if a user is a member
     * restriction: only owner and members can access this information
     */
    roomapi.get('/rooms/:owner/:room/members/:user', function(req, res) {

        // extract parameter
        var username = req.params.owner;
        var roomname = req.params.room;
        var membername = req.params.user;

        logger.debug('Get room: ' +  username + '/' + roomname);

        // requester, should be member of the room
        var jid = ApiUtils.getJID(req);

        // owner of the room
        var ownerjid = new JID(username + '@' + domain);

        // check if this user is member of the room
        var memberjid = new JID(membername);

        var usr = null;
        var r = null;
        var mem = null;

        // check if the "member" is a known user
        storage.findUser(memberjid.toString()).then(function(member){
            mem = member;
            // check if the requestor is a known user
            return storage.findUser(jid.toString());
        }).then(function (user) {
            usr = user;
            // check if the owner of the room is a known user
            return storage.findUser(ownerjid.toString());
        }).then(function(owner){
            // check if the owner has such room
            return storage.getRoom(owner, roomname);
        }).then(function(room) {
            r = room;
            // check if the requestor is member of the room
            return room.isMember(usr);
        }).then(function() {
            // check if the requested member is really a member of the room
            return r.isMember(mem);
        }).then(function() {
            res.send(204);
        }).catch(function(err) {
            logger.error(err);
            res.send(404);
        });
    });

    /**
     * Add user as a member
     * restriction: only owners can do this
     */
    roomapi.put('/rooms/:owner/:room/members/:user', function(req, res) {
        // extract parameter
        var username = req.params.owner;
        var roomname = req.params.room;
        var membername = req.params.user;

        logger.debug('Add member to room: ' +  username + '/' + roomname);

        // requester, should be member of the room
        var jid = ApiUtils.getJID(req);

        // owner of the room
        var ownerjid = new JID(username + '@' + domain);

        // check if this user is member of the room
        var memberjid = new JID(membername);

        // verify that owner and requestor are the same
        if (!ownerjid.equals(jid)) {
            res.send(404);
            return;
        }

        var own;
        var mem;
        var r;

        storage.findUser(jid.toString()).then(function(owner){
            own = owner;
            // check if the owner has such room
            return storage.getRoom(owner, roomname);
        }).then(function(room) {
            r = room;
            // find member
            return storage.findOrCreateUser(memberjid.toString());
        }).then(function(member){
            mem = member;
            // add member to room
            return storage.inviteMember({
                room: r,
                invitee: mem,
                inviter: own,
                reason: null
            });
        }).then(function() {
            res.send(204);
        }).catch(function(err) {
            logger.error(err);
            res.send(404);
        });
    });

    /**
     * Remove user as a member
     * restriction: only owners can do this
     */
    roomapi.delete('/rooms/:owner/:room/members/:user', function(req, res) {
        // extract parameter
        var username = req.params.owner;
        var roomname = req.params.room;
        var membername = req.params.user;

        logger.debug('Delete member from room: ' +  username + '/' + roomname);

        // requester, should be member of the room
        var jid = ApiUtils.getJID(req);

        // owner of the room
        var ownerjid = new JID(username + '@' + domain);

        // check if this user is member of the room
        var memberjid = new JID(membername);

        // verify that owner and requestor are the same
        if (!ownerjid.equals(jid)) {
            res.send(400);
            return;
        }

        // owner cannot remove owner
        logger.debug('OWNER: ' + ownerjid.toString());
        logger.debug('MEMBER: ' + memberjid.toString());

        if (ownerjid.equals(memberjid)) {
            res.send(400);
            return;
        }

        var mem;

        // check if the "member" is a known user
        storage.findUser(memberjid.toString()).then(function(member){
            mem = member;
            // check if the requestor is a known user
            return storage.findUser(jid.toString());
        }).then(function(owner){
            // check if the owner has such room
            return storage.getRoom(owner, roomname);
        }).then(function(room) {
            // add member to room
            return storage.removeMember(room, mem);
        }).then(function() {
            res.send(204);
        }).catch(function(err) {
            logger.error(err);
            res.send(404);
        });
    });

    /**
     * List messages for a room
     */
    roomapi.get('/rooms/:owner/:room/messages', function(req, res) {

        // extract parameter
        var username = req.params.owner;
        var roomname = req.params.room;

        logger.debug('Get room: ' +  username + '/' + roomname);

        // requester, should be member of the room
        var jid = ApiUtils.getJID(req);
        var ownerjid = new JID(username + '@' + domain);

        var usr = null;
        var r = null;
        storage.findUser(jid.toString()).then(function (user) {
            usr = user;
            return storage.findUser(ownerjid.toString());
        }).then(function(owner){
            return storage.getRoom(owner, roomname);
        }).then(function(room) {
            r = room;
            return room.isMember(usr);
        }).then(function() {
            return r.getMessages();
        }).then(function(messages) {
            res.json(messages);
        }).catch(function(err) {
            logger.error(err);
            res.status(404).json(new ApiError('not found'));
        });
    });

    /**
     * Get a single message
     */
    roomapi.get('/rooms/:owner/:room/messages/:number', function(req, res) {
        res.json({});
    });

    /**
     * Create an message
     */
    roomapi.post('/rooms/:owner/:room/messages', function(req, res) {
        res.json({});
    });

    /**
     * Edit an message
     */
    roomapi.patch('/rooms/:owner/:room/messages/:number', function(req, res) {
        res.json({});
    });

    return roomapi;
};

// Expose routes
module.exports = routes;<commit_msg>fix express 4 styles<commit_after>'use strict';

var express = require('express'),
    logger = require('../../core/Logger')('webapi'),
    JID = require('node-xmpp-core').JID,
    ApiError = require('../utils/ApiError'),
    ApiUtils = require('../utils/ApiUtils'),
    bodyParser = require('body-parser');

var routes = function (storage, settings) {

    logger.info('register room routes');

    var roomapi = express.Router();

    var domain = settings.get('domain');

    roomapi.use(bodyParser.json({ limit: '1mb' }));

    /**
     * Get room
     * restriction: only owner and members can access this information
     */
    roomapi.get('/rooms/:owner/:room', function (req, res) {

        // requester, should be member of the room
        var jid = ApiUtils.getJID(req);

        var username = req.params.owner;
        var roomname = req.params.room;

        logger.debug('Get room: ' +  username + '/' + roomname);

        var ownerjid = new JID(username + '@' + domain);

        var usr = null;
        var r = null;
        storage.findUser(jid.toString()).then(function (user) {
            usr = user;
            return storage.findUser(ownerjid.toString());
        }).then(function(owner){
            return storage.getRoom(owner, roomname);
        }).then(function(room) {
            r = room;
            return room.isMember(usr);
        }).then(function() {
            res.json(r);
        }).catch(function(err) {
            logger.error(err);
            res.status(404).json(new ApiError('not found'));
        });
    });

    /**
     * Edit room
     * restriction: only owner and members can access this information
     */
    roomapi.patch('/rooms/:owner/:room', function (req, res) {
        res.status(404).json(new ApiError('not found'));
    });

    /**
     * Delete a room (requires admin access)
     * restriction: only owner can do this
     */
    roomapi.delete('/rooms/:owner/:room', function (req, res) {
        var username = req.params.owner;
        var roomname = req.params.room;

        logger.debug('Delete room: ' +  username + '/' + roomname);

        // requester, should be member of the room
        var jid = ApiUtils.getJID(req);
        var ownerjid = new JID(username + '@' + domain);

        // verify that owner and requestor are the same
        if (!ownerjid.equals(jid)) {
            res.sendStatus(404);
            return;
        }

        // since only owner can delete rooms, we try to delete the room directly
        storage.findUser(jid.toString()).then(function (user) {
            return storage.getRoom(user, roomname);
        }).then(function(room) {
            return storage.delRoom(room);
        }).then(function() {
            res.sendStatus(204);
        }).catch(function(err) {
            logger.error(err);
            res.status(404).json(new ApiError('not found'));
        });
    });

    /**
     * List members
     * restriction: only owner and members can access this information
     */
    roomapi.get('/rooms/:owner/:room/members', function(req, res) {

        // extract parameter
        var username = req.params.owner;
        var roomname = req.params.room;

        logger.debug('Get room: ' +  username + '/' + roomname);

        // requester, should be member of the room
        var jid = ApiUtils.getJID(req);
        var ownerjid = new JID(username + '@' + domain);

        var usr = null;
        var r = null;
        storage.findUser(jid.toString()).then(function (user) {
            usr = user;
            return storage.findUser(ownerjid.toString());
        }).then(function(owner){
            return storage.getRoom(owner, roomname);
        }).then(function(room) {
            r = room;
            return room.isMember(usr);
        }).then(function() {
            return r.getMembers();
        }).then(function(members) {
            res.json(ApiUtils.exportJSON(members));
        }).catch(function(err) {
            logger.error(err);
            res.status(404).json(new ApiError('not found'));
        });
    });

    /**
     * Check if a user is a member
     * restriction: only owner and members can access this information
     */
    roomapi.get('/rooms/:owner/:room/members/:user', function(req, res) {

        // extract parameter
        var username = req.params.owner;
        var roomname = req.params.room;
        var membername = req.params.user;

        logger.debug('Get room: ' +  username + '/' + roomname);

        // requester, should be member of the room
        var jid = ApiUtils.getJID(req);

        // owner of the room
        var ownerjid = new JID(username + '@' + domain);

        // check if this user is member of the room
        var memberjid = new JID(membername);

        var usr = null;
        var r = null;
        var mem = null;

        // check if the "member" is a known user
        storage.findUser(memberjid.toString()).then(function(member){
            mem = member;
            // check if the requestor is a known user
            return storage.findUser(jid.toString());
        }).then(function (user) {
            usr = user;
            // check if the owner of the room is a known user
            return storage.findUser(ownerjid.toString());
        }).then(function(owner){
            // check if the owner has such room
            return storage.getRoom(owner, roomname);
        }).then(function(room) {
            r = room;
            // check if the requestor is member of the room
            return room.isMember(usr);
        }).then(function() {
            // check if the requested member is really a member of the room
            return r.isMember(mem);
        }).then(function() {
            res.sendStatus(204);
        }).catch(function(err) {
            logger.error(err);
            res.sendStatus(404);
        });
    });

    /**
     * Add user as a member
     * restriction: only owners can do this
     */
    roomapi.put('/rooms/:owner/:room/members/:user', function(req, res) {
        // extract parameter
        var username = req.params.owner;
        var roomname = req.params.room;
        var membername = req.params.user;

        logger.debug('Add member to room: ' +  username + '/' + roomname);

        // requester, should be member of the room
        var jid = ApiUtils.getJID(req);

        // owner of the room
        var ownerjid = new JID(username + '@' + domain);

        // check if this user is member of the room
        var memberjid = new JID(membername);

        // verify that owner and requestor are the same
        if (!ownerjid.equals(jid)) {
            res.sendStatus(404);
            return;
        }

        var own;
        var mem;
        var r;

        storage.findUser(jid.toString()).then(function(owner){
            own = owner;
            // check if the owner has such room
            return storage.getRoom(owner, roomname);
        }).then(function(room) {
            r = room;
            // find member
            return storage.findOrCreateUser(memberjid.toString());
        }).then(function(member){
            mem = member;
            // add member to room
            return storage.inviteMember({
                room: r,
                invitee: mem,
                inviter: own,
                reason: null
            });
        }).then(function() {
            res.sendStatus(204);
        }).catch(function(err) {
            logger.error(err);
            res.sendStatus(404);
        });
    });

    /**
     * Remove user as a member
     * restriction: only owners can do this
     */
    roomapi.delete('/rooms/:owner/:room/members/:user', function(req, res) {
        // extract parameter
        var username = req.params.owner;
        var roomname = req.params.room;
        var membername = req.params.user;

        logger.debug('Delete member from room: ' +  username + '/' + roomname);

        // requester, should be member of the room
        var jid = ApiUtils.getJID(req);

        // owner of the room
        var ownerjid = new JID(username + '@' + domain);

        // check if this user is member of the room
        var memberjid = new JID(membername);

        // verify that owner and requestor are the same
        if (!ownerjid.equals(jid)) {
            res.sendStatus(400);
            return;
        }

        // owner cannot remove owner
        logger.debug('OWNER: ' + ownerjid.toString());
        logger.debug('MEMBER: ' + memberjid.toString());

        if (ownerjid.equals(memberjid)) {
            res.send(400);
            return;
        }

        var mem;

        // check if the "member" is a known user
        storage.findUser(memberjid.toString()).then(function(member){
            mem = member;
            // check if the requestor is a known user
            return storage.findUser(jid.toString());
        }).then(function(owner){
            // check if the owner has such room
            return storage.getRoom(owner, roomname);
        }).then(function(room) {
            // add member to room
            return storage.removeMember(room, mem);
        }).then(function() {
            res.sendStatus(204);
        }).catch(function(err) {
            logger.error(err);
            res.sendStatus(404);
        });
    });

    /**
     * List messages for a room
     */
    roomapi.get('/rooms/:owner/:room/messages', function(req, res) {

        // extract parameter
        var username = req.params.owner;
        var roomname = req.params.room;

        logger.debug('Get room: ' +  username + '/' + roomname);

        // requester, should be member of the room
        var jid = ApiUtils.getJID(req);
        var ownerjid = new JID(username + '@' + domain);

        var usr = null;
        var r = null;
        storage.findUser(jid.toString()).then(function (user) {
            usr = user;
            return storage.findUser(ownerjid.toString());
        }).then(function(owner){
            return storage.getRoom(owner, roomname);
        }).then(function(room) {
            r = room;
            return room.isMember(usr);
        }).then(function() {
            return r.getMessages();
        }).then(function(messages) {
            res.json(messages);
        }).catch(function(err) {
            logger.error(err);
            res.status(404).json(new ApiError('not found'));
        });
    });

    /**
     * Get a single message
     */
    roomapi.get('/rooms/:owner/:room/messages/:number', function(req, res) {
        res.json({});
    });

    /**
     * Create an message
     */
    roomapi.post('/rooms/:owner/:room/messages', function(req, res) {
        res.json({});
    });

    /**
     * Edit an message
     */
    roomapi.patch('/rooms/:owner/:room/messages/:number', function(req, res) {
        res.json({});
    });

    return roomapi;
};

// Expose routes
module.exports = routes;<|endoftext|>


<commit_before>'use strict';

angular.module('core').controller('HomeController', ['$scope', '$rootScope', 'Authentication', 'Projects', '$location', '$state', '$stateParams',
	function($scope, $rootScope, Authentication, Projects, $location, $state, $stateParams) {
		// This provides Authentication context.
		$scope.authentication = Authentication;
		$scope.foundTop = false;
		$scope.previewTop = {};
		$rootScope.inPreview = false;
		$scope.state = $state;

	// sets isOpenAcc var which controls whether the accordion should be open
	// runs from accordion ng-init or on first page load
	$scope.checkOpenInit = function() {
		var currProjectId = $stateParams.projectId;
		var parentProject = $scope.resolveTop(lookup(currProjectId));
		console.log(JSON.stringify(parentProjectId));
		for(var i = 0; i < $scope.projects.length; i++) {
			if($scope.projects[i].children.length && $scope.projects[i]._id === parentProject._id) {
				$scope.projects[i].isOpenAcc = true;
			} else {
				$scope.projects[i].isOpenAcc = false;
			}
		}
	};

	// need to move variables and delete the function
	$scope.find = function() {
		$scope.projects = Projects.query();
		$scope.frame1 = $rootScope.frame1;
		$scope.frame2 = $rootScope.frame2;
	};
	/*
	$scope.accordian_stuff = function(project)
	{
		$location.path('projects/' + project._id);
	};
	*/
	$scope.preview_stuff = function(project)
	{
		$location.path('projects/' + project._id + '/preview');
	};
	$scope.setPreviewStatus = function(status)
	{
		$rootScope.inPreview = status;
	};
	$scope.getProjectId = function()
	{
		var full_path = $location.path();
		if (full_path.indexOf('/projects/') !== 0) return false;
		var reduced_path = full_path.replace('/projects/', '');
		if (reduced_path.indexOf('/') === -1) return reduced_path;
		return reduced_path.substring(0,reduced_path.indexOf('/'));
	};
	/*$scope.isProjectOpen = function(project)
	{
		if (!$scope.getProjectId()) return false;
		var top = $scope.resolveTop($scope.lookup($scope.getProjectId()));
		if (top._id === project._id) return true;
		return false;
	};*/
	// need to look into this function
	$scope.isCourseOpen = function(project)
	{
		if (!$scope.getProjectId()) return false;
		var top = $scope.resolveCourse($scope.lookup($scope.getProjectId()));
		if (top._id === project._id) return true;
		return false;
	};
	$scope.lookup = function(id)
	{
		var projects = $scope.projects;
		for (var i =0; i < projects.length; i++)
		{
			if (projects[i]._id === id) return projects[i];
		}
		return false;
	};
	$scope.resolveTop = function(project)
	{
		var projects = $scope.projects;
		//if ($scope.foundTop) return true;

		var current = project;
		while (current.parent !== undefined)
		{
			current = $scope.lookup(current.parent);
		}
		if (current.parent === undefined)
		{
			return current;
		}
		return false;
	};
	$scope.resolveCourse = function(project)
	{
		var projects = $scope.projects;
		var current = project;
		if (current.level === 1) return false;
		while (current.level > 2)
		{
			current = $scope.lookup(current.parent);
		}
		return current;

	};

	$scope.canView = function(project)
	{
		var topProject = $scope.resolveTop(project);
		if (topProject)
		{
			if (topProject.viewPermission === 'public') return true;
			else if ($scope.authentication.user._id === topProject.user._id) return true;
			else if (topProject.viewContributers.indexOf($scope.authentication.user.email) !== -1) return true;
			else return false;
		}
	};

	$scope.projectPage = function() {

			if (document.getElementById('view_project'))
			{
				var text = document.getElementById('view_project').innerHTML;

				if (document.getElementById('html_display'))
				{
					document.getElementById('html_display').innerHTML = text;
				}
			}

			var pathArray = $location.path().split('/');
			if(pathArray[1] !== 'projects')
				return false;
			else if(!pathArray[2])
				return false;
			else if(pathArray[2] === 'new')
				return false;
			else if(pathArray[3])
				return false;
			else
				return true;
	};
	$scope.previewInit = function() {
		$scope.previewTop = $scope.resolveTop($scope.lookup($scope.getProjectId()));
	};
	$scope.link = function(id) {
		$event.stopPropagation();
		$scope.state.go('home.viewProject', {projectId:id});
	};
	}

]);
<commit_msg>Fixed link and remove debug information from checkOpenInit<commit_after>'use strict';

angular.module('core').controller('HomeController', ['$scope', '$rootScope', 'Authentication', 'Projects', '$location', '$state', '$stateParams',
	function($scope, $rootScope, Authentication, Projects, $location, $state, $stateParams) {
		// This provides Authentication context.
		$scope.authentication = Authentication;
		$scope.foundTop = false;
		$scope.previewTop = {};
		$rootScope.inPreview = false;
		$scope.state = $state;

	// sets isOpenAcc var which controls whether the accordion should be open
	// runs from accordion ng-init or on first page load
	$scope.checkOpenInit = function() {
		var currProjectId = $stateParams.projectId;
		var parentProject = $scope.resolveTop($scope.lookup(currProjectId));
		for(var i = 0; i < $scope.projects.length; i++) {
			if($scope.projects[i].children.length && $scope.projects[i]._id === parentProject._id) {
				$scope.projects[i].isOpenAcc = true;
			} else {
				$scope.projects[i].isOpenAcc = false;
			}
		}
	};

	// need to move variables and delete the function
	$scope.find = function() {
		$scope.projects = Projects.query();
		$scope.frame1 = $rootScope.frame1;
		$scope.frame2 = $rootScope.frame2;
	};
	/*
	$scope.accordian_stuff = function(project)
	{
		$location.path('projects/' + project._id);
	};
	*/
	$scope.preview_stuff = function(project)
	{
		$location.path('projects/' + project._id + '/preview');
	};
	$scope.setPreviewStatus = function(status)
	{
		$rootScope.inPreview = status;
	};
	$scope.getProjectId = function()
	{
		var full_path = $location.path();
		if (full_path.indexOf('/projects/') !== 0) return false;
		var reduced_path = full_path.replace('/projects/', '');
		if (reduced_path.indexOf('/') === -1) return reduced_path;
		return reduced_path.substring(0,reduced_path.indexOf('/'));
	};
	/*$scope.isProjectOpen = function(project)
	{
		if (!$scope.getProjectId()) return false;
		var top = $scope.resolveTop($scope.lookup($scope.getProjectId()));
		if (top._id === project._id) return true;
		return false;
	};*/
	// need to look into this function
	$scope.isCourseOpen = function(project)
	{
		if (!$scope.getProjectId()) return false;
		var top = $scope.resolveCourse($scope.lookup($scope.getProjectId()));
		if (top._id === project._id) return true;
		return false;
	};
	$scope.lookup = function(id)
	{
		var projects = $scope.projects;
		for (var i =0; i < projects.length; i++)
		{
			if (projects[i]._id === id) return projects[i];
		}
		return false;
	};
	$scope.resolveTop = function(project)
	{
		var projects = $scope.projects;
		//if ($scope.foundTop) return true;

		var current = project;
		while (current.parent !== undefined)
		{
			current = $scope.lookup(current.parent);
		}
		if (current.parent === undefined)
		{
			return current;
		}
		return false;
	};
	$scope.resolveCourse = function(project)
	{
		var projects = $scope.projects;
		var current = project;
		if (current.level === 1) return false;
		while (current.level > 2)
		{
			current = $scope.lookup(current.parent);
		}
		return current;

	};

	$scope.canView = function(project)
	{
		var topProject = $scope.resolveTop(project);
		if (topProject)
		{
			if (topProject.viewPermission === 'public') return true;
			else if ($scope.authentication.user._id === topProject.user._id) return true;
			else if (topProject.viewContributers.indexOf($scope.authentication.user.email) !== -1) return true;
			else return false;
		}
	};

	$scope.projectPage = function() {

			if (document.getElementById('view_project'))
			{
				var text = document.getElementById('view_project').innerHTML;

				if (document.getElementById('html_display'))
				{
					document.getElementById('html_display').innerHTML = text;
				}
			}

			var pathArray = $location.path().split('/');
			if(pathArray[1] !== 'projects')
				return false;
			else if(!pathArray[2])
				return false;
			else if(pathArray[2] === 'new')
				return false;
			else if(pathArray[3])
				return false;
			else
				return true;
	};
	$scope.previewInit = function() {
		$scope.previewTop = $scope.resolveTop($scope.lookup($scope.getProjectId()));
	};
	$scope.link = function($event, id) {
		$event.stopPropagation();
		$scope.state.go('home.viewProject', {projectId:id});
	};
	}

]);
<|endoftext|>


<commit_before>/**
 * @fileoverview A thin interface for the redis client
 */

var redis = require('redis');
var _ = require('underscore');
var log = require('logg').getLogger('kickq.utils.kRedis');

var kconfig = require('./config');

var kRedis = module.exports = {};

var persistentClient = null;
var clients = [];

/**
 * Creates a persistent connection to redis and provides it.
 *
 * Optionally you can require a new connection from the arguments.
 *
 * @param {boolean=} optNew get a new client.
 * @return {redis.RedisClient} A redis client.
 */
kRedis.client = function(optNew) {
  log.fine('client() :: Init. new: ' + !!optNew);

  if (!optNew && !_.isNull(persistentClient)) {
    return persistentClient;
  }

  var port = kconfig.get('redisPort');
  var host = kconfig.get('redisHost');
  var pass = kconfig.get('redisPassword');
  var opts = kconfig.get('redisOptions');
  var client;
  try {
    client = redis.createClient(port, host, opts);
  } catch(ex) {
    log.error('client() :: Failed to create redis connection. Err: ', ex);
    return null;
  }

  if ( _.isString( pass ) ) {
    client.auth( pass );
  }

  if (!optNew) {
    persistentClient = client;
  }

  log.fine('client() :: Attaching error listener...');
  client.on('error', kRedis._onRedisError);

  clients.push(client);

  return client;
};

/**
 * Handle redis errors so exception will not bubble up.
 *
 * @param  {string} err the error message
 * @protected
 */
kRedis._onRedisError = function(err) {
  log.finer('_onRedisError() :: ', err.message, err);
};

/**
 * Close all connections and reset objects.
 *
 */
kRedis.dispose = function() {
  clients.forEach(function(client){
    client.end();
  });
  clients = [];
  persistentClient = null;
};

<commit_msg>Add logging on redis client creation<commit_after>/**
 * @fileoverview A thin interface for the redis client
 */

var redis = require('redis');
var _ = require('underscore');
var log = require('logg').getLogger('kickq.utils.kRedis');

var kconfig = require('./config');

var kRedis = module.exports = {};

var persistentClient = null;
var clients = [];

/**
 * Creates a persistent connection to redis and provides it.
 *
 * Optionally you can require a new connection from the arguments.
 *
 * @param {boolean=} optNew get a new client.
 * @return {redis.RedisClient} A redis client.
 */
kRedis.client = function(optNew) {
  log.fine('client() :: Init. new: ' + !!optNew);

  if (!optNew && !_.isNull(persistentClient)) {
    return persistentClient;
  }

  var port = kconfig.get('redisPort');
  var host = kconfig.get('redisHost');
  var pass = kconfig.get('redisPassword');
  var opts = kconfig.get('redisOptions');
  var client;

  log.fine('client() :: Creating client using host, port:', host, port);
  try {
    client = redis.createClient(port, host, opts);
  } catch(ex) {
    log.error('client() :: Failed to create redis connection. Err: ', ex);
    return null;
  }

  if ( _.isString( pass ) ) {
    client.auth( pass );
  }

  if (!optNew) {
    persistentClient = client;
  }

  log.fine('client() :: Attaching error listener...');
  client.on('error', kRedis._onRedisError);

  clients.push(client);

  return client;
};

/**
 * Handle redis errors so exception will not bubble up.
 *
 * @param  {string} err the error message
 * @protected
 */
kRedis._onRedisError = function(err) {
  log.finer('_onRedisError() :: ', err.message, err);
};

/**
 * Close all connections and reset objects.
 *
 */
kRedis.dispose = function() {
  clients.forEach(function(client){
    client.end();
  });
  clients = [];
  persistentClient = null;
};

<|endoftext|>


<commit_before>module.exports = {
  'default': {
    message: 'Something is wrong with this field.'
  },
  email: {
    rule: /\S+@\S+\.\S+/,
    message: 'Wrong email format.'
  },
  required: {
    rule: required,
    message: 'Required field'
  }
};

function required(value) {
  return (value !== null && value !== '' && typeof value !== 'undefined');
}
<commit_msg>Rework default validation to new api<commit_after>module.exports = {
  'default': {
    message: 'Something is wrong with this field.'
  },
  email: {
    rule: /\S+@\S+\.\S+/,
    message: 'Wrong email format.'
  },
  required: {
    rule: required,
    message: 'Required field'
  }
};

function required(value, callback) {
  callback(value !== null && value !== '' && typeof value !== 'undefined');
}
<|endoftext|>


<commit_before>var assert = require("assert");
var path = require("path");
var Q = require("q");
var createHash = require("crypto").createHash;
var getRequiredIDs = require("install").getRequiredIDs;
var slice = Array.prototype.slice;

var BuildContext = require("./context").BuildContext;

function ModuleReader(context, resolvers, builders) {
    var self = this;
    assert.ok(self instanceof ModuleReader);
    assert.ok(context instanceof BuildContext);
    assert.ok(resolvers instanceof Array);
    assert.ok(builders instanceof Array);

    var hash = createHash("sha1").update(context.configHash + "\0");

    function hashCallbacks(salt, cbs) {
        hash.update(salt + "\0");

        cbs = cbs.concat(slice.call(arguments, 2));
        cbs.forEach(function(cb) {
            assert.strictEqual(typeof cb, "function");
            hash.update(cb + "\0");
        });

        return cbs;
    }

    resolvers = hashCallbacks("resolvers", resolvers);
    builders = hashCallbacks("builders", builders, wrapModule);

    Object.defineProperties(self, {
        context: { value: context },
        resolvers: { value: resolvers },
        builders: { value: builders },
        salt: { value: hash.digest("hex") },
        promiseCache: { value: {} }
    });
}

ModuleReader.prototype = {
    getSourceP: function(id) {
        var context = this.context;
        var copy = this.resolvers.slice(0).reverse();
        assert.ok(copy.length > 0, "no source resolvers registered");

        function tryNextResolverP() {
            var resolve = copy.pop();
            var result = resolve && resolve.call(context, id);
            var promise = Q.resolve(result);
            return result ? promise.then(function(result) {
                return result || tryNextResolverP();
            }) : promise;
        }

        return tryNextResolverP();
    },

    readModuleP: function(id) {
        var cache = this.promiseCache;
        if (cache.hasOwnProperty(id))
            return cache[id];

        // TODO Invalidate cache when files change on disk.
        return cache[id] = this.noCacheReadModuleP(id);
    },

    noCacheReadModuleP: function(id) {
        var reader = this;

        var hash = createHash("sha1")
            .update("module\0")
            .update(id + "\0")
            .update(reader.salt + "\0");

        var promise = reader.getSourceP(id).then(function(source) {
            assert.strictEqual(
                typeof source, "string",
                "unable to resolve module " + JSON.stringify(id));
            hash.update(source.length + "\0" + source);
            return source;
        });

        reader.builders.forEach(function(build) {
            promise = promise.then(function(source) {
                return build.call(reader.context, id, source);
            });
        });

        return promise.then(function(source) {
            var deps = getRequiredIDs(id, source);
            return new Module(reader, id, hash.digest("hex"), deps, source);
        });
    },

    readMultiP: function(ids) {
        return Q.all(ids.map(this.readModuleP, this));
    }
};

exports.ModuleReader = ModuleReader;

function wrapModule(id, source) {
    return "install(ID,function(require,exports,module){SRC});"
        .replace("ID", JSON.stringify(id))
        .replace("SRC", source);
}

function Module(reader, id, hash, deps, source) {
    var self = this;
    assert.ok(self instanceof Module);
    assert.ok(reader instanceof ModuleReader);

    Object.defineProperties(self, {
        reader: { value: reader },
        id: { value: id },
        hash: { value: hash },
        deps: { value: deps },
        source: { value: source }
    });
}

Module.prototype = {
    getRequiredP: function() {
        return this.reader.readMultiP(this.deps);
    },

    toString: function() {
        return "Module(" + JSON.stringify(this.id) + ")";
    },

    resolveId: function(id) {
        return path.normalize(path.join(this.id, "..", id));
    }
};
<commit_msg>Fix a small bug in tryNextResolverP.<commit_after>var assert = require("assert");
var path = require("path");
var Q = require("q");
var createHash = require("crypto").createHash;
var getRequiredIDs = require("install").getRequiredIDs;
var slice = Array.prototype.slice;

var BuildContext = require("./context").BuildContext;

function ModuleReader(context, resolvers, builders) {
    var self = this;
    assert.ok(self instanceof ModuleReader);
    assert.ok(context instanceof BuildContext);
    assert.ok(resolvers instanceof Array);
    assert.ok(builders instanceof Array);

    var hash = createHash("sha1").update(context.configHash + "\0");

    function hashCallbacks(salt, cbs) {
        hash.update(salt + "\0");

        cbs = cbs.concat(slice.call(arguments, 2));
        cbs.forEach(function(cb) {
            assert.strictEqual(typeof cb, "function");
            hash.update(cb + "\0");
        });

        return cbs;
    }

    resolvers = hashCallbacks("resolvers", resolvers);
    builders = hashCallbacks("builders", builders, wrapModule);

    Object.defineProperties(self, {
        context: { value: context },
        resolvers: { value: resolvers },
        builders: { value: builders },
        salt: { value: hash.digest("hex") },
        promiseCache: { value: {} }
    });
}

ModuleReader.prototype = {
    getSourceP: function(id) {
        var context = this.context;
        var copy = this.resolvers.slice(0).reverse();
        assert.ok(copy.length > 0, "no source resolvers registered");

        function tryNextResolverP() {
            var resolve = copy.pop();
            var result = resolve && resolve.call(context, id);
            var promise = Q.resolve(result);
            return resolve ? promise.then(function(result) {
                return result || tryNextResolverP();
            }) : promise;
        }

        return tryNextResolverP();
    },

    readModuleP: function(id) {
        var cache = this.promiseCache;
        if (cache.hasOwnProperty(id))
            return cache[id];

        // TODO Invalidate cache when files change on disk.
        return cache[id] = this.noCacheReadModuleP(id);
    },

    noCacheReadModuleP: function(id) {
        var reader = this;

        var hash = createHash("sha1")
            .update("module\0")
            .update(id + "\0")
            .update(reader.salt + "\0");

        var promise = reader.getSourceP(id).then(function(source) {
            assert.strictEqual(
                typeof source, "string",
                "unable to resolve module " + JSON.stringify(id));
            hash.update(source.length + "\0" + source);
            return source;
        });

        reader.builders.forEach(function(build) {
            promise = promise.then(function(source) {
                return build.call(reader.context, id, source);
            });
        });

        return promise.then(function(source) {
            var deps = getRequiredIDs(id, source);
            return new Module(reader, id, hash.digest("hex"), deps, source);
        });
    },

    readMultiP: function(ids) {
        return Q.all(ids.map(this.readModuleP, this));
    }
};

exports.ModuleReader = ModuleReader;

function wrapModule(id, source) {
    return "install(ID,function(require,exports,module){SRC});"
        .replace("ID", JSON.stringify(id))
        .replace("SRC", source);
}

function Module(reader, id, hash, deps, source) {
    var self = this;
    assert.ok(self instanceof Module);
    assert.ok(reader instanceof ModuleReader);

    Object.defineProperties(self, {
        reader: { value: reader },
        id: { value: id },
        hash: { value: hash },
        deps: { value: deps },
        source: { value: source }
    });
}

Module.prototype = {
    getRequiredP: function() {
        return this.reader.readMultiP(this.deps);
    },

    toString: function() {
        return "Module(" + JSON.stringify(this.id) + ")";
    },

    resolveId: function(id) {
        return path.normalize(path.join(this.id, "..", id));
    }
};
<|endoftext|>


<commit_before>var gui_ajax_boot = [
    'res/js/vendor/es6/browser-polyfill.js',
    'res/js/vendor/nodejs/boot.prod.js',
    'res/js/core/http/Connexion.js',
    'res/js/core/PydioBootstrap.js'
];

var gui_ajax_core = [
    'res/js/vendor/modernizr/modernizr.min.js',
    'res/js/core/lang/Observable.js',
    'res/js/core/lang/Logger.js',
    'res/js/core/util/LangUtils.js',
    'res/js/core/util/FuncUtils.js',
    'res/js/core/util/XMLUtils.js',
    'res/js/core/util/PathUtils.js',
    'res/js/core/util/HasherUtils.js',
    'res/js/core/util/PassUtils.js',
    'res/js/core/util/DOMUtils.js',
    'res/js/core/util/CookiesManager.js',
    'res/js/core/util/PeriodicalExecuter.js',
    'res/js/core/model/Router.js',
    'res/js/core/model/AjxpNode.js',
    'res/js/core/model/User.js',
    'res/js/core/http/ResourcesManager.js',
    'res/js/core/model/RemoteNodeProvider.js',
    'res/js/core/model/EmptyNodeProvider.js',
    'res/js/core/model/Repository.js',
    'res/js/core/http/PydioApi.js',
    'res/js/core/http/PydioUsersApi.js',
    'res/js/core/http/MetaCacheService.js',
    'res/js/core/model/Action.js',
    'res/js/core/model/Controller.js',
    'res/js/core/model/PydioDataModel.js',
    'res/js/core/model/Registry.js',
    'res/js/core/Pydio.js'
];
module.exports = function(grunt) {
    grunt.initConfig({
        env: {
            build: {
                NODE_ENV: 'production',
                DEST: 'dist'
            },
            dev: {
                NODE_ENV: 'development',
                DEST: 'tmp'
            }
        },
        copy: {
            dndpatch: {
                expand: true,
                src: 'res/js/vendor/dnd-html5-backend-patch/NativeDragSources.js',
                dest: 'node_modules/react-dnd-html5-backend/lib/',
                flatten:true
            }
        },
        uglify: {
            options: {
                mangle: false,
                compress: {
                    hoist_funs: false
                }
            },
            js: {
                files: {
                    'res/js/pydio.min.js': gui_ajax_core,
                    'res/js/pydio.boot.min.js': gui_ajax_boot
                }
            },
            nodejs: {
                files: {
                    'res/js/vendor/nodejs/bundle.prod.min.js': ['res/js/vendor/nodejs/bundle.prod.js'],
                    'res/js/vendor/nodejs/bundle.legacy.min.js': ['res/js/vendor/nodejs/bundle.legacy.prod.js']
                }
            }
        },
        babel: {
            options: {
                loose: 'all'
            },
            dist: {
                files: [
                    {
                        mode: {loose: true},
                        expand: true,
                        cwd: 'res/js/es6/',
                        src: ['**/*.es6'],
                        dest: 'res/js/core/',
                        ext: '.js'
                    }
                ]
            },
            materialui: {
                files: [
                    {
                        mode: {loose: false},
                        expand: true,
                        cwd: 'node_modules/material-ui-legacy/src/',
                        src: ['**/*.js', '**/*.jsx'],
                        dest: 'node_modules/material-ui-legacy/lib/',
                        ext: '.js'
                    }]
            },
            pydio:{
                files: [
                    {
                        expand: true,
                        cwd: 'res/js/ui/reactjs/jsx',
                        src: ['**/*.js'],
                        dest: 'res/js/ui/reactjs/build/',
                        ext: '.js'
                    }
                ]
            }
        },
        browserify: {
            dist: {
                files: {
                    'res/js/vendor/nodejs/bundle.prod.js': 'res/js/vendor/nodejs/export.js',
                    'res/js/vendor/nodejs/bundle.legacy.prod.js': 'res/js/vendor/nodejs/export.legacy.js',
                    'res/js/vendor/nodejs/boot.prod.js': 'res/js/vendor/nodejs/boot.js'
                }
            },
            ui : {
                files: {
                    'res/js/ui/reactjs/build/PydioReactUI.js':'res/js/ui/reactjs/build/ReactUI/index.js',
                    'res/js/ui/reactjs/build/PydioComponents.js':'res/js/ui/reactjs/build/Components/index.js',
                    'res/js/ui/reactjs/build/PydioWorkspaces.js':'res/js/ui/reactjs/build/Workspaces/index.js'
                }
            }
        },
        less: {
            development: {
                options: {
                    plugins: [
                        new (require('less-plugin-autoprefix'))({browsers: ["last 2 versions, > 10%"]})
                    ]
                },
                files: {
                    "res/themes/orbit/css/pydio.css": "res/themes/orbit/css/pydio.less",
                    "res/themes/material/css/pydio.css": "res/themes/material/css/pydio.less"
                }
            }
        },
        watch: {
            es6 : {
                files:[
                    'res/js/es6/*.es6',
                    'res/js/es6/**/*.es6'
                ],
                tasks:['babel:dist'],
                options:{
                    spawn:false
                }
            },
            core: {
                files: gui_ajax_core,
                tasks: ['babel:dist', 'uglify:js'],
                options: {
                    spawn: false
                }
            },
            pydio:{
                files: [
                    'res/js/ui/reactjs/jsx/**/*.js'
                ],
                tasks:['babel:pydio','browserify:ui'],
                options: {
                    spawn: false
                }
            },
            styles_orbit: {
                files: ['res/themes/orbit/css/**/*.less'],
                tasks: ['less', 'cssmin'],
                options: {
                    nospawn: true
                }
            },
            styles_material: {
                files: ['res/themes/material/css/**/*.less'],
                tasks: ['less', 'cssmin'],
                options: {
                    nospawn: true
                }
            },
            manifests: {
                files: ['../*/manifest.xml'],
                tasks: ['clean:cache']
            }
        },
        cssmin: {
            options: {
                shorthandCompacting: false,
                roundingPrecision: -1
            },
            target: {
                files: {
                    'res/themes/orbit/css/allz.css': [
                        'res/themes/orbit/css/pydio.css',
                        'res/themes/common/css/animate-custom.css',
                        'res/themes/common/css/chosen.css',
                        'res/themes/common/css/media.css'
                    ],
                    'res/themes/material/css/allz.css': [
                        'res/themes/material/css/pydio.css',
                        'res/themes/common/css/animate-custom.css',
                        'res/themes/common/css/chosen.css',
                        'res/themes/common/css/media.css'
                    ]
                }
            }
        },
        clean: {
            options: {
                force: true
            },
            cache: ['../../data/cache/plugins_*.*']
        },
        hub: {
            all: {
                options:{
                    concurrent: 80,
                    allowSelf:true
                },
                src: ['../*/Gruntfile.js'],
                tasks: ['default']
            }
        }
    });
    grunt.loadNpmTasks('grunt-env');
    grunt.loadNpmTasks('grunt-browserify');
    grunt.loadNpmTasks('grunt-babel');
    grunt.loadNpmTasks('grunt-contrib-uglify');
    grunt.loadNpmTasks('grunt-contrib-watch');
    grunt.loadNpmTasks('grunt-contrib-copy');
    grunt.loadNpmTasks('grunt-run');
    grunt.loadNpmTasks('grunt-contrib-cssmin');
    grunt.loadNpmTasks('grunt-hub');
    grunt.loadNpmTasks('assemble-less');
    grunt.loadNpmTasks('grunt-contrib-clean');
    grunt.registerTask('type:js', [
        'copy',
        'babel:dist',
        'uglify:js',
        'babel:materialui',
        'babel:pydio',
        //'env:build',
        'browserify',
        'env:dev',
        'uglify:nodejs'
    ]);
    grunt.registerTask('type:css', [
        'cssmin'
    ]);
    grunt.registerTask('default', [
        'type:js',
        'type:css'
    ]);
    grunt.registerTask('build-core', [
        'babel:dist',
        'uglify:js'
    ]);
};
<commit_msg>Gruntfile commited with env dev<commit_after>var gui_ajax_boot = [
    'res/js/vendor/es6/browser-polyfill.js',
    'res/js/vendor/nodejs/boot.prod.js',
    'res/js/core/http/Connexion.js',
    'res/js/core/PydioBootstrap.js'
];

var gui_ajax_core = [
    'res/js/vendor/modernizr/modernizr.min.js',
    'res/js/core/lang/Observable.js',
    'res/js/core/lang/Logger.js',
    'res/js/core/util/LangUtils.js',
    'res/js/core/util/FuncUtils.js',
    'res/js/core/util/XMLUtils.js',
    'res/js/core/util/PathUtils.js',
    'res/js/core/util/HasherUtils.js',
    'res/js/core/util/PassUtils.js',
    'res/js/core/util/DOMUtils.js',
    'res/js/core/util/CookiesManager.js',
    'res/js/core/util/PeriodicalExecuter.js',
    'res/js/core/model/Router.js',
    'res/js/core/model/AjxpNode.js',
    'res/js/core/model/User.js',
    'res/js/core/http/ResourcesManager.js',
    'res/js/core/model/RemoteNodeProvider.js',
    'res/js/core/model/EmptyNodeProvider.js',
    'res/js/core/model/Repository.js',
    'res/js/core/http/PydioApi.js',
    'res/js/core/http/PydioUsersApi.js',
    'res/js/core/http/MetaCacheService.js',
    'res/js/core/model/Action.js',
    'res/js/core/model/Controller.js',
    'res/js/core/model/PydioDataModel.js',
    'res/js/core/model/Registry.js',
    'res/js/core/Pydio.js'
];
module.exports = function(grunt) {
    grunt.initConfig({
        env: {
            build: {
                NODE_ENV: 'production',
                DEST: 'dist'
            },
            dev: {
                NODE_ENV: 'development',
                DEST: 'tmp'
            }
        },
        copy: {
            dndpatch: {
                expand: true,
                src: 'res/js/vendor/dnd-html5-backend-patch/NativeDragSources.js',
                dest: 'node_modules/react-dnd-html5-backend/lib/',
                flatten:true
            }
        },
        uglify: {
            options: {
                mangle: false,
                compress: {
                    hoist_funs: false
                }
            },
            js: {
                files: {
                    'res/js/pydio.min.js': gui_ajax_core,
                    'res/js/pydio.boot.min.js': gui_ajax_boot
                }
            },
            nodejs: {
                files: {
                    'res/js/vendor/nodejs/bundle.prod.min.js': ['res/js/vendor/nodejs/bundle.prod.js'],
                    'res/js/vendor/nodejs/bundle.legacy.min.js': ['res/js/vendor/nodejs/bundle.legacy.prod.js']
                }
            }
        },
        babel: {
            options: {
                loose: 'all'
            },
            dist: {
                files: [
                    {
                        mode: {loose: true},
                        expand: true,
                        cwd: 'res/js/es6/',
                        src: ['**/*.es6'],
                        dest: 'res/js/core/',
                        ext: '.js'
                    }
                ]
            },
            materialui: {
                files: [
                    {
                        mode: {loose: false},
                        expand: true,
                        cwd: 'node_modules/material-ui-legacy/src/',
                        src: ['**/*.js', '**/*.jsx'],
                        dest: 'node_modules/material-ui-legacy/lib/',
                        ext: '.js'
                    }]
            },
            pydio:{
                files: [
                    {
                        expand: true,
                        cwd: 'res/js/ui/reactjs/jsx',
                        src: ['**/*.js'],
                        dest: 'res/js/ui/reactjs/build/',
                        ext: '.js'
                    }
                ]
            }
        },
        browserify: {
            dist: {
                files: {
                    'res/js/vendor/nodejs/bundle.prod.js': 'res/js/vendor/nodejs/export.js',
                    'res/js/vendor/nodejs/bundle.legacy.prod.js': 'res/js/vendor/nodejs/export.legacy.js',
                    'res/js/vendor/nodejs/boot.prod.js': 'res/js/vendor/nodejs/boot.js'
                }
            },
            ui : {
                files: {
                    'res/js/ui/reactjs/build/PydioReactUI.js':'res/js/ui/reactjs/build/ReactUI/index.js',
                    'res/js/ui/reactjs/build/PydioComponents.js':'res/js/ui/reactjs/build/Components/index.js',
                    'res/js/ui/reactjs/build/PydioWorkspaces.js':'res/js/ui/reactjs/build/Workspaces/index.js'
                }
            }
        },
        less: {
            development: {
                options: {
                    plugins: [
                        new (require('less-plugin-autoprefix'))({browsers: ["last 2 versions, > 10%"]})
                    ]
                },
                files: {
                    "res/themes/orbit/css/pydio.css": "res/themes/orbit/css/pydio.less",
                    "res/themes/material/css/pydio.css": "res/themes/material/css/pydio.less"
                }
            }
        },
        watch: {
            es6 : {
                files:[
                    'res/js/es6/*.es6',
                    'res/js/es6/**/*.es6'
                ],
                tasks:['babel:dist'],
                options:{
                    spawn:false
                }
            },
            core: {
                files: gui_ajax_core,
                tasks: ['babel:dist', 'uglify:js'],
                options: {
                    spawn: false
                }
            },
            pydio:{
                files: [
                    'res/js/ui/reactjs/jsx/**/*.js'
                ],
                tasks:['babel:pydio','browserify:ui'],
                options: {
                    spawn: false
                }
            },
            styles_orbit: {
                files: ['res/themes/orbit/css/**/*.less'],
                tasks: ['less', 'cssmin'],
                options: {
                    nospawn: true
                }
            },
            styles_material: {
                files: ['res/themes/material/css/**/*.less'],
                tasks: ['less', 'cssmin'],
                options: {
                    nospawn: true
                }
            },
            manifests: {
                files: ['../*/manifest.xml'],
                tasks: ['clean:cache']
            }
        },
        cssmin: {
            options: {
                shorthandCompacting: false,
                roundingPrecision: -1
            },
            target: {
                files: {
                    'res/themes/orbit/css/allz.css': [
                        'res/themes/orbit/css/pydio.css',
                        'res/themes/common/css/animate-custom.css',
                        'res/themes/common/css/chosen.css',
                        'res/themes/common/css/media.css'
                    ],
                    'res/themes/material/css/allz.css': [
                        'res/themes/material/css/pydio.css',
                        'res/themes/common/css/animate-custom.css',
                        'res/themes/common/css/chosen.css',
                        'res/themes/common/css/media.css'
                    ]
                }
            }
        },
        clean: {
            options: {
                force: true
            },
            cache: ['../../data/cache/plugins_*.*']
        },
        hub: {
            all: {
                options:{
                    concurrent: 80,
                    allowSelf:true
                },
                src: ['../*/Gruntfile.js'],
                tasks: ['default']
            }
        }
    });
    grunt.loadNpmTasks('grunt-env');
    grunt.loadNpmTasks('grunt-browserify');
    grunt.loadNpmTasks('grunt-babel');
    grunt.loadNpmTasks('grunt-contrib-uglify');
    grunt.loadNpmTasks('grunt-contrib-watch');
    grunt.loadNpmTasks('grunt-contrib-copy');
    grunt.loadNpmTasks('grunt-run');
    grunt.loadNpmTasks('grunt-contrib-cssmin');
    grunt.loadNpmTasks('grunt-hub');
    grunt.loadNpmTasks('assemble-less');
    grunt.loadNpmTasks('grunt-contrib-clean');
    grunt.registerTask('type:js', [
        'copy',
        'babel:dist',
        'uglify:js',
        'babel:materialui',
        'babel:pydio',
        'env:build',
        'browserify',
        'env:dev',
        'uglify:nodejs'
    ]);
    grunt.registerTask('type:css', [
        'cssmin'
    ]);
    grunt.registerTask('default', [
        'type:js',
        'type:css'
    ]);
    grunt.registerTask('build-core', [
        'babel:dist',
        'uglify:js'
    ]);
};
<|endoftext|>


<commit_before>module.exports = function resolveAbsoluteImport(importName) {
    const values = {
        Accordion: 'react-chayns-accordion/component/Accordion.js',
        AccordionIntro: 'react-chayns-accordion/component/AccordionIntro.js',
        AmountControl: 'react-chayns-amountcontrol/component/AmountControl.js',
        AnimationWrapper: 'react-chayns-animation_wrapper/component/AnimationWrapper.js',
        Badge: 'react-chayns-badge/component/Badge.js',
        Bubble: 'react-chayns-bubble/component/Bubble.js',
        Button: 'react-chayns-button/component/Button.js',
        ChooseButton: 'react-chayns-button/component/ChooseButton.js',
        Calendar: 'react-chayns-calendar/component/Calendar.js',
        Checkbox: 'react-chayns-checkbox/component/Checkbox.js',
        HueSlider: 'react-chayns-color_picker/component/hueSlider/HueSlider.js',
        TransparencySlider: 'react-chayns-color_picker/component/transparencySlider/TransparencySlider.js',
        ColorInput: 'react-chayns-color_picker/component/colorInput/ColorInput.js',
        ColorArea: 'react-chayns-color_picker/component/colorArea/ColorArea.js',
        ColorPicker: 'react-chayns-color_picker/component/ColorPicker.js',
        ColorScheme: 'react-chayns-color_scheme/component/ColorScheme.js',
        ComboBox: 'react-chayns-combobox/component/ComboBox.js',
        ContextMenu: 'react-chayns-contextmenu/component/ContextMenu.js',
        DateInfo: 'react-chayns-dateinfo/component/DateInfo.js',
        EmojiInput: 'react-chayns-emoji_input/component/EmojiInput.js',
        ExpandableContent: 'react-chayns-expandable_content/component/ExpandableContent.js',
        FilterButton: 'react-chayns-filterbutton/component/FilterButton.js',
        FormattedInput: 'react-chayns-formatted_input/component/FormattedInput.js',
        Formatter: 'react-chayns-formatted_input/utils/Formatter.js',
        Gallery: 'react-chayns-gallery/component/Gallery.js',
        GridCalendar: 'react-chayns-gridcalendar/component/GridCalendar.js',
        Icon: 'react-chayns-icon/component/Icon.js',
        Image: 'react-chayns-gallery/component/Image.js',
        ImageContainer: 'react-chayns-gallery/component/ImageContainer.js',
        ImageAccordion: 'react-chayns-image_accordion/component/ImageAccordion.js',
        ImageAccordionGroup: 'react-chayns-image_accordion/component/ImageAccordionGroup.js',
        Input: 'react-chayns-input/component/Input.js',
        IntegerFormatter: 'react-chayns-formatted_input/utils/IntegerFormatter.js',
        List: 'react-chayns-list/component/List.js',
        ListItem: 'react-chayns-list/component/ListItem.js',
        ModeSwitch: 'react-chayns-modeswitch/component/ModeSwitch.js',
        Mode: 'react-chayns-modeswitch/component/Mode.js',
        DecimalFormatter: 'react-chayns-formatted_input/utils/DecimalFormatter.js',
        OrientationHelper: 'utils/OrientationHelper.js',
        OpeningTimes: 'react-chayns-openingtimes/component/OpeningTimes.js',
        PersonFinder: 'react-chayns-personfinder/component/PersonFinder.js',
        SimpleWrapperContext: 'react-chayns-personfinder/component/data/simpleWrapper/SimpleWrapperContext.js',
        PositionInput: 'react-chayns-position_input/component/PositionInput.js',
        PriceFormatter: 'react-chayns-formatted_input/utils/PriceFormatter.js',
        ProgressBar: 'react-chayns-progress_bar/component/ProgressBar.js',
        RadioButton: 'react-chayns-radiobutton/component/RadioButton.js',
        ReceiverInput: 'react-chayns-receiverinput/component/ReceiverInput.js',
        RfidInput: 'react-chayns-rfid_input/component/RfidInput.js',
        ScrollView: 'react-chayns-scrollview/component/ScrollView.js',
        SelectButton: 'react-chayns-selectbutton/component/SelectButton.js',
        SelectList: 'react-chayns-selectlist/component/SelectList.js',
        SelectListItem: 'react-chayns-selectlist/component/SelectItem.js',
        SetupWizard: 'react-chayns-setupwizard/component/SetupWizard.js',
        SetupWizardItem: 'react-chayns-setupwizard/component/SetupItem.js',
        withSetupWizardContext: 'react-chayns-setupwizard/component/withSetupWizardContext.js',
        SharingBar: 'react-chayns-sharingbar/component/SharingBar.js',
        SmallWaitCursor: 'react-chayns-smallwaitcursor/component/SmallWaitCursor.js',
        TagInput: 'react-chayns-tag_input/component/TagInput.js',
        TextArea: 'react-chayns-textarea/component/TextArea.js',
        TextString: 'react-chayns-textstring/component/TextString.js',
        Tooltip: 'react-chayns-tooltip/component/Tooltip.js',
        FileInput: 'react-chayns-file_input/component/FileInput.js',
        Slider: 'react-chayns-slider/component/Slider.js',
        imageUpload: 'utils/imageUpload.js',
        createLinks: 'utils/createLinks',
        removeHtml: 'utils/removeHtml',
        equalize: 'utils/equalizer',
        isTobitEmployee: 'utils/tobitEmployee',
        FORMAT_INTEGER: 'react-chayns-formatted_input/component/FormattedInput/instances/formatInteger.js',
        FORMAT_DECIMAL: 'react-chayns-formatted_input/component/FormattedInput/instances/formatDecimal.js',
        FORMAT_PRICE: 'react-chayns-formatted_input/component/FormattedInput/instances/formatPrice.js',
    };

    if (!values[importName]) {
        // eslint-disable-next-line max-len
        throw new Error(`Unable to resolve ${importName} from chayns-components. Please check the spelling. If it's not wrong please create an issue (https://github.com/TobitSoftware/chayns-components/issues).`);
    }

    return `chayns-components/lib/${values[importName]}`;
};
<commit_msg>:bug: Fix resolveAbsoluteImport<commit_after>module.exports = function resolveAbsoluteImport(importName) {
    const values = {
        Accordion: 'react-chayns-accordion/component/Accordion.js',
        AccordionIntro: 'react-chayns-accordion/component/AccordionIntro.js',
        AmountControl: 'react-chayns-amountcontrol/component/AmountControl.js',
        AnimationWrapper: 'react-chayns-animation_wrapper/component/AnimationWrapper.js',
        Badge: 'react-chayns-badge/component/Badge.js',
        Bubble: 'react-chayns-bubble/component/Bubble.js',
        Button: 'react-chayns-button/component/Button.js',
        ChooseButton: 'react-chayns-button/component/ChooseButton.js',
        Calendar: 'react-chayns-calendar/component/Calendar.js',
        Checkbox: 'react-chayns-checkbox/component/Checkbox.js',
        HueSlider: 'react-chayns-color_picker/component/hueSlider/HueSlider.js',
        TransparencySlider: 'react-chayns-color_picker/component/transparencySlider/TransparencySlider.js',
        ColorInput: 'react-chayns-color_picker/component/colorInput/ColorInput.js',
        ColorArea: 'react-chayns-color_picker/component/colorArea/ColorArea.js',
        ColorPicker: 'react-chayns-color_picker/component/ColorPicker.js',
        ColorScheme: 'react-chayns-color_scheme/component/ColorScheme.js',
        ComboBox: 'react-chayns-combobox/component/ComboBox.js',
        ContextMenu: 'react-chayns-contextmenu/component/ContextMenu.js',
        DateInfo: 'react-chayns-dateinfo/component/DateInfo.js',
        EmojiInput: 'react-chayns-emoji_input/component/EmojiInput.js',
        ExpandableContent: 'react-chayns-expandable_content/component/ExpandableContent.js',
        FilterButton: 'react-chayns-filterbutton/component/FilterButton.js',
        FormattedInput: 'react-chayns-formatted_input/component/FormattedInput.js',
        Formatter: 'react-chayns-formatted_input/utils/Formatter.js',
        Gallery: 'react-chayns-gallery/component/Gallery.js',
        GridCalendar: 'react-chayns-gridcalendar/component/GridCalendar.js',
        Icon: 'react-chayns-icon/component/Icon.js',
        Image: 'react-chayns-gallery/component/Image.js',
        ImageContainer: 'react-chayns-gallery/component/ImageContainer.js',
        ImageAccordion: 'react-chayns-image_accordion/component/ImageAccordion.js',
        ImageAccordionGroup: 'react-chayns-image_accordion/component/ImageAccordionGroup.js',
        Input: 'react-chayns-input/component/Input.js',
        IntegerFormatter: 'react-chayns-formatted_input/utils/IntegerFormatter.js',
        List: 'react-chayns-list/component/List.js',
        ListItem: 'react-chayns-list/component/ListItem.js',
        ModeSwitch: 'react-chayns-modeswitch/component/ModeSwitch.js',
        Mode: 'react-chayns-modeswitch/component/Mode.js',
        DecimalFormatter: 'react-chayns-formatted_input/utils/DecimalFormatter.js',
        OrientationHelper: 'utils/OrientationHelper.js',
        OpeningTimes: 'react-chayns-openingtimes/component/OpeningTimes.js',
        PersonFinder: 'react-chayns-personfinder/component/PersonFinder.js',
        SimpleWrapperContext: 'react-chayns-personfinder/component/data/simpleWrapper/SimpleWrapperContext.js',
        PositionInput: 'react-chayns-position_input/component/PositionInput.js',
        PriceFormatter: 'react-chayns-formatted_input/utils/PriceFormatter.js',
        ProgressBar: 'react-chayns-progress_bar/component/ProgressBar.js',
        RadioButton: 'react-chayns-radiobutton/component/RadioButton.js',
        ReceiverInput: 'react-chayns-receiverinput/component/ReceiverInput.js',
        RfidInput: 'react-chayns-rfid_input/component/RfidInput.js',
        ScrollView: 'react-chayns-scrollview/component/ScrollView.js',
        SelectButton: 'react-chayns-selectbutton/component/SelectButton.js',
        SelectList: 'react-chayns-selectlist/component/SelectList.js',
        SelectListItem: 'react-chayns-selectlist/component/SelectItem.js',
        SetupWizard: 'react-chayns-setupwizard/component/SetupWizard.js',
        SetupWizardItem: 'react-chayns-setupwizard/component/SetupItem.js',
        withSetupWizardContext: 'react-chayns-setupwizard/component/withSetupWizardContext.js',
        SharingBar: 'react-chayns-sharingbar/component/SharingBar.js',
        SmallWaitCursor: 'react-chayns-smallwaitcursor/component/SmallWaitCursor.js',
        TagInput: 'react-chayns-tag_input/component/TagInput.js',
        TextArea: 'react-chayns-textarea/component/TextArea.js',
        TextString: 'react-chayns-textstring/component/TextString.js',
        Tooltip: 'react-chayns-tooltip/component/Tooltip.js',
        FileInput: 'react-chayns-file_input/component/FileInput.js',
        Slider: 'react-chayns-slider/component/Slider.js',
        imageUpload: 'utils/imageUpload.js',
        createLinks: 'utils/createLinks.js',
        removeHtml: 'utils/removeHtml.js',
        equalize: 'utils/equalizer.js',
        isTobitEmployee: 'utils/tobitEmployee.js',
        FORMAT_INTEGER: 'react-chayns-formatted_input/utils/instances/formatInteger.js',
        FORMAT_DECIMAL: 'react-chayns-formatted_input/utils/instances/formatDecimal.js',
        FORMAT_PRICE: 'react-chayns-formatted_input/utils/instances/formatPrice.js',
    };

    if (!values[importName]) {
        // eslint-disable-next-line max-len
        throw new Error(`Unable to resolve ${importName} from chayns-components. Please check the spelling. If it's not wrong please create an issue (https://github.com/TobitSoftware/chayns-components/issues).`);
    }

    return `chayns-components/lib/${values[importName]}`;
};
<|endoftext|>