<commit_before>'use strict';

var webpack = require('webpack');
var autoprefixer = require('autoprefixer');
var HtmlWebpackPlugin = require('html-webpack-plugin');
var ExtractTextPlugin = require('extract-text-webpack-plugin');
var CopyWebpackPlugin = require('copy-webpack-plugin');
var OfflinePlugin = require('offline-plugin');

const WebpackShellPlugin = require('webpack-shell-plugin');

const PROD_DOMAIN = 'domain';
const PROD_ROOT_PATH = '/' + PROD_DOMAIN;
const PreBuildTask = `ls -l ${PROD_DOMAIN} && rm -rf  ${PROD_DOMAIN} && ls -l ${PROD_DOMAIN}`;
console.log('PreBuildTask ' + PreBuildTask);

require('url-loader');

module.exports = function makeWebpackConfig() {
  var config = {};
  config.entry = {
    app: './src/app/app.js'
  };

  config.output = {
    path: __dirname + PROD_ROOT_PATH,
    publicPath: PROD_ROOT_PATH,
    filename: '[name].[hash].js',
    chunkFilename: '[name].[hash].js'
  };

  config.devtool = 'source-map';

  config.module = {
    preLoaders: [],
    loaders: [{
      test: /\.js$/,
      loader: 'babel',
      exclude: /node_modules/
    }, {
      test: /\.css$/,
      loader: ExtractTextPlugin.extract('style', 'css?sourceMap!postcss')
    }, {
      test: /\.(png|jpg|jpeg|gif|svg|woff|woff2|ttf|eot)$/,
      loader: 'file'
    }, {
      test: /\.html$/,
      loader: 'raw'
    },
          { test: /\.woff(2)?(\?v=[0-9]\.[0-9]\.[0-9])?$/, loader: "url-loader?limit=10000&minetype=application/font-woff" },
      { test: /\.(ttf|eot|svg)(\?v=[0-9]\.[0-9]\.[0-9])?$/, loader: "file-loader" }
]
  };
  config.postcss = [
    autoprefixer({
      browsers: ['last 2 version']
    })
  ];

  config.plugins = [];

  config.plugins.push(
    new WebpackShellPlugin({
      onBuildStart: [PreBuildTask],
      onBuildEnd: [`echo "Ending "${PROD_ROOT_PATH}`]
    }),
    new HtmlWebpackPlugin({
      template: './src/public/index.prod.html',
      filename: 'index.html',
      inject: 'body'
    }),

    new ExtractTextPlugin('[name].[hash].css', {
      disable: false
    }),

    new webpack.NoErrorsPlugin(),

    new webpack.optimize.DedupePlugin(),

    new webpack.optimize.UglifyJsPlugin(),

    new CopyWebpackPlugin(
      [{from: __dirname + '/src/public'}],
      {
      ignore: [{glob: '**/*.prod.html'}]
    }),
    new OfflinePlugin({
      // All options are optional
      caches: 'all',
      scope: PROD_ROOT_PATH + '/',
      updateStrategy: 'all',
      version: 'v2',

      ServiceWorker: {
        output: 'sw.js'
      },

      AppCache: {
        directory: 'appcache/'
      }
    })
  )
  return config;
}();<commit_msg>support deployment to external directory outside of the project<commit_after>'use strict';

var webpack = require('webpack');
var autoprefixer = require('autoprefixer');
var HtmlWebpackPlugin = require('html-webpack-plugin');
var ExtractTextPlugin = require('extract-text-webpack-plugin');
var CopyWebpackPlugin = require('copy-webpack-plugin');
var OfflinePlugin = require('offline-plugin');

const WebpackShellPlugin = require('webpack-shell-plugin');

const PROD_DOMAIN = 'domain';
const PROD_ROOT_PATH = '/' + PROD_DOMAIN;
const PreBuildTask = `ls -l ${PROD_DOMAIN} && rm -rf  ${PROD_DOMAIN} && ls -l ${PROD_DOMAIN}`;
const PROD_DEPLOY_PATH = '/www';
const PostBuildTask = `cp -r ${PROD_DOMAIN} ${PROD_DEPLOY_PATH}`;

console.log('PostBuildTask ' + PostBuildTask);

require('url-loader');

module.exports = function makeWebpackConfig() {
  var config = {};
  config.entry = {
    app: './src/app/app.js'
  };

  config.output = {
    path: __dirname + PROD_ROOT_PATH,
    publicPath: PROD_ROOT_PATH,
    filename: '[name].[hash].js',
    chunkFilename: '[name].[hash].js'
  };

  config.devtool = 'source-map';

  config.module = {
    preLoaders: [],
    loaders: [{
      test: /\.js$/,
      loader: 'babel',
      exclude: /node_modules/
    }, {
      test: /\.css$/,
      loader: ExtractTextPlugin.extract('style', 'css?sourceMap!postcss')
    }, {
      test: /\.(png|jpg|jpeg|gif|svg|woff|woff2|ttf|eot)$/,
      loader: 'file'
    }, {
      test: /\.html$/,
      loader: 'raw'
    }, {
      test: /\.woff(2)?(\?v=[0-9]\.[0-9]\.[0-9])?$/,
      loader: "url-loader?limit=10000&minetype=application/font-woff"
    }, {
      test: /\.(ttf|eot|svg)(\?v=[0-9]\.[0-9]\.[0-9])?$/,
      loader: "file-loader"
    }]
  };
  config.postcss = [
    autoprefixer({
      browsers: ['last 2 version']
    })
  ];

  config.plugins = [];

  config.plugins.push(

    new WebpackShellPlugin({
      onBuildStart: [PreBuildTask],
      onBuildEnd: ['echo "endddddd" && ls -l ./domain', PostBuildTask, 'echo "endddddd222"']
    }),
    new HtmlWebpackPlugin({
      template: './src/public/index.prod.html',
      filename: 'index.html',
      inject: 'body'
    }),

    new ExtractTextPlugin('[name].[hash].css', {
      disable: false
    }),

    new webpack.NoErrorsPlugin(),

    new webpack.optimize.DedupePlugin(),

    new webpack.optimize.UglifyJsPlugin(),

    new CopyWebpackPlugin(
      [{
        from: __dirname + '/src/public'
      }], {
        ignore: [{
          glob: '**/*.prod.html'
        }]
      }),
    new OfflinePlugin({
      // All options are optional
      caches: 'all',
      scope: PROD_ROOT_PATH + '/',
      updateStrategy: 'all',
      version: 'v2',

      ServiceWorker: {
        output: 'sw.js'
      },

      AppCache: {
        directory: 'appcache/'
      }
    })
  )
  return config;
}();<|endoftext|>


<commit_before>var path = require('path');

module.exports = {
  devtool: "source-map",
  entry: [
    'webpack-dev-server/client?http://localhost:8080',
    'webpack/hot/dev-server',
    path.join(__dirname, 'src/scripts/app.jsx'),
  ],
  output: {
    path: path.join(__dirname, 'build'),
    filename: 'bundle.js',
    publicPath: '/'
  },
  resolve: {
    extensions: ['', '.js', '.jsx'],
  },
  module: {
    loaders: [
      {
        // test for both js and jsx
        test: /\.jsx?$/,

        // use babel loader with Stage 1 features
        loader: 'babel?stage=1',

        // operate only on our app directory
        include: path.join(__dirname, 'src'),
      },
    ]
  }

};<commit_msg>fixed some errors according to eslint<commit_after>var path = require('path');

module.exports = {
  devtool: 'source-map',
  entry: [
    'webpack-dev-server/client?http://localhost:8080',
    'webpack/hot/dev-server',
    path.join(__dirname, 'src/scripts/app.jsx')
  ],
  output: {
    path: path.join(__dirname, 'build'),
    filename: 'bundle.js',
    publicPath: '/'
  },
  resolve: {
    extensions: ['', '.js', '.jsx']
  },
  module: {
    loaders: [
      {
        // test for both js and jsx
        test: /\.jsx?$/,

        // use babel loader with Stage 1 features
        loader: 'babel?stage=1',

        // operate only on our app directory
        include: path.join(__dirname, 'src')
      }
    ]
  }

};
<|endoftext|>


<commit_before>/*
 * Webpack distribution configuration
 *
 * This file is set up for serving the distribution version. It will be compiled to dist/ by default
 */

var webpack = require('webpack'),
    path = require('path');
var eslintrcPath = path.resolve(__dirname, '.eslintrc');

module.exports = {
  devtool: false,
  output: {
    publicPath: './',
    path: 'dist/',
    filename: 'main.js',
    library: 'SmartBanner',
    libraryTarget: 'umd'
  },

  entry: {
    main: './src/components/SmartBanner.js'
  },

  externals: {
    'react': {
      root: 'React',
      commonjs2: 'react',
      commonjs: 'react',
      amd: 'react'
    },
    'react-dom': {
      root: 'ReactDOM',
      commonjs2: 'react-dom',
      commonjs: 'react-dom',
      amd: 'react-dom'
    }
  },

  stats: {
    colors: true,
    reasons: false
  },

  stats: {
    colors: true,
    reasons: false
  },

  plugins: [
    new webpack.DefinePlugin({
      'process.env': {
        'NODE_ENV': JSON.stringify('production')
      }
    }),
    new webpack.optimize.DedupePlugin(),
    new webpack.optimize.UglifyJsPlugin({
      compress: {
        warnings: false
      }
    }),
    new webpack.optimize.OccurenceOrderPlugin(),
    new webpack.optimize.AggressiveMergingPlugin()
  ],

  resolve: {
    extensions: ['', '.js'],
    alias: {
      'styles': __dirname + '/src/styles',
      'mixins': __dirname + '/src/mixins',
      'components': __dirname + '/src/components/'
    }
  },

  module: {
    loaders: [{
      test: /\.js$/,
      exclude: /node_modules/,
      loader: 'uglify!babel'
    }, {
      test: /\.css$/,
      loader: 'style!css'
    }, {
      test: /\.scss/,
      loader: 'style!css!sass?outputStyle=expanded'
    }, {
      test: /\.(png|jpg|woff|woff2)$/,
      loader: 'url?limit=8192'
    }]
  },

  eslint: {
    configFile: eslintrcPath
  }
};
<commit_msg>Output css setting<commit_after>/*
 * Webpack distribution configuration
 *
 * This file is set up for serving the distribution version. It will be compiled to dist/ by default
 */

var webpack = require('webpack'),
    path = require('path');
var eslintrcPath = path.resolve(__dirname, '.eslintrc');
var ExtractTextPlugin = require('extract-text-webpack-plugin');

module.exports = {
  devtool: false,
  output: {
    publicPath: './',
    path: 'dist/',
    filename: 'main.js',
    library: 'SmartBanner',
    libraryTarget: 'umd'
  },

  entry: {
    main: './src/components/SmartBanner.js'
  },

  externals: {
    'react': {
      root: 'React',
      commonjs2: 'react',
      commonjs: 'react',
      amd: 'react'
    },
    'react-dom': {
      root: 'ReactDOM',
      commonjs2: 'react-dom',
      commonjs: 'react-dom',
      amd: 'react-dom'
    }
  },

  stats: {
    colors: true,
    reasons: false
  },

  stats: {
    colors: true,
    reasons: false
  },

  plugins: [
    new webpack.DefinePlugin({
      'process.env': {
        'NODE_ENV': JSON.stringify('production')
      }
    }),
    new webpack.optimize.DedupePlugin(),
    new webpack.optimize.UglifyJsPlugin({
      compress: {
        warnings: false
      }
    }),
    new webpack.optimize.OccurenceOrderPlugin(),
    new webpack.optimize.AggressiveMergingPlugin()
  ],

  resolve: {
    extensions: ['', '.js'],
    alias: {
      'styles': __dirname + '/src/styles',
      'mixins': __dirname + '/src/mixins',
      'components': __dirname + '/src/components/'
    }
  },

  module: {
    loaders: [{
      test: /\.js$/,
      exclude: /node_modules/,
      loader: 'uglify!babel'
    }, {
      test: /\.scss/,
      loader: ExtractTextPlugin.extract('style', 'css!sass?outputStyle=expanded')
    }]
  },

  eslint: {
    configFile: eslintrcPath
  }
};
<|endoftext|>


<commit_before>var path = require('path');
var webpack = require('webpack');
var TARGET = process.env.TARGET || null;

var config = {
  entry: {
    index: './src/react-measure.js',
  },
  output: {
    path: path.join(__dirname, 'dist'),
    publicPath: 'dist/',
    filename: 'react-measure.js',
    sourceMapFilename: 'react-measure.sourcemap.js',
    library: 'Measure',
    libraryTarget: 'umd'
  },
  module: {
    loaders: [
      {test: /\.(js|jsx)/, loader: 'babel?stage=0'}
    ]
  },
  plugins: [],
  resolve: {
    extensions: ['', '.js', '.jsx']
  },
  externals: {
    'react': 'React',
    'react-dom': 'ReactDOM'
  },
};

if(TARGET === 'minify') {
  config.output.filename = 'react-measure.min.js';
  config.output.sourceMapFilename = 'react-measure.min.js';
  config.plugins.push(new webpack.optimize.UglifyJsPlugin({
    compress: {
      warnings: false
    },
    mangle: {
      except: ['React', 'ReactDOM', 'Measure']
    }
  }));
}

module.exports = config;<commit_msg>fix webpack build to not include element-resize-detector<commit_after>var path = require('path');
var webpack = require('webpack');
var TARGET = process.env.TARGET || null;

var config = {
  entry: {
    index: './src/react-measure.js',
  },
  output: {
    path: path.join(__dirname, 'dist'),
    publicPath: 'dist/',
    filename: 'react-measure.js',
    sourceMapFilename: 'react-measure.sourcemap.js',
    library: 'Measure',
    libraryTarget: 'umd'
  },
  module: {
    loaders: [
      {test: /\.(js|jsx)/, loader: 'babel?stage=0'}
    ]
  },
  plugins: [],
  resolve: {
    extensions: ['', '.js', '.jsx']
  },
  externals: {
    'react': 'React',
    'react-dom': 'ReactDOM',
    'element-resize-detector': 'createResizeDetector'
  },
};

if(TARGET === 'minify') {
  config.output.filename = 'react-measure.min.js';
  config.output.sourceMapFilename = 'react-measure.min.js';
  config.plugins.push(new webpack.optimize.UglifyJsPlugin({
    compress: {
      warnings: false
    },
    mangle: {
      except: ['React', 'ReactDOM', 'Measure', 'createResizeDetector']
    }
  }));
}

module.exports = config;
<|endoftext|>


<commit_before>const config = require('./webpack.config.js');
const webpack = require('webpack');

config.plugins.push(
  new webpack.DefinePlugin({
    "process.env": {
      "NODE_ENV": JSON.stringify("production")
    }
  })
);

config.plugins.push(
  new webpack.optimize.UglifyJsPlugin({
    comments:false,
    //added for compression
    mangle:true,
    //
    compress: {
      warnings: false,
      //added for compression
      sequences: true,
      dead_code: true,
      conditionals: true,
      booleans: true,
      unused: true,
      if_return: true,
      join_vars: true,
      drop_console: true,
      screw_ie8: true,
    }
  })
);

config.plugins.push(
  new webpack.optimize.DedupePlugin()
);
/*
config.plugins.push(
  new webpack.optimize.CommonsChunkPlugin({
      name:'vendor',
      entries:['history',
                'react',
                'react-dom',
                'react-router',
                'react-redux',
                'redux'],
      chunks:['vendor'],
      minChunks:Infinity
    })
);*/
module.exports = config;<commit_msg>trying to access the console changed value from webpack.config.prod dropconsole from true to false<commit_after>const config = require('./webpack.config.js');
const webpack = require('webpack');

config.plugins.push(
  new webpack.DefinePlugin({
    "process.env": {
      "NODE_ENV": JSON.stringify("production")
    }
  })
);

config.plugins.push(
  new webpack.optimize.UglifyJsPlugin({
    comments:false,
    //added for compression
    mangle:true,
    //
    compress: {
      warnings: false,
      //added for compression
      sequences: true,
      dead_code: true,
      conditionals: true,
      booleans: true,
      unused: true,
      if_return: true,
      join_vars: true,
      drop_console: false,
      screw_ie8: true,
    }
  })
);

config.plugins.push(
  new webpack.optimize.DedupePlugin()
);
/*
config.plugins.push(
  new webpack.optimize.CommonsChunkPlugin({
      name:'vendor',
      entries:['history',
                'react',
                'react-dom',
                'react-router',
                'react-redux',
                'redux'],
      chunks:['vendor'],
      minChunks:Infinity
    })
);*/
module.exports = config;<|endoftext|>


<commit_before>/*eslint no-undef: "error"*/

const config = require('./webpack.base.config.js')
const path = require('path')
const webpack = require('webpack')
const BundleTracker = require('webpack-bundle-tracker')

// Use webpack dev server
config.entry = {
  //dashboard: ['./assets/pages/dashboard/dashboard.jsx'],
  //dashboard: ['./assets/pages/families/families.jsx'],
  //search: ['./assets/pages/search/search.jsx'],
  case_review: ['./assets/pages/case-review/CaseReview.jsx'],
}

config.output.path = path.resolve('./assets/dist')
config.output.publicPath = '/assets/dist/'

config.plugins = [
  new webpack.DefinePlugin({
    // removes a lot of debugging code in React
    'process.env.NODE_ENV': JSON.stringify('production'),
  }),

  new webpack.optimize.OccurenceOrderPlugin(), // keeps hashes consistent between builds

  ...config.plugins,

  new BundleTracker({ filename: './webpack-stats-prod.json' }),

  new webpack.optimize.UglifyJsPlugin({
    beautify: false,
    compressor: {
      dead_code: true,
      evaluate: true,
      booleans: true,
      drop_debugger: true,
      warnings: false,
      reduce_vars: true,
      collapse_vars: true,
    },
  }),

]

config.module.loaders = [
  { test: /\.jsx$/, exclude: /node_modules/, loaders: ['babel', 'eslint-loader'] },
  ...config.module.loaders,
]

module.exports = config
<commit_msg>updated production static file path<commit_after>/*eslint no-undef: "error"*/

const config = require('./webpack.base.config.js')
const path = require('path')
const webpack = require('webpack')
const BundleTracker = require('webpack-bundle-tracker')

// Use webpack dev server
config.entry = {
  //dashboard: ['./assets/pages/dashboard/dashboard.jsx'],
  //dashboard: ['./assets/pages/families/families.jsx'],
  //search: ['./assets/pages/search/search.jsx'],
  case_review: ['./assets/pages/case-review/CaseReview.jsx'],
}

config.output.path = path.resolve('./assets/dist')
config.output.publicPath = '/static/dist/'

config.plugins = [
  new webpack.DefinePlugin({
    // removes a lot of debugging code in React
    'process.env.NODE_ENV': JSON.stringify('production'),
  }),

  new webpack.optimize.OccurenceOrderPlugin(), // keeps hashes consistent between builds

  ...config.plugins,

  new BundleTracker({ filename: './webpack-stats-prod.json' }),

  new webpack.optimize.UglifyJsPlugin({
    beautify: false,
    compressor: {
      dead_code: true,
      evaluate: true,
      booleans: true,
      drop_debugger: true,
      warnings: false,
      reduce_vars: true,
      collapse_vars: true,
    },
  }),

]

config.module.loaders = [
  { test: /\.jsx$/, exclude: /node_modules/, loaders: ['babel', 'eslint-loader'] },
  ...config.module.loaders,
]

module.exports = config
<|endoftext|>


<commit_before>require('babel-polyfill');

// Webpack config for creating the production bundle.
var path = require('path');
var webpack = require('webpack');
var CleanPlugin = require('clean-webpack-plugin');
var ExtractTextPlugin = require('extract-text-webpack-plugin');
var strip = require('strip-loader');
var purify = require("purifycss-webpack-plugin")
var projectRootPath = path.resolve(__dirname, '../');
var assetsPath = path.resolve(projectRootPath, './static/dist');
var LodashModuleReplacementPlugin = require('lodash-webpack-plugin');
// https://github.com/halt-hammerzeit/webpack-isomorphic-tools
var WebpackIsomorphicToolsPlugin = require('webpack-isomorphic-tools/plugin');
var webpackIsomorphicToolsPlugin = new WebpackIsomorphicToolsPlugin(require('./webpack-isomorphic-tools'));
var S3Plugin = require('webpack-s3-plugin');
var CompressionPlugin = require("compression-webpack-plugin");
var config = require('config');
var Visualizer = require('webpack-visualizer-plugin');

module.exports = {
  devtool: 'source-map',
  context: path.resolve(__dirname, '..'),
  entry: {
    'main': [
      // 'bootstrap-sass!./src/theme/bootstrap.config.prod.js',
      // 'font-awesome-webpack!./src/theme/font-awesome.config.prod.js',
      './src/client.js'
    ]
  },
  output: {
    path: assetsPath,
    filename: '[name]-[chunkhash].js',
    chunkFilename: '[name]-[chunkhash].js',
    publicPath: config.publicAssetPath,
    // publicPath: '/dist/'
  },
  module: {
    loaders: [
      { test: /\.json$/, loader: 'json-loader' },
      // {
      //   test: /\.less$/,
      //   loader: ExtractTextPlugin.extract('style', 'css?modules&importLoaders=3&sourceMap!autoprefixer?browsers=last 2 version!less?outputStyle=expanded&sourceMap=true&sourceMapContents=true')
      // },
      // {
      //   test: /(\.scss$|\.css$)/,
      //   loader: ExtractTextPlugin.extract('style', 'css?modules&importLoaders=3&sourceMap!autoprefixer?browsers=last 2 version!sass?outputStyle=expanded&sourceMap=true&sourceMapContents=true')
      // },
      { test: /\.jsx?$/, exclude: /node_modules/, loaders: [strip.loader('debug'), 'babel'] },
      { test: /\.woff2?(\?v=\d+\.\d+\.\d+)?$/, loader: "url?limit=10000&mimetype=application/font-woff" },
      { test: /\.ttf(\?v=\d+\.\d+\.\d+)?$/, loader: "url?limit=10000&mimetype=application/octet-stream" },
      { test: /\.eot(\?v=\d+\.\d+\.\d+)?$/, loader: "file" },
      { test: /\.svg(\?v=\d+\.\d+\.\d+)?$/, loader: "url?limit=10000&mimetype=image/svg+xml" },
      { test: webpackIsomorphicToolsPlugin.regular_expression('images'), loader: 'url-loader?limit=10240' }
    ]
  },
  progress: true,
  resolve: {
    modulesDirectories: [
      'src',
      'node_modules'
    ],
    extensions: ['', '.json', '.js', '.jsx']
  },
  plugins: [
    // new CleanPlugin([assetsPath], { root: projectRootPath }),

    // css files from the extract-text-plugin loader
    // new ExtractTextPlugin('[name]-[chunkhash].css', { allChunks: true }),
    // new purify({
    //   basePath: __dirname,
    //   paths: [
    //     'static/dist/**/*',
    //   ],
    //   purifyOptions: {
    //     minify: true,
    //     info: true,
    //   }
    // }),
    new webpack.DefinePlugin({
      'process.env': {
        NODE_ENV: '"production"'
      },
      __TEST__: false,
      __CLIENT__: true,
      __SERVER__: false,
      __DEVELOPMENT__: false,
      __DEVTOOLS__: false,
      __DLLS__: false
    }),

    // ignore dev config
    new webpack.IgnorePlugin(/\.\/dev/, /\/config$/),

    // optimizations
    new webpack.optimize.OccurrenceOrderPlugin(),
      new webpack.optimize.AggressiveMergingPlugin(),
    new webpack.optimize.DedupePlugin(),
    // new LodashModuleReplacementPlugin(),
    new webpack.optimize.UglifyJsPlugin({
      compress: {
        warnings: false,
      },
      output: {comments: false},
      comments: false
    }),
    new Visualizer(),
    new CompressionPlugin({
      asset: "[path][query]",
      algorithm: "gzip",
      test: /\.js$|\.css$|\.ttf$|\.eot$|\.svg$/,
      threshold: 10240,
      minRatio: 0.8
    }),
    new S3Plugin({
      // Only upload css and js
      include: /.*\.(css|js|woff|woff2|ttf|eot|svg|html)/,
      directory: assetsPath,
      // s3Options are required
      s3Options: {
        accessKeyId: config.awsKey,
        secretAccessKey: config.awsSecret,
      },
      s3UploadOptions: {
        Bucket: config.awsBucket,
        // ContentType: function(fileName) {
        //   console.error('fileName', fileName);
        //   if (/\.js/.test(fileName))
        //     return 'application/javascript'
        //   else if (/\.css/.test(fileName))
        //     return 'text/css'
        //   else if (/\.woff/.test(fileName))
        //     return 'application/font-woff'
        //   else if (/\.woff2/.test(fileName))
        //     return 'application/font-woff'
        //   else if (/\.ttf/.test(fileName))
        //     return 'font/ttf'
        //   else if (/\.svg/.test(fileName))
        //     return 'image/svg+xml'
        // },
        ContentEncoding: function(fileName) {
          if (/.*\.(css|js|ttf|eot|svg)/.test(fileName))
            return 'gzip'
        }
      }
    }),

    webpackIsomorphicToolsPlugin
  ]
};
<commit_msg>Added extract text...<commit_after>require('babel-polyfill');

// Webpack config for creating the production bundle.
var path = require('path');
var webpack = require('webpack');
var CleanPlugin = require('clean-webpack-plugin');
var ExtractTextPlugin = require('extract-text-webpack-plugin');
var strip = require('strip-loader');
var purify = require("purifycss-webpack-plugin")
var projectRootPath = path.resolve(__dirname, '../');
var assetsPath = path.resolve(projectRootPath, './static/dist');
var LodashModuleReplacementPlugin = require('lodash-webpack-plugin');
// https://github.com/halt-hammerzeit/webpack-isomorphic-tools
var WebpackIsomorphicToolsPlugin = require('webpack-isomorphic-tools/plugin');
var webpackIsomorphicToolsPlugin = new WebpackIsomorphicToolsPlugin(require('./webpack-isomorphic-tools'));
var S3Plugin = require('webpack-s3-plugin');
var CompressionPlugin = require("compression-webpack-plugin");
var config = require('config');
var Visualizer = require('webpack-visualizer-plugin');

module.exports = {
  devtool: 'source-map',
  context: path.resolve(__dirname, '..'),
  entry: {
    'main': [
      'bootstrap-sass!./src/theme/bootstrap.config.prod.js',
      'font-awesome-webpack!./src/theme/font-awesome.config.prod.js',
      './src/client.js'
    ]
  },
  output: {
    path: assetsPath,
    filename: '[name]-[chunkhash].js',
    chunkFilename: '[name]-[chunkhash].js',
    publicPath: config.publicAssetPath,
    // publicPath: '/dist/'
  },
  module: {
    loaders: [
      { test: /\.json$/, loader: 'json-loader' },
      {
        test: /\.less$/,
        loader: ExtractTextPlugin.extract('style', 'css?modules&importLoaders=3&sourceMap!autoprefixer?browsers=last 2 version!less?outputStyle=expanded&sourceMap=true&sourceMapContents=true')
      },
      {
        test: /(\.scss$|\.css$)/,
        loader: ExtractTextPlugin.extract('style', 'css?modules&importLoaders=3&sourceMap!autoprefixer?browsers=last 2 version!sass?outputStyle=expanded&sourceMap=true&sourceMapContents=true')
      },
      { test: /\.jsx?$/, exclude: /node_modules/, loaders: [strip.loader('debug'), 'babel'] },
      { test: /\.woff2?(\?v=\d+\.\d+\.\d+)?$/, loader: "url?limit=10000&mimetype=application/font-woff" },
      { test: /\.ttf(\?v=\d+\.\d+\.\d+)?$/, loader: "url?limit=10000&mimetype=application/octet-stream" },
      { test: /\.eot(\?v=\d+\.\d+\.\d+)?$/, loader: "file" },
      { test: /\.svg(\?v=\d+\.\d+\.\d+)?$/, loader: "url?limit=10000&mimetype=image/svg+xml" },
      { test: webpackIsomorphicToolsPlugin.regular_expression('images'), loader: 'url-loader?limit=10240' }
    ]
  },
  progress: true,
  resolve: {
    modulesDirectories: [
      'src',
      'node_modules'
    ],
    extensions: ['', '.json', '.js', '.jsx']
  },
  plugins: [
    new CleanPlugin([assetsPath], { root: projectRootPath }),

    // css files from the extract-text-plugin loader
    new ExtractTextPlugin('[name]-[chunkhash].css', { allChunks: true }),
    new purify({
      basePath: __dirname,
      paths: [
        'static/dist/**/*',
      ],
      purifyOptions: {
        minify: true,
        info: true,
      }
    }),
    new webpack.DefinePlugin({
      'process.env': {
        NODE_ENV: '"production"'
      },
      __TEST__: false,
      __CLIENT__: true,
      __SERVER__: false,
      __DEVELOPMENT__: false,
      __DEVTOOLS__: false,
      __DLLS__: false
    }),

    // ignore dev config
    new webpack.IgnorePlugin(/\.\/dev/, /\/config$/),

    // optimizations
    new webpack.optimize.OccurrenceOrderPlugin(),
      new webpack.optimize.AggressiveMergingPlugin(),
    new webpack.optimize.DedupePlugin(),
    // new LodashModuleReplacementPlugin(),
    new webpack.optimize.UglifyJsPlugin({
      compress: {
        warnings: false,
      },
      output: {comments: false},
      comments: false
    }),
    new Visualizer(),
    new CompressionPlugin({
      asset: "[path][query]",
      algorithm: "gzip",
      test: /\.js$|\.css$|\.ttf$|\.eot$|\.svg$/,
      threshold: 10240,
      minRatio: 0.8
    }),
    new S3Plugin({
      // Only upload css and js
      include: /.*\.(css|js|woff|woff2|ttf|eot|svg|html)/,
      directory: assetsPath,
      // s3Options are required
      s3Options: {
        accessKeyId: config.awsKey,
        secretAccessKey: config.awsSecret,
      },
      s3UploadOptions: {
        Bucket: config.awsBucket,
        // ContentType: function(fileName) {
        //   console.error('fileName', fileName);
        //   if (/\.js/.test(fileName))
        //     return 'application/javascript'
        //   else if (/\.css/.test(fileName))
        //     return 'text/css'
        //   else if (/\.woff/.test(fileName))
        //     return 'application/font-woff'
        //   else if (/\.woff2/.test(fileName))
        //     return 'application/font-woff'
        //   else if (/\.ttf/.test(fileName))
        //     return 'font/ttf'
        //   else if (/\.svg/.test(fileName))
        //     return 'image/svg+xml'
        // },
        ContentEncoding: function(fileName) {
          if (/.*\.(css|js|ttf|eot|svg)/.test(fileName))
            return 'gzip'
        }
      }
    }),

    webpackIsomorphicToolsPlugin
  ]
};
<|endoftext|>


<commit_before>// Webpack config for creating the production bundle.
require('babel-core/polyfill');
var path = require('path');
var webpack = require('webpack');
var CleanPlugin = require('clean-webpack-plugin');
var ExtractTextPlugin = require('extract-text-webpack-plugin');
var strip = require('strip-loader');

var relativeAssetsPath = '../static/dist';
var assetsPath = path.join(__dirname, relativeAssetsPath);

// https://github.com/halt-hammerzeit/webpack-isomorphic-tools
var WebpackIsomorphicToolsPlugin = require('webpack-isomorphic-tools/plugin');
var webpackIsomorphicToolsPlugin = new WebpackIsomorphicToolsPlugin(require('./webpack-isomorphic-tools'));

module.exports = {
  devtool: 'source-map',
  context: path.resolve(__dirname, '..'),
  entry: {
    'main': [
      // 'bootstrap-sass!./src/theme/bootstrap.config.js',
      // 'font-awesome-webpack!./src/theme/font-awesome.config.js',
      './src/client.js'
    ]
  },
  output: {
    path: assetsPath,
    filename: '[name]-[chunkhash].js',
    chunkFilename: '[name]-[chunkhash].js',
    publicPath: '/dist/'
  },
  module: {
    loaders: [
      { test: /\.js$/, exclude: /node_modules/, loaders: [strip.loader('debug'), 'babel']},
      { test: /\.json$/, loader: 'json-loader' },
      { test: /\.less$/, loader: ExtractTextPlugin.extract('style', 'css?modules&importLoaders=2&sourceMap!autoprefixer?browsers=last 2 version!less?sourceMap=true&sourceMapContents=true') },
      { test: /\.scss$/, loader: ExtractTextPlugin.extract('style', 'css?modules&importLoaders=2&sourceMap!autoprefixer?browsers=last 2 version!sass?sourceMap=true&sourceMapContents=true') },
      // { test: /\.less$/, loader: ExtractTextPlugin.extract('style', 'css?modules&importLoaders=2&sourceMap!autoprefixer?browsers=last 2 version!less?outputStyle=expanded&sourceMap=true&sourceMapContents=true') },
      // { test: /\.scss$/, loader: ExtractTextPlugin.extract('style', 'css?modules&importLoaders=2&sourceMap!autoprefixer?browsers=last 2 version!sass?outputStyle=expanded&sourceMap=true&sourceMapContents=true') },
      { test: /\.woff(\?v=\d+\.\d+\.\d+)?$/, loader: "url?limit=10000&mimetype=application/font-woff" },
      { test: /\.woff2(\?v=\d+\.\d+\.\d+)?$/, loader: "url?limit=10000&mimetype=application/font-woff" },
      { test: /\.ttf(\?v=\d+\.\d+\.\d+)?$/, loader: "url?limit=10000&mimetype=application/octet-stream" },
      { test: /\.eot(\?v=\d+\.\d+\.\d+)?$/, loader: "file" },
      { test: /\.svg(\?v=\d+\.\d+\.\d+)?$/, loader: "url?limit=10000&mimetype=image/svg+xml" },
      { test: webpackIsomorphicToolsPlugin.regular_expression('images'), loader: 'url-loader?limit=10240' }
    ]
  },
  progress: true,
  resolve: {
    modulesDirectories: [
      'src',
      'node_modules'
    ],
    extensions: ['', '.json', '.js']
  },
  plugins: [
    new CleanPlugin([relativeAssetsPath]),

    // css files from the extract-text-plugin loader
    new ExtractTextPlugin('[name]-[chunkhash].css', {allChunks: true}),
    new webpack.DefinePlugin({
      __CLIENT__: true,
      __SERVER__: false,
      __DEVELOPMENT__: false,
      __DEVTOOLS__: false
    }),

    // ignore dev config
    new webpack.IgnorePlugin(/\.\/dev/, /\/config$/),

    // set global vars
    new webpack.DefinePlugin({
      'process.env': {
        // Useful to reduce the size of client-side libraries, e.g. react
        NODE_ENV: JSON.stringify('production')
      }
    }),

    // optimizations
    new webpack.optimize.DedupePlugin(),
    new webpack.optimize.OccurenceOrderPlugin(),
    new webpack.optimize.UglifyJsPlugin({
      compress: {
          warnings: false
        }
    }),

    webpackIsomorphicToolsPlugin
  ]
};
<commit_msg>less compile prod to dev<commit_after>// Webpack config for creating the production bundle.
require('babel-core/polyfill');
var path = require('path');
var webpack = require('webpack');
var CleanPlugin = require('clean-webpack-plugin');
var ExtractTextPlugin = require('extract-text-webpack-plugin');
var strip = require('strip-loader');

var relativeAssetsPath = '../static/dist';
var assetsPath = path.join(__dirname, relativeAssetsPath);

// https://github.com/halt-hammerzeit/webpack-isomorphic-tools
var WebpackIsomorphicToolsPlugin = require('webpack-isomorphic-tools/plugin');
var webpackIsomorphicToolsPlugin = new WebpackIsomorphicToolsPlugin(require('./webpack-isomorphic-tools'));

module.exports = {
  devtool: 'source-map',
  context: path.resolve(__dirname, '..'),
  entry: {
    'main': [
      // 'bootstrap-sass!./src/theme/bootstrap.config.js',
      // 'font-awesome-webpack!./src/theme/font-awesome.config.js',
      './src/client.js'
    ]
  },
  output: {
    path: assetsPath,
    filename: '[name]-[chunkhash].js',
    chunkFilename: '[name]-[chunkhash].js',
    publicPath: '/dist/'
  },
  module: {
    loaders: [
      { test: /\.js$/, exclude: /node_modules/, loaders: [strip.loader('debug'), 'babel']},
      { test: /\.json$/, loader: 'json-loader' },
      { test: /\.less$/, loader: 'style!css?modules&importLoaders=2&sourceMap!autoprefixer?browsers=last 2 version!less?outputStyle=expanded&sourceMap' },
      // { test: /\.less$/, loader: ExtractTextPlugin.extract('style', 'css?modules&importLoaders=2&sourceMap!autoprefixer?browsers=last 2 version!less?sourceMap=true&sourceMapContents=true') },
      { test: /\.scss$/, loader: ExtractTextPlugin.extract('style', 'css?modules&importLoaders=2&sourceMap!autoprefixer?browsers=last 2 version!sass?sourceMap=true&sourceMapContents=true') },
      // { test: /\.less$/, loader: ExtractTextPlugin.extract('style', 'css?modules&importLoaders=2&sourceMap!autoprefixer?browsers=last 2 version!less?outputStyle=expanded&sourceMap=true&sourceMapContents=true') },
      // { test: /\.scss$/, loader: ExtractTextPlugin.extract('style', 'css?modules&importLoaders=2&sourceMap!autoprefixer?browsers=last 2 version!sass?outputStyle=expanded&sourceMap=true&sourceMapContents=true') },
      { test: /\.woff(\?v=\d+\.\d+\.\d+)?$/, loader: "url?limit=10000&mimetype=application/font-woff" },
      { test: /\.woff2(\?v=\d+\.\d+\.\d+)?$/, loader: "url?limit=10000&mimetype=application/font-woff" },
      { test: /\.ttf(\?v=\d+\.\d+\.\d+)?$/, loader: "url?limit=10000&mimetype=application/octet-stream" },
      { test: /\.eot(\?v=\d+\.\d+\.\d+)?$/, loader: "file" },
      { test: /\.svg(\?v=\d+\.\d+\.\d+)?$/, loader: "url?limit=10000&mimetype=image/svg+xml" },
      { test: webpackIsomorphicToolsPlugin.regular_expression('images'), loader: 'url-loader?limit=10240' }
    ]
  },
  progress: true,
  resolve: {
    modulesDirectories: [
      'src',
      'node_modules'
    ],
    extensions: ['', '.json', '.js']
  },
  plugins: [
    new CleanPlugin([relativeAssetsPath]),

    // css files from the extract-text-plugin loader
    new ExtractTextPlugin('[name]-[chunkhash].css', {allChunks: true}),
    new webpack.DefinePlugin({
      __CLIENT__: true,
      __SERVER__: false,
      __DEVELOPMENT__: false,
      __DEVTOOLS__: false
    }),

    // ignore dev config
    new webpack.IgnorePlugin(/\.\/dev/, /\/config$/),

    // set global vars
    new webpack.DefinePlugin({
      'process.env': {
        // Useful to reduce the size of client-side libraries, e.g. react
        NODE_ENV: JSON.stringify('production')
      }
    }),

    // optimizations
    new webpack.optimize.DedupePlugin(),
    new webpack.optimize.OccurenceOrderPlugin(),
    new webpack.optimize.UglifyJsPlugin({
      compress: {
          warnings: false
        }
    }),

    webpackIsomorphicToolsPlugin
  ]
};
<|endoftext|>


<commit_before>function abiejs(g){function l(a,s,b){var e="";b?(e=new Date,e.setTime(e.getTime()+864E5*b),e="; expires="+e.toGMTString()):e="";document.cookie=a+"="+s+e+"; path=/"}function q(a){a+="=";for(var b=document.cookie.split(";"),d=0;d<b.length;d++){for(var e=b[d];" "==e.charAt(0);)e=e.substring(1,e.length);if(0==e.indexOf(a))return e.substring(a.length,e.length)}return null}function b(a,c){if(!0===h.first)return!1;!1===b.firstStep&&(b.firstStep=!0,b.inc=-1*c);-1>b.inc?setTimeout(function(){"t"===a?abiejs.e.style.top=
b.inc+"px":abiejs.e.style.bottom=b.inc+"px";b.inc++;b(a,c)},20):d.firstStep=!1;return!0}function d(a,c){if(!0===h.first)return!1;!1===d.firstStep&&(d.firstStep=!0,d.dec=0);if(d.dec<c)setTimeout(function(){"t"===a?abiejs.e.style.top="-"+d.dec+"px":abiejs.e.style.bottom="-"+d.dec+"px";d.dec++;d(a,c)},10);else return b.firstStep=!1,!0}function m(a,b,c){function e(a){var b=c.apply(this,arguments);!1===b&&(a.stopPropagation(),a.preventDefault());return b}function d(){var b=c.call(a,window.event);!1===
b&&(window.event.returnValue=!1,window.event.cancelBubble=!0);return b}a.addEventListener?a.addEventListener(b,e,!1):a.attachEvent("on"+b,d)}function r(){var a=parseInt(navigator.sayswho[1],10);return"Chrome"===navigator.sayswho[0]?a<g.chrome?!1:!0:"Firefox"===navigator.sayswho[0]?a<g.firefox?!1:!0:"MSIE"===navigator.sayswho[0]?a<g.msie?!1:!0:"Safari"===navigator.sayswho[0]?a<g.safari?!1:!0:"Opera"===navigator.sayswho[0]?a<g.opera?!1:!0:!1}function k(){k.judgement=r();if(!0===k.judgement){if("string"===
typeof abiejs.d.merit){window.location=abiejs.d.mer;return}return abiejs.d.merit()}if(!1===k.judgement){if("string"===typeof abiejs.d.demerit){window.location=abiejs.d.dmer;return}return abiejs.d.demerit()}return abiejs.d.dmer()}function n(a){n.cookie=q("abiejs");if(n.cookie<abiejs.d.cookieShowLimit||!1===abiejs.d.cookie)-1!==a.indexOf("t")?(b("t",abiejs.e.height),setTimeout(function(){d("t",abiejs.e.height)},abiejs.d.showTime)):(b("b",abiejs.e.height),setTimeout(function(){d("b",abiejs.e.height)},
abiejs.d.showTime))}function h(a){m(abiejs.c,"mouseover",function(){h.first=!0;-1!==a.indexOf("t")?abiejs.e.style.top=0:abiejs.e.style.bottom=0});m(abiejs.c,"mouseout",function(){h.first=!0;-1!==a.indexOf("t")?abiejs.e.style.top="-"+abiejs.e.height+"px":abiejs.e.style.bottom="-"+abiejs.e.height+"px"});m(abiejs.e,"click",function(){k()})}function j(){if(!0===abiejs.d.cookie){var a=q("abiejs");j.expry="none"===abiejs.d.cookieExperiation?1E3:abiejs.d.cookieExperiation;null===a?l("abiejs",0,j.expry):
"none"===abiejs.d.cookieShowLimit?l("abiejs",0,j.expry):(a++,l("abiejs",a,j.expry))}}var p=abiejs,a=g;a.position||(a.position="tr");a.merit||(a.merit="http://browsehappy.com/");a.demerit||(a.demerit="http://browsehappy.com/");a.showTime||(a.showTime=5E3);a.content||(a.content="");a.meritColor||(a.meritColor="green");a.demeritColor||(a.demeritColor="red");a.cookie=a.cookie?!0:!1;a.cookieShowLimit||(a.cookieShowLimit="none");a.cookieExperiation||(a.cookieExperiation=1E4);a.flag=a.flag?!0:!1;a.chrome||
(a.chrome=27);a.firefox||(a.firefox=21);a.msie||(a.msie=9);a.safari||(a.safari=6);a.opera||(a.opera=12);p.d=a;var p=navigator.appName,a=navigator.userAgent,c,f=a.match(/(opera|chrome|safari|firefox|msie)\/?\s*(\.?\d+(\.\d+)*)/i);if(f&&null!==(c=a.match(/version\/([\.\d]+)/i)))f[2]=c[1];f=f?[f[1],f[2]]:[p,navigator.appVersion,"-?"];navigator.sayswho=f;b.firstStep=!1;d.firstStep=!1;h.first=!1;c=abiejs.d.position.toLowerCase();abiejs.c=document.createElement("div");abiejs.c.id="abie";abiejs.c.style.position=
"fixed";abiejs.c.style.display="block";document.getElementsByTagName("body")[0].appendChild(abiejs.c);abiejs.e=document.createElement("div");abiejs.e.id="abieExp";abiejs.e.style.position="absolute";abiejs.e.style.cursor="pointer";abiejs.e.innerHTML=abiejs.d.content;abiejs.c.appendChild(abiejs.e);abiejs.e.height=abiejs.d.height||abiejs.e.offsetHeight;abiejs.e.width=abiejs.d.width||abiejs.e.offsetWidth;abiejs.c.style.height=abiejs.e.height+"px";abiejs.c.style.width=abiejs.e.width+"px";abiejs.e.style.height=
abiejs.e.height+"px";abiejs.e.style.width=abiejs.e.width+"px";-1!==c.indexOf("t")?(abiejs.c.style.top="0",abiejs.e.style.top=-1*abiejs.e.height+"px"):-1!==c.indexOf("b")?(abiejs.c.style.bottom="0",abiejs.e.style.bottom=-1*abiejs.e.height+"px"):(abiejs.c.style.top="0",abiejs.e.style.top=-1*abiejs.e.height+"px");-1!==c.indexOf("r")?(abiejs.c.style.right="0",abiejs.e.style.right="0",abiejs.e.style.textAlign="right"):-1!==c.indexOf("l")?(abiejs.c.style.left="0",abiejs.e.style.left="0",abiejs.e.style.textAlign=
"left"):(abiejs.c.style.right="0",abiejs.e.style.textAlign="right");abiejs.e.style.background=!0===r()?abiejs.d.meritColor:abiejs.d.demeritColor;h(abiejs.d.position);c=abiejs.d.position;!0===abiejs.d.flag&&(-1!==c.indexOf("t")?-1!==c.indexOf("r")?(abiejs.e.style.WebkitBorderRadius="0 0 0 100%",abiejs.e.style.MozBorderRadius="0 0 0 100%",abiejs.e.style.borderRadius="0 0 0 100%"):(abiejs.e.style.WebkitBorderRadius="0 0 100% 0",abiejs.e.style.MozBorderRadius="0 0 100% 0",abiejs.e.style.borderRadius=
"0 0 100% 0"):-1!==c.indexOf("r")?(abiejs.e.style.WebkitBorderRadius="100% 0 0 0",abiejs.e.style.MozBorderRadius="100% 0 0 0",abiejs.e.style.borderRadius="100% 0 0 0"):(abiejs.e.style.WebkitBorderRadius="0 100% 0 0",abiejs.e.style.MozBorderRadius="0 100% 0 0",abiejs.e.style.borderRadius="0 100% 0 0"));j();n(abiejs.d.position)};
<commit_msg>Updated default browsers to more realistic modern browser versions<commit_after>function abiejs(g){function l(a,s,b){var e="";b?(e=new Date,e.setTime(e.getTime()+864E5*b),e="; expires="+e.toGMTString()):e="";document.cookie=a+"="+s+e+"; path=/"}function q(a){a+="=";for(var b=document.cookie.split(";"),d=0;d<b.length;d++){for(var e=b[d];" "==e.charAt(0);)e=e.substring(1,e.length);if(0==e.indexOf(a))return e.substring(a.length,e.length)}return null}function b(a,c){if(!0===h.first)return!1;!1===b.firstStep&&(b.firstStep=!0,b.inc=-1*c);-1>b.inc?setTimeout(function(){"t"===a?abiejs.e.style.top=
b.inc+"px":abiejs.e.style.bottom=b.inc+"px";b.inc++;b(a,c)},20):d.firstStep=!1;return!0}function d(a,c){if(!0===h.first)return!1;!1===d.firstStep&&(d.firstStep=!0,d.dec=0);if(d.dec<c)setTimeout(function(){"t"===a?abiejs.e.style.top="-"+d.dec+"px":abiejs.e.style.bottom="-"+d.dec+"px";d.dec++;d(a,c)},10);else return b.firstStep=!1,!0}function m(a,b,c){function e(a){var b=c.apply(this,arguments);!1===b&&(a.stopPropagation(),a.preventDefault());return b}function d(){var b=c.call(a,window.event);!1===
b&&(window.event.returnValue=!1,window.event.cancelBubble=!0);return b}a.addEventListener?a.addEventListener(b,e,!1):a.attachEvent("on"+b,d)}function r(){var a=parseInt(navigator.sayswho[1],10);return"Chrome"===navigator.sayswho[0]?a<g.chrome?!1:!0:"Firefox"===navigator.sayswho[0]?a<g.firefox?!1:!0:"MSIE"===navigator.sayswho[0]?a<g.msie?!1:!0:"Safari"===navigator.sayswho[0]?a<g.safari?!1:!0:"Opera"===navigator.sayswho[0]?a<g.opera?!1:!0:!1}function k(){k.judgement=r();if(!0===k.judgement){if("string"===
typeof abiejs.d.merit){window.location=abiejs.d.mer;return}return abiejs.d.merit()}if(!1===k.judgement){if("string"===typeof abiejs.d.demerit){window.location=abiejs.d.dmer;return}return abiejs.d.demerit()}return abiejs.d.dmer()}function n(a){n.cookie=q("abiejs");if(n.cookie<abiejs.d.cookieShowLimit||!1===abiejs.d.cookie)-1!==a.indexOf("t")?(b("t",abiejs.e.height),setTimeout(function(){d("t",abiejs.e.height)},abiejs.d.showTime)):(b("b",abiejs.e.height),setTimeout(function(){d("b",abiejs.e.height)},
abiejs.d.showTime))}function h(a){m(abiejs.c,"mouseover",function(){h.first=!0;-1!==a.indexOf("t")?abiejs.e.style.top=0:abiejs.e.style.bottom=0});m(abiejs.c,"mouseout",function(){h.first=!0;-1!==a.indexOf("t")?abiejs.e.style.top="-"+abiejs.e.height+"px":abiejs.e.style.bottom="-"+abiejs.e.height+"px"});m(abiejs.e,"click",function(){k()})}function j(){if(!0===abiejs.d.cookie){var a=q("abiejs");j.expry="none"===abiejs.d.cookieExperiation?1E3:abiejs.d.cookieExperiation;null===a?l("abiejs",0,j.expry):
"none"===abiejs.d.cookieShowLimit?l("abiejs",0,j.expry):(a++,l("abiejs",a,j.expry))}}var p=abiejs,a=g;a.position||(a.position="tr");a.merit||(a.merit="http://browsehappy.com/");a.demerit||(a.demerit="http://browsehappy.com/");a.showTime||(a.showTime=5E3);a.content||(a.content="");a.meritColor||(a.meritColor="green");a.demeritColor||(a.demeritColor="red");a.cookie=a.cookie?!0:!1;a.cookieShowLimit||(a.cookieShowLimit="none");a.cookieExperiation||(a.cookieExperiation=1E4);a.flag=a.flag?!0:!1;a.chrome||
(a.chrome=8);a.firefox||(a.firefox=6);a.msie||(a.msie=9);a.safari||(a.safari=5);a.opera||(a.opera=11);p.d=a;var p=navigator.appName,a=navigator.userAgent,c,f=a.match(/(opera|chrome|safari|firefox|msie)\/?\s*(\.?\d+(\.\d+)*)/i);if(f&&null!==(c=a.match(/version\/([\.\d]+)/i)))f[2]=c[1];f=f?[f[1],f[2]]:[p,navigator.appVersion,"-?"];navigator.sayswho=f;b.firstStep=!1;d.firstStep=!1;h.first=!1;c=abiejs.d.position.toLowerCase();abiejs.c=document.createElement("div");abiejs.c.id="abie";abiejs.c.style.position=
"fixed";abiejs.c.style.display="block";document.getElementsByTagName("body")[0].appendChild(abiejs.c);abiejs.e=document.createElement("div");abiejs.e.id="abieExp";abiejs.e.style.position="absolute";abiejs.e.style.cursor="pointer";abiejs.e.innerHTML=abiejs.d.content;abiejs.c.appendChild(abiejs.e);abiejs.e.height=abiejs.d.height||abiejs.e.offsetHeight;abiejs.e.width=abiejs.d.width||abiejs.e.offsetWidth;abiejs.c.style.height=abiejs.e.height+"px";abiejs.c.style.width=abiejs.e.width+"px";abiejs.e.style.height=
abiejs.e.height+"px";abiejs.e.style.width=abiejs.e.width+"px";-1!==c.indexOf("t")?(abiejs.c.style.top="0",abiejs.e.style.top=-1*abiejs.e.height+"px"):-1!==c.indexOf("b")?(abiejs.c.style.bottom="0",abiejs.e.style.bottom=-1*abiejs.e.height+"px"):(abiejs.c.style.top="0",abiejs.e.style.top=-1*abiejs.e.height+"px");-1!==c.indexOf("r")?(abiejs.c.style.right="0",abiejs.e.style.right="0",abiejs.e.style.textAlign="right"):-1!==c.indexOf("l")?(abiejs.c.style.left="0",abiejs.e.style.left="0",abiejs.e.style.textAlign=
"left"):(abiejs.c.style.right="0",abiejs.e.style.textAlign="right");abiejs.e.style.background=!0===r()?abiejs.d.meritColor:abiejs.d.demeritColor;h(abiejs.d.position);c=abiejs.d.position;!0===abiejs.d.flag&&(-1!==c.indexOf("t")?-1!==c.indexOf("r")?(abiejs.e.style.WebkitBorderRadius="0 0 0 100%",abiejs.e.style.MozBorderRadius="0 0 0 100%",abiejs.e.style.borderRadius="0 0 0 100%"):(abiejs.e.style.WebkitBorderRadius="0 0 100% 0",abiejs.e.style.MozBorderRadius="0 0 100% 0",abiejs.e.style.borderRadius=
"0 0 100% 0"):-1!==c.indexOf("r")?(abiejs.e.style.WebkitBorderRadius="100% 0 0 0",abiejs.e.style.MozBorderRadius="100% 0 0 0",abiejs.e.style.borderRadius="100% 0 0 0"):(abiejs.e.style.WebkitBorderRadius="0 100% 0 0",abiejs.e.style.MozBorderRadius="0 100% 0 0",abiejs.e.style.borderRadius="0 100% 0 0"));j();n(abiejs.d.position)};
<|endoftext|>


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

var days = {
  SUN: 0,
  MON: 1,
  TUE: 2,
  WED: 3,
  THU: 4,
  FRI: 5,
  SAT: 6
};

var daysInverse = _.invert(days);

function fail(str) {
  throw new Error("Invalid time string: " + str);
}

var parseTime = function parseTime(str) {
  var match, hour, min, pm;

  match = str.match(/^(\d\d?)(:\d\d)?\s*((?:A|P)M)$/i);
  if(!match || !match[1] || !match[3]) {
    fail(str);
  }

  hour = parseInt(match[1], 10);

  if(match[2]) {
    min = parseInt(match[2].replace(":",""), 10);
  } else {
    min = 0;
  }

  pm = !!match[3].match(/PM/i);

  if(pm && hour !== 12) {
    return [(hour + 12), min];
  }

  if(!pm && hour == 12) {
    return [0, min];
  }

  return [hour, min];

};

var timeToOffset = function(time) {
  return time.getHours()*100 + time.getMinutes();
};

var timeStringToOffset = function(timeString) {
  var parsed = parseTime(timeString),
      val = parsed[0]*100 + parsed[1];

  return val;
};

var is24HourString = function(timeString) {
  return timeString.match(/^24\s*(hr|hour|hours)/i);
};

/* Input format:

 {
   "Mon": "9:00AM-5:00PM",
   "Tue": "9:00AM-11:00AM,1:00PM-5:00PM",
   "Wed": "9:00AM-5:00PM",
   "Thu": "9:00AM-5:00PM",
   "Fri": "9:00AM-5:00PM",
   "Sat": "9:00AM-11:00AM",
   "Sun": "9:00AM-11:00AM"
 }

*/

var Hours = function Hours(hours){
  var processed = {};

  Object.keys(hours || {}).forEach(function(day) {
    var dayNum = days[day.toUpperCase()];
    processed[dayNum] = this.parseDay(hours[day]);
  }.bind(this));

  this.hours = processed;
};

Hours.fromData = function(data) {
  var hours = new Hours();
  hours.hours = data || {};
  return hours;
};

Hours.prototype.addDay = function(day, str) {
  var dayNum = days[day.toUpperCase()];
  this.hours[dayNum] = this.parseDay(str);
};

Hours.prototype.parseDay = function(str) {
  var intervals, interval, result = [], times = [];
  intervals = str.split(',');

  for(var idx = 0; idx < intervals.length; idx++) {
    if ( is24HourString(intervals[idx].trim()) ) {
      result.push([0,2359]);
    } else {
      interval = intervals[idx].trim().split(/\s?-\s?/);
      if(!interval[1]) { fail(str); }

      times = [ timeStringToOffset(interval[0]),
                timeStringToOffset(interval[1]) ];

      if(times[0] > 2400 || times[1] > 2400) { fail(str); }

      if(times[0] === times[1] && times[0] !== 0) { fail(str); }

      if(times[0] >= times[1] && times[1] !== 0) { fail(str); }

      result.push(times);
    }
  }

  return result;
};

/*
  mergeIntervals - take a set of open intervals and union them

  1. Flatten [[S1, E1], [S2, E2], [S3, E3]] onto a timeline.

    S1, E1, etc are all HHMM sortable integers; 1700 for 5PM.
    S1--S2--E1--E2--S3--E3

  2. Walk the timeline, opening/closing intervals at the shallowest level of nesting

    S1 - depth 0 -> 1, open interval
    S2 - depth 1 -> 2
    E1 - depth 2 -> 1
    E2 - depth 1 -> 0, close interval
    S3 - depth 0 -> 1, open interval
    E3 - depth 1 -> 0, close interval

  return merged intervals: [[S1, E2], [S3, E3]]
*/
function mergeIntervals(intervals) {
  var stack = [],
      mergedIntervals = [];

  buildTimeline(intervals).forEach(function(boundary) {
    if ( boundary.side === 'start' ) {
      stack.push(boundary);
    } else {
      if ( stack.length === 1 ) {
        mergedIntervals.push([stack.pop().time, boundary.time]);
      } else {
        stack.pop();
      }
    }
  });

  return mergedIntervals;
}

function buildTimeline(intervals) {
  var labeledBoundaries, boundaries, timeline;

  // convert intervals to labeled start/end boundary objects
  labeledBoundaries = intervals.map(function(interval) {
    return [
      { side: 'start', time: parseInt(interval[0], 10) },
      { side: 'end',   time: parseInt(interval[1], 10) }
    ];
  });

  // flatten interval boundaries to get a sortable list
  boundaries = _.flatten(labeledBoundaries);

  // sort boundaries by timestamp, generating timeline
  timeline = boundaries.sort(function(a, b) {
    return a.time - b.time;
  });

  return timeline;
}

Hours.DAY_NAMES = [
  {short: "Sun", long: "Sunday"},
  {short: "Mon", long: "Monday"},
  {short: "Tue", long: "Tuesday"},
  {short: "Wed", long: "Wednesday"},
  {short: "Thu", long: "Thursday"},
  {short: "Fri", long: "Friday"},
  {short: "Sat", long: "Saturday"}
];

Hours.SHORT_DAY_NAMES = _.map(Hours.DAY_NAMES, function(day) { return day.short; });
Hours.LONG_DAY_NAMES = _.map(Hours.DAY_NAMES, function(day) { return day.long; });

Hours.merge = function() {
  var data = {};
  Array.prototype.slice.call(arguments).forEach(function(item) {
    Object.keys(item.hours).forEach(function(day) {
      data[day] = (data[day] || []).concat(item.hours[day] || []);
    });
  });

  return Hours.fromData(data).merge();
};

Hours.prototype.merge = function() {
  var data = {};
  Object.keys(this.hours).forEach(function(day) {
    data[day] = mergeIntervals(this.hours[day]);
  }, this);

  return Hours.fromData(data);
};

function humanizeInterval(intervals) {
  if ( intervals.length === 2 &&
        intervals[0] === 0 &&
        intervals[1] === 2359 ) {
    return "24 Hours";
  }

  return intervals.map(function(time) {
    //1200 -> 12:00PM
    //1230 -> 12:30PM
    //0 -> 12:00AM
    //1400 -> 2:00PM

    var pm, hour, min;

    pm = time >= 1200;
    hour = Math.floor(time / 100);
    min = time % 100;

    if(hour > 12) {
      hour = hour - 12;
    }

    if(hour === 0) {
      hour = 12;
    }

    if(min < 10) {
      min = "0" + min;
    }

    if ( min === "00" ) {
      return hour + (pm ? "pm" : "am");
    } else {
      return [hour, ":", min, pm ? "pm" : "am"].join("");
    }
  }).join(" - ");
}

Hours.prototype.humanize = function(options) {
  var hours = this.hours,
      dayNames;

  options = options || {};
  dayNames = options.shortDayNames ? Hours.SHORT_DAY_NAMES : Hours.LONG_DAY_NAMES;

  return dayNames.map(function(dayName, index) {
    var intervals = hours[index];

    return {
      day: dayName,
      hours: intervals ? intervals.map(humanizeInterval).join(', ') : null
    };
  });
};

Hours.prototype.within = function(time) {
  var intervals, instant, parts, day;

  if(_.isDate(time)) {
    intervals = this.hours[time.getDay()];
    instant   = timeToOffset(time);
  } else {
    parts     = time.split(","),

    day       = days[parts[0].toUpperCase()],
    intervals = this.hours[day],
    instant   = timeStringToOffset(parts[1]);
  }

  return !!_(intervals).find(function(interval) {
    return (interval[0] <= instant) &&
           (interval[1] >= instant);
  });
};

Hours.prototype.serialize = function () {
  if ( !this.isEmpty() ) {
    return this.hours;
  } else {
    return null;
  }
};

Hours.prototype.isEmpty = function () {
  var count = 0;
  for(var k in this.hours) {
    if(!this.hours.hasOwnProperty(k)) { continue; }
    count++;
  }

  return (count === 0);
};

Hours.prototype.humanizeCondensed = function (options) {

  var merged = this.merge(),
      obj = merged.hours,
      dayNames;

  options = options || {};
  dayNames = options.shortDayNames ? Hours.SHORT_DAY_NAMES : Hours.LONG_DAY_NAMES;

  var condensed = Object.keys(obj).reduce(function(acc, i){
    if(!acc.length) {
      acc.push({days: [parseInt(i, 10)], intervals: obj[i]});
    } else {
      var last = acc[acc.length - 1];

      if(_.isEqual(last.intervals, obj[i])) {
        last.days.push(parseInt(i, 10));
      } else {
        acc.push({days: [parseInt(i, 10)], intervals: obj[i]});
      }
    }
    return acc;
  }, []);

  return condensed.map(function(run) {
    if(run.days.length === 1) {
      return {
        day: dayNames[run.days[0]],
        hours: _(run.intervals).map(humanizeInterval).join(", ")
      };
    } else {
      var start = Math.min.apply(Math, run.days);
      var end = Math.max.apply(Math, run.days);
      var ret = {hours: _(run.intervals).map(humanizeInterval).join(", ")};

      if ( start === 0 && end === 6 ) {
        ret.day = "Every day";
      } else {
        ret.day = [dayNames[start], dayNames[end]].join(" - ");
      }
      return ret;
    }
  });
};

module.exports = Hours;
<commit_msg>guard against falsy hours<commit_after>var _ = require('underscore');

var days = {
  SUN: 0,
  MON: 1,
  TUE: 2,
  WED: 3,
  THU: 4,
  FRI: 5,
  SAT: 6
};

var daysInverse = _.invert(days);

function fail(str) {
  throw new Error("Invalid time string: " + str);
}

var parseTime = function parseTime(str) {
  var match, hour, min, pm;

  match = str.match(/^(\d\d?)(:\d\d)?\s*((?:A|P)M)$/i);
  if(!match || !match[1] || !match[3]) {
    fail(str);
  }

  hour = parseInt(match[1], 10);

  if(match[2]) {
    min = parseInt(match[2].replace(":",""), 10);
  } else {
    min = 0;
  }

  pm = !!match[3].match(/PM/i);

  if(pm && hour !== 12) {
    return [(hour + 12), min];
  }

  if(!pm && hour == 12) {
    return [0, min];
  }

  return [hour, min];

};

var timeToOffset = function(time) {
  return time.getHours()*100 + time.getMinutes();
};

var timeStringToOffset = function(timeString) {
  var parsed = parseTime(timeString),
      val = parsed[0]*100 + parsed[1];

  return val;
};

var is24HourString = function(timeString) {
  return timeString.match(/^24\s*(hr|hour|hours)/i);
};

/* Input format:

 {
   "Mon": "9:00AM-5:00PM",
   "Tue": "9:00AM-11:00AM,1:00PM-5:00PM",
   "Wed": "9:00AM-5:00PM",
   "Thu": "9:00AM-5:00PM",
   "Fri": "9:00AM-5:00PM",
   "Sat": "9:00AM-11:00AM",
   "Sun": "9:00AM-11:00AM"
 }

*/

var Hours = function Hours(hours){
  var processed = {};

  Object.keys(hours || {}).forEach(function(day) {
    var dayNum = days[day.toUpperCase()];
    processed[dayNum] = this.parseDay(hours[day]);
  }.bind(this));

  this.hours = processed;
};

Hours.fromData = function(data) {
  var hours = new Hours();
  hours.hours = data || {};
  return hours;
};

Hours.prototype.addDay = function(day, str) {
  var dayNum = days[day.toUpperCase()];
  this.hours[dayNum] = this.parseDay(str);
};

Hours.prototype.parseDay = function(str) {
  var intervals, interval, result = [], times = [];
  intervals = str.split(',');

  for(var idx = 0; idx < intervals.length; idx++) {
    if ( is24HourString(intervals[idx].trim()) ) {
      result.push([0,2359]);
    } else {
      interval = intervals[idx].trim().split(/\s?-\s?/);
      if(!interval[1]) { fail(str); }

      times = [ timeStringToOffset(interval[0]),
                timeStringToOffset(interval[1]) ];

      if(times[0] > 2400 || times[1] > 2400) { fail(str); }

      if(times[0] === times[1] && times[0] !== 0) { fail(str); }

      if(times[0] >= times[1] && times[1] !== 0) { fail(str); }

      result.push(times);
    }
  }

  return result;
};

/*
  mergeIntervals - take a set of open intervals and union them

  1. Flatten [[S1, E1], [S2, E2], [S3, E3]] onto a timeline.

    S1, E1, etc are all HHMM sortable integers; 1700 for 5PM.
    S1--S2--E1--E2--S3--E3

  2. Walk the timeline, opening/closing intervals at the shallowest level of nesting

    S1 - depth 0 -> 1, open interval
    S2 - depth 1 -> 2
    E1 - depth 2 -> 1
    E2 - depth 1 -> 0, close interval
    S3 - depth 0 -> 1, open interval
    E3 - depth 1 -> 0, close interval

  return merged intervals: [[S1, E2], [S3, E3]]
*/
function mergeIntervals(intervals) {
  var stack = [],
      mergedIntervals = [];

  buildTimeline(intervals).forEach(function(boundary) {
    if ( boundary.side === 'start' ) {
      stack.push(boundary);
    } else {
      if ( stack.length === 1 ) {
        mergedIntervals.push([stack.pop().time, boundary.time]);
      } else {
        stack.pop();
      }
    }
  });

  return mergedIntervals;
}

function buildTimeline(intervals) {
  var labeledBoundaries, boundaries, timeline;

  // convert intervals to labeled start/end boundary objects
  labeledBoundaries = intervals.map(function(interval) {
    return [
      { side: 'start', time: parseInt(interval[0], 10) },
      { side: 'end',   time: parseInt(interval[1], 10) }
    ];
  });

  // flatten interval boundaries to get a sortable list
  boundaries = _.flatten(labeledBoundaries);

  // sort boundaries by timestamp, generating timeline
  timeline = boundaries.sort(function(a, b) {
    return a.time - b.time;
  });

  return timeline;
}

Hours.DAY_NAMES = [
  {short: "Sun", long: "Sunday"},
  {short: "Mon", long: "Monday"},
  {short: "Tue", long: "Tuesday"},
  {short: "Wed", long: "Wednesday"},
  {short: "Thu", long: "Thursday"},
  {short: "Fri", long: "Friday"},
  {short: "Sat", long: "Saturday"}
];

Hours.SHORT_DAY_NAMES = _.map(Hours.DAY_NAMES, function(day) { return day.short; });
Hours.LONG_DAY_NAMES = _.map(Hours.DAY_NAMES, function(day) { return day.long; });

Hours.merge = function() {
  var data = {};
  Array.prototype.slice.call(arguments).forEach(function(item) {
    Object.keys(item.hours || {}).forEach(function(day) {
      data[day] = (data[day] || []).concat(item.hours[day] || []);
    });
  });

  return Hours.fromData(data).merge();
};

Hours.prototype.merge = function() {
  var data = {};
  Object.keys(this.hours).forEach(function(day) {
    data[day] = mergeIntervals(this.hours[day]);
  }, this);

  return Hours.fromData(data);
};

function humanizeInterval(intervals) {
  if ( intervals.length === 2 &&
        intervals[0] === 0 &&
        intervals[1] === 2359 ) {
    return "24 Hours";
  }

  return intervals.map(function(time) {
    //1200 -> 12:00PM
    //1230 -> 12:30PM
    //0 -> 12:00AM
    //1400 -> 2:00PM

    var pm, hour, min;

    pm = time >= 1200;
    hour = Math.floor(time / 100);
    min = time % 100;

    if(hour > 12) {
      hour = hour - 12;
    }

    if(hour === 0) {
      hour = 12;
    }

    if(min < 10) {
      min = "0" + min;
    }

    if ( min === "00" ) {
      return hour + (pm ? "pm" : "am");
    } else {
      return [hour, ":", min, pm ? "pm" : "am"].join("");
    }
  }).join(" - ");
}

Hours.prototype.humanize = function(options) {
  var hours = this.hours,
      dayNames;

  options = options || {};
  dayNames = options.shortDayNames ? Hours.SHORT_DAY_NAMES : Hours.LONG_DAY_NAMES;

  return dayNames.map(function(dayName, index) {
    var intervals = hours[index];

    return {
      day: dayName,
      hours: intervals ? intervals.map(humanizeInterval).join(', ') : null
    };
  });
};

Hours.prototype.within = function(time) {
  var intervals, instant, parts, day;

  if(_.isDate(time)) {
    intervals = this.hours[time.getDay()];
    instant   = timeToOffset(time);
  } else {
    parts     = time.split(","),

    day       = days[parts[0].toUpperCase()],
    intervals = this.hours[day],
    instant   = timeStringToOffset(parts[1]);
  }

  return !!_(intervals).find(function(interval) {
    return (interval[0] <= instant) &&
           (interval[1] >= instant);
  });
};

Hours.prototype.serialize = function () {
  if ( !this.isEmpty() ) {
    return this.hours;
  } else {
    return null;
  }
};

Hours.prototype.isEmpty = function () {
  var count = 0;
  for(var k in this.hours) {
    if(!this.hours.hasOwnProperty(k)) { continue; }
    count++;
  }

  return (count === 0);
};

Hours.prototype.humanizeCondensed = function (options) {

  var merged = this.merge(),
      obj = merged.hours,
      dayNames;

  options = options || {};
  dayNames = options.shortDayNames ? Hours.SHORT_DAY_NAMES : Hours.LONG_DAY_NAMES;

  var condensed = Object.keys(obj).reduce(function(acc, i){
    if(!acc.length) {
      acc.push({days: [parseInt(i, 10)], intervals: obj[i]});
    } else {
      var last = acc[acc.length - 1];

      if(_.isEqual(last.intervals, obj[i])) {
        last.days.push(parseInt(i, 10));
      } else {
        acc.push({days: [parseInt(i, 10)], intervals: obj[i]});
      }
    }
    return acc;
  }, []);

  return condensed.map(function(run) {
    if(run.days.length === 1) {
      return {
        day: dayNames[run.days[0]],
        hours: _(run.intervals).map(humanizeInterval).join(", ")
      };
    } else {
      var start = Math.min.apply(Math, run.days);
      var end = Math.max.apply(Math, run.days);
      var ret = {hours: _(run.intervals).map(humanizeInterval).join(", ")};

      if ( start === 0 && end === 6 ) {
        ret.day = "Every day";
      } else {
        ret.day = [dayNames[start], dayNames[end]].join(" - ");
      }
      return ret;
    }
  });
};

module.exports = Hours;
<|endoftext|>


<commit_before>
var User = require('../models/user');
var Event = require('../models/event');

function invitesIndex(req, res) {
  Event.find({}).populate('_owner').populate('invites._invitees').exec( function (err, events) {

    if (err) res.status(403).send({ message: "An error occurred - Couldn't retreive invites"})

      var i=0; j=0; myInvitations=[];

    for(i;i< events.length;i++){
      for (j;j< events[i].invites.length; j++) {
        if (events[i].invites[j]._invitee == req.user.id) {
          myInvitations.push(events[i]);
          break;
        }
      }
    }
    if (myInvitations) { res.json(myInvitations) }
      else {
        res.json({ message: "Could not find any invitations", myInvitations: myInvitations })}
      });
}

function invitesCreate (req, res) {
  Event.findOne({ _owner: req.user.userId }, {}, { sort: { created_at: -1} }, function (err, event) {

    if (err) res.json( { message: "Could not invite user. An error occurred"})
    // go through the event to see if the user was already invited.
  if(event) {
    var i=0; for(i;i < event.invites.length;i++) {
      if (event.invites[i]._invitee == req.body.userId) {
        res.json( { message: "This user is already invited to this event"});
      }
    }
    event.invites.push({ _invitee: req.body.userId });
    event.save(function (err) {
      if (err) res.json({ message: "could not create invite"});
      res.json({ message: "invited user to event", event: event})
    });
    event.save();
    res.json(event);
  }
  else {
    res.json( { message: "There is no current event"})
  }
});
}

function invitesAccept (req, res) {
  Event.findById(req.body.event_id, function (err, event) {
    if (err) res.json({ message: "An error occurred. Please check your request"})
      var i=0;
    console.log(event.invites);
    for (i;i < event.invites.length;i++) {
      console.log(event.invites[i]._invitee)
      if (event.invites[i]._invitee == req.user.id) {
        event.invites[i].accepted = true;
        event.save( function (err) {
          res.json( { message: "Invite accepted for event!", event: event})
        });
      }
    }
    for (i;i < event.invites.length;i++) {
      console.log(event.invites[i]._invitee)
      if (!(event.invites[i]._invitee == req.user.id)) {
        res.json({ message: "You aren't invited to this event"});
      }
    }
  });
}

function invitesDelete (req,res) {
  Event.findById(req.body.event_id, function (err, event) {
    var i=0;
    for(i;i < event.invites.length;i++) {
      console.log(event.invites[i]._invitee);
      console.log(req.body.user_id);
      if (event.invites[i]._invitee == req.body.user_id) {
        event.invites[i].remove();
        event.save(function (error) {
          if (error) res.json({message: "could not delete"})
            res.json({ message: "Invite deleted"})
        });

      }

    }
    res.json({ message: "Could not find user"});
  }
  );
}

module.exports = {
  invitesIndex: invitesIndex,
  invitesAccept: invitesAccept,
  invitesCreate: invitesCreate,
  invitesDelete: invitesDelete
}<commit_msg>fixed apis<commit_after>
var User = require('../models/user');
var Event = require('../models/event');

function invitesIndex(req, res) {
  Event.find({}).populate('_owner').populate('invites._invitees').exec( function (err, events) {

    if (err) res.status(403).send({ message: "An error occurred - Couldn't retreive invites"})

      var i=0; j=0; myInvitations=[];

    for(i;i< events.length;i++){
      for (j;j< events[i].invites.length; j++) {
        if (events[i].invites[j]._invitee == req.user.id) {
          myInvitations.push(events[i]);
          break;
        }
      }
    }
    if (myInvitations) { res.json(myInvitations) }
      else {
        res.json({ message: "Could not find any invitations", myInvitations: myInvitations })}
      });
}

function invitesCreate (req, res) {
  Event.findOne({ _owner: req.user.userId }, {}, { sort: { created_at: -1} }, function (err, event) {

    if (err) res.json( { message: "Could not invite user. An error occurred"})
    // go through the event to see if the user was already invited.
  if(event) {
    var i=0; for(i;i < event.invites.length;i++) {
      if (event.invites[i]._invitee == req.body.userId) {
        res.json( { message: "This user is already invited to this event"});
      }
    }
    event.invites.push({ _invitee: req.body.userId });
    event.save(function (err) {
      if (err) res.json({ message: "could not create invite"});
      res.json({ message: "invited user to event", event: event})
    });
    event.save();
    res.json(event);
  }
  else {
    res.json( { message: "There is no current event"})
  }
});
}

function invitesAccept (req, res) {
  Event.findById(req.body.eventId, function (err, event) {
    if (err) res.json({ message: "An error occurred. Please check your request"})
      var i=0;
    for (i;i < event.invites.length;i++) {
      console.log(event.invites[i]._invitee)
      if (event.invites[i]._invitee == req.user.id) {
        event.invites[i].accepted = true;
        event.save( function (err) {
          res.json( { message: "Invite accepted for event!", event: event})
        });
      }
    }
    for (i;i < event.invites.length;i++) {
      console.log(event.invites[i]._invitee)
      if (!(event.invites[i]._invitee == req.user.id)) {
        res.json({ message: "You aren't invited to this event"});
      }
    }
  });
}

function invitesDelete (req,res) {
  Event.findById(req.body.eventId, function (err, event) {
    if (err) res.json({ message: "an error occoured"})
    var i=0; for(i;i < event.invites.length;i++) {
      if (event.invites[i]._invitee == req.body.userId) {
        console.log(event.invites[i])
        event.invites[i].remove();
        event.save(function (error) {
          if (error) res.json({message: "could not delete"})
          res.json({ message: "Invite deleted"})
        });

      }

    }

  res.json({ message: "Could not find event"})
  });
}

module.exports = {
  invitesIndex: invitesIndex,
  invitesAccept: invitesAccept,
  invitesCreate: invitesCreate,
  invitesDelete: invitesDelete
}<|endoftext|>


<commit_before>
// http://stackoverflow.com/a/4234006
$.ajaxSetup({beforeSend: function(xhr) {
    if (xhr.overrideMimeType)
    {
      xhr.overrideMimeType("application/json");
    }
}
});

var dataDir = "./data/";
var lineScaleFactor = 0.5;

var map = new ol.Map({target: 'map'});
var view = new ol.View( {center: [0, 0], zoom: 3, projection: 'EPSG:3857'} );
map.setView(view);

var osmSource = new ol.source.OSM("OpenCycleMap");
osmSource.setUrl("http://a.tile.opencyclemap.org/transport/{z}/{x}/{y}.png");
//osmSource.setUrl("http://a.tile.openstreetmap.org/{z}/{x}/{y}.png");
//osmSource.setUrl("https://maps.wikimedia.org/osm-intl/{z}/{x}/{y}.png");
//osmSource.setUrl("http://a.tile.stamen.com/toner/{z}/{x}/{y}.png");

var osmLayer = new ol.layer.Tile({source: osmSource});

map.addLayer(osmLayer);

var lon = 360.0;
var lat = 0.0;
view.setCenter(ol.proj.fromLonLat([lon, lat]));

var plotTypesMonthsLayers = {};

addContours('precipitation', 1);  // initial contourd of January

function addContours(dateType, monthNr)
{
    $.getJSON(dataDir + "contour_" + dateType + "_" + monthNr + ".json", function(json) {
        var contours = json.contours;
        var contourLayers = createContoursLayer(contours, dateType);
        if ( !(dateType in plotTypesMonthsLayers)) {
            plotTypesMonthsLayers[dateType] = {};
        }
        plotTypesMonthsLayers[dateType][monthNr] = contourLayers;
    });
};

function getLineWidth() {
    return Math.pow(view.getZoom(), 1.2)  * lineScaleFactor;
};

function createContoursLayer(contours, name) {
    console.log('create new contour layers');
    console.log(contours.length + ' contours');
    var contourLayers = [];

    // each contour can have multiple (including zero) paths.
    for (var k = 0; k < contours.length; ++k)
    {
        var paths = contours[k].paths;
        for (var j = 0; j < paths.length; ++j)
        {
            var markers = [];
            for (var i = 0; i < paths[j].x.length; ++i)
            {
                var lon = paths[j].x[i];
                var lat = -paths[j].y[i];
                var lonLat = [lon, lat];
                markers.push(ol.proj.fromLonLat(lonLat));
            }

            var color = [paths[j].linecolor[0]*255, paths[j].linecolor[1]*255, paths[j].linecolor[2]*255, 0.8];

            var lineStyle = new ol.style.Style({
                stroke: new ol.style.Stroke({
                    color: color,
                    width: getLineWidth()
                })
            });

            var layerLines = new ol.layer.Vector({
                source: new ol.source.Vector({
                    features: [new ol.Feature({
                        geometry: new ol.geom.LineString(markers, 'XY'),
                        name: paths[j].label
                    })]
                }),
                style: lineStyle
            });

            contourLayers.push(layerLines);
            map.addLayer(layerLines);
        }
    }

    return contourLayers;
}

map.addControl(new ol.control.FullScreen());

// Tooltip

var info = $('#info');

var displayFeatureInfo = function(pixel) {
  info.css({
    left: (pixel[0] + 10) + 'px',
    top: (pixel[1] - 50) + 'px'
  });

  var feature = map.forEachFeatureAtPixel(pixel, function(feature, layer) {
    return feature;
  });

  if (feature) {
    info.text(feature.get('name'));
    info.show();
  } else {
    info.hide();
  }
};

map.on('pointermove', function(evt) {
  if (evt.dragging) {
    info.hide();
    return;
  }
  displayFeatureInfo(map.getEventPixel(evt.originalEvent));
});

// Select features

//var select = new ol.interaction.Select({
//    condition: ol.events.condition.click
//});
//
//select.on('select', function(evt) {
//    for (var i = 0; i < contourLayers.length; ++i)
//    {
//        var removedLayer = map.removeLayer(contourLayers[i]);
//    }
//    contourLayers.length = 0;
//    addContours(1);
//});

//map.addInteraction(select);

var months = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec", "Jan"];

$(function() {
    $("#month-slider").slider({
      orientation: "horizontal",
      range: "min",
      min: 0,
      max: 12,
      value: 0,
      slide: sliderChanged,
      change: sliderChanged
    })
    .slider("pips", {
        rest: "label",
        labels: months
    })
//    .slider("float");
});

var hideAllContours = function() {
    console.log('hide all contours');
    for (type in plotTypesMonthsLayers) {
        for (month in plotTypesMonthsLayers[type]) {
            for (var i = 0; i < plotTypesMonthsLayers[type][month].length; ++i) {
                plotTypesMonthsLayers[type][month][i].setVisible(false);
            }
        }
    }
};

var showOrCreateContour = function(monthNr) {
    console.log("showOrCreateContour");
    hideAllContours();
    var selectedType = getSelectedType();
    if ( !plotExists(selectedType, monthNr) ) {
        addContours(selectedType, monthNr);
    }
    else {
        var monthLayers = plotTypesMonthsLayers[selectedType][monthNr];
        for (var i = 0; i < monthLayers.length; ++i) {
            monthLayers[i].setVisible(true);
        }
    }
};

var sliderChanged = function() {
    var monthNr = $("#month-slider").slider("value") + 1;
    if (monthNr == 13) {
        $("#month-slider").slider("value", 0);
        return;
    }
    console.log("slider changed to: " + monthNr);
    showOrCreateContour(monthNr);
};

var intervalID = 0;

var toggleAnimation = function() {
    var playButton = document.getElementById('animate-button');
    var selectedType = getSelectedType();
    if (playButton.innerHTML == "Animate") {
        for (var i = 1; i < 13; ++i) {
            if ( !plotExists(selectedType, i) ) {
                addContours(selectedType, i);
            };
        };
        playButton.innerHTML = "Stop";
        intervalID = window.setInterval(playAnimation, 800);
    }
    else {
        window.clearInterval(intervalID);
        playButton.innerHTML = "Animate";
    }
};

var stopAnimation = function() {
    window.clearInterval(intervalID);
};

var playAnimation = function() {
    var monthNr = $("#month-slider").slider("value");
    $("#month-slider").slider("value", monthNr+1);
};

document.getElementById("animate-button").onclick = toggleAnimation;

var updateMap = function() {
    hideAllContours();
};

var getSelectedType = function() {
    return document.getElementById("select-type").value;
};

var typeChanged = function() {
//    alert('type changed');
    var selection = getSelectedType()
    console.log(selection);
    sliderChanged();
};

document.getElementById("select-type").onchange = typeChanged;

var plotExists = function(typeName, monthNr) {
    var exists = (typeName in plotTypesMonthsLayers) && (plotTypesMonthsLayers[typeName].hasOwnProperty(monthNr));
    return exists;
};

map.on("moveend", function() {
    for (type in plotTypesMonthsLayers) {
        for (month in plotTypesMonthsLayers[type]) {
            for (var i = 0; i < plotTypesMonthsLayers[type][month].length; ++i) {
                var oldStyle = plotTypesMonthsLayers[type][month][i].getStyle();
                oldStyle.getStroke().setWidth(getLineWidth());
                plotTypesMonthsLayers[type][month][i].setStyle(oldStyle);
            }
        }
    }
});<commit_msg>Show contour plot as image overlay on map<commit_after>
// http://stackoverflow.com/a/4234006
$.ajaxSetup({beforeSend: function(xhr) {
    if (xhr.overrideMimeType)
    {
      xhr.overrideMimeType("application/json");
    }
}
});

var dataDir = "./data/";
var lineScaleFactor = 0.5;

var map = new ol.Map({target: 'map'});
var view = new ol.View( {center: [0, 0], zoom: 3, projection: 'EPSG:3857'} );
map.setView(view);

var osmSource = new ol.source.OSM("OpenCycleMap");
osmSource.setUrl("http://a.tile.opencyclemap.org/transport/{z}/{x}/{y}.png");
//osmSource.setUrl("http://a.tile.openstreetmap.org/{z}/{x}/{y}.png");
//osmSource.setUrl("https://maps.wikimedia.org/osm-intl/{z}/{x}/{y}.png");
//osmSource.setUrl("http://a.tile.stamen.com/toner/{z}/{x}/{y}.png");

var osmLayer = new ol.layer.Tile({source: osmSource});

map.addLayer(osmLayer);

var lon = 0.0;
var lat = 40.0;
view.setCenter(ol.proj.fromLonLat([lon, lat]));

var plotTypesMonthsLayers = {};

addContours('precipitation', 1);  // initial contour of January

var imageLayer = new ol.layer.Image({
    source: new ol.source.ImageStatic({
        url: '/climatemaps/website/data/contour_precipitation_1.png',
        projection: map.getView().getProjection(),
        imageExtent: ol.extent.applyTransform([-180, -85, 180, 85], ol.proj.getTransform("EPSG:4326", "EPSG:3857")),
    }),
    opacity: 0.5,
});

map.addLayer(imageLayer);

function addContours(dateType, monthNr)
{
    $.getJSON(dataDir + "contour_" + dateType + "_" + monthNr + ".json", function(json) {
        var contours = json.contours;
        var contourLayers = createContoursLayer(contours, dateType);
        if ( !(dateType in plotTypesMonthsLayers)) {
            plotTypesMonthsLayers[dateType] = {};
        }
        plotTypesMonthsLayers[dateType][monthNr] = contourLayers;
    });
};

function getLineWidth() {
    return Math.pow(view.getZoom(), 1.2)  * lineScaleFactor;
};

function createContoursLayer(contours, name) {
    console.log('create new contour layers');
    console.log(contours.length + ' contours');
    var contourLayers = [];

    // each contour can have multiple (including zero) paths.
    for (var k = 0; k < contours.length; ++k)
    {
        var paths = contours[k].paths;
        for (var j = 0; j < paths.length; ++j)
        {
            var markers = [];
            for (var i = 0; i < paths[j].x.length; ++i)
            {
                var lon = paths[j].x[i];
                var lat = paths[j].y[i];
                var lonLat = [lon, lat];
                markers.push(ol.proj.fromLonLat(lonLat));
            }

            var color = [paths[j].linecolor[0]*255, paths[j].linecolor[1]*255, paths[j].linecolor[2]*255, 1.0];

            var lineStyle = new ol.style.Style({
                stroke: new ol.style.Stroke({
                    color: color,
                    width: getLineWidth()
                })
            });

            var layerLines = new ol.layer.Vector({
                source: new ol.source.Vector({
                    features: [new ol.Feature({
                        geometry: new ol.geom.LineString(markers, 'XY'),
                        name: paths[j].label
                    })],
                    wrapX: false
                }),
                style: lineStyle
            });

            contourLayers.push(layerLines);
            map.addLayer(layerLines);
        }
    }

    return contourLayers;
}

map.addControl(new ol.control.FullScreen());

// Tooltip

var info = $('#info');

var displayFeatureInfo = function(pixel) {
  info.css({
    left: (pixel[0] + 10) + 'px',
    top: (pixel[1] - 50) + 'px'
  });

  var feature = map.forEachFeatureAtPixel(pixel, function(feature, layer) {
    return feature;
  });

  if (feature) {
    info.text(feature.get('name'));
    info.show();
  } else {
    info.hide();
  }
};

map.on('pointermove', function(evt) {
  if (evt.dragging) {
    info.hide();
    return;
  }
  displayFeatureInfo(map.getEventPixel(evt.originalEvent));
});

// Select features

//var select = new ol.interaction.Select({
//    condition: ol.events.condition.click
//});
//
//select.on('select', function(evt) {
//    for (var i = 0; i < contourLayers.length; ++i)
//    {
//        var removedLayer = map.removeLayer(contourLayers[i]);
//    }
//    contourLayers.length = 0;
//    addContours(1);
//});

//map.addInteraction(select);

var months = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec", "Jan"];

$(function() {
    $("#month-slider").slider({
      orientation: "horizontal",
      range: "min",
      min: 0,
      max: 12,
      value: 0,
      slide: sliderChanged,
      change: sliderChanged
    })
    .slider("pips", {
        rest: "label",
        labels: months
    })
//    .slider("float");
});

var hideAllContours = function() {
    console.log('hide all contours');
    for (type in plotTypesMonthsLayers) {
        for (month in plotTypesMonthsLayers[type]) {
            for (var i = 0; i < plotTypesMonthsLayers[type][month].length; ++i) {
                plotTypesMonthsLayers[type][month][i].setVisible(false);
            }
        }
    }
};

var showOrCreateContour = function(monthNr) {
    console.log("showOrCreateContour");
    hideAllContours();
    var selectedType = getSelectedType();
    if ( !plotExists(selectedType, monthNr) ) {
        addContours(selectedType, monthNr);
    }
    else {
        var monthLayers = plotTypesMonthsLayers[selectedType][monthNr];
        for (var i = 0; i < monthLayers.length; ++i) {
            monthLayers[i].setVisible(true);
        }
    }
};

var sliderChanged = function() {
    var monthNr = $("#month-slider").slider("value") + 1;
    if (monthNr == 13) {
        $("#month-slider").slider("value", 0);
        return;
    }
    console.log("slider changed to: " + monthNr);
    showOrCreateContour(monthNr);
};

var intervalID = 0;

var toggleAnimation = function() {
    var playButton = document.getElementById('animate-button');
    var selectedType = getSelectedType();
    if (playButton.innerHTML == "Animate") {
        for (var i = 1; i < 13; ++i) {
            if ( !plotExists(selectedType, i) ) {
                addContours(selectedType, i);
            };
        };
        playButton.innerHTML = "Stop";
        intervalID = window.setInterval(playAnimation, 800);
    }
    else {
        window.clearInterval(intervalID);
        playButton.innerHTML = "Animate";
    }
};

var stopAnimation = function() {
    window.clearInterval(intervalID);
};

var playAnimation = function() {
    var monthNr = $("#month-slider").slider("value");
    $("#month-slider").slider("value", monthNr+1);
};

document.getElementById("animate-button").onclick = toggleAnimation;

var updateMap = function() {
    hideAllContours();
};

var getSelectedType = function() {
    return document.getElementById("select-type").value;
};

var typeChanged = function() {
//    alert('type changed');
    var selection = getSelectedType()
    console.log(selection);
    sliderChanged();
};

document.getElementById("select-type").onchange = typeChanged;

var plotExists = function(typeName, monthNr) {
    var exists = (typeName in plotTypesMonthsLayers) && (plotTypesMonthsLayers[typeName].hasOwnProperty(monthNr));
    return exists;
};

map.on("moveend", function() {
    for (type in plotTypesMonthsLayers) {
        for (month in plotTypesMonthsLayers[type]) {
            for (var i = 0; i < plotTypesMonthsLayers[type][month].length; ++i) {
                var oldStyle = plotTypesMonthsLayers[type][month][i].getStyle();
                oldStyle.getStroke().setWidth(getLineWidth());
                plotTypesMonthsLayers[type][month][i].setStyle(oldStyle);
            }
        }
    }
});<|endoftext|>


<commit_before>/**
 * Copyright (c) 2017-present, Facebook, Inc.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 */

const React = require('react');

class Footer extends React.Component {
  docUrl(doc, language) {
    const baseUrl = this.props.config.baseUrl;
    return `${baseUrl}docs/${language ? `${language}/` : ''}${doc}`;
  }

  pageUrl(doc, language) {
    const baseUrl = this.props.config.baseUrl;
    return baseUrl + (language ? `${language}/` : '') + doc;
  }

  render() {
    return (

            {this.props.config.footerIcon && (

            )}

Docs

              Getting Started

              Securing Unleash

              API Reference

Community

              User Showcase

              Slack community

              Unleash-hosted.com

              Twitter

More

            GitHub

              Star

    );
  }
}

module.exports = Footer;
<commit_msg>fix: documentation footer<commit_after>/**
 * Copyright (c) 2017-present, Facebook, Inc.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 */

const React = require('react');

class Footer extends React.Component {
  docUrl(doc, language) {
    const baseUrl = this.props.config.baseUrl;
    return `${baseUrl}docs/${language ? `${language}/` : ''}${doc}`;
  }

  pageUrl(doc, language) {
    const baseUrl = this.props.config.baseUrl;
    return baseUrl + (language ? `${language}/` : '') + doc;
  }

  render() {
    return (

            {this.props.config.footerIcon && (

            )}

Docs

              Getting Started

              Securing Unleash

              API Reference

Community

              User Showcase

              Slack community

              Unleash-hosted.com

              Twitter

More

            GitHub

              Star

    );
  }
}

module.exports = Footer;
<|endoftext|>


<commit_before>"use strict";

const React = require("react");
const PropTypes = require("prop-types");

const GithubButton = props => (

    Star

);

GithubButton.propTypes = {
  config: PropTypes.object
};

class Footer extends React.Component {
  url(path) {
    const language = this.props.language || "en";
    return `${this.props.config.baseUrl}docs/${language}${path}`;
  }

  usersUrl() {
    const language = this.props.language || "en";
    return `${this.props.config.baseUrl}${language}/users`;
  }

  render() {
    return (

Docs

            About
            Usage

Community

            User Showcase

              Stack Overflow

            Chat on Gitter

              @PrettierCode on Twitter

            <object
              type="image/svg+xml"
              data="https://img.shields.io/twitter/follow/prettiercode.svg?label=Follow+Prettier&style=social"
            >

            </object>

More

            Blog
            GitHub
            Issues
            <GithubButton config={this.props.config} />

    );
  }
}

Footer.propTypes = {
  language: PropTypes.string,
  config: PropTypes.object
};

module.exports = Footer;
<commit_msg>Add a Netlify badge to the footer (#7289)<commit_after>"use strict";

const React = require("react");
const PropTypes = require("prop-types");

const GithubButton = props => (

    Star

);

GithubButton.propTypes = {
  config: PropTypes.object
};

class Footer extends React.Component {
  url(path) {
    const language = this.props.language || "en";
    return `${this.props.config.baseUrl}docs/${language}${path}`;
  }

  usersUrl() {
    const language = this.props.language || "en";
    return `${this.props.config.baseUrl}${language}/users`;
  }

  render() {
    return (

Docs

            About
            Usage

Community

            User Showcase

              Stack Overflow

            Chat on Gitter

              @PrettierCode on Twitter

            <object
              type="image/svg+xml"
              data="https://img.shields.io/twitter/follow/prettiercode.svg?label=Follow+Prettier&style=social"
            >

            </object>

More

            Blog
            GitHub
            Issues
            <GithubButton config={this.props.config} />

    );
  }
}

Footer.propTypes = {
  language: PropTypes.string,
  config: PropTypes.object
};

module.exports = Footer;
<|endoftext|>


<commit_before>/**
 * Copyright (c) 2017-present, Facebook, Inc.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 */

const React = require("react")

class Footer extends React.Component {
    docUrl(doc, language) {
        const baseUrl = this.props.config.baseUrl
        const docsUrl = this.props.config.docsUrl
        const docsPart = `${docsUrl ? `${docsUrl}/` : ""}`
        const langPart = `${language ? `${language}/` : ""}`
        return `${baseUrl}${docsPart}${langPart}${doc}`
    }

    pageUrl(doc, language) {
        const baseUrl = this.props.config.baseUrl
        return baseUrl + (language ? `${language}/` : "") + doc
    }

    render() {
        return (

                        {this.props.config.footerIcon && (

                        )}

Docs

                        Why MobX
                        Concepts

Community

                        {/*
              User Showcase
             */}

                            Stack Overflow

                        Project Chat

More

                            Star

                        {this.props.config.twitterUsername && (

                                    Follow @{this.props.config.twitterUsername}

                        )}
                        {this.props.config.facebookAppId && (

                        )}

        )
    }
}

module.exports = Footer
<commit_msg>docs: fix footer links (#2140) (#2142)<commit_after>/**
 * Copyright (c) 2017-present, Facebook, Inc.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 */

const React = require("react")

class Footer extends React.Component {
    docUrl(doc, language) {
        const baseUrl = this.props.config.baseUrl
        const docsUrl = this.props.config.docsUrl
        const docsPart = `${docsUrl ? `${docsUrl}/` : ""}`
        const langPart = `${language ? `${language}/` : ""}`
        return `${baseUrl}${docsPart}${langPart}${doc}`
    }

    pageUrl(doc, language) {
        const baseUrl = this.props.config.baseUrl
        return baseUrl + (language ? `${language}/` : "") + doc
    }

    render() {
        return (

                        {this.props.config.footerIcon && (

                        )}

Docs

                        Why MobX
                        Concepts

Community

                        {/*
              User Showcase
             */}

                            Stack Overflow

                        Project Chat

More

                            Star

                        {this.props.config.twitterUsername && (

                                    Follow @{this.props.config.twitterUsername}

                        )}
                        {this.props.config.facebookAppId && (

                        )}

        )
    }
}

module.exports = Footer
<|endoftext|>


<commit_before>angular.module('app.services', []);

.factory('firebaseService', function () {

})
<commit_msg>added some servies (unfinished)<commit_after>//services are basically private functions and connecting to outside sources
// like servers, to call a funtion you do
angular.module('app.services', []);

.factory('firebaseService', function () {
    return {
        check_if_logged_in: function () {

        },
        create_user_cookie: function () {

        }
    }
});
<|endoftext|>