<commit_before>// Generated on 2014-03-08 using generator-angular 0.7.1
'use strict';

// # Globbing
// for performance reasons we're only matching one level down:
// 'test/spec/{,*/}*.js'
// use this if you want to recursively match all subfolders:
// 'test/spec/**/*.js'

module.exports = function (grunt) {

  // Load grunt tasks automatically
  require('load-grunt-tasks')(grunt);

  // Time how long tasks take. Can help when optimizing build times
  require('time-grunt')(grunt);

  // Define the configuration for all the tasks
  grunt.initConfig({

    // Project settings
    yeoman: {
      // configurable paths
      app: require('./bower.json').appPath || 'app',
      dist: 'dist'
    },

    // Watches files for changes and runs tasks based on the changed files
    watch: {
      js: {
        files: ['<%= yeoman.app %>/scripts/{,*/}*.js'],
        tasks: ['newer:jshint:all'],
        options: {
          livereload: true
        }
      },
      jsTest: {
        files: ['test/spec/{,*/}*.js'],
        tasks: ['newer:jshint:test', 'karma']
      },
      styles: {
        files: ['<%= yeoman.app %>/styles/{,*/}*.css'],
        tasks: ['newer:copy:styles', 'autoprefixer']
      },
      gruntfile: {
        files: ['Gruntfile.js']
      },
      livereload: {
        options: {
          livereload: '<%= connect.options.livereload %>'
        },
        files: [
          '<%= yeoman.app %>/{,*/}*.html',
          '.tmp/styles/{,*/}*.css',
          '<%= yeoman.app %>/images/{,*/}*.{png,jpg,jpeg,gif,webp,svg}'
        ]
      }
    },

    // The actual grunt server settings
    connect: {
      options: {
        port: 9000,
        // Change this to '0.0.0.0' to access the server from outside.
        hostname: 'localhost',
        livereload: 35729
      },
      livereload: {
        options: {
          open: true,
          base: [
            '.tmp',
            '<%= yeoman.app %>'
          ]
        }
      },
      test: {
        options: {
          port: 9001,
          base: [
            '.tmp',
            'test',
            '<%= yeoman.app %>'
          ]
        }
      },
      dist: {
        options: {
          base: '<%= yeoman.dist %>'
        }
      }
    },

    // Make sure code styles are up to par and there are no obvious mistakes
    jshint: {
      options: {
        jshintrc: '.jshintrc',
        reporter: require('jshint-stylish')
      },
      all: [
        'Gruntfile.js',
        '<%= yeoman.app %>/scripts/{,*/}*.js'
      ],
      test: {
        options: {
          jshintrc: 'test/.jshintrc'
        },
        src: ['test/spec/{,*/}*.js']
      }
    },

    // Empties folders to start fresh
    clean: {
      dist: {
        files: [{
          dot: true,
          src: [
            '.tmp',
            '<%= yeoman.dist %>/*',
            '!<%= yeoman.dist %>/.git*'
          ]
        }]
      },
      server: '.tmp'
    },

    // Add vendor prefixed styles
    autoprefixer: {
      options: {
        browsers: ['last 1 version']
      },
      dist: {
        files: [{
          expand: true,
          cwd: '.tmp/styles/',
          src: '{,*/}*.css',
          dest: '.tmp/styles/'
        }]
      }
    },

    // Automatically inject Bower components into the app
    'bower-install': {
      app: {
        html: '<%= yeoman.app %>/index.html',
        ignorePath: '<%= yeoman.app %>/'
      }
    },

    // Renames files for browser caching purposes
    rev: {
      dist: {
        files: {
          src: [
            '<%= yeoman.dist %>/scripts/{,*/}*.js',
            '<%= yeoman.dist %>/styles/{,*/}*.css',
            '<%= yeoman.dist %>/images/{,*/}*.{png,jpg,jpeg,gif,webp,svg}',
            '<%= yeoman.dist %>/styles/fonts/*'
          ]
        }
      }
    },

    // Reads HTML for usemin blocks to enable smart builds that automatically
    // concat, minify and revision files. Creates configurations in memory so
    // additional tasks can operate on them
    useminPrepare: {
      html: '<%= yeoman.app %>/index.html',
      options: {
        dest: '<%= yeoman.dist %>'
      }
    },

    // Performs rewrites based on rev and the useminPrepare configuration
    usemin: {
      html: ['<%= yeoman.dist %>/{,*/}*.html'],
      css: ['<%= yeoman.dist %>/styles/{,*/}*.css'],
      options: {
        assetsDirs: ['<%= yeoman.dist %>']
      }
    },

    // The following *-min tasks produce minified files in the dist folder
    imagemin: {
      dist: {
        files: [{
          expand: true,
          cwd: '<%= yeoman.app %>/images',
          src: '{,*/}*.{png,jpg,jpeg,gif}',
          dest: '<%= yeoman.dist %>/images'
        }]
      }
    },
    svgmin: {
      dist: {
        files: [{
          expand: true,
          cwd: '<%= yeoman.app %>/images',
          src: '{,*/}*.svg',
          dest: '<%= yeoman.dist %>/images'
        }]
      }
    },
    htmlmin: {
      dist: {
        options: {
          collapseWhitespace: true,
          collapseBooleanAttributes: true,
          removeCommentsFromCDATA: true,
          removeOptionalTags: true
        },
        files: [{
          expand: true,
          cwd: '<%= yeoman.dist %>',
          src: ['*.html', 'views/{,*/}*.html'],
          dest: '<%= yeoman.dist %>'
        }]
      }
    },

    // Allow the use of non-minsafe AngularJS files. Automatically makes it
    // minsafe compatible so Uglify does not destroy the ng references
    ngmin: {
      dist: {
        files: [{
          expand: true,
          cwd: '.tmp/concat/scripts',
          src: '*.js',
          dest: '.tmp/concat/scripts'
        }]
      }
    },

    // Replace Google CDN references
    cdnify: {
      dist: {
        html: ['<%= yeoman.dist %>/*.html']
      }
    },

    // Copies remaining files to places other tasks can use
    copy: {
      dist: {
        files: [{
          expand: true,
          dot: true,
          cwd: '<%= yeoman.app %>',
          dest: '<%= yeoman.dist %>',
          src: [
            '*.{ico,png,txt}',
            '.htaccess',
            '*.html',
            'views/{,*/}*.html',
            'bower_components/**/*',
            'images/{,*/}*.{webp}',
            'fonts/*'
          ]
        }, {
          expand: true,
          cwd: '.tmp/images',
          dest: '<%= yeoman.dist %>/images',
          src: ['generated/*']
        }]
      },
      styles: {
        expand: true,
        cwd: '<%= yeoman.app %>/styles',
        dest: '.tmp/styles/',
        src: '{,*/}*.css'
      }
    },

    // Run some tasks in parallel to speed up the build process
    concurrent: {
      server: [
        'copy:styles'
      ],
      test: [
        'copy:styles'
      ],
      dist: [
        'copy:styles',
        'imagemin',
        'svgmin'
      ]
    },

    // By default, your `index.html`'s <!-- Usemin block --> will take care of
    // minification. These next options are pre-configured if you do not wish
    // to use the Usemin blocks.
    // cssmin: {
    //   dist: {
    //     files: {
    //       '<%= yeoman.dist %>/styles/main.css': [
    //         '.tmp/styles/{,*/}*.css',
    //         '<%= yeoman.app %>/styles/{,*/}*.css'
    //       ]
    //     }
    //   }
    // },
    // uglify: {
    //   dist: {
    //     files: {
    //       '<%= yeoman.dist %>/scripts/scripts.js': [
    //         '<%= yeoman.dist %>/scripts/scripts.js'
    //       ]
    //     }
    //   }
    // },
    // concat: {
    //   dist: {}
    // },

    // Test settings
    karma: {
      unit: {
        configFile: 'karma.conf.js',
        singleRun: true
      }
    }
  });

  grunt.registerTask('serve', function (target) {
    if (target === 'dist') {
      return grunt.task.run(['build', 'connect:dist:keepalive']);
    }

    grunt.task.run([
      'clean:server',
      'bower-install',
      'concurrent:server',
      'autoprefixer',
      'connect:livereload',
      'watch'
    ]);
  });

  grunt.registerTask('server', function () {
    grunt.log.warn('The `server` task has been deprecated. Use `grunt serve` to start a server.');
    grunt.task.run(['serve']);
  });

  grunt.registerTask('test', [
    'clean:server',
    'concurrent:test',
    'autoprefixer',
    'connect:test',
    'karma'
  ]);

  grunt.registerTask('build', [
    'clean:dist',
    'bower-install',
    'useminPrepare',
    'concurrent:dist',
    'autoprefixer',
    'concat',
    'ngmin',
    'copy:dist',
    'cdnify',
    'cssmin',
    'uglify',
    'rev',
    'usemin',
    'htmlmin'
  ]);

  grunt.registerTask('default', [
    'newer:jshint',
    'test',
    'build'
  ]);
};
<commit_msg>Gruntfile.js: autoWatch for karma<commit_after>// Generated on 2014-03-08 using generator-angular 0.7.1
'use strict';

// # Globbing
// for performance reasons we're only matching one level down:
// 'test/spec/{,*/}*.js'
// use this if you want to recursively match all subfolders:
// 'test/spec/**/*.js'

module.exports = function (grunt) {

  // Load grunt tasks automatically
  require('load-grunt-tasks')(grunt);

  // Time how long tasks take. Can help when optimizing build times
  require('time-grunt')(grunt);

  // Define the configuration for all the tasks
  grunt.initConfig({

    // Project settings
    yeoman: {
      // configurable paths
      app: require('./bower.json').appPath || 'app',
      dist: 'dist'
    },

    // Watches files for changes and runs tasks based on the changed files
    watch: {
      js: {
        files: ['<%= yeoman.app %>/scripts/{,*/}*.js'],
        tasks: ['newer:jshint:all'],
        options: {
          livereload: true
        }
      },
      jsTest: {
        files: ['test/spec/{,*/}*.js'],
        tasks: ['newer:jshint:test', 'karma']
      },
      styles: {
        files: ['<%= yeoman.app %>/styles/{,*/}*.css'],
        tasks: ['newer:copy:styles', 'autoprefixer']
      },
      gruntfile: {
        files: ['Gruntfile.js']
      },
      livereload: {
        options: {
          livereload: '<%= connect.options.livereload %>'
        },
        files: [
          '<%= yeoman.app %>/{,*/}*.html',
          '.tmp/styles/{,*/}*.css',
          '<%= yeoman.app %>/images/{,*/}*.{png,jpg,jpeg,gif,webp,svg}'
        ]
      }
    },

    // The actual grunt server settings
    connect: {
      options: {
        port: 9000,
        // Change this to '0.0.0.0' to access the server from outside.
        hostname: 'localhost',
        livereload: 35729
      },
      livereload: {
        options: {
          open: true,
          base: [
            '.tmp',
            '<%= yeoman.app %>'
          ]
        }
      },
      test: {
        options: {
          port: 9001,
          base: [
            '.tmp',
            'test',
            '<%= yeoman.app %>'
          ]
        }
      },
      dist: {
        options: {
          base: '<%= yeoman.dist %>'
        }
      }
    },

    // Make sure code styles are up to par and there are no obvious mistakes
    jshint: {
      options: {
        jshintrc: '.jshintrc',
        reporter: require('jshint-stylish')
      },
      all: [
        'Gruntfile.js',
        '<%= yeoman.app %>/scripts/{,*/}*.js'
      ],
      test: {
        options: {
          jshintrc: 'test/.jshintrc'
        },
        src: ['test/spec/{,*/}*.js']
      }
    },

    // Empties folders to start fresh
    clean: {
      dist: {
        files: [{
          dot: true,
          src: [
            '.tmp',
            '<%= yeoman.dist %>/*',
            '!<%= yeoman.dist %>/.git*'
          ]
        }]
      },
      server: '.tmp'
    },

    // Add vendor prefixed styles
    autoprefixer: {
      options: {
        browsers: ['last 1 version']
      },
      dist: {
        files: [{
          expand: true,
          cwd: '.tmp/styles/',
          src: '{,*/}*.css',
          dest: '.tmp/styles/'
        }]
      }
    },

    // Automatically inject Bower components into the app
    'bower-install': {
      app: {
        html: '<%= yeoman.app %>/index.html',
        ignorePath: '<%= yeoman.app %>/'
      }
    },

    // Renames files for browser caching purposes
    rev: {
      dist: {
        files: {
          src: [
            '<%= yeoman.dist %>/scripts/{,*/}*.js',
            '<%= yeoman.dist %>/styles/{,*/}*.css',
            '<%= yeoman.dist %>/images/{,*/}*.{png,jpg,jpeg,gif,webp,svg}',
            '<%= yeoman.dist %>/styles/fonts/*'
          ]
        }
      }
    },

    // Reads HTML for usemin blocks to enable smart builds that automatically
    // concat, minify and revision files. Creates configurations in memory so
    // additional tasks can operate on them
    useminPrepare: {
      html: '<%= yeoman.app %>/index.html',
      options: {
        dest: '<%= yeoman.dist %>'
      }
    },

    // Performs rewrites based on rev and the useminPrepare configuration
    usemin: {
      html: ['<%= yeoman.dist %>/{,*/}*.html'],
      css: ['<%= yeoman.dist %>/styles/{,*/}*.css'],
      options: {
        assetsDirs: ['<%= yeoman.dist %>']
      }
    },

    // The following *-min tasks produce minified files in the dist folder
    imagemin: {
      dist: {
        files: [{
          expand: true,
          cwd: '<%= yeoman.app %>/images',
          src: '{,*/}*.{png,jpg,jpeg,gif}',
          dest: '<%= yeoman.dist %>/images'
        }]
      }
    },
    svgmin: {
      dist: {
        files: [{
          expand: true,
          cwd: '<%= yeoman.app %>/images',
          src: '{,*/}*.svg',
          dest: '<%= yeoman.dist %>/images'
        }]
      }
    },
    htmlmin: {
      dist: {
        options: {
          collapseWhitespace: true,
          collapseBooleanAttributes: true,
          removeCommentsFromCDATA: true,
          removeOptionalTags: true
        },
        files: [{
          expand: true,
          cwd: '<%= yeoman.dist %>',
          src: ['*.html', 'views/{,*/}*.html'],
          dest: '<%= yeoman.dist %>'
        }]
      }
    },

    // Allow the use of non-minsafe AngularJS files. Automatically makes it
    // minsafe compatible so Uglify does not destroy the ng references
    ngmin: {
      dist: {
        files: [{
          expand: true,
          cwd: '.tmp/concat/scripts',
          src: '*.js',
          dest: '.tmp/concat/scripts'
        }]
      }
    },

    // Replace Google CDN references
    cdnify: {
      dist: {
        html: ['<%= yeoman.dist %>/*.html']
      }
    },

    // Copies remaining files to places other tasks can use
    copy: {
      dist: {
        files: [{
          expand: true,
          dot: true,
          cwd: '<%= yeoman.app %>',
          dest: '<%= yeoman.dist %>',
          src: [
            '*.{ico,png,txt}',
            '.htaccess',
            '*.html',
            'views/{,*/}*.html',
            'bower_components/**/*',
            'images/{,*/}*.{webp}',
            'fonts/*'
          ]
        }, {
          expand: true,
          cwd: '.tmp/images',
          dest: '<%= yeoman.dist %>/images',
          src: ['generated/*']
        }]
      },
      styles: {
        expand: true,
        cwd: '<%= yeoman.app %>/styles',
        dest: '.tmp/styles/',
        src: '{,*/}*.css'
      }
    },

    // Run some tasks in parallel to speed up the build process
    concurrent: {
      server: [
        'copy:styles'
      ],
      test: [
        'copy:styles'
      ],
      dist: [
        'copy:styles',
        'imagemin',
        'svgmin'
      ]
    },

    // By default, your `index.html`'s <!-- Usemin block --> will take care of
    // minification. These next options are pre-configured if you do not wish
    // to use the Usemin blocks.
    // cssmin: {
    //   dist: {
    //     files: {
    //       '<%= yeoman.dist %>/styles/main.css': [
    //         '.tmp/styles/{,*/}*.css',
    //         '<%= yeoman.app %>/styles/{,*/}*.css'
    //       ]
    //     }
    //   }
    // },
    // uglify: {
    //   dist: {
    //     files: {
    //       '<%= yeoman.dist %>/scripts/scripts.js': [
    //         '<%= yeoman.dist %>/scripts/scripts.js'
    //       ]
    //     }
    //   }
    // },
    // concat: {
    //   dist: {}
    // },

    // Test settings
    karma: {
      unit: {
        configFile: 'karma.conf.js',
        autoWatch: true
      }
    }
  });

  grunt.registerTask('serve', function (target) {
    if (target === 'dist') {
      return grunt.task.run(['build', 'connect:dist:keepalive']);
    }

    grunt.task.run([
      'clean:server',
      'bower-install',
      'concurrent:server',
      'autoprefixer',
      'connect:livereload',
      'watch'
    ]);
  });

  grunt.registerTask('server', function () {
    grunt.log.warn('The `server` task has been deprecated. Use `grunt serve` to start a server.');
    grunt.task.run(['serve']);
  });

  grunt.registerTask('test', [
    'clean:server',
    'concurrent:test',
    'autoprefixer',
    'connect:test',
    'karma'
  ]);

  grunt.registerTask('build', [
    'clean:dist',
    'bower-install',
    'useminPrepare',
    'concurrent:dist',
    'autoprefixer',
    'concat',
    'ngmin',
    'copy:dist',
    'cdnify',
    'cssmin',
    'uglify',
    'rev',
    'usemin',
    'htmlmin'
  ]);

  grunt.registerTask('default', [
    'newer:jshint',
    'test',
    'build'
  ]);
};
<|endoftext|>


<commit_before>/*
Copyright 2015, 2016 OpenMarket Ltd

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

'use strict';

var React = require('react');

var MatrixClientPeg = require('matrix-react-sdk/lib/MatrixClientPeg');
var dis = require('matrix-react-sdk/lib/dispatcher');
var sdk = require('matrix-react-sdk')
var Modal = require('matrix-react-sdk/lib/Modal');
var Resend = require("matrix-react-sdk/lib/Resend");

module.exports = React.createClass({
    displayName: 'MessageContextMenu',

    onResendClick: function() {
        Resend.resend(this.props.mxEvent);
        if (this.props.onFinished) this.props.onFinished();
    },

    onViewSourceClick: function() {
        var ViewSource = sdk.getComponent('structures.ViewSource');
        Modal.createDialog(ViewSource, {
            mxEvent: this.props.mxEvent
        });
        if (this.props.onFinished) this.props.onFinished();
    },

    onRedactClick: function() {
        MatrixClientPeg.get().redactEvent(
            this.props.mxEvent.getRoomId(), this.props.mxEvent.getId()
        ).done(function() {
            // message should disappear by itself
        }, function(e) {
            var ErrorDialog = sdk.getComponent("dialogs.ErrorDialog");
            // display error message stating you couldn't delete this.
            var code = e.errcode || e.statusCode;
            Modal.createDialog(ErrorDialog, {
                title: "Error",
                description: "You cannot delete this message. (" + code + ")"
            });
        });
        if (this.props.onFinished) this.props.onFinished();
    },

    onCancelSendClick: function() {
        Resend.removeFromQueue(this.props.mxEvent);
        if (this.props.onFinished) this.props.onFinished();
    },

    onPermalinkClick: function() {
        if (this.props.onFinished) this.props.onFinished();
    },

    onUnhidePreviewClick: function() {
        if (global.localStorage) {
            // FIXME: factor this out with LinkPreviewWidget
            // FIXME: somehow propagate this to the EventTile such that it updates itself and realises the link has rematerialised
            global.localStorage.removeItem("hide_preview_" + this.props.mxEvent.getId());
        }
        this.props.mxEvent.widgetHidden = false;
        if (this.props.onFinished) this.props.onFinished();
    },

    render: function() {
        var eventStatus = this.props.mxEvent.status;
        var resendButton;
        var viewSourceButton;
        var redactButton;
        var cancelButton;
        var permalinkButton;
        var unhidePreviewButton;

        if (eventStatus === 'not_sent') {
            resendButton = (

                    Resend

            );
        }

        if (!eventStatus) { // sent
            redactButton = (

                    Redact

            );
        }

        if (eventStatus === "queued" || eventStatus === "not_sent") {
            cancelButton = (

                    Cancel Sending

            );
        }

        viewSourceButton = (

                View Source

        );

        if (global.localStorage) {
            // FIXME: factor this out with LinkPreviewWidget
            if (global.localStorage.getItem("hide_preview_" + this.props.mxEvent.getId()) === "1") {
                unhidePreviewButton = (

                        Unhide Preview

                )
            }
        }

        // XXX: this should be https://matrix.to.
        // XXX: if we use room ID, we should also include a server where the event can be found (other than in the domain of the event ID)
        permalinkButton = (

                Permalink

        );

        return (

                {resendButton}
                {redactButton}
                {cancelButton}
                {viewSourceButton}
                {unhidePreviewButton}
                {permalinkButton}

        );
    }
});
<commit_msg>add the concept of eventTileOps for managing widget visibility based on vdh's PR feedback<commit_after>/*
Copyright 2015, 2016 OpenMarket Ltd

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

'use strict';

var React = require('react');

var MatrixClientPeg = require('matrix-react-sdk/lib/MatrixClientPeg');
var dis = require('matrix-react-sdk/lib/dispatcher');
var sdk = require('matrix-react-sdk')
var Modal = require('matrix-react-sdk/lib/Modal');
var Resend = require("matrix-react-sdk/lib/Resend");

module.exports = React.createClass({
    displayName: 'MessageContextMenu',

    propTypes: {
        /* the MatrixEvent associated with the context menu */
        mxEvent: React.PropTypes.object.isRequired,

        /* an optional EventTileOps implementation that can be used to unhide preview widgets */
        eventTileOps: React.PropTypes.object,

        /* callback called when the menu is dismissed */
        onFinished: React.PropTypes.func,
    },

    onResendClick: function() {
        Resend.resend(this.props.mxEvent);
        if (this.props.onFinished) this.props.onFinished();
    },

    onViewSourceClick: function() {
        var ViewSource = sdk.getComponent('structures.ViewSource');
        Modal.createDialog(ViewSource, {
            mxEvent: this.props.mxEvent
        });
        if (this.props.onFinished) this.props.onFinished();
    },

    onRedactClick: function() {
        MatrixClientPeg.get().redactEvent(
            this.props.mxEvent.getRoomId(), this.props.mxEvent.getId()
        ).done(function() {
            // message should disappear by itself
        }, function(e) {
            var ErrorDialog = sdk.getComponent("dialogs.ErrorDialog");
            // display error message stating you couldn't delete this.
            var code = e.errcode || e.statusCode;
            Modal.createDialog(ErrorDialog, {
                title: "Error",
                description: "You cannot delete this message. (" + code + ")"
            });
        });
        if (this.props.onFinished) this.props.onFinished();
    },

    onCancelSendClick: function() {
        Resend.removeFromQueue(this.props.mxEvent);
        if (this.props.onFinished) this.props.onFinished();
    },

    onPermalinkClick: function() {
        if (this.props.onFinished) this.props.onFinished();
    },

    onUnhidePreviewClick: function() {
        if (global.localStorage) {
            // FIXME: factor this out with LinkPreviewWidget
            global.localStorage.removeItem("hide_preview_" + this.props.mxEvent.getId());
        }
        if (this.props.eventTileOps) {
            this.props.eventTileOps.unhideWidget();
        }
        if (this.props.onFinished) this.props.onFinished();
    },

    render: function() {
        var eventStatus = this.props.mxEvent.status;
        var resendButton;
        var viewSourceButton;
        var redactButton;
        var cancelButton;
        var permalinkButton;
        var unhidePreviewButton;

        if (eventStatus === 'not_sent') {
            resendButton = (

                    Resend

            );
        }

        if (!eventStatus) { // sent
            redactButton = (

                    Redact

            );
        }

        if (eventStatus === "queued" || eventStatus === "not_sent") {
            cancelButton = (

                    Cancel Sending

            );
        }

        viewSourceButton = (

                View Source

        );

        if (global.localStorage) {
            // FIXME: factor this out with LinkPreviewWidget
            if (global.localStorage.getItem("hide_preview_" + this.props.mxEvent.getId()) === "1") {
                unhidePreviewButton = (

                        Unhide Preview

                )
            }
        }

        // XXX: this should be https://matrix.to.
        // XXX: if we use room ID, we should also include a server where the event can be found (other than in the domain of the event ID)
        permalinkButton = (

                Permalink

        );

        return (

                {resendButton}
                {redactButton}
                {cancelButton}
                {viewSourceButton}
                {unhidePreviewButton}
                {permalinkButton}

        );
    }
});
<|endoftext|>


<commit_before>"use strict";

var fs = require( "fs" );
var path = require( "path" );
var wrench = require( "wrench" );

function command( expr ) {
	expr = expr.split( " " );
	expr[ 0 ] = path.resolve( __dirname, "node_modules/.bin/" + expr[ 0 ] + ( path.sep === "/" ? "" : ".cmd" ) );
	expr = expr.join( " " );
	console.log( "COMMAND: " + expr );
	return expr;
}

module.exports = function( grunt ) {

	var lcov = "data.lcov";
	var lib = path.resolve( __dirname, "lib" );
	var libSave = lib + "-save";
	var lintTargets = [ "*.js", "lib/**/*.js", "test/**/*.js", "bin/wires" ];

	grunt.initConfig( {
		jscs: {
			files: lintTargets,
			options: {
				config: ".jscsrc"
			}
		},
		jshint: {
			files: lintTargets,
			options: {
				jshintrc: ".jshintrc"
			}
		},
		shell: {
			coveralls: {
				command: command( "coveralls < " + lcov )
			},
			jscoverage: {
				command: command( "jscoverage " + lib + " " + libSave )
			},
			test: {
				command: "node bin/wires test"
			},
			testWithCoverage: {
				command: "node bin/wires test --reporter=lcov > " + lcov
			}
		}
	} );

	// load npm modules
	require( "load-grunt-tasks" )( grunt );

	// Tasks
	grunt.registerTask( "lint", [ "jscs", "jshint" ] );
	grunt.registerTask( "default", [ "lint", "shell:test" ] );

	// Coverage
	grunt.registerTask( "coverage-file-manipulation", function() {
		fs.renameSync( lib, "__coverage_tmp" );
		fs.renameSync( libSave, lib );
		fs.renameSync( "__coverage_tmp", libSave );
		process.on( "exit", function() {
			wrench.rmdirSyncRecursive( lib );
			fs.renameSync( libSave, lib );
			fs.unlinkSync( lcov );
		} );
	} );

	grunt.registerTask( "coverage", [
		"shell:jscoverage",
		"coverage-file-manipulation",
		"shell:testWithCoverage",
		"shell:coveralls"
	] );
};
<commit_msg>jscoverage is pretty bad at handling paths. Assume we're in the main directory when using `grunt coverage` and let's see if it works in travis now<commit_after>"use strict";

var fs = require( "fs" );
var path = require( "path" );
var wrench = require( "wrench" );

function command( expr ) {
	expr = expr.split( " " );
	expr[ 0 ] = path.resolve( __dirname, "node_modules/.bin/" + expr[ 0 ] + ( path.sep === "/" ? "" : ".cmd" ) );
	return expr.join( " " );
}

module.exports = function( grunt ) {

	var lcov = "data.lcov";
	var lib = "lib";
	var libSave = lib + "-save";
	var lintTargets = [ "*.js", "lib/**/*.js", "test/**/*.js", "bin/wires" ];

	grunt.initConfig( {
		jscs: {
			files: lintTargets,
			options: {
				config: ".jscsrc"
			}
		},
		jshint: {
			files: lintTargets,
			options: {
				jshintrc: ".jshintrc"
			}
		},
		shell: {
			coveralls: {
				command: command( "coveralls < " + lcov )
			},
			jscoverage: {
				command: command( "jscoverage " + lib + " " + libSave )
			},
			test: {
				command: "node bin/wires test"
			},
			testWithCoverage: {
				command: "node bin/wires test --reporter=lcov > " + lcov
			}
		}
	} );

	// load npm modules
	require( "load-grunt-tasks" )( grunt );

	// Tasks
	grunt.registerTask( "lint", [ "jscs", "jshint" ] );
	grunt.registerTask( "default", [ "lint", "shell:test" ] );

	// Coverage
	grunt.registerTask( "coverage-file-manipulation", function() {
		fs.renameSync( lib, "__coverage_tmp" );
		fs.renameSync( libSave, lib );
		fs.renameSync( "__coverage_tmp", libSave );
		process.on( "exit", function() {
			wrench.rmdirSyncRecursive( lib );
			fs.renameSync( libSave, lib );
			fs.unlinkSync( lcov );
		} );
	} );

	grunt.registerTask( "coverage", [
		"shell:jscoverage",
		"coverage-file-manipulation",
		"shell:testWithCoverage",
		"shell:coveralls"
	] );
};
<|endoftext|>


<commit_before>// @flow
import React, { Component, PropTypes } from 'react';
import shallowCompare from 'react-addons-shallow-compare';
import classNames from 'classnames';
import { timeCode } from '../../common/time-code';
import { withSize } from '../with-size';
import type { Milliseconds, CssPixels } from '../../common/types/units';
import type { TracingMarker } from '../profile-data';

type MarkerState = 'PRESSED' | 'HOVERED' | 'NONE';

type Props = {
  className: string,
  rangeStart: Milliseconds,
  rangeEnd: Milliseconds,
  intervalMarkers: TracingMarker[],
  width: number,
  threadIndex: number,
  threadName: string,
  onSelect: any,
  styles: any,
  overlayFills: {
    HOVERED: string,
    PRESSED: string,
  },
};

class IntervalMarkerOverview extends Component {

  props: Props

  state: {
    hoveredItem: TracingMarker|null,
    mouseDownItem: TracingMarker|null,
  }

  _canvas: HTMLCanvasElement|null
  _requestedAnimationFrame: bool|null

  constructor(props: Props) {
    super(props);
    this.state = { hoveredItem: null, mouseDownItem: null };
    (this: any)._onMouseDown = this._onMouseDown.bind(this);
    (this: any)._onMouseMove = this._onMouseMove.bind(this);
    (this: any)._onMouseUp = this._onMouseUp.bind(this);
    (this: any)._onMouseOut = this._onMouseOut.bind(this);
    this._canvas = null;
  }

  _takeCanvasRef(c: HTMLCanvasElement) {
    this._canvas = c;
  }

  _scheduleDraw() {
    if (!this._requestedAnimationFrame) {
      this._requestedAnimationFrame = true;
      window.requestAnimationFrame(() => {
        this._requestedAnimationFrame = false;
        const c = this._canvas;
        if (c) {
          timeCode('IntervalMarkerTimeline render', () => {
            this.drawCanvas(c);
          });
        }
      });
    }
  }

  _hitTest(e): TracingMarker|null {
    const c = this._canvas;
    if (c === null) {
      return null;
    }

    const r = c.getBoundingClientRect();
    const { width, rangeStart, rangeEnd, intervalMarkers, styles } = this.props;
    const x = e.pageX - r.left;
    const y = e.pageY - r.top;
    const time = rangeStart + x / width * (rangeEnd - rangeStart);

    // Markers are drawn in array order; the one drawn last is on top. So if
    // there are multiple markers under the mouse, we want to find the one
    // with the highest array index. So we walk the list of intervalMarkers
    // from high index to low index, which is front to back in z-order.
    for (let i = intervalMarkers.length - 1; i >= 0; i--) {
      const { start, dur, name } = intervalMarkers[i];
      if (time < start || time >= start + dur) {
        continue;
      }
      const style = (name in styles) ? styles[name] : styles.default;
      if (y >= style.top && y < style.top + style.height) {
        return intervalMarkers[i];
      }
    }
    return null;
  }

  _onMouseMove(e) {
    const hoveredItem = this._hitTest(e);
    if (this.state.hoveredItem !== hoveredItem) {
      this.setState({ hoveredItem });
    }
  }

  _onMouseDown(e) {
    const mouseDownItem = this._hitTest(e);
    this.setState({ mouseDownItem });
    if (mouseDownItem !== null) {
      if (e.target.setCapture) {
        e.target.setCapture();
      }
      e.stopPropagation();
    }
  }

  _onMouseUp(e) {
    const { mouseDownItem } = this.state;
    if (mouseDownItem !== null) {
      const mouseUpItem = this._hitTest(e);
      if (mouseDownItem === mouseUpItem &&
          mouseUpItem !== null /* extra null check because flow doesn't realize it's unnecessary */) {
        const { onSelect, threadIndex } = this.props;
        onSelect(threadIndex, mouseUpItem.start, mouseUpItem.start + mouseUpItem.dur);
      }
      this.setState({
        hoveredItem: mouseUpItem,
        mouseDownItem: null,
      });
    }
  }

  _onMouseOut() {
    this.setState({
      hoveredItem: null,
    });
  }

  shouldComponentUpdate(nextProps, nextState) {
    return shallowCompare(this, nextProps, nextState);
  }

  render() {
    this._scheduleDraw();
    const { className } = this.props;
    const { mouseDownItem, hoveredItem } = this.state;
    const title = !mouseDownItem && hoveredItem ? hoveredItem.title : null;
    return (

        <canvas className={classNames(`${className}Canvas`, 'intervalMarkerTimelineCanvas')}
                ref={this._takeCanvasRef}
                onMouseDown={this._onMouseDown}
                onMouseMove={this._onMouseMove}
                onMouseUp={this._onMouseUp}
                onMouseOut={this._onMouseOut}
                title={title}/>

    );
  }

  _drawRoundedRect(ctx: CanvasRenderingContext2D,
                   x: CssPixels, y: CssPixels, width: CssPixels, height: CssPixels,
                   cornerSize: CssPixels) {
    // Cut out c x c -sized squares in the corners.
    const c = Math.min(width / 2, Math.min(height / 2, cornerSize));
    const bottom = y + height;
    ctx.fillRect(x + c, y, width - 2 * c, c);
    ctx.fillRect(x, y + c, width, height - 2 * c);
    ctx.fillRect(x + c, bottom - c, width - 2 * c, c);
  }

  drawCanvas(c: HTMLCanvasElement) {
    const { rangeStart, rangeEnd, width, intervalMarkers, styles, overlayFills } = this.props;

    const devicePixelRatio = c.ownerDocument ? c.ownerDocument.defaultView.devicePixelRatio : 1;
    const height = c.getBoundingClientRect().height;
    const pixelWidth = Math.round(width * devicePixelRatio);
    const pixelHeight = Math.round(height * devicePixelRatio);

    if (c.width !== pixelWidth || c.height !== pixelHeight) {
      c.width = pixelWidth;
      c.height = pixelHeight;
    }
    const ctx = c.getContext('2d');
    if (ctx === null || ctx === undefined) {
      return;
    }

    ctx.clearRect(0, 0, pixelWidth, pixelHeight);
    ctx.scale(devicePixelRatio, devicePixelRatio);

    intervalMarkers.forEach(marker => {
      const { start, dur, name } = marker;
      const pos = (start - rangeStart) / (rangeEnd - rangeStart) * width;
      const itemWidth = dur / (rangeEnd - rangeStart) * width;
      const style = (name in styles) ? styles[name] : styles.default;
      ctx.fillStyle = style.background;
      if (style.squareCorners) {
        ctx.fillRect(pos, style.top, itemWidth, style.height);
      } else {
        this._drawRoundedRect(ctx, pos, style.top, itemWidth, style.height, 1 / devicePixelRatio);
      }
      if (style.borderLeft !== null) {
        ctx.fillStyle = style.borderLeft;
        ctx.fillRect(pos, style.top, 1, style.height);
      }
      if (style.borderRight !== null) {
        ctx.fillStyle = style.borderRight;
        ctx.fillRect(pos + itemWidth - 1, style.top, 1, style.height);
      }
      const markerState = this._getMarkerState(marker);
      if (markerState === 'HOVERED' || markerState === 'PRESSED') {
        ctx.fillStyle = overlayFills[markerState];
        if (style.squareCorners) {
          ctx.fillRect(pos, style.top, itemWidth, style.height);
        } else {
          this._drawRoundedRect(ctx, pos, style.top, itemWidth, style.height, 1 / devicePixelRatio);
        }
      }
    });
    ctx.scale(1 / devicePixelRatio, 1 / devicePixelRatio);
  }

  _getMarkerState(marker): MarkerState {
    const { hoveredItem, mouseDownItem } = this.state;
    if (mouseDownItem !== null) {
      if (marker === mouseDownItem && marker === hoveredItem) {
        return 'PRESSED';
      }
      return 'NONE';
    }
    if (marker === hoveredItem) {
      return 'HOVERED';
    }
    return 'NONE';
  }

}

IntervalMarkerOverview.propTypes = {
  className: PropTypes.string.isRequired,
  rangeStart: PropTypes.number.isRequired,
  rangeEnd: PropTypes.number.isRequired,
  intervalMarkers: PropTypes.arrayOf(PropTypes.shape({
    start: PropTypes.number.isRequired,
    dur: PropTypes.number.isRequired,
    title: PropTypes.string.isRequired,
    name: PropTypes.string,
  })).isRequired,
  width: PropTypes.number.isRequired, // provided by withSize
  threadIndex: PropTypes.number.isRequired,
  threadName: PropTypes.string.isRequired,
  onSelect: PropTypes.func.isRequired,
  styles: PropTypes.object.isRequired,
  overlayFills: PropTypes.shape({
    HOVERED: PropTypes.string.isRequired,
    PRESSED: PropTypes.string.isRequired,
  }).isRequired,
};

export default withSize(IntervalMarkerOverview);
<commit_msg>Fix up canvas interval marker patch.<commit_after>// @flow
import React, { Component, PropTypes } from 'react';
import shallowCompare from 'react-addons-shallow-compare';
import classNames from 'classnames';
import { timeCode } from '../../common/time-code';
import { withSize } from '../with-size';
import type { Milliseconds, CssPixels } from '../../common/types/units';
import type { TracingMarker } from '../profile-data';

type MarkerState = 'PRESSED' | 'HOVERED' | 'NONE';

type Props = {
  className: string,
  rangeStart: Milliseconds,
  rangeEnd: Milliseconds,
  intervalMarkers: TracingMarker[],
  width: number,
  threadIndex: number,
  threadName: string,
  onSelect: any,
  styles: any,
  overlayFills: {
    HOVERED: string,
    PRESSED: string,
  },
};

class IntervalMarkerOverview extends Component {

  props: Props

  state: {
    hoveredItem: TracingMarker|null,
    mouseDownItem: TracingMarker|null,
  }

  _canvas: HTMLCanvasElement|null
  _requestedAnimationFrame: bool|null

  constructor(props: Props) {
    super(props);
    this.state = { hoveredItem: null, mouseDownItem: null };
    (this: any)._onMouseDown = this._onMouseDown.bind(this);
    (this: any)._onMouseMove = this._onMouseMove.bind(this);
    (this: any)._onMouseUp = this._onMouseUp.bind(this);
    (this: any)._onMouseOut = this._onMouseOut.bind(this);
    (this: any)._takeCanvasRef = this._takeCanvasRef.bind(this);
    this._canvas = null;
  }

  _takeCanvasRef(c: HTMLCanvasElement) {
    this._canvas = c;
  }

  _scheduleDraw() {
    if (!this._requestedAnimationFrame) {
      this._requestedAnimationFrame = true;
      window.requestAnimationFrame(() => {
        this._requestedAnimationFrame = false;
        const c = this._canvas;
        if (c) {
          timeCode('IntervalMarkerTimeline render', () => {
            this.drawCanvas(c);
          });
        }
      });
    }
  }

  _hitTest(e): TracingMarker|null {
    const c = this._canvas;
    if (c === null) {
      return null;
    }

    const r = c.getBoundingClientRect();
    const { width, rangeStart, rangeEnd, intervalMarkers, styles } = this.props;
    const x = e.pageX - r.left;
    const y = e.pageY - r.top;
    const time = rangeStart + x / width * (rangeEnd - rangeStart);

    // Markers are drawn in array order; the one drawn last is on top. So if
    // there are multiple markers under the mouse, we want to find the one
    // with the highest array index. So we walk the list of intervalMarkers
    // from high index to low index, which is front to back in z-order.
    for (let i = intervalMarkers.length - 1; i >= 0; i--) {
      const { start, dur, name } = intervalMarkers[i];
      if (time < start || time >= start + dur) {
        continue;
      }
      const style = (name in styles) ? styles[name] : styles.default;
      if (y >= style.top && y < style.top + style.height) {
        return intervalMarkers[i];
      }
    }
    return null;
  }

  _onMouseMove(e) {
    const hoveredItem = this._hitTest(e);
    if (this.state.hoveredItem !== hoveredItem) {
      this.setState({ hoveredItem });
    }
  }

  _onMouseDown(e) {
    const mouseDownItem = this._hitTest(e);
    this.setState({ mouseDownItem });
    if (mouseDownItem !== null) {
      if (e.target.setCapture) {
        e.target.setCapture();
      }
      e.stopPropagation();
    }
  }

  _onMouseUp(e) {
    const { mouseDownItem } = this.state;
    if (mouseDownItem !== null) {
      const mouseUpItem = this._hitTest(e);
      if (mouseDownItem === mouseUpItem &&
          mouseUpItem !== null /* extra null check because flow doesn't realize it's unnecessary */) {
        const { onSelect, threadIndex } = this.props;
        onSelect(threadIndex, mouseUpItem.start, mouseUpItem.start + mouseUpItem.dur);
      }
      this.setState({
        hoveredItem: mouseUpItem,
        mouseDownItem: null,
      });
    }
  }

  _onMouseOut() {
    this.setState({
      hoveredItem: null,
    });
  }

  shouldComponentUpdate(nextProps, nextState) {
    return shallowCompare(this, nextProps, nextState);
  }

  render() {
    this._scheduleDraw();
    const { className } = this.props;
    const { mouseDownItem, hoveredItem } = this.state;
    const title = !mouseDownItem && hoveredItem ? hoveredItem.title : null;
    return (

        <canvas className={classNames(`${className}Canvas`, 'intervalMarkerTimelineCanvas')}
                ref={this._takeCanvasRef}
                onMouseDown={this._onMouseDown}
                onMouseMove={this._onMouseMove}
                onMouseUp={this._onMouseUp}
                onMouseOut={this._onMouseOut}
                title={title}/>

    );
  }

  _drawRoundedRect(ctx: CanvasRenderingContext2D,
                   x: CssPixels, y: CssPixels, width: CssPixels, height: CssPixels,
                   cornerSize: CssPixels) {
    // Cut out c x c -sized squares in the corners.
    const c = Math.min(width / 2, Math.min(height / 2, cornerSize));
    const bottom = y + height;
    ctx.fillRect(x + c, y, width - 2 * c, c);
    ctx.fillRect(x, y + c, width, height - 2 * c);
    ctx.fillRect(x + c, bottom - c, width - 2 * c, c);
  }

  drawCanvas(c: HTMLCanvasElement) {
    const { rangeStart, rangeEnd, width, intervalMarkers, styles, overlayFills } = this.props;

    const devicePixelRatio = c.ownerDocument ? c.ownerDocument.defaultView.devicePixelRatio : 1;
    const height = c.getBoundingClientRect().height;
    const pixelWidth = Math.round(width * devicePixelRatio);
    const pixelHeight = Math.round(height * devicePixelRatio);

    if (c.width !== pixelWidth || c.height !== pixelHeight) {
      c.width = pixelWidth;
      c.height = pixelHeight;
    }
    const ctx = c.getContext('2d');
    if (ctx === null || ctx === undefined) {
      return;
    }

    ctx.clearRect(0, 0, pixelWidth, pixelHeight);
    ctx.scale(devicePixelRatio, devicePixelRatio);

    intervalMarkers.forEach(marker => {
      const { start, dur, name } = marker;
      const pos = (start - rangeStart) / (rangeEnd - rangeStart) * width;
      const itemWidth = dur / (rangeEnd - rangeStart) * width;
      const style = (name in styles) ? styles[name] : styles.default;
      ctx.fillStyle = style.background;
      if (style.squareCorners) {
        ctx.fillRect(pos, style.top, itemWidth, style.height);
      } else {
        this._drawRoundedRect(ctx, pos, style.top, itemWidth, style.height, 1 / devicePixelRatio);
      }
      if (style.borderLeft !== null) {
        ctx.fillStyle = style.borderLeft;
        ctx.fillRect(pos, style.top, 1, style.height);
      }
      if (style.borderRight !== null) {
        ctx.fillStyle = style.borderRight;
        ctx.fillRect(pos + itemWidth - 1, style.top, 1, style.height);
      }
      const markerState = this._getMarkerState(marker);
      if (markerState === 'HOVERED' || markerState === 'PRESSED') {
        ctx.fillStyle = overlayFills[markerState];
        if (style.squareCorners) {
          ctx.fillRect(pos, style.top, itemWidth, style.height);
        } else {
          this._drawRoundedRect(ctx, pos, style.top, itemWidth, style.height, 1 / devicePixelRatio);
        }
      }
    });
    ctx.scale(1 / devicePixelRatio, 1 / devicePixelRatio);
  }

  _getMarkerState(marker): MarkerState {
    const { hoveredItem, mouseDownItem } = this.state;
    if (mouseDownItem !== null) {
      if (marker === mouseDownItem && marker === hoveredItem) {
        return 'PRESSED';
      }
      return 'NONE';
    }
    if (marker === hoveredItem) {
      return 'HOVERED';
    }
    return 'NONE';
  }

}

IntervalMarkerOverview.propTypes = {
  className: PropTypes.string.isRequired,
  rangeStart: PropTypes.number.isRequired,
  rangeEnd: PropTypes.number.isRequired,
  intervalMarkers: PropTypes.arrayOf(PropTypes.shape({
    start: PropTypes.number.isRequired,
    dur: PropTypes.number.isRequired,
    title: PropTypes.string.isRequired,
    name: PropTypes.string,
  })).isRequired,
  width: PropTypes.number.isRequired, // provided by withSize
  threadIndex: PropTypes.number.isRequired,
  threadName: PropTypes.string.isRequired,
  onSelect: PropTypes.func.isRequired,
  styles: PropTypes.object.isRequired,
  overlayFills: PropTypes.shape({
    HOVERED: PropTypes.string.isRequired,
    PRESSED: PropTypes.string.isRequired,
  }).isRequired,
};

export default withSize(IntervalMarkerOverview);
<|endoftext|>


<commit_before>/*
 * Generated on 2014-03-26
 * generator-assemble v0.4.11
 * https://github.com/assemble/generator-assemble
 *
 * Copyright (c) 2014 Hariadi Hinta
 * Licensed under the MIT license.
 */

'use strict';

// # Globbing
// for performance reasons we're only matching one level down:
// '<%= config.src %>/templates/pages/{,*/}*.hbs'
// use this if you want to match all subfolders:
// '<%= config.src %>/templates/pages/**/*.hbs'

module.exports = function(grunt) {

  require('time-grunt')(grunt);
  //jit-grunt loads only the npm tasks required for the grunt task.
  //makes livereload much faster.
  require('jit-grunt')(grunt, {
    replace: 'grunt-text-replace'
  });

  // Project configuration.
  grunt.initConfig({
    config: {
      preview: {
        options: {
          variables: {
            environment: 'preview',
            environmentData: 'website-guts/data/environments/production/environmentVariables.json',
            assets_dir: '/assets',
            sassSourceMap: false,
            sassImagePath: '/assets/img/',
            compress_js: true,
            concat_banner: '(function($){ \n\n' +
                           '  window.optly = window.optly || {}; \n\n' +
                           '  window.optly.mrkt = window.optly.mrkt || {}; \n\n' +
                           '  try { \n\n',
            concat_footer: '  } catch(error){ \n\n' +
                           '  //report errors to GA \n\n' +
                           '  window.console.log("js error: " + error);' +
                           '  } \n' +
                           '})(jQuery);'
          }
        }
      },
      dev: {
        options: {
          variables: {
            environment: 'dev',
            environmentData: 'website-guts/data/environments/development/environmentVariables.json',
            assets_dir: '/<%= config.dist %>/assets',
            sassSourceMap: true,
            sassImagePath: '/dist/assets/img/',
            compress_js: false,
            concat_banner: '(function($){ \n\n' +
                           '  window.optly = window.optly || {}; \n\n' +
                           '  window.optly.mrkt = window.optly.mrkt || {}; \n\n',
            concat_footer: '})(jQuery);'
          }
        }
      },
      content: 'website',
      guts: 'website-guts',
      dist: 'dist',
      temp: 'temp',
      bowerDir: 'bower_components'
    },
    aws: grunt.file.readJSON('configs/s3Config.json'),
    watch: {
      assemble: {
        files: [
          '<%= config.content %>/{,*/}*.{md,hbs,yml,json}',
          '<%= config.guts %>/templates/**/*.hbs',
          '<%= config.content %>/**/*.hbs'
        ],
        tasks: ['config:dev', 'assemble']
      },
      sass: {
        files: '<%= config.guts %>/assets/css/**/*.scss',
        tasks: ['config:dev', 'sass', 'replace', 'autoprefixer', 'clean:postBuild']
      },
      img: {
        files: ['<%= config.guts %>/assets/img/*.{png,jpg,svg}'],
        tasks: ['copy:img']
      },
      js: {
        files: ['<%= config.guts %>/assets/js/**/*.js', '<%= config.temp %>/assets/js/**/*.js'],
        tasks: ['config:dev', 'jshint', 'concat', 'uglify', 'clean:postBuild']
      },
      livereload: {
        options: {
          livereload: '<%= connect.options.livereload %>'
        },
        files: [
          '<%= config.dist %>/**/*.html',
          '<%= config.dist %>/assets/css/**/*.css',
          '<%= config.dist %>/assets/js/**/*.js'
        ]
      }
    },
    connect: {
      options: {
        port: 9000,
        livereload: 35729,
        // change this to '0.0.0.0' to access the server from outside
        hostname: '0.0.0.0',
        middleware: function(connect, options, middlewares){
          middlewares.push(function(req, res, next){
            if(req.url === '/account/free_trial_landing'){

              res.writeHead(200, {'Content-Type': 'application/json'});
              res.end( grunt.file.read('website-guts/endpoint-mocks/formSuccess.json') );

            } else if(req.url === '/account/info') {

              res.writeHead(200, {'Content-Type': 'application/json'});
              res.end( grunt.file.read('website-guts/endpoint-mocks/accountInfo.json') );

            }
            else{

              return next();

            }

          });
          return middlewares;
        }
      },
      livereload: {
        options: {
          open: {
            target: 'http://0.0.0.0:9000/dist/'
          },
          base: '.'
        }
      }
    },
    assemble: {
      options: {
        layoutdir: '<%= config.guts %>/templates/layouts/',
        assetsDir: '<%= grunt.config.get("assets_dir") %>',
        environmentIsProduction: '<%= grunt.config.get("environmentIsProduction") %>',
        environmentIsDev: '<%= grunt.config.get("environmentIsDev") %>',
        data: ['<%= config.content %>/**/*.json', '<%= grunt.config.get("environmentData") %>']
      },
      pages: {
        files: [
          {
            src: ['**/*.hbs'],
            dest: '<%= config.dist %>/',
            cwd: '<%= config.content %>/',
            expand: true
          }
        ]
      }
    },
    sass: {
      styles: {
        options: {
          sourceMap: true,
          imagePath: '<%= grunt.config.get("sassImagePath") %>'
        },
        files: [
          {
            src: '<%= config.guts %>/assets/css/styles.scss',
            dest: '<%= config.temp %>/css/styles.css'
          }
        ]
      }
    },
    replace: {
      cssSourceMap: {
        src: '<%= config.temp %>/css/styles.css.map',
        overwrite: true,
        replacements: [
          {
            from: 'website-guts/',
            to: '../../../website-guts/'
          }
        ]
      }
    },
    autoprefixer: {
      options: {
        options: ['last 2 versions', "Firefox ESR"]
      },
      files: {
        flatten: true,
        src: '<%= config.temp %>/css/styles.css',
        dest: '<%= config.dist %>/assets/css/styles.css'
      }
    },
    copy: {
      cssSourceMap: {
        src: '<%= config.temp %>/css/styles.css.map',
        dest: '<%= config.dist %>/assets/css/styles.css.map'
      },
      cssFontFile: {
        src: ['<%= config.guts %>/assets/css/fonts.css'],
        dest: '<%= config.dist %>/assets/css/fonts.css'
      },
      js: {
        files: [
          {
            src: '<%= config.bowerDir %>/jquery/jquery.js',
            dest: '<%= config.dist %>/assets/js/libraries/jquery.js',
            flatten: true,
            filter: 'isFile'
          }
        ]
      },
      img: {
        files: [
          {
            cwd: '<%= config.guts %>/assets/img/',
            src: '**',
            dest: '<%= config.dist %>/assets/img/',
            expand: true
          }
        ]
      }
    },
    clean: {
      preBuild: ['<%= config.dist %>/'],
      postBuild: ['<%= config.temp %>']
    },
    s3: {
      options: {
        key: '<%= aws.key %>',
        secret: '<%= aws.secret %>',
        bucket: '<%= aws.bucket %>',
        access: 'public-read',
      },
      dev: {
        upload: [
          {
            src: '<%= config.dist %>/**/*',
            dest: '/',
            rel: '<%= config.dist %>'
          }
        ]
      }
    },
    jshint: {
      options: {
        trailing: true,
        curly: true,
        eqeqeq: true,
        indent: 4,
        latedef: true,
        noempty: true,
        nonbsp: true,
        undef: true,
        unused: true,
        quotmark: 'single',
        browser: true,
        globals: {
          jQuery: true,
          $: true,
          console: false,
          Handlebars: false,
          moment: false,
          _gaq: false
        }
      },
      files: ['<%= config.guts %>/assets/js/**/*.js', '!<%= config.guts %>/assets/js/libraries/**/*.js']
    },
    concat: {
      temp: {
        options: {
          banner: '<%= grunt.config.get("concat_banner") %>',
          footer: '<%= grunt.config.get("concat_footer") %>'
        },
        src: ['**/*.js', '!libraries/**/*.js'],
        expand: true,
        cwd: '<%= config.guts %>/assets/js/',
        dest: '<%= config.temp %>/assets/js/'
      }
    },
    uglify: {
      options: {
        mangle: false,
        compress: false,
        beautify: false
      },
      globalJS: {
        files: {
          '<%= config.dist %>/assets/js/libraries/modernizr-yepnope.js': ['<%= config.guts %>/assets/js/libraries/modernizr-2.8.2.min.js','<%= config.bowerDir %>/yepnope/yepnope.1.5.4-min.js'],
          '<%= config.dist %>/assets/js/libraries/fastclick.js': ['<%= config.bowerDir %>/fastclick/lib/fastclick.js'],
          '<%= config.dist %>/assets/js/bundle.js': [
            '<%= config.bowerDir %>/jquery-cookie/jquery.cookie.js',
            '<%= config.guts %>/assets/js/libraries/handlebars-v1.3.0.js',
            '<%= config.bowerDir %>/momentjs/moment.js',
            '<%= config.guts %>/assets/js/libraries/oForm/oForm.js',
            '<%= config.temp %>/assets/js/global.js'
          ]
        }
      },
      pageFiles: {
        files: [
          {
            expand: true,
            cwd: '<%= config.temp %>/assets/js/pages',
            src: '**/*.js',
            dest: '<%= config.dist %>/assets/js/pages'
          }
        ]
      }
    }
  });

/*
  grunt.loadNpmTasks('assemble');
  grunt.loadNpmTasks('grunt-contrib-clean');
  grunt.loadNpmTasks('grunt-contrib-connect');
  grunt.loadNpmTasks('grunt-autoprefixer');
  grunt.loadNpmTasks('grunt-contrib-watch');
  grunt.loadNpmTasks('grunt-sass');
  grunt.loadNpmTasks('grunt-contrib-copy');
  //do not load the npm grunt-s3 task when using 'grunt server' per: https://github.com/pifantastic/grunt-s3/issues/68
  //do load it for running 'grunt preview'
  //grunt.loadNpmTasks('grunt-s3');
  grunt.loadNpmTasks('grunt-config');
  grunt.loadNpmTasks('grunt-contrib-concat');
  grunt.loadNpmTasks('grunt-contrib-uglify');
  grunt.loadNpmTasks('grunt-contrib-jshint');
  grunt.loadNpmTasks('grunt-text-replace');
*/

  grunt.registerTask('server', [
    'config:dev',
    'jshint',
    'clean:preBuild',
    'assemble',
    'concat',
    'uglify',
    'sass',
    'replace',
    'autoprefixer',
    'copy',
    'clean:postBuild',
    'connect:livereload',
    'watch'
  ]);

  grunt.registerTask('build', [
    'config:dev',
    'jshint',
    'clean:preBuild',
    'assemble',
    'concat',
    'uglify',
    'sass',
    'replace',
    'autoprefixer',
    'copy',
    'clean:postBuild'
  ]);

  grunt.registerTask('preview', [
    'config:preview',
    'jshint',
    'clean:preBuild',
    'assemble',
    'concat',
    'uglify',
    'sass',
    'autoprefixer',
    'copy',
    's3',
    'clean:postBuild'
  ]);

  grunt.registerTask('default', [
    'build'
  ]);

};
<commit_msg>Move aws config to preview task only.<commit_after>/*
 * Generated on 2014-03-26
 * generator-assemble v0.4.11
 * https://github.com/assemble/generator-assemble
 *
 * Copyright (c) 2014 Hariadi Hinta
 * Licensed under the MIT license.
 */

'use strict';

// # Globbing
// for performance reasons we're only matching one level down:
// '<%= config.src %>/templates/pages/{,*/}*.hbs'
// use this if you want to match all subfolders:
// '<%= config.src %>/templates/pages/**/*.hbs'

module.exports = function(grunt) {

  require('time-grunt')(grunt);
  //jit-grunt loads only the npm tasks required for the grunt task.
  //makes livereload much faster.
  require('jit-grunt')(grunt, {
    replace: 'grunt-text-replace'
  });

  // Project configuration.
  grunt.initConfig({
    config: {
      preview: {
        options: {
          variables: {
            aws: grunt.file.readJSON('configs/s3Config.json'),
            environment: 'preview',
            environmentData: 'website-guts/data/environments/production/environmentVariables.json',
            assets_dir: '/assets',
            sassSourceMap: false,
            sassImagePath: '/assets/img/',
            compress_js: true,
            concat_banner: '(function($){ \n\n' +
                           '  window.optly = window.optly || {}; \n\n' +
                           '  window.optly.mrkt = window.optly.mrkt || {}; \n\n' +
                           '  try { \n\n',
            concat_footer: '  } catch(error){ \n\n' +
                           '  //report errors to GA \n\n' +
                           '  window.console.log("js error: " + error);' +
                           '  } \n' +
                           '})(jQuery);'
          }
        }
      },
      dev: {
        options: {
          variables: {
            environment: 'dev',
            environmentData: 'website-guts/data/environments/development/environmentVariables.json',
            assets_dir: '/<%= config.dist %>/assets',
            sassSourceMap: true,
            sassImagePath: '/dist/assets/img/',
            compress_js: false,
            concat_banner: '(function($){ \n\n' +
                           '  window.optly = window.optly || {}; \n\n' +
                           '  window.optly.mrkt = window.optly.mrkt || {}; \n\n',
            concat_footer: '})(jQuery);'
          }
        }
      },
      content: 'website',
      guts: 'website-guts',
      dist: 'dist',
      temp: 'temp',
      bowerDir: 'bower_components'
    },
    watch: {
      assemble: {
        files: [
          '<%= config.content %>/{,*/}*.{md,hbs,yml,json}',
          '<%= config.guts %>/templates/**/*.hbs',
          '<%= config.content %>/**/*.hbs'
        ],
        tasks: ['config:dev', 'assemble']
      },
      sass: {
        files: '<%= config.guts %>/assets/css/**/*.scss',
        tasks: ['config:dev', 'sass', 'replace', 'autoprefixer', 'clean:postBuild']
      },
      img: {
        files: ['<%= config.guts %>/assets/img/*.{png,jpg,svg}'],
        tasks: ['copy:img']
      },
      js: {
        files: ['<%= config.guts %>/assets/js/**/*.js', '<%= config.temp %>/assets/js/**/*.js'],
        tasks: ['config:dev', 'jshint', 'concat', 'uglify', 'clean:postBuild']
      },
      livereload: {
        options: {
          livereload: '<%= connect.options.livereload %>'
        },
        files: [
          '<%= config.dist %>/**/*.html',
          '<%= config.dist %>/assets/css/**/*.css',
          '<%= config.dist %>/assets/js/**/*.js'
        ]
      }
    },
    connect: {
      options: {
        port: 9000,
        livereload: 35729,
        // change this to '0.0.0.0' to access the server from outside
        hostname: '0.0.0.0',
        middleware: function(connect, options, middlewares){
          middlewares.push(function(req, res, next){
            if(req.url === '/account/free_trial_landing'){

              res.writeHead(200, {'Content-Type': 'application/json'});
              res.end( grunt.file.read('website-guts/endpoint-mocks/formSuccess.json') );

            } else if(req.url === '/account/info') {

              res.writeHead(200, {'Content-Type': 'application/json'});
              res.end( grunt.file.read('website-guts/endpoint-mocks/accountInfo.json') );

            }
            else{

              return next();

            }

          });
          return middlewares;
        }
      },
      livereload: {
        options: {
          open: {
            target: 'http://0.0.0.0:9000/dist/'
          },
          base: '.'
        }
      }
    },
    assemble: {
      options: {
        layoutdir: '<%= config.guts %>/templates/layouts/',
        assetsDir: '<%= grunt.config.get("assets_dir") %>',
        environmentIsProduction: '<%= grunt.config.get("environmentIsProduction") %>',
        environmentIsDev: '<%= grunt.config.get("environmentIsDev") %>',
        data: ['<%= config.content %>/**/*.json', '<%= grunt.config.get("environmentData") %>']
      },
      pages: {
        files: [
          {
            src: ['**/*.hbs'],
            dest: '<%= config.dist %>/',
            cwd: '<%= config.content %>/',
            expand: true
          }
        ]
      }
    },
    sass: {
      styles: {
        options: {
          sourceMap: true,
          imagePath: '<%= grunt.config.get("sassImagePath") %>'
        },
        files: [
          {
            src: '<%= config.guts %>/assets/css/styles.scss',
            dest: '<%= config.temp %>/css/styles.css'
          }
        ]
      }
    },
    replace: {
      cssSourceMap: {
        src: '<%= config.temp %>/css/styles.css.map',
        overwrite: true,
        replacements: [
          {
            from: 'website-guts/',
            to: '../../../website-guts/'
          }
        ]
      }
    },
    autoprefixer: {
      options: {
        options: ['last 2 versions', "Firefox ESR"]
      },
      files: {
        flatten: true,
        src: '<%= config.temp %>/css/styles.css',
        dest: '<%= config.dist %>/assets/css/styles.css'
      }
    },
    copy: {
      cssSourceMap: {
        src: '<%= config.temp %>/css/styles.css.map',
        dest: '<%= config.dist %>/assets/css/styles.css.map'
      },
      cssFontFile: {
        src: ['<%= config.guts %>/assets/css/fonts.css'],
        dest: '<%= config.dist %>/assets/css/fonts.css'
      },
      js: {
        files: [
          {
            src: '<%= config.bowerDir %>/jquery/jquery.js',
            dest: '<%= config.dist %>/assets/js/libraries/jquery.js',
            flatten: true,
            filter: 'isFile'
          }
        ]
      },
      img: {
        files: [
          {
            cwd: '<%= config.guts %>/assets/img/',
            src: '**',
            dest: '<%= config.dist %>/assets/img/',
            expand: true
          }
        ]
      }
    },
    clean: {
      preBuild: ['<%= config.dist %>/'],
      postBuild: ['<%= config.temp %>']
    },
    s3: {
      options: {
        key: '<%= grunt.config.get("aws.key") %>',
        secret: '<%= grunt.config.get("aws.secret") %>',
        bucket: '<%= grunt.config.get("aws.bucket") %>',
        access: 'public-read',
      },
      dev: {
        upload: [
          {
            src: '<%= config.dist %>/**/*',
            dest: '/',
            rel: '<%= config.dist %>'
          }
        ]
      }
    },
    jshint: {
      options: {
        trailing: true,
        curly: true,
        eqeqeq: true,
        indent: 4,
        latedef: true,
        noempty: true,
        nonbsp: true,
        undef: true,
        unused: true,
        quotmark: 'single',
        browser: true,
        globals: {
          jQuery: true,
          $: true,
          console: false,
          Handlebars: false,
          moment: false,
          _gaq: false
        }
      },
      files: ['<%= config.guts %>/assets/js/**/*.js', '!<%= config.guts %>/assets/js/libraries/**/*.js']
    },
    concat: {
      temp: {
        options: {
          banner: '<%= grunt.config.get("concat_banner") %>',
          footer: '<%= grunt.config.get("concat_footer") %>'
        },
        src: ['**/*.js', '!libraries/**/*.js'],
        expand: true,
        cwd: '<%= config.guts %>/assets/js/',
        dest: '<%= config.temp %>/assets/js/'
      }
    },
    uglify: {
      options: {
        mangle: false,
        compress: false,
        beautify: false
      },
      globalJS: {
        files: {
          '<%= config.dist %>/assets/js/libraries/modernizr-yepnope.js': ['<%= config.guts %>/assets/js/libraries/modernizr-2.8.2.min.js','<%= config.bowerDir %>/yepnope/yepnope.1.5.4-min.js'],
          '<%= config.dist %>/assets/js/libraries/fastclick.js': ['<%= config.bowerDir %>/fastclick/lib/fastclick.js'],
          '<%= config.dist %>/assets/js/bundle.js': [
            '<%= config.bowerDir %>/jquery-cookie/jquery.cookie.js',
            '<%= config.guts %>/assets/js/libraries/handlebars-v1.3.0.js',
            '<%= config.bowerDir %>/momentjs/moment.js',
            '<%= config.guts %>/assets/js/libraries/oForm/oForm.js',
            '<%= config.temp %>/assets/js/global.js'
          ]
        }
      },
      pageFiles: {
        files: [
          {
            expand: true,
            cwd: '<%= config.temp %>/assets/js/pages',
            src: '**/*.js',
            dest: '<%= config.dist %>/assets/js/pages'
          }
        ]
      }
    }
  });

/*
  grunt.loadNpmTasks('assemble');
  grunt.loadNpmTasks('grunt-contrib-clean');
  grunt.loadNpmTasks('grunt-contrib-connect');
  grunt.loadNpmTasks('grunt-autoprefixer');
  grunt.loadNpmTasks('grunt-contrib-watch');
  grunt.loadNpmTasks('grunt-sass');
  grunt.loadNpmTasks('grunt-contrib-copy');
  //do not load the npm grunt-s3 task when using 'grunt server' per: https://github.com/pifantastic/grunt-s3/issues/68
  //do load it for running 'grunt preview'
  //grunt.loadNpmTasks('grunt-s3');
  grunt.loadNpmTasks('grunt-config');
  grunt.loadNpmTasks('grunt-contrib-concat');
  grunt.loadNpmTasks('grunt-contrib-uglify');
  grunt.loadNpmTasks('grunt-contrib-jshint');
  grunt.loadNpmTasks('grunt-text-replace');
*/

  grunt.registerTask('server', [
    'config:dev',
    'jshint',
    'clean:preBuild',
    'assemble',
    'concat',
    'uglify',
    'sass',
    'replace',
    'autoprefixer',
    'copy',
    'clean:postBuild',
    'connect:livereload',
    'watch'
  ]);

  grunt.registerTask('build', [
    'config:dev',
    'jshint',
    'clean:preBuild',
    'assemble',
    'concat',
    'uglify',
    'sass',
    'replace',
    'autoprefixer',
    'copy',
    'clean:postBuild'
  ]);

  grunt.registerTask('preview', [
    'config:preview',
    'jshint',
    'clean:preBuild',
    'assemble',
    'concat',
    'uglify',
    'sass',
    'autoprefixer',
    'copy',
    's3',
    'clean:postBuild'
  ]);

  grunt.registerTask('default', [
    'build'
  ]);

};
<|endoftext|>


<commit_before>'use strict';

module.exports = function (grunt) {

    require('load-grunt-tasks')(grunt);
    require('time-grunt')(grunt);

    grunt.initConfig({
        config: {
            hosts: {
                runtime: '0.0.0.0'
            },
            paths: {
                tmp: '.tmp',
                base: require('path').resolve(),
                src: 'src/webapp',
                test: 'test/webapp',
                results: 'results',
                instrumented: 'instrumented',
                config: 'config',
                build: 'build'
            }
        },
        clean: {
            files: [
                '<%=config.paths.tmp%>',
                '<%=config.paths.results%>',
                '<%=config.paths.instrumented%>',
                '<%=config.paths.build%>'
            ]
        },
        jshint: {
            options: {
                jshintrc: '<%=config.paths.base%>/.jshintrc',
                reporter: require('jshint-junit-reporter'),
                reporterOutput: '<%=config.paths.results%>/jshint/jshint.xml'
            },
            files: {
                src: ['<%=config.paths.src%>/**/*.js']
            }
        },
        karma: {
            options: {
                singleRun: true,
                reporters: ['progress', 'coverage', 'junit']
            },
            unit: {
                configFile: '<%=config.paths.config%>/karma.conf.js'
            }
        },
        less: {
            development: {
                options: {
                    sourceMap: true,
                    dumpLineNumbers: 'comments',
                    relativeUrls: true
                },
                files: {
                    "<%=config.paths.src%>/css/jpointme.css": "<%=config.paths.src%>/css/jpointme.less"
                }
            }
        },
        concat: {
            options: {
                separator: grunt.util.linefeed + ';' + grunt.util.linefeed
            },
            angular: {
                files: {
                    'build/js/angular.min.js': ['bower_components/angular/angular.min.js']
                }
            },
            modules: {
                files: {
                    'build/js/modules.min.js': ['bower_components/angular-*/*.min.js']
                }
            },
            plugins: {
                files: {
                    'build/js/plugins.min.js': [
                        'bower_components/jquery/dist/jquery.min.js',
                        'bower_components/bootstrap/js/carousel.js',
                        'bower_components/firebase/firebase.js',
                        'bower_components/angularfire/dist/angularfire.min.js'
                    ]
                }
            },
            jpointme: {
                files: {
                    '.tmp/js/jpointme.js': [
                        '<%=config.paths.src%>/js/jpointme.js',
                        '<%=config.paths.src%>/js/**/*.js']
                }
            }
        },
        uglify: {
            options: {
                banner: '/*! j.point.me <%= grunt.template.today("dd-mm-yyyy HH:MM:ss") %> */\n'
            },
            jpointme: {
                files: {
                    'build/js/jpointme.min.js': ['.tmp/js/jpointme.js']
                }
            }
        },
        instrument: {
            files: '<%=config.paths.src%>/**/*.js',
            options: {
                basePath: '<%=config.paths.instrumented%>',
                lazy: true
            }
        },
        portPick: {
            options: {
                port: 9000
            },
            protractor: {
                targets: [
                    'connect.options.port'
                ]
            }
        },
        connect: {
            options: {
                port: 0,
                hostname: '<%= config.hosts.runtime%>'
            },
            runtime: {
                options: {
                    open: {
                        target: 'http://<%= config.hosts.runtime%>:<%= connect.options.port%>/<%=config.paths.src%>'
                    },
                    middleware: function (connect) {
                        var config = grunt.config.get('config');

                        return [
                            connect().use('/' + config.paths.src + '/bower_components', connect.static('./bower_components')),
                            connect().use('/' + config.paths.src + '/js', connect.static(config.paths.instrumented + '/' + config.paths.src + '/js')),
                            connect().use('/' + config.paths.src, connect.static(config.paths.src))
                        ];
                    }
                }
            },
            dist: {
                options: {
                    open: {
                        target: 'http://<%= config.hosts.runtime%>:<%= connect.options.port%>'
                    },
                    middleware: function (connect) {
                        var config = grunt.config.get('config');

                        return [
                            connect().use('/', connect.static(config.paths.build))
                        ];
                    }
                }
            },
            test: {
                options: {
                    open: false,
                    middleware: function (connect) {
                        var config = grunt.config.get('config');

                        return [
                            connect().use('/' + config.paths.src + '/bower_components', connect.static('./bower_components')),
                            connect().use('/' + config.paths.src + '/js', connect.static(config.paths.instrumented + '/' + config.paths.src + '/js')),
                            connect().use('/' + config.paths.src, connect.static(config.paths.src)),
                            connect().use('/' + config.paths.test, connect.static(config.paths.test))
                        ];
                    }
                }
            }
        },
        protractor_coverage: {
            options: {
                keepAlive: true,
                noColor: false,
                debug: false,
                coverageDir: '<%=config.paths.results%>/protractor/coverage',
                args: {
                    resultsDir: '<%=config.paths.results%>/protractor',
                    baseUrl: 'http://<%= config.hosts.runtime %>:<%= connect.test.options.port %>',
                    specs: [
                        '<%=config.paths.test%>/protractor/**/*Spec.js',
                        '<%=config.paths.test%>/protractor/**/*spec.js'
                    ]
                }
            },
            test: {
                options: {
                    keepAlive: true,
                    configFile: '<%=config.paths.config%>/protractor.conf.js'
                }
            }
        },
        makeReport: {
            src: '<%=config.paths.results%>/protractor/coverage/*.json',
            options: {
                type: 'lcov',
                dir: '<%=config.paths.results%>/protractor/coverage',
                print: 'detail'
            }
        },
        watch: {
            test: {
                files: [
                    '<%=config.paths.instrumented%>/<%=config.paths.src%>/{,*/}*.js'
                ]
            }
        },
        copy: {
            jpointme: {
                files: [
                    {
                        expand: true,
                        dot: true,
                        cwd: '<%=config.paths.src%>',
                        dest: '<%=config.paths.build%>',
                        src: [
                            'img/{,*/}*.{gif,webp,svg,png,jpg}'
                        ]
                    }
                ]
            }
        },
        cssmin: {
            build: {
                files: {
                    'build/css/jpointme.min.css': [
                        '<%=config.paths.src%>/css/jpointme.css'
                    ]
                }
            }
        },
        htmlmin: {
            jpointme: {
                options: {
                    removeComments: false,
                    collapseWhitespace: false
                },
                files: [
                    {
                        expand: true,
                        cwd: '<%=config.paths.src%>',
                        src: ['*.html'],
                        dest: 'build'
                    }
                ]
            }
        },
        usemin: {
            html: ['build/{,*/}*.html'],
            css: ['build/css/{,*/}*.css'],
            options: {
                dirs: ['build']
            }
        },
        shell: {
            bowerupdate: {
                command: function () {
                    return './node_modules/bower/bin/bower update';
                }
            }
        }
    });

    grunt.registerTask('serve', 'Serve the app.', [
        'clean',
        'portPick',
        'package',
        'connect:dist',
        'watch'
    ]);

    /** Prepare the build with all the necessary stuff. */
    grunt.registerTask('prepare', 'Prepare the build with all the necessary stuff.', [
        'clean',
        'shell:bowerupdate',
        'portPick'
    ]);

    grunt.registerTask('test', 'Execute tests.', [
        'force:on',
        'jshint',
        'karma'
//        'instrument',
//        'connect:test',
//        'protractor_coverage',
//        'makeReport'
    ]);

    grunt.registerTask('verify', 'Verify if the current state meets the criteria.', function () {
        grunt.log.subhead('Not applicable yet');
    });

    grunt.registerTask('package', 'Package the code in a distributable format.', [
        'less',
        'copy',
        'concat',
        'htmlmin',
        'uglify',
        'cssmin',
        'usemin'
    ]);

    grunt.registerTask('integration-test', 'Execute tests against the packaged distribution.', function () {
        grunt.log.subhead('Not applicable yet');
    });

    grunt.registerTask('release', 'Release if compliant to all checks.', function () {
        grunt.log.subhead('Not applicable yet build');
    });

    grunt.registerTask('default', [
        'prepare',
        'test',
        'verify',
        'package',
        'integration-test',
        'release'
    ]);
};
<commit_msg>Added firebase to modules instead of plugins.<commit_after>'use strict';

module.exports = function (grunt) {

    require('load-grunt-tasks')(grunt);
    require('time-grunt')(grunt);

    grunt.initConfig({
        config: {
            hosts: {
                runtime: '0.0.0.0'
            },
            paths: {
                tmp: '.tmp',
                base: require('path').resolve(),
                src: 'src/webapp',
                test: 'test/webapp',
                results: 'results',
                instrumented: 'instrumented',
                config: 'config',
                build: 'build'
            }
        },
        clean: {
            files: [
                '<%=config.paths.tmp%>',
                '<%=config.paths.results%>',
                '<%=config.paths.instrumented%>',
                '<%=config.paths.build%>'
            ]
        },
        jshint: {
            options: {
                jshintrc: '<%=config.paths.base%>/.jshintrc',
                reporter: require('jshint-junit-reporter'),
                reporterOutput: '<%=config.paths.results%>/jshint/jshint.xml'
            },
            files: {
                src: ['<%=config.paths.src%>/**/*.js']
            }
        },
        karma: {
            options: {
                singleRun: true,
                reporters: ['progress', 'coverage', 'junit']
            },
            unit: {
                configFile: '<%=config.paths.config%>/karma.conf.js'
            }
        },
        less: {
            development: {
                options: {
                    sourceMap: true,
                    dumpLineNumbers: 'comments',
                    relativeUrls: true
                },
                files: {
                    "<%=config.paths.src%>/css/jpointme.css": "<%=config.paths.src%>/css/jpointme.less"
                }
            }
        },
        concat: {
            options: {
                separator: grunt.util.linefeed + ';' + grunt.util.linefeed
            },
            angular: {
                files: {
                    'build/js/angular.min.js': ['bower_components/angular/angular.min.js']
                }
            },
            modules: {
                files: {
                    'build/js/modules.min.js': [
                        'bower_components/angular-*/*.min.js',
                        'bower_components/firebase/firebase.js',
                        'bower_components/angularfire/dist/angularfire.min.js'
                    ]
                }
            },
            plugins: {
                files: {
                    'build/js/plugins.min.js': [
                        'bower_components/jquery/dist/jquery.min.js',
                        'bower_components/bootstrap/js/carousel.js'
                    ]
                }
            },
            jpointme: {
                files: {
                    '.tmp/js/jpointme.js': [
                        '<%=config.paths.src%>/js/jpointme.js',
                        '<%=config.paths.src%>/js/**/*.js']
                }
            }
        },
        uglify: {
            options: {
                banner: '/*! j.point.me <%= grunt.template.today("dd-mm-yyyy HH:MM:ss") %> */\n'
            },
            jpointme: {
                files: {
                    'build/js/jpointme.min.js': ['.tmp/js/jpointme.js']
                }
            }
        },
        instrument: {
            files: '<%=config.paths.src%>/**/*.js',
            options: {
                basePath: '<%=config.paths.instrumented%>',
                lazy: true
            }
        },
        portPick: {
            options: {
                port: 9000
            },
            protractor: {
                targets: [
                    'connect.options.port'
                ]
            }
        },
        connect: {
            options: {
                port: 0,
                hostname: '<%= config.hosts.runtime%>'
            },
            runtime: {
                options: {
                    open: {
                        target: 'http://<%= config.hosts.runtime%>:<%= connect.options.port%>/<%=config.paths.src%>'
                    },
                    middleware: function (connect) {
                        var config = grunt.config.get('config');

                        return [
                            connect().use('/' + config.paths.src + '/bower_components', connect.static('./bower_components')),
                            connect().use('/' + config.paths.src + '/js', connect.static(config.paths.instrumented + '/' + config.paths.src + '/js')),
                            connect().use('/' + config.paths.src, connect.static(config.paths.src))
                        ];
                    }
                }
            },
            dist: {
                options: {
                    open: {
                        target: 'http://<%= config.hosts.runtime%>:<%= connect.options.port%>'
                    },
                    middleware: function (connect) {
                        var config = grunt.config.get('config');

                        return [
                            connect().use('/', connect.static(config.paths.build))
                        ];
                    }
                }
            },
            test: {
                options: {
                    open: false,
                    middleware: function (connect) {
                        var config = grunt.config.get('config');

                        return [
                            connect().use('/' + config.paths.src + '/bower_components', connect.static('./bower_components')),
                            connect().use('/' + config.paths.src + '/js', connect.static(config.paths.instrumented + '/' + config.paths.src + '/js')),
                            connect().use('/' + config.paths.src, connect.static(config.paths.src)),
                            connect().use('/' + config.paths.test, connect.static(config.paths.test))
                        ];
                    }
                }
            }
        },
        protractor_coverage: {
            options: {
                keepAlive: true,
                noColor: false,
                debug: false,
                coverageDir: '<%=config.paths.results%>/protractor/coverage',
                args: {
                    resultsDir: '<%=config.paths.results%>/protractor',
                    baseUrl: 'http://<%= config.hosts.runtime %>:<%= connect.test.options.port %>',
                    specs: [
                        '<%=config.paths.test%>/protractor/**/*Spec.js',
                        '<%=config.paths.test%>/protractor/**/*spec.js'
                    ]
                }
            },
            test: {
                options: {
                    keepAlive: true,
                    configFile: '<%=config.paths.config%>/protractor.conf.js'
                }
            }
        },
        makeReport: {
            src: '<%=config.paths.results%>/protractor/coverage/*.json',
            options: {
                type: 'lcov',
                dir: '<%=config.paths.results%>/protractor/coverage',
                print: 'detail'
            }
        },
        watch: {
            test: {
                files: [
                    '<%=config.paths.instrumented%>/<%=config.paths.src%>/{,*/}*.js'
                ]
            }
        },
        copy: {
            jpointme: {
                files: [
                    {
                        expand: true,
                        dot: true,
                        cwd: '<%=config.paths.src%>',
                        dest: '<%=config.paths.build%>',
                        src: [
                            'img/{,*/}*.{gif,webp,svg,png,jpg}'
                        ]
                    }
                ]
            }
        },
        cssmin: {
            build: {
                files: {
                    'build/css/jpointme.min.css': [
                        '<%=config.paths.src%>/css/jpointme.css'
                    ]
                }
            }
        },
        htmlmin: {
            jpointme: {
                options: {
                    removeComments: false,
                    collapseWhitespace: false
                },
                files: [
                    {
                        expand: true,
                        cwd: '<%=config.paths.src%>',
                        src: ['*.html'],
                        dest: 'build'
                    }
                ]
            }
        },
        usemin: {
            html: ['build/{,*/}*.html'],
            css: ['build/css/{,*/}*.css'],
            options: {
                dirs: ['build']
            }
        },
        shell: {
            bowerupdate: {
                command: function () {
                    return './node_modules/bower/bin/bower update';
                }
            }
        }
    });

    grunt.registerTask('serve', 'Serve the app.', [
        'clean',
        'portPick',
        'package',
        'connect:dist',
        'watch'
    ]);

    /** Prepare the build with all the necessary stuff. */
    grunt.registerTask('prepare', 'Prepare the build with all the necessary stuff.', [
        'clean',
        'shell:bowerupdate',
        'portPick'
    ]);

    grunt.registerTask('test', 'Execute tests.', [
        'force:on',
        'jshint',
        'karma'
//        'instrument',
//        'connect:test',
//        'protractor_coverage',
//        'makeReport'
    ]);

    grunt.registerTask('verify', 'Verify if the current state meets the criteria.', function () {
        grunt.log.subhead('Not applicable yet');
    });

    grunt.registerTask('package', 'Package the code in a distributable format.', [
        'less',
        'copy',
        'concat',
        'htmlmin',
        'uglify',
        'cssmin',
        'usemin'
    ]);

    grunt.registerTask('integration-test', 'Execute tests against the packaged distribution.', function () {
        grunt.log.subhead('Not applicable yet');
    });

    grunt.registerTask('release', 'Release if compliant to all checks.', function () {
        grunt.log.subhead('Not applicable yet build');
    });

    grunt.registerTask('default', [
        'prepare',
        'test',
        'verify',
        'package',
        'integration-test',
        'release'
    ]);
};
<|endoftext|>


<commit_before>'use strict';

module.exports = function(grunt) {

  //Load NPM tasks
  grunt.loadNpmTasks('grunt-contrib-watch');
  grunt.loadNpmTasks('grunt-contrib-jshint');
  grunt.loadNpmTasks('grunt-mocha-test');
  grunt.loadNpmTasks('grunt-nodemon');
  grunt.loadNpmTasks('grunt-concurrent');
  grunt.loadNpmTasks('grunt-env');

  // Project Configuration
  grunt.initConfig({
    pkg: grunt.file.readJSON('package.json'),
    watch: {
      jade: {
        files: ['app/views/**'],
        options: {
          livereload: true,
        },
      },
      js: {
        files: ['Gruntfile.js', 'server.js', 'app/**/*.js', 'public/js/**'],
        tasks: ['jshint'],
        options: {
          livereload: true,
        },
      },
      html: {
        files: ['public/views/**'],
        options: {
          livereload: true,
        },
      },
      css: {
        files: ['public/css/**'],
        options: {
          livereload: true
        }
      },
        // we monitor only app/models/* because we have test for models only now
//      test: {
//        files: ['test/**/*.js', 'test/*.js','app/models/*.js'],
//        tasks: ['test'],
//      }
    },
    jshint: {
      all: {
        src: ['Gruntfile.js', 'server.js', 'app/**/*.js', 'public/js/**','lib/*.js'],
        options: {
          jshintrc: true
        }
      }
    },
    mochaTest: {
      options: {
        reporter: 'spec',
      },
      src: ['test/**/*.js'],
    },

    nodemon: {
      dev: {
        options: {
          file: 'server.js',
          args: [],
          ignoredFiles: ['public/**', 'test/**','util/**'],
          watchedExtensions: ['js'],
          // nodeArgs: ['--debug'],
          delayTime: 1,
          env: {
            PORT: 3000
          },
          cwd: __dirname
        }
      }
    },
    concurrent: {
      tasks: ['nodemon', 'watch'],
      options: {
        logConcurrentOutput: true
      }
    },
    env: {
      test: {
        NODE_ENV: 'test'
      }
    }
  });

  //Making grunt default to force in order not to break the project.
  grunt.option('force', true);

  //Default task(s).
  grunt.registerTask('default', ['jshint','concurrent']);

  //Test task.
  grunt.registerTask('test', ['env:test', 'mochaTest']);
};
<commit_msg>grunt-nodemon options updated to the new version<commit_after>'use strict';

module.exports = function(grunt) {

  //Load NPM tasks
  grunt.loadNpmTasks('grunt-contrib-watch');
  grunt.loadNpmTasks('grunt-contrib-jshint');
  grunt.loadNpmTasks('grunt-mocha-test');
  grunt.loadNpmTasks('grunt-nodemon');
  grunt.loadNpmTasks('grunt-concurrent');
  grunt.loadNpmTasks('grunt-env');

  // Project Configuration
  grunt.initConfig({
    pkg: grunt.file.readJSON('package.json'),
    watch: {
      jade: {
        files: ['app/views/**'],
        options: {
          livereload: true,
        },
      },
      js: {
        files: ['Gruntfile.js', 'server.js', 'app/**/*.js', 'public/js/**'],
        tasks: ['jshint'],
        options: {
          livereload: true,
        },
      },
      html: {
        files: ['public/views/**'],
        options: {
          livereload: true,
        },
      },
      css: {
        files: ['public/css/**'],
        options: {
          livereload: true
        }
      },
        // we monitor only app/models/* because we have test for models only now
//      test: {
//        files: ['test/**/*.js', 'test/*.js','app/models/*.js'],
//        tasks: ['test'],
//      }
    },
    jshint: {
      all: {
        src: ['Gruntfile.js', 'server.js', 'app/**/*.js', 'public/js/**','lib/*.js'],
        options: {
          jshintrc: true
        }
      }
    },
    mochaTest: {
      options: {
        reporter: 'spec',
      },
      src: ['test/**/*.js'],
    },

    nodemon: {
      dev: {
        script: 'server.js',
        options: {
          args: [],
          ignore: ['public/**', 'test/**','util/**'],
          // nodeArgs: ['--debug'],
          delayTime: 1,
          env: {
            PORT: 3000
          },
          cwd: __dirname
        }
      }
    },
    concurrent: {
      tasks: ['nodemon', 'watch'],
      options: {
        logConcurrentOutput: true
      }
    },
    env: {
      test: {
        NODE_ENV: 'test'
      }
    }
  });

  //Making grunt default to force in order not to break the project.
  grunt.option('force', true);

  //Default task(s).
  grunt.registerTask('default', ['jshint','concurrent']);

  //Test task.
  grunt.registerTask('test', ['env:test', 'mochaTest']);
};
<|endoftext|>


<commit_before>module.exports = function(grunt) {

    // Project configuration.
    grunt.initConfig({
        pkg: grunt.file.readJSON('package.json'),
        uglify: {
            main: {
                src: 'js/<%= pkg.name %>.js',
                dest: 'js/<%= pkg.name %>.min.js'
            }
        },
        less: {
            expanded: {
                options: {
                    paths: ["css"]
                },
                files: {
                    "css/<%= pkg.name %>.css": "less/<%= pkg.name %>.less"
                }
            },
            minified: {
                options: {
                    paths: ["css"],
                    cleancss: true
                },
                files: {
                    "css/<%= pkg.name %>.min.css": "less/<%= pkg.name %>.less"
                }
            }
        },
        banner: '/*!\n' +
            ' * <%= pkg.title %> v<%= pkg.version %> (<%= pkg.homepage %>)\n' +
            ' * Copyright <%= grunt.template.today("yyyy") %> <%= pkg.author %>\n' +
            ' * Licensed under <%= pkg.license.type %> (<%= pkg.license.url %>)\n' +
            ' */\n',
        usebanner: {
            dist: {
                options: {
                    position: 'top',
                    banner: '<%= banner %>'
                },
                files: {
                    src: ['css/<%= pkg.name %>.css', 'css/<%= pkg.name %>.min.css', 'js/<%= pkg.name %>.min.js']
                }
            }
        },
        watch: {
            scripts: {
                files: ['js/<%= pkg.name %>.js'],
                tasks: ['uglify'],
                options: {
                    spawn: false,
                },
            },
            less: {
                files: ['less/*.less'],
                tasks: ['less'],
                options: {
                    spawn: false,
                }
            },
        },
    });

    // Load the plugins.
    grunt.loadNpmTasks('grunt-contrib-uglify');
    grunt.loadNpmTasks('grunt-contrib-less');
    grunt.loadNpmTasks('grunt-banner');
    grunt.loadNpmTasks('grunt-contrib-watch');

    // Default task(s).
    grunt.registerTask('default', ['uglify', 'less', 'usebanner']);

};
<commit_msg>Delete Gruntfile.js<commit_after><|endoftext|>