<commit_before>require('js-yaml');
var path = require('path');

module.exports = function (grunt) {
  grunt.loadNpmTasks('grunt-bower-task');
  grunt.loadNpmTasks('grunt-contrib-jst');
  grunt.loadNpmTasks('grunt-mocha-cli');
  grunt.loadNpmTasks('grunt-mocha-cov');
  grunt.loadNpmTasks('grunt-karma');
  grunt.loadNpmTasks('grunt-exec');
  grunt.loadNpmTasks('grunt-contrib-less');
  grunt.loadNpmTasks('grunt-contrib-watch');

  grunt.initConfig({
    paths: require('./js_paths.yml'),
    bower: {
      install: {
        options: {
          layout: 'byComponent',
          cleanTargetDir: true,
          targetDir: 'go/base/static/vendor'
        }
      }
    },
    mochacli: {
      jsbox_apps: {
        options: {reporter: 'dot'},
        src: ['<%= paths.tests.jsbox_apps.spec %>']
      },
    },
    mochacov: {
      jsbox_apps: {
        options: {
          files: ['<%= paths.tests.jsbox_apps.spec %>'],
          reporter: 'mocha-lcov-reporter',
          output: 'mochacov.lcov',
          coverage: true
        }
      },
    },
    jst: {
      options: {
        processName: function(filename) {
          // We need to process the template names the same way Django
          // Pipelines does
          var dir = path.dirname(filename);
          dir = path.relative('go/base/static/templates', dir);

          var parts = dir.split('/');
          parts.push(path.basename(filename, '.jst'));

          return parts.join('_');
        }
      },
      templates: {
        files: {
          "<%= paths.client.templates.dest %>": [
            "<%= paths.client.templates.src %>"
          ]
        }
      },
    },
    karma: {
      dev: {
        singleRun: true,
        reporters: ['dots', 'coverage'],
        configFile: 'karma.conf.js'
      }
    },
    exec: {
      'fonts': {
        cmd: [
          'mkdir -p `dirname <%= paths.client.fonts.vendor.dest %>`',
          ' && ',
          'cp <%= paths.client.fonts.vendor.src %> ',
          '   <%= paths.client.fonts.vendor.dest %>'
        ].join('')
      }
    },
    less: {
      dev: {
        options: {
          paths: ["go/base/static/css"],
          compress: true,
          sourceMap: true,
          sourceMapFilename: "go/base/static/css/vumigo.css.map",
          sourceMapBasepath: "go/base/static/css/"
        },
        files: {
          "go/base/static/css/vumigo.css": "go/base/static/css/vumigo.less"
        },
      }
    },
    watch: {
      less: {
        files: ['go/base/static/css/*.less'],
        tasks: ['less']
      }
    }
  });

  grunt.registerTask('test:jsbox_apps', [
    'mochacli:jsbox_apps',
    'mochacov:jsbox_apps'
  ]);

  grunt.registerTask('test:client', [
    'jst:templates',
    'karma:dev'
  ]);

  grunt.registerTask('vendor', [
    'bower',
    'exec:fonts'
  ]);

  grunt.registerTask('test', [
    'test:jsbox_apps',
    'test:client'
  ]);

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

};
<commit_msg>Oops, remove mini since Django does it<commit_after>require('js-yaml');
var path = require('path');

module.exports = function (grunt) {
  grunt.loadNpmTasks('grunt-bower-task');
  grunt.loadNpmTasks('grunt-contrib-jst');
  grunt.loadNpmTasks('grunt-mocha-cli');
  grunt.loadNpmTasks('grunt-mocha-cov');
  grunt.loadNpmTasks('grunt-karma');
  grunt.loadNpmTasks('grunt-exec');
  grunt.loadNpmTasks('grunt-contrib-less');
  grunt.loadNpmTasks('grunt-contrib-watch');

  grunt.initConfig({
    paths: require('./js_paths.yml'),
    bower: {
      install: {
        options: {
          layout: 'byComponent',
          cleanTargetDir: true,
          targetDir: 'go/base/static/vendor'
        }
      }
    },
    mochacli: {
      jsbox_apps: {
        options: {reporter: 'dot'},
        src: ['<%= paths.tests.jsbox_apps.spec %>']
      },
    },
    mochacov: {
      jsbox_apps: {
        options: {
          files: ['<%= paths.tests.jsbox_apps.spec %>'],
          reporter: 'mocha-lcov-reporter',
          output: 'mochacov.lcov',
          coverage: true
        }
      },
    },
    jst: {
      options: {
        processName: function(filename) {
          // We need to process the template names the same way Django
          // Pipelines does
          var dir = path.dirname(filename);
          dir = path.relative('go/base/static/templates', dir);

          var parts = dir.split('/');
          parts.push(path.basename(filename, '.jst'));

          return parts.join('_');
        }
      },
      templates: {
        files: {
          "<%= paths.client.templates.dest %>": [
            "<%= paths.client.templates.src %>"
          ]
        }
      },
    },
    karma: {
      dev: {
        singleRun: true,
        reporters: ['dots', 'coverage'],
        configFile: 'karma.conf.js'
      }
    },
    exec: {
      'fonts': {
        cmd: [
          'mkdir -p `dirname <%= paths.client.fonts.vendor.dest %>`',
          ' && ',
          'cp <%= paths.client.fonts.vendor.src %> ',
          '   <%= paths.client.fonts.vendor.dest %>'
        ].join('')
      }
    },
    less: {
      dev: {
        options: {
          paths: ["go/base/static/css"],
          sourceMap: true,
          sourceMapFilename: "go/base/static/css/vumigo.css.map",
          sourceMapBasepath: "go/base/static/css/"
        },
        files: {
          "go/base/static/css/vumigo.css": "go/base/static/css/vumigo.less"
        },
      }
    },
    watch: {
      less: {
        files: ['go/base/static/css/*.less'],
        tasks: ['less']
      }
    }
  });

  grunt.registerTask('test:jsbox_apps', [
    'mochacli:jsbox_apps',
    'mochacov:jsbox_apps'
  ]);

  grunt.registerTask('test:client', [
    'jst:templates',
    'karma:dev'
  ]);

  grunt.registerTask('vendor', [
    'bower',
    'exec:fonts'
  ]);

  grunt.registerTask('test', [
    'test:jsbox_apps',
    'test:client'
  ]);

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

};
<|endoftext|>


<commit_before>const _ = require('lodash');
const { ServerAPI } = require('../../services');

let isUniprotId = token => {
  return /uniprot:\w+$/i.test( token );
};

let isNcbiId = token => {
  return /ncbi:[0-9]+$/i.test( token );
};

let isHgncId = token => {
  return /hgnc:\w+$/i.test( token );
};

let dbInfos = {
  'HGNC Symbol': {
    name: 'HGNC Symbol',
    displayName: 'HGNC',
    url: 'http://identifiers.org/hgnc.symbol/',
    gProfiler: 'HGNCSYMBOL',
    hgncName: 'symbol',
    ncbiName: 'name'
  },
  'NCBI Gene': {
    name: 'NCBI Gene',
    displayName: 'NCBI Gene',
    url: 'http://identifiers.org/ncbigene/',
    gProfiler: 'NCBIGene',
    hgncName: 'entrez_id',
    ncbiName: 'uid'
  },
  'Uniprot': {
    name: 'Uniprot',
    displayName: 'UniProt',
    url: 'http://identifiers.org/uniprot/',
    gProfiler: 'Uniprot',
    hgncName: 'uniprot_ids'
  },
  'Gene Cards': {
    name: 'Gene Cards',
    displayName: 'Gene Cards',
    url: 'https://www.genecards.org/cgi-bin/carddisp.pl?gene=',
    gProfiler: 'HGNCSYMBOL',
    hgncName: 'symbol',
    ncbiName: 'name'
  }
};

/**
 * Get database link and display name based on gene ids
 * @param {{string:string}} ids NCBI id to search, e.g.{GENE CARD:MDM2}
 * @return {[{string:string,string,string}]} Array of database containing link and display name, e.g.{link: URI, displayName: MDM2}
 */
const idToLinkConverter = ids => {

  let links = Object.entries(ids).map( ( entry ) => {
    let [ dbName, geneId ] = entry;
    let dbInfo = dbInfos[ dbName ];

    return  {
      link: dbInfo.url + geneId,
      displayName: dbInfo.displayName
    };
  });

  return links;
};

/**
 * Get gene information from NCBI
 * @param {string:string} ids NCBI id to search, e.g.{4193:MDM2}
 * @param {} genes Validated gene id from databse, e.g.{gene:{db1:id,db2:id}}
 * @return {json} JSON of gene information.
 */
const getNcbiInfo = ( ids, genes ) => {
  const ncbiIds = Object.keys( ids );

  return ServerAPI.getGeneInformation( ncbiIds ).then( result => {

    if( _.isEmpty(result) ) return [];
    let geneResults = result.result;

    return geneResults.uids.map( uid => {
      const gene = geneResults[ uid ];

      let databaseId = {};
      if( genes ) {
        //Called from validator
        const originalSearch = ids[ uid ];
        databaseId = genes[ originalSearch ];
      }
      else{
        //Data from provider
        Object.entries(dbInfos).forEach( dbInfo => {
          if ( gene[ dbInfo[1].ncbiName ] ) databaseId[ dbInfo[1].name ] = gene[ dbInfo[1].ncbiName ];
        });
      }
      let links = idToLinkConverter( databaseId );

      return {
        databaseID: uid,
        name: gene.nomenclaturename,
        function: gene.summary,
        officialSymbol: gene.nomenclaturesymbol,
        otherNames: gene.otheraliases ? gene.otheraliases : '',
        links: links
      };
    });
  });
};

/**
 * Get entity information from Uniprot
 * @param {string:string} ids Uniprot accessions to search, e.g.{ 4193: MDM2 }
 * @return {json} JSON of gene information.
 */
const getUniprotInfo = ids => {

  let uniprotIds = Object.keys( ids );

  return ServerAPI.getUniprotInformation( uniprotIds ).then( uniprotInfos => {

    return uniprotInfos.map( uniprotInfo => {

      let dbIds = { Uniprot: uniprotInfo.accession };

      uniprotInfo.dbReferences.forEach( db => {
        if( db.type === 'GeneID' ){
          dbIds['NCBI Gene'] = db.id;
        }
        if( db.type === 'HGNC' ){
          const hgncSymbol = db.properties['gene designation'];
          dbIds['HGNC Symbol'] = hgncSymbol;
          dbIds['Gene Cards'] = hgncSymbol;
        }
      });

      let links = idToLinkConverter( dbIds );

      return {
        databaseID: uniprotInfo.accession,
        name: uniprotInfo.gene[0].name.value,
        function: uniprotInfo.comments && uniprotInfo.comments[0].type === 'FUNCTION' ? uniprotInfo.comments[0].text[0].value : '',
        officialSymbol: dbIds['HGNC Symbol'],
        otherNames: '',
        links: links
      };
    });
  });
};

const getHgncInfo = hgncSymbols => {
  return Promise.all(Object.keys(hgncSymbols).map( hgncSymbol => {

    return ServerAPI.getHgncInformation( hgncSymbol ).then( result => {

      if( _.isEmpty(result) ) return [];
      const geneResults = result.response.docs;
      return geneResults.map(gene => {

        let databaseId = {};
        Object.entries(dbInfos).forEach( dbInfo => {
          if ( gene[ dbInfo[1].hgncName ] ) databaseId[ dbInfo[1].name ] = gene[ dbInfo[1].hgncName ];
        });
        const links = idToLinkConverter( databaseId );

        return {
          databaseID: gene,
          name: gene.name,
          function: '',
          officialSymbol: gene.symbol,
          otherNames: gene.alias_symbol.join(', '),
          showMore: {
            full: !( geneResults.length> 1 ),
            function: false,
            synonyms: false
          },
          links: links
        };
      });
    });
  }));
};

const getProviderSpecificEntityInfo = ( ncbiIds, uniprotIds, hgncIds, entityInfos ) => {
  let providerSpecificEntityInfo = [];

  if( Object.keys(ncbiIds).length > 0 ){
    providerSpecificEntityInfo.push( getNcbiInfo( ncbiIds, entityInfos ) );
  }
  if( Object.keys(uniprotIds).length > 0 ){
    providerSpecificEntityInfo.push( getUniprotInfo( uniprotIds ) );
  }
  if ( Object.keys(hgncIds).length > 0 ){
   providerSpecificEntityInfo.push( getHgncInfo( hgncIds ) );
  }
  return Promise.all( providerSpecificEntityInfo ).then( providerInfo => {
   // legacy computation that is hard to understand
   return _.uniqWith(  _.flattenDeep( providerInfo ), ( arrVal, othVal ) => {
     return _.intersectionWith( _.values( arrVal.links ), _.values( othVal.links ), _.isEqual ).length;
   });
 });
};

// two types of searches:
// * general searches
// * db specific link in searches

// link in examples
// http://localhost:3000/search?q=uniprot:q99988
// http://localhost:3000/search?q=ncbi:7157
// http://localhost:3000/search?q=hgnc:tp53
// * dont use the validator for these special searches
// * use db specific info for each corresponding link  e.g uniprot uses a uniprot speciifc entity info box

// general searches
// * use validator
// * the validator defaults to ncbi because it is the most general db

// takes in a string and looks for substrings of the form:
// * uniprot:<uniprot_id>
// * ncbi:<ncbi_id>
// * <hgnc_id>
const queryEntityInfo = query => {
  let tokens = query.trim().split(' ');
  let ncbiIds = {};
  let uniprotIds = {};
  let hgncId = {};
  let genes = [];
  let hasPrefix = true;
  let entityQueries;

  // look for special tokens
  if (tokens.length === 1) {
    const token = tokens[0];
    const [ dbId, entityId ] = token.split(':');

    if( isUniprotId( token ) ){
      uniprotIds[ entityId ] = entityId;
    } else if( isNcbiId( token ) ){
      ncbiIds[ entityId ] = entityId;
    } else if (isHgncId( token ) ){
      hgncId[ entityId ] = entityId;
    } else {
      hasPrefix = false;
      genes.push( dbId );
    }
  } else {
  tokens.forEach( token => {
    hasPrefix = false;
      genes.push( token );
  });
}

  if ( hasPrefix ) {
    return getProviderSpecificEntityInfo( ncbiIds, uniprotIds, hgncId );
  }
  else {
   let dbsToQuery = Object.entries(dbInfos).map( dbInfo => dbInfo[1] );

   // create entity recognizer queries
   entityQueries = dbsToQuery.map( db => {
     return ServerAPI.geneQuery({
       genes: genes,
       targetDb: db.gProfiler
     }).then(res => {
       let { geneInfo: entityInfos, unrecognized: unrecognizedEntities } = res;
       let duplicates = new Set();
       let entities = { unrecognizedEntities };

       entityInfos.forEach( entityInfo => {
         let { convertedAlias } = entityInfo;
         if( !duplicates.has( convertedAlias ) ){
           entities[ entityInfo.initialAlias ] = { [db.name]: convertedAlias };
           duplicates.add( convertedAlias );
         }
       });

       return entities;
     });
   });

   // send queries and return entity info
   return Promise.all( entityQueries ).then( results => {
     let entityInfos = {};
     results.forEach( dbResult => _.merge( entityInfos, dbResult ) ); //Merge the array of result into one json

     Object.entries( entityInfos ).forEach( entityInfo => {
       let [ originalSearchTerm, mappedGene ] = entityInfo;

       if( mappedGene['NCBI Gene'] ){
         ncbiIds[ mappedGene['NCBI Gene'] ] = originalSearchTerm;
       }
       else if( mappedGene['Uniprot'] ){
         uniprotIds[ mappedGene['Uniprot'] ] = originalSearchTerm;
       }
     });
     return getProviderSpecificEntityInfo( ncbiIds, uniprotIds, hgncId, entityInfos );
   });
  }
};

module.exports = queryEntityInfo;<commit_msg>Fix display name<commit_after>const _ = require('lodash');
const { ServerAPI } = require('../../services');

let isUniprotId = token => {
  return /uniprot:\w+$/i.test( token );
};

let isNcbiId = token => {
  return /ncbi:[0-9]+$/i.test( token );
};

let isHgncId = token => {
  return /hgnc:\w+$/i.test( token );
};

let dbInfos = {
  'HGNC Symbol': {
    name: 'HGNC Symbol',
    displayName: 'HGNC',
    url: 'http://identifiers.org/hgnc.symbol/',
    gProfiler: 'HGNCSYMBOL',
    hgncName: 'symbol',
    ncbiName: 'name'
  },
  'NCBI Gene': {
    name: 'NCBI Gene',
    displayName: 'NCBI Gene',
    url: 'http://identifiers.org/ncbigene/',
    gProfiler: 'NCBIGene',
    hgncName: 'entrez_id',
    ncbiName: 'uid'
  },
  'Uniprot': {
    name: 'Uniprot',
    displayName: 'UniProt',
    url: 'http://identifiers.org/uniprot/',
    gProfiler: 'Uniprot',
    hgncName: 'uniprot_ids'
  },
  'Gene Cards': {
    name: 'Gene Cards',
    displayName: 'GeneCards',
    url: 'https://www.genecards.org/cgi-bin/carddisp.pl?gene=',
    gProfiler: 'HGNCSYMBOL',
    hgncName: 'symbol',
    ncbiName: 'name'
  }
};

/**
 * Get database link and display name based on gene ids
 * @param {{string:string}} ids NCBI id to search, e.g.{GENE CARD:MDM2}
 * @return {[{string:string,string,string}]} Array of database containing link and display name, e.g.{link: URI, displayName: MDM2}
 */
const idToLinkConverter = ids => {

  let links = Object.entries(ids).map( ( entry ) => {
    let [ dbName, geneId ] = entry;
    let dbInfo = dbInfos[ dbName ];

    return  {
      link: dbInfo.url + geneId,
      displayName: dbInfo.displayName
    };
  });

  return links;
};

/**
 * Get gene information from NCBI
 * @param {string:string} ids NCBI id to search, e.g.{4193:MDM2}
 * @param {} genes Validated gene id from databse, e.g.{gene:{db1:id,db2:id}}
 * @return {json} JSON of gene information.
 */
const getNcbiInfo = ( ids, genes ) => {
  const ncbiIds = Object.keys( ids );

  return ServerAPI.getGeneInformation( ncbiIds ).then( result => {

    if( _.isEmpty(result) ) return [];
    let geneResults = result.result;

    return geneResults.uids.map( uid => {
      const gene = geneResults[ uid ];

      let databaseId = {};
      if( genes ) {
        //Called from validator
        const originalSearch = ids[ uid ];
        databaseId = genes[ originalSearch ];
      }
      else{
        //Data from provider
        Object.entries(dbInfos).forEach( dbInfo => {
          if ( gene[ dbInfo[1].ncbiName ] ) databaseId[ dbInfo[1].name ] = gene[ dbInfo[1].ncbiName ];
        });
      }
      let links = idToLinkConverter( databaseId );

      return {
        databaseID: uid,
        name: gene.nomenclaturename,
        function: gene.summary,
        officialSymbol: gene.nomenclaturesymbol,
        otherNames: gene.otheraliases ? gene.otheraliases : '',
        links: links
      };
    });
  });
};

/**
 * Get entity information from Uniprot
 * @param {string:string} ids Uniprot accessions to search, e.g.{ 4193: MDM2 }
 * @return {json} JSON of gene information.
 */
const getUniprotInfo = ids => {

  let uniprotIds = Object.keys( ids );

  return ServerAPI.getUniprotInformation( uniprotIds ).then( uniprotInfos => {

    return uniprotInfos.map( uniprotInfo => {

      let dbIds = { Uniprot: uniprotInfo.accession };

      uniprotInfo.dbReferences.forEach( db => {
        if( db.type === 'GeneID' ){
          dbIds['NCBI Gene'] = db.id;
        }
        if( db.type === 'HGNC' ){
          const hgncSymbol = db.properties['gene designation'];
          dbIds['HGNC Symbol'] = hgncSymbol;
          dbIds['Gene Cards'] = hgncSymbol;
        }
      });

      let links = idToLinkConverter( dbIds );

      return {
        databaseID: uniprotInfo.accession,
        name: uniprotInfo.gene[0].name.value,
        function: uniprotInfo.comments && uniprotInfo.comments[0].type === 'FUNCTION' ? uniprotInfo.comments[0].text[0].value : '',
        officialSymbol: dbIds['HGNC Symbol'],
        otherNames: '',
        links: links
      };
    });
  });
};

const getHgncInfo = hgncSymbols => {
  return Promise.all(Object.keys(hgncSymbols).map( hgncSymbol => {

    return ServerAPI.getHgncInformation( hgncSymbol ).then( result => {

      if( _.isEmpty(result) ) return [];
      const geneResults = result.response.docs;
      return geneResults.map(gene => {

        let databaseId = {};
        Object.entries(dbInfos).forEach( dbInfo => {
          if ( gene[ dbInfo[1].hgncName ] ) databaseId[ dbInfo[1].name ] = gene[ dbInfo[1].hgncName ];
        });
        const links = idToLinkConverter( databaseId );

        return {
          databaseID: gene,
          name: gene.name,
          function: '',
          officialSymbol: gene.symbol,
          otherNames: gene.alias_symbol.join(', '),
          showMore: {
            full: !( geneResults.length> 1 ),
            function: false,
            synonyms: false
          },
          links: links
        };
      });
    });
  }));
};

const getProviderSpecificEntityInfo = ( ncbiIds, uniprotIds, hgncIds, entityInfos ) => {
  let providerSpecificEntityInfo = [];

  if( Object.keys(ncbiIds).length > 0 ){
    providerSpecificEntityInfo.push( getNcbiInfo( ncbiIds, entityInfos ) );
  }
  if( Object.keys(uniprotIds).length > 0 ){
    providerSpecificEntityInfo.push( getUniprotInfo( uniprotIds ) );
  }
  if ( Object.keys(hgncIds).length > 0 ){
   providerSpecificEntityInfo.push( getHgncInfo( hgncIds ) );
  }
  return Promise.all( providerSpecificEntityInfo ).then( providerInfo => {
   // legacy computation that is hard to understand
   return _.uniqWith(  _.flattenDeep( providerInfo ), ( arrVal, othVal ) => {
     return _.intersectionWith( _.values( arrVal.links ), _.values( othVal.links ), _.isEqual ).length;
   });
 });
};

// two types of searches:
// * general searches
// * db specific link in searches

// link in examples
// http://localhost:3000/search?q=uniprot:q99988
// http://localhost:3000/search?q=ncbi:7157
// http://localhost:3000/search?q=hgnc:tp53
// * dont use the validator for these special searches
// * use db specific info for each corresponding link  e.g uniprot uses a uniprot speciifc entity info box

// general searches
// * use validator
// * the validator defaults to ncbi because it is the most general db

// takes in a string and looks for substrings of the form:
// * uniprot:<uniprot_id>
// * ncbi:<ncbi_id>
// * <hgnc_id>
const queryEntityInfo = query => {
  let tokens = query.trim().split(' ');
  let ncbiIds = {};
  let uniprotIds = {};
  let hgncId = {};
  let genes = [];
  let hasPrefix = true;
  let entityQueries;

  // look for special tokens
  if (tokens.length === 1) {
    const token = tokens[0];
    const [ dbId, entityId ] = token.split(':');

    if( isUniprotId( token ) ){
      uniprotIds[ entityId ] = entityId;
    } else if( isNcbiId( token ) ){
      ncbiIds[ entityId ] = entityId;
    } else if (isHgncId( token ) ){
      hgncId[ entityId ] = entityId;
    } else {
      hasPrefix = false;
      genes.push( dbId );
    }
  } else {
  tokens.forEach( token => {
    hasPrefix = false;
      genes.push( token );
  });
}

  if ( hasPrefix ) {
    return getProviderSpecificEntityInfo( ncbiIds, uniprotIds, hgncId );
  }
  else {
   let dbsToQuery = Object.entries(dbInfos).map( dbInfo => dbInfo[1] );

   // create entity recognizer queries
   entityQueries = dbsToQuery.map( db => {
     return ServerAPI.geneQuery({
       genes: genes,
       targetDb: db.gProfiler
     }).then(res => {
       let { geneInfo: entityInfos, unrecognized: unrecognizedEntities } = res;
       let duplicates = new Set();
       let entities = { unrecognizedEntities };

       entityInfos.forEach( entityInfo => {
         let { convertedAlias } = entityInfo;
         if( !duplicates.has( convertedAlias ) ){
           entities[ entityInfo.initialAlias ] = { [db.name]: convertedAlias };
           duplicates.add( convertedAlias );
         }
       });

       return entities;
     });
   });

   // send queries and return entity info
   return Promise.all( entityQueries ).then( results => {
     let entityInfos = {};
     results.forEach( dbResult => _.merge( entityInfos, dbResult ) ); //Merge the array of result into one json

     Object.entries( entityInfos ).forEach( entityInfo => {
       let [ originalSearchTerm, mappedGene ] = entityInfo;

       if( mappedGene['NCBI Gene'] ){
         ncbiIds[ mappedGene['NCBI Gene'] ] = originalSearchTerm;
       }
       else if( mappedGene['Uniprot'] ){
         uniprotIds[ mappedGene['Uniprot'] ] = originalSearchTerm;
       }
     });
     return getProviderSpecificEntityInfo( ncbiIds, uniprotIds, hgncId, entityInfos );
   });
  }
};

module.exports = queryEntityInfo;<|endoftext|>


<commit_before>'use strict';

const got = require('got');
const path = require('path');
const moment = require('moment');
const pad = require('lodash.padstart');
const _ = require('lodash');
const AWS = require('aws-sdk')
const local = require('kes/src/local');
const metadata = require('../../lib/metadata');
var through2 = require('through2')

const bands = [
  'ANG.txt',
  'B1.TIF',
  'B2.TIF',
  'B3.TIF',
  'B4.TIF',
  'B5.TIF',
  'B6.TIF',
  'B7.TIF',
  'B8.TIF',
  'B9.TIF',
  'B10.TIF',
  'B11.TIF',
  'BQA.TIF',
  'MTL.txt'
];

const s3 = new AWS.S3()

function googleLinks(data) {
  const row = pad(data.row, 3, '0');
  const _path = pad(data.path, 3, '0');
  //const sceneId = data.sceneID;
  const productId = data.LANDSAT_PRODUCT_ID;

  const c1Console = `https://console.cloud.google.com/storage/browser/gcp-public-data-landsat/LC08/${path.join(_path, row, productId)}`;
  const c1Base = `https://storage.googleapis.com/gcp-public-data-landsat/LC08/01/${path.join(_path, row, productId)}`;

  const c1Files = bands.map((b) => `${c1Base}/${productId}_${b}`);

  const c1 = {
    index: c1Console,
    files: c1Files
  };

  return { c1 };
}

//! Check to see if a URL exists
function fileExists(url) {
  var params = {
    Bucket: 'landsat-pds',
    Key: url.slice(36)
  }
  return new Promise(function(resolve, reject) {
    s3.headObject(params, function (err, metadata) {
      if (err && err.code === 'NotFound') {
        reject(url)
      } else {
        resolve(url)
      }
    })
  })
  /*return new Promise(function(resolve, reject) {
    got(url).then(response => {
      resolve(url);
    }).catch(e => {
      reject(url);
    });
  });*/
}

//! iterate over an array synchronously, invoke function on each element
function arrayIterate(values, fn) {
  return new Promise(function(resolve, reject) {
    // Are there any values to check?
    if (values.length === 0) {
      // All were rejected
      reject();
    }
    // Try the first value
    fn(values[0]).then(function(val) {
      // Resolved, we're all done
      //console.log('Resolved ' + val);
      resolve(val);
    }).catch(function() {
      // Rejected, remove the first item from the array and recursively
      // try the next one
      //console.log('Rejected ' + values[0]);
      values.shift();
      arrayIterate(values, fn).then(resolve).catch(reject);
    });
  });
}

function awsLinks(data) {
  const row = pad(data.row, 3, '0');
  const _path = pad(data.path, 3, '0');
  const sceneId = data.sceneID;
  const productId = data.LANDSAT_PRODUCT_ID;

  const c1Base = `https://landsat-pds.s3.amazonaws.com/c1/L8/${path.join(_path, row, productId)}`;
  const c1Files = bands.map((b) => `${c1Base}/${productId}_${b}`);

  const c1 = {
    index: `${c1Base}/index.html`,
    files: c1Files,
    thumbnail: `${c1Base}/${productId}_thumb_large.jpg`
  };

  return new Promise(function(resolve, reject) {
    // AWS doesn't include all C1 scenes, we return the old urls for
    // any scenes that is before May 1 2017
    info = {};
    if (moment(data.acquisitionDate) > moment('2017-04-30')) {
      resolve(c1)
    } else {
      const _sceneId = sceneId.slice(0, -2);
      const rev = sceneId.slice(-2)
      var prefix = `http://landsat-pds.s3.amazonaws.com/L8/${path.join(_path, row, _sceneId)}`;
      var links = _.range(rev, -1, -1).map(r => `${prefix}` + pad(r, 2, '0') + '/index.html');

      arrayIterate(links, fileExists).then(val => {
        prefix = prefix + val.slice(-13, -11);
        const pre = {
          index: `${prefix}/index.html`,
          files: bands.map((b) => `${prefix}_${b}`),
          thumbnail: `${prefix}_thumb_large.jpg`
        };
        resolve(pre);
      }).catch(e => {
        reject(`${prefix} not available`);
      });
    }
  });
}

function transform(data, encoding, next) {
  const numberFields = [
    'cloudCoverFull',
    'path',
    'row',
    'upperLeftCornerLatitude',
    'upperLeftCornerLongitude',
    'upperRightCornerLatitude',
    'upperRightCornerLongitude',
    'lowerLeftCornerLatitude',
    'lowerLeftCornerLongitude',
    'lowerRightCornerLatitude',
    'lowerRightCornerLongitude',
    'sceneCenterLatitude',
    'sceneCenterLongitude',
    'cloudCover',
    'sunElevation',
    'sunAzimuth',
    'receivingStation',
    'imageQuality1',
    //'ROLL_ANGLE',
    //'GEOMETRIC_RMSE_MODEL',
    //'GEOMETRIC_RMSE_MODEL_X',
    //'GEOMETRIC_RMSE_MODEL_Y',
    //'COLLECTION_NUMBER',
    //'CLOUD_COVER_LAND'
  ];

  numberFields.forEach(f => {
    data[f] = parseFloat(data[f]);
  });

  const data_geometry = { // eslint-disable-line camelcase
    type: 'Polygon',
    crs: {
      type: 'name',
      properties: {
        name: 'urn:ogc:def:crs:EPSG:8.9:4326'
      }
    },
    coordinates: [[
      [data.upperRightCornerLongitude, data.upperRightCornerLatitude],
      [data.upperLeftCornerLongitude, data.upperLeftCornerLatitude],
      [data.lowerLeftCornerLongitude, data.lowerLeftCornerLatitude],
      [data.lowerRightCornerLongitude, data.lowerRightCornerLatitude],
      [data.upperRightCornerLongitude, data.upperRightCornerLatitude]
    ]]
  };

  const leftLong = Math.min(data.lowerLeftCornerLongitude, data.upperLeftCornerLongitude)
  const rightLong = Math.max(data.lowerRightCornerLongitude, data.upperRightCornerLongitude)
  if (Math.abs(rightLong - leftLong) > 300) {
    console.log(`warning: skipping ${data.sceneID} for crossing 180th Meridian (${JSON.stringify(data_geometry)})`)
    next()
  } else {
    const google = googleLinks(data);

    const customFields = {
      scene_id: data.sceneID,
      product_id: data.LANDSAT_PRODUCT_ID,
      satellite_name: 'landsat-8',
      cloud_coverage: data.cloudCoverFull,
      date: data.acquisitionDate,
      thumbnail: data.browseURL,
      data_geometry,
      download_links: {
        usgs: `https://earthexplorer.usgs.gov/download/12864/${data.sceneID}/STANDARD/EE`,
        aws_s3: [],
        google: google.c1.files
      },
      aws_thumbnail: null,
      aws_index: null,
      google_index: google.c1.index,
    };

    delete data.cloudCoverFull

    awsLinks(data).then((info) => {
      //console.log('awslinks', info)
      customFields.download_links.aws_s3 = info.files
      customFields.aws_thumbnail = info.thumbnail
      customFields.aws_index = info.index
      record = Object.assign({}, customFields, data)
      this.push(record)
      next()
    }).catch(e => {
      console.log(`error processing ${customFields.scene_id}: ${e}`)
      next()
    })
  }

  //if (thumbnailUrl) {
  //customFields.thumbnail = url.resolve(thumbnailUrl, `${data.LANDSAT_PRODUCT_ID}.jpg`);
  //}
}

function handler (event, context, cb) {
  var _transform = through2({'objectMode': true, 'consume': true}, transform)
  console.log('Landsat handler:', event)
  metadata.update(event, _transform, cb)
}

local.localRun(() => {
  const a = {
    bucket: 'sat-api',
    key: 'test',
    satellite: 'landsat',
    currentFileNum: 11,
    lastFileNum: 11,
    arn: 'arn:aws:states:us-east-1:552819999234:stateMachine:landsat-meta'
  };
  console.log('running locally')

  handler(a, null, (e, r) => {});
});

module.exports.handler = handler;
<commit_msg>fix links<commit_after>'use strict';

const got = require('got');
const path = require('path');
const moment = require('moment');
const pad = require('lodash.padstart');
const _ = require('lodash');
const AWS = require('aws-sdk')
const local = require('kes/src/local');
const metadata = require('../../lib/metadata');
var through2 = require('through2')

const bands = [
  'ANG.txt',
  'B1.TIF',
  'B2.TIF',
  'B3.TIF',
  'B4.TIF',
  'B5.TIF',
  'B6.TIF',
  'B7.TIF',
  'B8.TIF',
  'B9.TIF',
  'B10.TIF',
  'B11.TIF',
  'BQA.TIF',
  'MTL.txt'
];

const s3 = new AWS.S3()

function googleLinks(data) {
  const row = pad(data.row, 3, '0');
  const _path = pad(data.path, 3, '0');
  //const sceneId = data.sceneID;
  const productId = data.LANDSAT_PRODUCT_ID;

  const c1Console = `https://console.cloud.google.com/storage/browser/gcp-public-data-landsat/LC08/${path.join(_path, row, productId)}`;
  const c1Base = `https://storage.googleapis.com/gcp-public-data-landsat/LC08/01/${path.join(_path, row, productId)}`;

  const c1Files = bands.map((b) => `${c1Base}/${productId}_${b}`);

  const c1 = {
    index: c1Console,
    files: c1Files
  };

  return { c1 };
}

//! Check to see if a URL exists
function fileExists(url) {
  var params = {
    Bucket: 'landsat-pds',
    Key: url.slice(36)
  }
  return new Promise(function(resolve, reject) {
    s3.headObject(params, function (err, metadata) {
      if (err && err.code === 'NotFound') {
        reject(url)
      } else {
        resolve(url)
      }
    })
  })
  /*return new Promise(function(resolve, reject) {
    got(url).then(response => {
      resolve(url);
    }).catch(e => {
      reject(url);
    });
  });*/
}

//! iterate over an array synchronously, invoke function on each element
function arrayIterate(values, fn) {
  return new Promise(function(resolve, reject) {
    // Are there any values to check?
    if (values.length === 0) {
      // All were rejected
      reject();
    }
    // Try the first value
    fn(values[0]).then(function(val) {
      // Resolved, we're all done
      //console.log('Resolved ' + val);
      resolve(val);
    }).catch(function() {
      // Rejected, remove the first item from the array and recursively
      // try the next one
      //console.log('Rejected ' + values[0]);
      values.shift();
      arrayIterate(values, fn).then(resolve).catch(reject);
    });
  });
}

function awsLinks(data) {
  const row = pad(data.row, 3, '0');
  const _path = pad(data.path, 3, '0');
  const sceneId = data.sceneID;
  const productId = data.LANDSAT_PRODUCT_ID;

  const c1Base = `https://landsat-pds.s3.amazonaws.com/c1/L8/${path.join(_path, row, productId)}`;
  const c1Files = bands.map((b) => `${c1Base}/${productId}_${b}`);

  const c1 = {
    index: `${c1Base}/index.html`,
    files: c1Files,
    thumbnail: `${c1Base}/${productId}_thumb_large.jpg`
  };

  return new Promise(function(resolve, reject) {
    // AWS doesn't include all C1 scenes, we return the old urls for
    // any scenes that is before May 1 2017
    info = {};
    if (moment(data.acquisitionDate) > moment('2017-04-30')) {
      resolve(c1)
    } else {
      const _sceneId = sceneId.slice(0, -2);
      var sid;
      const rev = sceneId.slice(-2)
      var prefix = `http://landsat-pds.s3.amazonaws.com/L8/${path.join(_path, row, _sceneId)}`;
      var links = _.range(rev, -1, -1).map(r => `${prefix}` + pad(r, 2, '0') + '/index.html');

      arrayIterate(links, fileExists).then(val => {
        prefix = prefix + val.slice(-13, -11)
        sid = _sceneId + val.slice(-13, -11)
        const pre = {
          index: `${prefix}/index.html`,
          files: bands.map((b) => `${prefix}/${sid}_${b}`),
          thumbnail: `${prefix}/${sid}_thumb_large.jpg`
        };
        resolve(pre);
      }).catch(e => {
        reject(`${prefix} not available`);
      });
    }
  });
}

function transform(data, encoding, next) {
  const numberFields = [
    'cloudCoverFull',
    'path',
    'row',
    'upperLeftCornerLatitude',
    'upperLeftCornerLongitude',
    'upperRightCornerLatitude',
    'upperRightCornerLongitude',
    'lowerLeftCornerLatitude',
    'lowerLeftCornerLongitude',
    'lowerRightCornerLatitude',
    'lowerRightCornerLongitude',
    'sceneCenterLatitude',
    'sceneCenterLongitude',
    'cloudCover',
    'sunElevation',
    'sunAzimuth',
    'receivingStation',
    'imageQuality1',
    //'ROLL_ANGLE',
    //'GEOMETRIC_RMSE_MODEL',
    //'GEOMETRIC_RMSE_MODEL_X',
    //'GEOMETRIC_RMSE_MODEL_Y',
    //'COLLECTION_NUMBER',
    //'CLOUD_COVER_LAND'
  ];

  numberFields.forEach(f => {
    data[f] = parseFloat(data[f]);
  });

  const data_geometry = { // eslint-disable-line camelcase
    type: 'Polygon',
    crs: {
      type: 'name',
      properties: {
        name: 'urn:ogc:def:crs:EPSG:8.9:4326'
      }
    },
    coordinates: [[
      [data.upperRightCornerLongitude, data.upperRightCornerLatitude],
      [data.upperLeftCornerLongitude, data.upperLeftCornerLatitude],
      [data.lowerLeftCornerLongitude, data.lowerLeftCornerLatitude],
      [data.lowerRightCornerLongitude, data.lowerRightCornerLatitude],
      [data.upperRightCornerLongitude, data.upperRightCornerLatitude]
    ]]
  };

  const leftLong = Math.min(data.lowerLeftCornerLongitude, data.upperLeftCornerLongitude)
  const rightLong = Math.max(data.lowerRightCornerLongitude, data.upperRightCornerLongitude)
  if (Math.abs(rightLong - leftLong) > 300) {
    console.log(`warning: skipping ${data.sceneID} for crossing 180th Meridian (${JSON.stringify(data_geometry)})`)
    next()
  } else {
    const google = googleLinks(data);

    const customFields = {
      scene_id: data.sceneID,
      product_id: data.LANDSAT_PRODUCT_ID,
      satellite_name: 'landsat-8',
      cloud_coverage: data.cloudCoverFull,
      date: data.acquisitionDate,
      thumbnail: data.browseURL,
      data_geometry,
      download_links: {
        usgs: `https://earthexplorer.usgs.gov/download/12864/${data.sceneID}/STANDARD/EE`,
        aws_s3: [],
        google: google.c1.files
      },
      aws_thumbnail: null,
      aws_index: null,
      google_index: google.c1.index,
    };

    delete data.cloudCoverFull

    awsLinks(data).then((info) => {
      //console.log('awslinks', info)
      customFields.download_links.aws_s3 = info.files
      customFields.aws_thumbnail = info.thumbnail
      customFields.aws_index = info.index
      record = Object.assign({}, customFields, data)
      this.push(record)
      next()
    }).catch(e => {
      console.log(`error processing ${customFields.scene_id}: ${e}`)
      next()
    })
  }

  //if (thumbnailUrl) {
  //customFields.thumbnail = url.resolve(thumbnailUrl, `${data.LANDSAT_PRODUCT_ID}.jpg`);
  //}
}

function handler (event, context, cb) {
  var _transform = through2({'objectMode': true, 'consume': true}, transform)
  console.log('Landsat handler:', event)
  metadata.update(event, _transform, cb)
}

local.localRun(() => {
  const a = {
    bucket: 'sat-api',
    key: 'test',
    satellite: 'landsat',
    currentFileNum: 11,
    lastFileNum: 11,
    arn: 'arn:aws:states:us-east-1:552819999234:stateMachine:landsat-meta'
  };
  console.log('running locally')

  handler(a, null, (e, r) => {});
});

module.exports.handler = handler;
<|endoftext|>


<commit_before>// This file defines grunt tasks used by [Grunt.js](http://gruntjs.com/sample-gruntfile)
module.exports = function ( grunt ) {

  // Project configuration
  grunt.initConfig( {

    // Metadata
    pkg: grunt.file.readJSON("package.json"),
    banner: "/* ==========================================================\n" +
            " *                  GitGraph v<%= pkg.version %>\n" +
            " *      <%= pkg.repository.url %>\n" +
            " * ==========================================================\n" +
            " * Copyright (c) <%= grunt.template.today('yyyy') %>" +
            " Nicolas CARLO (@nicoespeon) ٩(^‿^)۶\n" +
            " * Copyright (c) <%= grunt.template.today('yyyy') %>" +
            " Fabien BERNARD (@fabien0102) ✌(✰‿✰)✌\n" +
            " *\n" +
            " * GitGraph.js may be freely distributed under the" +
            " <%= pkg.license %> Licence\n" +
            " * ========================================================== */\n",

    // The `clean` task ensures all files are removed from the `dist/` directory
    // so that no files linger from previous builds.
    clean: {
      dist: [ "dist/" ],
      server: ["server/"]
    },

    // The `concat` task copies the source file into the `build/` directory with
    // the compiled banner for release use.
    concat: {
      options: {
        banner: "<%= banner %>\n"
      },
      release: {
        src: [ "src/gitgraph.js" ],
        dest: "build/gitgraph.js"
      }
    },
    copy: {
      dist: {
        files: [
          {src: ["src/gitgraph.css"], dest: "dist/gitgraph.css"}
        ]
      },
      release: {
        files: [
          {src: ["src/gitgraph.css"], dest: "build/gitgraph.css"}
        ]
      },
      server: {
        files: [
          {cwd: "src/", src: "*", dest: "server/", flatten: true, expand: true},
          {cwd: "examples/", src: ["*.js", "*.css"], dest: "server/", flatten: true, expand: true}
        ]
      }
    },

    // The `jsdoc` task will produce the code documentation for the whole project.
    jsdoc: {
      dist: {
        src: [ "src/*.js", "README.md" ],
        options: {
          configure: '.jsdocrc',
          destination: "dist/docs"
        }
      },
      release: {
        src: [ "src/*.js", "README.md" ],
        options: {
          configure: '.jsdocrc',
          destination: "docs"
        }
      }
    },

    // The `jasmine` task run unit tests over the source code
    jasmine: {
      gitgraph: {
        src: "src/*.js",
        options: {
          specs: "tests/*.js"
        }
      }
    },

    // The `jshint` task lint all the JavaScript code against best practices.
    // Warnings are here to help us improve code and follow best standards.
    jshint: {
      src: [ "src/*.js" ],
      options: {
        force: true,
        jshintrc: ".jshintrc"
      }
    },

    // The `uglify` task will minified the JavaScript source code for production.
    uglify: {
      options: {
        banner: "<%= banner %>"
      },
      dist: {
        src: [ "src/gitgraph.js" ],
        dest: "dist/gitgraph.min.js",
        options: {
          report: "min"
        }
      },
      release: {
        src: [ "src/gitgraph.js" ],
        dest: "build/gitgraph.min.js",
        options: {
          report: "min"
        }
      }
    },

    // The `watch` task will monitor the projects files
    watch: {
     server: {
       options: { livereload: true },
       files: ["src/*", "examples/*"],
       tasks: ["copy:server"]
     }
    },
    express: {
      server: {
        options: {
          port: 9000,
          hostname: "0.0.0.0", // localhost|127.0.0.0
          bases: ["server"],
          livereload: true
        }
      }
    },
    open: {
      server: {
        path: "http://127.0.0.1:<%= express.server.options.port %>"
      }
    },
    "string-replace": {
     server: {
       files: {
         "server/index.html": "examples/index.html"
       },
       options: {
         replacements: [
           {
             pattern: "../src/gitgraph.css",
             replacement: "gitgraph.css"
           },
           {
             pattern: "../src/gitgraph.js",
             replacement: "gitgraph.js"
           },
         ]
       }
     }
   }

  } );

  // Loads grunt tasks from `package.json`
  require( "load-grunt-tasks" )( grunt, [ "grunt-*" ] );

  // `grunt lint` will check code by running JSHint and unit tests over it.
  grunt.registerTask( "lint", [ "jshint", "jasmine" ] );

  // `grunt docs` will create non-versioned documentation for development use.
  grunt.registerTask( "docs", [ "jsdoc:dist" ] );

  // `grunt dist` will create a non-versioned new release for development use.
  grunt.registerTask( "dist", [
    "clean:dist",
    "lint",
    "copy:dist",
    "uglify:dist",
    "jsdoc:dist"
  ] );

  // `grunt release` will create a new release of the source code.
  grunt.registerTask( "release", [
    "lint",
    "copy:release",
    "concat:release",
    "uglify:release",
    "jsdoc:release"
  ] );

  // `grunt server` will open a live reload server on your favorite browser
  grunt.registerTask('server', [
    "copy:server",
    "string-replace:server",
    "express:server",
    "open",
    "watch:server"
  ]);
};
<commit_msg>Fix jsdoc with IIFE - close #26<commit_after>// This file defines grunt tasks used by [Grunt.js](http://gruntjs.com/sample-gruntfile)
module.exports = function ( grunt ) {

  // Project configuration
  grunt.initConfig( {

    // Metadata
    pkg: grunt.file.readJSON("package.json"),
    banner: "/* ==========================================================\n" +
            " *                  GitGraph v<%= pkg.version %>\n" +
            " *      <%= pkg.repository.url %>\n" +
            " * ==========================================================\n" +
            " * Copyright (c) <%= grunt.template.today('yyyy') %>" +
            " Nicolas CARLO (@nicoespeon) ٩(^‿^)۶\n" +
            " * Copyright (c) <%= grunt.template.today('yyyy') %>" +
            " Fabien BERNARD (@fabien0102) ✌(✰‿✰)✌\n" +
            " *\n" +
            " * GitGraph.js may be freely distributed under the" +
            " <%= pkg.license %> Licence\n" +
            " * ========================================================== */\n",

    // The `clean` task ensures all files are removed from the `dist/`, `server/`, `temp/` directories
    // so that no files linger from previous builds.
    clean: {
      options: {force: true},
      dist: [ "dist/" ],
      server: ["server/"],
      temp: ["temp/"]
    },

    // The `concat` task copies the source file into the `build/` directory with
    // the compiled banner for release use.
    concat: {
      options: {
        banner: "<%= banner %>\n"
      },
      release: {
        src: [ "src/gitgraph.js" ],
        dest: "build/gitgraph.js"
      }
    },
    copy: {
      dist: {
        files: [
          {src: ["src/gitgraph.css"], dest: "dist/gitgraph.css"}
        ]
      },
      release: {
        files: [
          {src: ["src/gitgraph.css"], dest: "build/gitgraph.css"}
        ]
      },
      server: {
        files: [
          {cwd: "src/", src: "*", dest: "server/", flatten: true, expand: true},
          {cwd: "examples/", src: ["*.js", "*.css"], dest: "server/", flatten: true, expand: true}
        ]
      }
    },

    // The `jsdoc` task will produce the code documentation for the whole project.
    jsdoc: {
      dist: {
        src: [ "temp/src/*.js", "README.md" ],
        options: {
          configure: '.jsdocrc',
          destination: "dist/docs"
        }
      },
      release: {
        src: [ "temp/src/*.js", "README.md" ],
        options: {
          configure: '.jsdocrc',
          destination: "docs"
        }
      }
    },

    // The `jasmine` task run unit tests over the source code
    jasmine: {
      gitgraph: {
        src: "src/*.js",
        options: {
          specs: "tests/*.js"
        }
      }
    },

    // The `jshint` task lint all the JavaScript code against best practices.
    // Warnings are here to help us improve code and follow best standards.
    jshint: {
      src: [ "src/*.js" ],
      options: {
        force: true,
        jshintrc: ".jshintrc"
      }
    },

    // The `uglify` task will minified the JavaScript source code for production.
    uglify: {
      options: {
        banner: "<%= banner %>"
      },
      dist: {
        src: [ "src/gitgraph.js" ],
        dest: "dist/gitgraph.min.js",
        options: {
          report: "min"
        }
      },
      release: {
        src: [ "src/gitgraph.js" ],
        dest: "build/gitgraph.min.js",
        options: {
          report: "min"
        }
      }
    },

    // The `watch` task will monitor the projects files
    watch: {
     server: {
       options: { livereload: true },
       files: ["src/*", "examples/*"],
       tasks: ["copy:server"]
     }
    },
    express: {
      server: {
        options: {
          port: 9000,
          hostname: "0.0.0.0", // localhost|127.0.0.0
          bases: ["server"],
          livereload: true
        }
      }
    },
    open: {
      server: {
        path: "http://127.0.0.1:<%= express.server.options.port %>"
      }
    },
    "string-replace": {
       server: {
         files: {
           "server/index.html": "examples/index.html"
         },
         options: {
           replacements: [
             {
               pattern: "../src/gitgraph.css",
               replacement: "gitgraph.css"
             },
             {
               pattern: "../src/gitgraph.js",
               replacement: "gitgraph.js"
             },
           ]
         }
       },
       jsdoc: {
         files: {
           "temp/": "src/*.js"
          },
          options: {
            replacements: [
              {
                pattern: "(function () {",
                replacement: ""
              },
              {
                pattern: "})();",
                replacement: ""
              },
            ]
          }
        }
      }

  } );

  // Loads grunt tasks from `package.json`
  require( "load-grunt-tasks" )( grunt, [ "grunt-*" ] );

  // `grunt lint` will check code by running JSHint and unit tests over it.
  grunt.registerTask( "lint", [ "jshint", "jasmine" ] );

  // `grunt docs` will create non-versioned documentation for development use.
  grunt.registerTask( "docs", [ "string-replace:jsdoc", "jsdoc:dist", "clean:temp" ] );

  // `grunt dist` will create a non-versioned new release for development use.
  grunt.registerTask( "dist", [
    "clean:dist",
    "lint",
    "copy:dist",
    "uglify:dist",
    "string-replace:jsdoc",
    "jsdoc:dist",
    "clean:temp"
  ] );

  // `grunt release` will create a new release of the source code.
  grunt.registerTask( "release", [
    "lint",
    "copy:release",
    "concat:release",
    "uglify:release",
    "string-replace:jsdoc",
    "jsdoc:release",
    "clean:temp"
  ] );

  // `grunt server` will open a live reload server on your favorite browser
  grunt.registerTask('server', [
    "copy:server",
    "string-replace:server",
    "express:server",
    "open",
    "watch:server"
  ]);
};
<|endoftext|>


<commit_before>// {"request_idle_timeout_sec":10}
//
// vim:set sw=8 et:
//
// Scrolls to the bottom of the page. That's it at the moment.
//

var umbraAboveBelowOrOnScreen = function(e) {
        var eTop = e.getBoundingClientRect().top;
        if (eTop < window.scrollY) {
                return -1; // above
        } else if (eTop > window.scrollY + window.innerHeight) {
                return 1;  // below
        } else {
                return 0;  // on screen
        }
}

var umbraState = {'idleSince':null};
var umbraAlreadyClicked = {};
var UMBRA_IFRAME_SOUNDCLOUD_EMBEDDED_SELECTOR = "iframe[src^='http://w.soundcloud.com/player'], iframe[src^='https://w.soundcloud.com/player']";
var UMBRA_THINGS_TO_CLICK_SOUNDCLOUD_EMBEDDED_SELECTOR = "button.playButton";
var umbraFinished = false;
var umbraIntervalFunc = function() {

	var umbraSoundCloudEmbeddedElements = getUmbraSoundCloudEmbeddedElements();

    var clickedSomething = false;
    var somethingLeftBelow = false;
    var somethingLeftAbove = false;
    var missedAbove = 0;

    for (var i = 0; i < umbraSoundCloudEmbeddedElements.length; i++) {

    		var targetId = umbraSoundCloudEmbeddedElements[i].id;
            var target = umbraSoundCloudEmbeddedElements[i].target;

            if (!(targetId in umbraAlreadyClicked)) {
                    var where = umbraAboveBelowOrOnScreen(target);

                    if (where == 0) { // on screen
                            // var pos = target.getBoundingClientRect().top;
                            // window.scrollTo(0, target.getBoundingClientRect().top - 100);
                            console.log("clicking at " + target.getBoundingClientRect().top + " on " + target.outerHTML);
                            if (target.click != undefined) {
                                    target.click();
                            }
                            umbraAlreadyClicked[targetId] = true;
                            clickedSomething = true;
                            umbraState.idleSince = null;
                            break;
                    } else if (where > 0) {
                            somethingLeftBelow = true;
                    } else if (where < 0) {
                            somethingLeftAbove = true;
                    }
            }
    }

    if (!clickedSomething) {
        if (somethingLeftAbove) {
                console.log("scrolling UP because everything on this screen has been clicked but we missed something above");
                window.scrollBy(0, -500);
                umbraState.idleSince = null;
        } else if (somethingLeftBelow) {
                console.log("scrolling because everything on this screen has been clicked but there's more below document.body.clientHeight=" + document.body.clientHeight);
                window.scrollBy(0, 200);
                umbraState.idleSince = null;
        } else if (window.scrollY + window.innerHeight < document.documentElement.scrollHeight) {
                console.log("scrolling because we're not to the bottom yet document.body.clientHeight=" + document.body.clientHeight);
                window.scrollBy(0, 200);
                umbraState.idleSince = null;
        } else if (umbraState.idleSince == null) {
                umbraState.idleSince = Date.now();
        }
    }

	if (umbraState.idleSince == null) {
                umbraState.idleSince = Date.now();
    }
}

//try to detect sound cloud "Play" buttons and return them as targets for clicking
var getUmbraSoundCloudEmbeddedElements = function() {

	var soundCloudEmbeddedElements = [];

	var id = 0;

	[].forEach.call(document.querySelectorAll(UMBRA_IFRAME_SOUNDCLOUD_EMBEDDED_SELECTOR),
		function  fn(elem){
		    var button = elem.contentWindow.document.body.querySelectorAll(UMBRA_THINGS_TO_CLICK_SOUNDCLOUD_EMBEDDED_SELECTOR);

		    //use the iframe's src attribute as the key to the sound cloud player button. assumption is that each iframe created by the sound cloud widget
		    //contains only a single unique audio file on a given page
			if (button && button.length > 0) {
				//get the Element from the NodeList
				soundCloudEmbeddedElements.push({"id" : elem.src, "target" : button.item(0)});
				id++;
			}
	    }
	);

	return soundCloudEmbeddedElements;
}

// If we haven't had anything to do (scrolled, clicked, etc) in this amount of
// time, then we consider ourselves finished with the page.
var UMBRA_USER_ACTION_IDLE_TIMEOUT_SEC = 10;

// Called from outside of this script.
var umbraBehaviorFinished = function() {
        if (umbraState.idleSince != null) {
                var idleTimeMs = Date.now() - umbraState.idleSince;
                if (idleTimeMs / 1000 > UMBRA_USER_ACTION_IDLE_TIMEOUT_SEC) {
                        return true;
                }
        }
        return false;
}

var umbraIntervalId = setInterval(umbraIntervalFunc, 100);
<commit_msg>More soundcloud changes.<commit_after>// {"request_idle_timeout_sec":10}
//
// vim:set sw=8 et:
//
// Scrolls to the bottom of the page. That's it at the moment.
//
var umbraAboveBelowOrOnScreen = function(e) {
        var eTop = e.getBoundingClientRect().top;
        if (eTop < window.scrollY) {
                return -1; // above
        } else if (eTop > window.scrollY + window.innerHeight) {
                return 1;  // below
        } else {
                return 0;  // on screen
        }
}

var UMBRA_IFRAME_SOUNDCLOUD_EMBEDDED_SELECTOR = "iframe";
var UMBRA_THINGS_TO_CLICK_SOUNDCLOUD_EMBEDDED_SELECTOR = "button.sc-button-play, button.playButton";
var MAX_IFRAME_RECURSE_DEPTH = 1; //0-based
var umbraState = {'idleSince':null};
var umbraAlreadyClicked = {};
var umbraFinished = false;
var umbraIntervalFunc = function() {

	var umbraSoundCloudEmbeddedElements = [];

	getUmbraSoundCloudEmbeddedElements(umbraSoundCloudEmbeddedElements);

    var clickedSomething = false;
    var somethingLeftBelow = false;
    var somethingLeftAbove = false;
    var missedAbove = 0;

    for (var i = 0; i < umbraSoundCloudEmbeddedElements.length; i++) {

    		var targetId = umbraSoundCloudEmbeddedElements[i].id;
            var target = umbraSoundCloudEmbeddedElements[i].target;

            if (!(targetId in umbraAlreadyClicked)) {

                    var where = umbraAboveBelowOrOnScreen(target);

                    if (where == 0) { // on screen
                            // var pos = target.getBoundingClientRect().top;
                            // window.scrollTo(0, target.getBoundingClientRect().top - 100);
                            console.log("clicking at " + target.getBoundingClientRect().top + " on " + target.outerHTML);
                            if (target.click != undefined) {
                                    target.click();
                            }
                            umbraAlreadyClicked[targetId] = true;
                            clickedSomething = true;
                            umbraState.idleSince = null;
                            break;
                    } else if (where > 0) {
                            somethingLeftBelow = true;
                    } else if (where < 0) {
                            somethingLeftAbove = true;
                    }
            }
    }

    if (!clickedSomething) {
        if (somethingLeftAbove) {
                console.log("scrolling UP because everything on this screen has been clicked but we missed something above");
                window.scrollBy(0, -500);
                umbraState.idleSince = null;
        } else if (somethingLeftBelow) {
                console.log("scrolling because everything on this screen has been clicked but there's more below document.body.clientHeight=" + document.body.clientHeight);
                window.scrollBy(0, 200);
                umbraState.idleSince = null;
        } else if (window.scrollY + window.innerHeight < document.documentElement.scrollHeight) {
                console.log("scrolling because we're not to the bottom yet document.body.clientHeight=" + document.body.clientHeight);
                window.scrollBy(0, 200);
                umbraState.idleSince = null;
        } else if (umbraState.idleSince == null) {
                umbraState.idleSince = Date.now();
        }
    }

	if (umbraState.idleSince == null) {
                umbraState.idleSince = Date.now();
    }
}

//try to detect sound cloud "Play" buttons and return them as targets for clicking
var getUmbraSoundCloudEmbeddedElements = function(soundCloudEmbeddedElements, currentIframeDepth, currentDocument) {

	//set default values for parameters
	currentIframeDepth = currentIframeDepth || 0;
	currentDocument = currentDocument || document;

	if (currentIframeDepth > MAX_IFRAME_RECURSE_DEPTH) {
		return;
	}

	//collect all buttons on current document first
	var button = [];

	button = currentDocument.querySelectorAll(UMBRA_THINGS_TO_CLICK_SOUNDCLOUD_EMBEDDED_SELECTOR);

	for (var i = 0; i < button.length; i++) {
		soundCloudEmbeddedElements.push({"id" : getElementCssPath(button.item(i)), "target" : button.item(i)});
	}

	//now get all buttons in embedded iframes
	var iframe = [];

	iframe = currentDocument.querySelectorAll(UMBRA_IFRAME_SOUNDCLOUD_EMBEDDED_SELECTOR);

	for (var i = 0; i < iframe.length; i++) {
		getUmbraSoundCloudEmbeddedElements(soundCloudEmbeddedElements, currentIframeDepth + 1, iframe[i].contentWindow.document.body);
	}
}

// If we haven't had anything to do (scrolled, clicked, etc) in this amount of
// time, then we consider ourselves finished with the page.
var UMBRA_USER_ACTION_IDLE_TIMEOUT_SEC = 10;

// Called from outside of this script.
var umbraBehaviorFinished = function() {
        if (umbraState.idleSince != null) {
                var idleTimeMs = Date.now() - umbraState.idleSince;
                if (idleTimeMs / 1000 > UMBRA_USER_ACTION_IDLE_TIMEOUT_SEC) {
                        return true;
                }
        }
        return false;
}

//copied from http://stackoverflow.com/questions/4588119/get-elements-css-selector-without-element-id
var getElementCssPath = function(element) {

	var names = [];

	while (element.parentNode){
		if (element.id){
			names.unshift('#' + element.id);
			break;
		} else {
			if (element == element.ownerDocument.documentElement) {
				names.unshift(element.tagName);
			}
			else {
				for (var c = 1, e = element; e.previousElementSibling; e = e.previousElementSibling, c++);

				names.unshift(element.tagName + ":nth-child(" + c + ")");
			}

			element = element.parentNode;
		}
	}

	return names.join(" > ");
}

var umbraIntervalId = setInterval(umbraIntervalFunc, 100);
<|endoftext|>


<commit_before>module.exports = function(grunt) {
    grunt.initConfig({
        pkg: grunt.file.readJSON('package.json'),
        concat: {
            'dist/all.js': ['src/js/**/*.js']
        },
        // Test settings
        karma: {
            options: {
                configFile: 'karma.conf.js',
                browsers: ['PhantomJS']
            },
            unit: {
                singleRun: true,
                options: {
                    reporters: ['dots', 'coverage']
                }
            },
            server: {
                autoWatch: true
            }
        }
    });

    grunt.loadNpmTasks('grunt-contrib-watch');
    grunt.loadNpmTasks('grunt-karma');
    grunt.loadNpmTasks('grunt-contrib-jshint');
    grunt.loadNpmTasks('grunt-contrib-concat');

    grunt.registerTask('test', [
        'karma:unit'
    ]);

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

}<commit_msg>Update<commit_after>module.exports = function(grunt) {
    grunt.initConfig({
        pkg: grunt.file.readJSON('package.json'),
        concat: {
            'dist/all.js': ['src/js/**/*.js']
        },
        // Test settings
        karma: {
            options: {
                configFile: 'karma.conf.js',
                browsers: ['PhantomJS']
            },
            unit: {
                singleRun: true,
                options: {
                    reporters: ['dots', 'coverage']
                }
            },
            server: {
                autoWatch: true
            }
        }
    });

    grunt.loadNpmTasks('grunt-contrib-watch');
    grunt.loadNpmTasks('grunt-karma');
    grunt.loadNpmTasks('grunt-contrib-jshint');
    grunt.loadNpmTasks('grunt-contrib-concat');

    grunt.registerTask('test', [
        'karma:unit', 'concat'
    ]);

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

}<|endoftext|>


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

  // Project configuration.
  grunt.initConfig({
    pkg: grunt.file.readJSON('package.json'),
    meta: {
      banner: '/*! <%= pkg.name %> - v<%= pkg.version %> - ' +
        '<%= grunt.template.today("yyyy-mm-dd") %>' + "\n" +
        '<%= pkg.homepage ? "* " + pkg.homepage + "\\n" : "" %>' +
        '* Copyright (c) <%= grunt.template.today("yyyy") %> <%= pkg.author.name %>;' +
        ' Licensed <%= _.pluck(pkg.licenses, "type").join(", ") %> */\n'
    },
    clean: ['dist'],
    concat: {
      options: {
        separator: ";",
        stripBanners: true,
        banner: '<%= meta.banner %>'
      },
      add_banner: {
        src: ['dist/<%= pkg.name %>.js'],
        dest: 'dist/<%= pkg.name %>.js'
      }
    },
    requirejs: {
      compile: {
        options: {
          baseUrl: 'lib',
          name: 'blisp',
          optimize: 'none',
          out: 'dist/<%= pkg.name %>.js'
        }
      }
    },
    uglify: {
      options: {
        banner: '<%= meta.banner %>'
      },
      dist: {
        files: {
          'dist/<%= pkg.name %>.min.js': ['dist/<%= pkg.name %>.js']
        }
      }
    },
    watch: {
      dev: {
        files: ['lib/**/*.js', 'spec/**/*.coffee'],
        tasks: ['default']
      }
    },
    jshint: {
      files: ['*.js', 'lib/**/*.js', 'spec/**/*.js'],
      options: {
        curly: true,
        eqeqeq: true,
        immed: true,
        latedef: true,
        newcap: true,
        noarg: true,
        sub: true,
        undef: true,
        boss: true,
        eqnull: true,
        globals: {
          define: true,
          console: true,
          require: true,
          exports: true,
          module: false,
          describe: true,
          it: true,
          xit: true,
          expect: true,
          beforeEach: true
        }
      }
    },
    exec: {
      spec: {
        cmd: 'jasmine-node --verbose --coffee spec',
        stdout: true,
        stderr: true
      }
    }
  });

  grunt.loadNpmTasks('grunt-contrib-coffee');
  grunt.loadNpmTasks('grunt-contrib-watch');
  grunt.loadNpmTasks('grunt-contrib-jshint');
  grunt.loadNpmTasks('grunt-contrib-concat');
  grunt.loadNpmTasks('grunt-contrib-requirejs');
  grunt.loadNpmTasks('grunt-contrib-uglify');
  grunt.loadNpmTasks('grunt-contrib-clean');
  grunt.loadNpmTasks('grunt-exec');

  grunt.registerTask('default', ['jshint', 'spec']);  // Default task
  grunt.registerTask('dist', ['default', 'concatenate', 'uglify']);
  grunt.registerTask('spec', ['exec:spec']);
  grunt.registerTask('concatenate', ['requirejs', 'concat:add_banner']); // Just using concat to put the nice banner in place...
};
<commit_msg>Don't lint scratchfile<commit_after>module.exports = function(grunt) {

  // Project configuration.
  grunt.initConfig({
    pkg: grunt.file.readJSON('package.json'),
    meta: {
      banner: '/*! <%= pkg.name %> - v<%= pkg.version %> - ' +
        '<%= grunt.template.today("yyyy-mm-dd") %>' + "\n" +
        '<%= pkg.homepage ? "* " + pkg.homepage + "\\n" : "" %>' +
        '* Copyright (c) <%= grunt.template.today("yyyy") %> <%= pkg.author.name %>;' +
        ' Licensed <%= _.pluck(pkg.licenses, "type").join(", ") %> */\n'
    },
    clean: ['dist'],
    concat: {
      options: {
        separator: ";",
        stripBanners: true,
        banner: '<%= meta.banner %>'
      },
      add_banner: {
        src: ['dist/<%= pkg.name %>.js'],
        dest: 'dist/<%= pkg.name %>.js'
      }
    },
    requirejs: {
      compile: {
        options: {
          baseUrl: 'lib',
          name: 'blisp',
          optimize: 'none',
          out: 'dist/<%= pkg.name %>.js'
        }
      }
    },
    uglify: {
      options: {
        banner: '<%= meta.banner %>'
      },
      dist: {
        files: {
          'dist/<%= pkg.name %>.min.js': ['dist/<%= pkg.name %>.js']
        }
      }
    },
    watch: {
      dev: {
        files: ['lib/**/*.js', 'spec/**/*.coffee'],
        tasks: ['default']
      }
    },
    jshint: {
      files: ['*.js', '!scratch.js', 'lib/**/*.js', 'spec/**/*.js'],
      options: {
        curly: true,
        eqeqeq: true,
        immed: true,
        latedef: true,
        newcap: true,
        noarg: true,
        sub: true,
        undef: true,
        boss: true,
        eqnull: true,
        globals: {
          define: true,
          console: true,
          require: true,
          exports: true,
          module: false,
          describe: true,
          it: true,
          xit: true,
          expect: true,
          beforeEach: true
        }
      }
    },
    exec: {
      spec: {
        cmd: 'jasmine-node --verbose --coffee spec',
        stdout: true,
        stderr: true
      }
    }
  });

  grunt.loadNpmTasks('grunt-contrib-coffee');
  grunt.loadNpmTasks('grunt-contrib-watch');
  grunt.loadNpmTasks('grunt-contrib-jshint');
  grunt.loadNpmTasks('grunt-contrib-concat');
  grunt.loadNpmTasks('grunt-contrib-requirejs');
  grunt.loadNpmTasks('grunt-contrib-uglify');
  grunt.loadNpmTasks('grunt-contrib-clean');
  grunt.loadNpmTasks('grunt-exec');

  grunt.registerTask('default', ['jshint', 'spec']);  // Default task
  grunt.registerTask('dist', ['default', 'concatenate', 'uglify']);
  grunt.registerTask('spec', ['exec:spec']);
  grunt.registerTask('concatenate', ['requirejs', 'concat:add_banner']); // Just using concat to put the nice banner in place...
};
<|endoftext|>


<commit_before>// Write an image and a JSON file to the database.

// MarkLogic allows us to generate the URIs for documents, if we want. We can
// also transform content as it is loaded. For details, see
// http://docs.marklogic.com/guide/node-dev/documents#id_85896

var fs = require('fs');
var ml = require('marklogic');
var conn = require('../config.js').admin;
var db = ml.createDatabaseClient(conn);
var pb = ml.patchBuilder;

var jsonURI = '/image/20140721_144421b.jpg.json';

function uploadDocs() {
  return db.documents.write(
    {
      uri: jsonURI,
      contentType: 'application/json',
      content: JSON.parse(fs.readFileSync('../data/20140721_144421b.jpg.json')),
      collections: ['image']
    },
    {
      uri: '/binary/20140721_144421b.jpg',
      contentType: 'image/jpeg',
      content: fs.readFileSync('../data/20140721_144421b.jpg'),
      collections: ['binary']
    }
  ).result();
}

function addState() {
  console.log('files loaded');
  return db.documents.patch(
    jsonURI,
    pb.insert(
      '/location/city',
      'after',
      {state: 'Maine'}
    )
  ).result();
}

function readDocument() {
  console.log('updated with state');
  return db.documents.read(jsonURI).result();
}

function printDocument(docs) {
  console.log(docs);
}

uploadDocs()
  .then(addState)
  .then(readDocument)
  .then(printDocument)
  .catch(function(error) {
    console.log('Problem: ' + error);
  });
<commit_msg>stringify results<commit_after>// Write an image and a JSON file to the database.

// MarkLogic allows us to generate the URIs for documents, if we want. We can
// also transform content as it is loaded. For details, see
// http://docs.marklogic.com/guide/node-dev/documents#id_85896

var fs = require('fs');
var ml = require('marklogic');
var conn = require('../config.js').admin;
var db = ml.createDatabaseClient(conn);
var pb = ml.patchBuilder;

var jsonURI = '/image/20140721_144421b.jpg.json';

function uploadDocs() {
  return db.documents.write(
    {
      uri: jsonURI,
      contentType: 'application/json',
      content: JSON.parse(fs.readFileSync('../data/20140721_144421b.jpg.json')),
      collections: ['image']
    },
    {
      uri: '/binary/20140721_144421b.jpg',
      contentType: 'image/jpeg',
      content: fs.readFileSync('../data/20140721_144421b.jpg'),
      collections: ['binary']
    }
  ).result();
}

function addState() {
  console.log('files loaded');
  return db.documents.patch(
    jsonURI,
    pb.insert(
      '/location/city',
      'after',
      {state: 'Maine'}
    )
  ).result();
}

function readDocument() {
  console.log('updated with state');
  return db.documents.read(jsonURI).result();
}

function printDocument(docs) {
  console.log(JSON.stringify(docs));
}

uploadDocs()
  .then(addState)
  .then(readDocument)
  .then(printDocument)
  .catch(function(error) {
    console.log('Problem: ' + error);
  });
<|endoftext|>


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

	grunt.initConfig({

		pkg: grunt.file.readJSON('package.json')
	});

	grunt.registerTask('default', []);
};<commit_msg>Add clean and copy tasks for Grunt.<commit_after>module.exports = function (grunt) {

	grunt.initConfig({

		pkg: grunt.file.readJSON('package.json'),

		clean: {
			build: {
				src: "build"
			}
		},

		copy: {
			build: {
				files: [
					{
						expand: true,
						cwd: 'source/',
						src: ['cleverlay.css', 'cleverlay.js'],
						dest: 'build/'
					}
				]
			}
		}
	});

	grunt.loadNpmTasks('grunt-contrib-clean');
	grunt.loadNpmTasks('grunt-contrib-copy');

	grunt.registerTask('default', []);
};<|endoftext|>


<commit_before>/*global module:false*/
module.exports = function(grunt) {

	// Project configuration.
	grunt.initConfig({
		pkg: grunt.file.readJSON('package.json'),
		banner: '/*! <%= pkg.title || pkg.name %> - v<%= pkg.version %> - ' +
			'<%= grunt.template.today("yyyy-mm-dd") %>\n' +
			'<%= pkg.homepage ? "* " + pkg.homepage + "\\n" : "" %>' +
			'* Copyright (c) <%= grunt.template.today("yyyy") %> <%= pkg.author.name %>;' +
			' Licensed <%= _.pluck(pkg.licenses, "type").join(", ") %> */\n',
		concat: {
			options: {
				stripBanners: true
			},
			distjs: {
				src: [
					'src/socialcount.js',
					'src/networks/facebook.js',
					'src/networks/twitter.js',
					'src/networks/googleplus.js',
					'src/networks/pinterest.js',
					// 'src/networks/sharethis.js',
				],
				dest: 'dist/socialcount.js'
			},
			distcss: {
				src: [
					'src/socialcount.css',
					'src/networks/facebook.css',
					'src/networks/pinterest.css',
					// 'src/networks/sharethis.css',
					'src/loading.css'
				],
				dest: 'dist/socialcount.css'
			},
			distcsswithicons: {
				src: [
					'<%= concat.distcss.dest %>',
					'src/socialcount-icons.css'
				],
				dest: 'dist/socialcount-with-icons.css'
			}
		},
		sass: {
			icons: {
				options: {
					compass: true
				},
				files: {
					'src/socialcount-icons.css': 'src/socialcount-icons.scss'
				}
			}
		},
		copy: {
			images: {
				cwd: 'src/',
				src: '*.png',
				dest: 'dist/',
				expand: true,
				flatten: true
			},
			service: {
				cwd: 'src/service/',
				src: '**',
				dest: 'dist/service/',
				expand: true,
				flatten: true
			}
		},
		qunit: {
			all: ['test/**/*.html']
		},
		watch: {
			files: ['<%= concat.distjs.src %>', '<%= concat.distcsswithicons.src %>'],
			tasks: 'default'
		},
		jshint: {
			options: {
				jshintrc: '.jshintrc'
			},
			src: ['src/**/*.js']
		},
		clean: ['dist'],
		compress: {
			zip: {
				options: {
					archive: 'dist/socialcount.zip'
				},
				files: [
					{
						expand: true,
						cwd: 'dist/',
						src: ['*.js', '*.css', '*.png', 'service/**' ],
						dest: 'socialcount/'
					}
				]
			}
		},
		usebanner: {
			dist: {
				options: {
					position: 'top',
					banner: '<%= banner %>'
				},
				files: {
					src: [ 'dist/*.js', 'dist/*.css' ]
				}
			}
		}
	});

	require('matchdep').filterDev('grunt-*').forEach(grunt.loadNpmTasks);

	// Default task.
	grunt.registerTask( 'build-icons', [ 'sass', 'default' ] );
	grunt.registerTask( 'default', [ 'jshint', 'sass', 'concat', 'usebanner', 'copy', 'qunit' ] );
	grunt.registerTask( 'stage', [ 'default' ]);
	grunt.registerTask( 'release', [ 'clean', 'build-icons', 'compress' ] );
};
<commit_msg>Ugh, no sass for real this time.<commit_after>/*global module:false*/
module.exports = function(grunt) {

	// Project configuration.
	grunt.initConfig({
		pkg: grunt.file.readJSON('package.json'),
		banner: '/*! <%= pkg.title || pkg.name %> - v<%= pkg.version %> - ' +
			'<%= grunt.template.today("yyyy-mm-dd") %>\n' +
			'<%= pkg.homepage ? "* " + pkg.homepage + "\\n" : "" %>' +
			'* Copyright (c) <%= grunt.template.today("yyyy") %> <%= pkg.author.name %>;' +
			' Licensed <%= _.pluck(pkg.licenses, "type").join(", ") %> */\n',
		concat: {
			options: {
				stripBanners: true
			},
			distjs: {
				src: [
					'src/socialcount.js',
					'src/networks/facebook.js',
					'src/networks/twitter.js',
					'src/networks/googleplus.js',
					'src/networks/pinterest.js',
					// 'src/networks/sharethis.js',
				],
				dest: 'dist/socialcount.js'
			},
			distcss: {
				src: [
					'src/socialcount.css',
					'src/networks/facebook.css',
					'src/networks/pinterest.css',
					// 'src/networks/sharethis.css',
					'src/loading.css'
				],
				dest: 'dist/socialcount.css'
			},
			distcsswithicons: {
				src: [
					'<%= concat.distcss.dest %>',
					'src/socialcount-icons.css'
				],
				dest: 'dist/socialcount-with-icons.css'
			}
		},
		sass: {
			icons: {
				options: {
					compass: true
				},
				files: {
					'src/socialcount-icons.css': 'src/socialcount-icons.scss'
				}
			}
		},
		copy: {
			images: {
				cwd: 'src/',
				src: '*.png',
				dest: 'dist/',
				expand: true,
				flatten: true
			},
			service: {
				cwd: 'src/service/',
				src: '**',
				dest: 'dist/service/',
				expand: true,
				flatten: true
			}
		},
		qunit: {
			all: ['test/**/*.html']
		},
		watch: {
			files: ['<%= concat.distjs.src %>', '<%= concat.distcsswithicons.src %>'],
			tasks: 'default'
		},
		jshint: {
			options: {
				jshintrc: '.jshintrc'
			},
			src: ['src/**/*.js']
		},
		clean: ['dist'],
		compress: {
			zip: {
				options: {
					archive: 'dist/socialcount.zip'
				},
				files: [
					{
						expand: true,
						cwd: 'dist/',
						src: ['*.js', '*.css', '*.png', 'service/**' ],
						dest: 'socialcount/'
					}
				]
			}
		},
		usebanner: {
			dist: {
				options: {
					position: 'top',
					banner: '<%= banner %>'
				},
				files: {
					src: [ 'dist/*.js', 'dist/*.css' ]
				}
			}
		}
	});

	require('matchdep').filterDev('grunt-*').forEach(grunt.loadNpmTasks);

	// Default task.
	grunt.registerTask( 'build-icons', [ 'sass', 'default' ] );
	grunt.registerTask( 'default', [ 'jshint', 'concat', 'usebanner', 'copy', 'qunit' ] );
	grunt.registerTask( 'stage', [ 'default' ]);
	grunt.registerTask( 'release', [ 'clean', 'build-icons', 'compress' ] );
};
<|endoftext|>


<commit_before>(function ($) {
  $.extend($.summernote.lang, {
    'de-DE': {
      font: {
        bold: 'Fett',
        italic: 'Kursiv',
        underline: 'Unterstreichen',
        clear: 'Zurücksetzen',
        height: 'Zeilenhöhe',
        name: 'Schriftart',
        strikethrough: 'Durchgestrichen',
        subscript: 'Tiefgestellt',
        superscript: 'Hochgestellt',
        size: 'Schriftgröße'
      },
      image: {
        image: 'Bild',
        insert: 'Bild einfügen',
        resizeFull: 'Originalgröße',
        resizeHalf: '1/2 Größe',
        resizeQuarter: '1/4 Größe',
        floatLeft: 'Linksbündig',
        floatRight: 'Rechtsbündig',
        floatNone: 'Kein Textfluss',
        shapeRounded: 'Abgerundeter Rahmen',
        shapeCircle: 'Kreisförmiger Rahmen',
        shapeThumbnail: 'Rahmenvorschau',
        shapeNone: 'Kein Rahmen',
        dragImageHere: 'Bild hierher ziehen',
        dropImage: 'Bild oder Text nehmen',
        selectFromFiles: 'Datei auswählen',
        maximumFileSize: 'Maximale Dateigröße',
        maximumFileSizeError: 'Maximale Dateigröße überschritten',
        url: 'Bild URL',
        remove: 'Bild entfernen',
        original: 'Original'
      },
      video: {
        video: 'Video',
        videoLink: 'Videolink',
        insert: 'Video einfügen',
        url: 'Video URL',
        providers: '(YouTube, Vimeo, Vine, Instagram, DailyMotion oder Youku)'
      },
      link: {
        link: 'Link',
        insert: 'Link einfügen',
        unlink: 'Link entfernen',
        edit: 'Bearbeiten',
        textToDisplay: 'Anzeigetext',
        url: 'Link URL',
        openInNewWindow: 'In neuem Fenster öffnen'
      },
      table: {
        table: 'Tabelle',
        addRowAbove: '+ Zeile oberhalb',
		    addRowBelow: '+ Zeile unterhalb',
		    addColLeft: '+ Spalte links',
		    addColRight: '+ Spalte rechts',
		    delRow: 'Reihe löschen',
		    delCol: 'Spalte löschen',
		    delTable: 'Tabelle löschen'
      },
      hr: {
        insert: 'Horizontale Linie einfügen'
      },
      style: {
        style: 'Stil',
        normal: 'Normal',
        p: 'Normal',
        blockquote: 'Zitat',
        pre: 'Quellcode',
        h1: 'Überschrift 1',
        h2: 'Überschrift 2',
        h3: 'Überschrift 3',
        h4: 'Überschrift 4',
        h5: 'Überschrift 5',
        h6: 'Überschrift 6'
      },
      lists: {
        unordered: 'Unnummerierte Liste',
        ordered: 'Nummerierte Liste'
      },
      options: {
        help: 'Hilfe',
        fullscreen: 'Vollbild',
        codeview: 'Quellcode anzeigen'
      },
      paragraph: {
        paragraph: 'Absatz',
        outdent: 'Einzug vergrößern',
        indent: 'Einzug verkleinern',
        left: 'Links ausrichten',
        center: 'Zentriert ausrichten',
        right: 'Rechts ausrichten',
        justify: 'Blocksatz'
      },
      color: {
        recent: 'Letzte Farbe',
        more: 'Weitere Farben',
        background: 'Hintergrundfarbe',
        foreground: 'Schriftfarbe',
        transparent: 'Transparenz',
        setTransparent: 'Transparenz setzen',
        reset: 'Zurücksetzen',
        resetToDefault: 'Auf Standard zurücksetzen'
      },
      shortcut: {
        shortcuts: 'Tastenkürzel',
        close: 'Schließen',
        textFormatting: 'Textformatierung',
        action: 'Aktion',
        paragraphFormatting: 'Absatzformatierung',
        documentStyle: 'Dokumentenstil',
        extraKeys: 'Weitere Tasten'
      },
      help: {
        'insertParagraph': 'Absatz einfügen',
        'undo': 'Letzte Anweisung rückgängig',
        'redo': 'Letzte Anweisung wiederholen',
        'tab': 'Einzug hinzufügen',
        'untab': 'Einzug entfernen',
        'bold': 'Schrift Fett',
        'italic': 'Schrift Kursiv',
        'underline': 'Unterstreichen',
        'strikethrough': 'Durchstreichen',
        'removeFormat': 'Entfernt Format',
        'justifyLeft': 'Linksbündig',
        'justifyCenter': 'Mittig',
        'justifyRight': 'Rechtsbündig',
        'justifyFull': 'Blocksatz',
        'insertUnorderedList': 'Unnummerierte Liste',
        'insertOrderedList': 'Nummerierte Liste',
        'outdent': 'Aktuellen Absatz ausrücken',
        'indent': 'Aktuellen Absatz einrücken',
        'formatPara': 'Formatiert aktuellen Block als Absatz (P-Tag)',
        'formatH1': 'Formatiert aktuellen Block als H1',
        'formatH2': 'Formatiert aktuellen Block als H2',
        'formatH3': 'Formatiert aktuellen Block als H3',
        'formatH4': 'Formatiert aktuellen Block als H4',
        'formatH5': 'Formatiert aktuellen Block als H5',
        'formatH6': 'Formatiert aktuellen Block als H6',
        'insertHorizontalRule': 'Fügt eine horizontale Linie ein',
        'linkDialog.show': 'Zeigt Linkdialog'
      },
      history: {
        undo: 'Rückgängig',
        redo: 'Wiederholen'
      },
      specialChar: {
        specialChar: 'Sonderzeichen',
        select: 'Zeichen auswählen'
      }
    }
  });
})(jQuery);
<commit_msg>Fix lint error<commit_after>(function($) {
  $.extend($.summernote.lang, {
    'de-DE': {
      font: {
        bold: 'Fett',
        italic: 'Kursiv',
        underline: 'Unterstreichen',
        clear: 'Zurücksetzen',
        height: 'Zeilenhöhe',
        name: 'Schriftart',
        strikethrough: 'Durchgestrichen',
        subscript: 'Tiefgestellt',
        superscript: 'Hochgestellt',
        size: 'Schriftgröße'
      },
      image: {
        image: 'Bild',
        insert: 'Bild einfügen',
        resizeFull: 'Originalgröße',
        resizeHalf: '1/2 Größe',
        resizeQuarter: '1/4 Größe',
        floatLeft: 'Linksbündig',
        floatRight: 'Rechtsbündig',
        floatNone: 'Kein Textfluss',
        shapeRounded: 'Abgerundeter Rahmen',
        shapeCircle: 'Kreisförmiger Rahmen',
        shapeThumbnail: 'Rahmenvorschau',
        shapeNone: 'Kein Rahmen',
        dragImageHere: 'Bild hierher ziehen',
        dropImage: 'Bild oder Text nehmen',
        selectFromFiles: 'Datei auswählen',
        maximumFileSize: 'Maximale Dateigröße',
        maximumFileSizeError: 'Maximale Dateigröße überschritten',
        url: 'Bild URL',
        remove: 'Bild entfernen',
        original: 'Original'
      },
      video: {
        video: 'Video',
        videoLink: 'Videolink',
        insert: 'Video einfügen',
        url: 'Video URL',
        providers: '(YouTube, Vimeo, Vine, Instagram, DailyMotion oder Youku)'
      },
      link: {
        link: 'Link',
        insert: 'Link einfügen',
        unlink: 'Link entfernen',
        edit: 'Bearbeiten',
        textToDisplay: 'Anzeigetext',
        url: 'Link URL',
        openInNewWindow: 'In neuem Fenster öffnen'
      },
      table: {
        table: 'Tabelle',
        addRowAbove: '+ Zeile oberhalb',
        addRowBelow: '+ Zeile unterhalb',
        addColLeft: '+ Spalte links',
        addColRight: '+ Spalte rechts',
        delRow: 'Reihe löschen',
        delCol: 'Spalte löschen',
        delTable: 'Tabelle löschen'
      },
      hr: {
        insert: 'Horizontale Linie einfügen'
      },
      style: {
        style: 'Stil',
        normal: 'Normal',
        p: 'Normal',
        blockquote: 'Zitat',
        pre: 'Quellcode',
        h1: 'Überschrift 1',
        h2: 'Überschrift 2',
        h3: 'Überschrift 3',
        h4: 'Überschrift 4',
        h5: 'Überschrift 5',
        h6: 'Überschrift 6'
      },
      lists: {
        unordered: 'Unnummerierte Liste',
        ordered: 'Nummerierte Liste'
      },
      options: {
        help: 'Hilfe',
        fullscreen: 'Vollbild',
        codeview: 'Quellcode anzeigen'
      },
      paragraph: {
        paragraph: 'Absatz',
        outdent: 'Einzug vergrößern',
        indent: 'Einzug verkleinern',
        left: 'Links ausrichten',
        center: 'Zentriert ausrichten',
        right: 'Rechts ausrichten',
        justify: 'Blocksatz'
      },
      color: {
        recent: 'Letzte Farbe',
        more: 'Weitere Farben',
        background: 'Hintergrundfarbe',
        foreground: 'Schriftfarbe',
        transparent: 'Transparenz',
        setTransparent: 'Transparenz setzen',
        reset: 'Zurücksetzen',
        resetToDefault: 'Auf Standard zurücksetzen'
      },
      shortcut: {
        shortcuts: 'Tastenkürzel',
        close: 'Schließen',
        textFormatting: 'Textformatierung',
        action: 'Aktion',
        paragraphFormatting: 'Absatzformatierung',
        documentStyle: 'Dokumentenstil',
        extraKeys: 'Weitere Tasten'
      },
      help: {
        'insertParagraph': 'Absatz einfügen',
        'undo': 'Letzte Anweisung rückgängig',
        'redo': 'Letzte Anweisung wiederholen',
        'tab': 'Einzug hinzufügen',
        'untab': 'Einzug entfernen',
        'bold': 'Schrift Fett',
        'italic': 'Schrift Kursiv',
        'underline': 'Unterstreichen',
        'strikethrough': 'Durchstreichen',
        'removeFormat': 'Entfernt Format',
        'justifyLeft': 'Linksbündig',
        'justifyCenter': 'Mittig',
        'justifyRight': 'Rechtsbündig',
        'justifyFull': 'Blocksatz',
        'insertUnorderedList': 'Unnummerierte Liste',
        'insertOrderedList': 'Nummerierte Liste',
        'outdent': 'Aktuellen Absatz ausrücken',
        'indent': 'Aktuellen Absatz einrücken',
        'formatPara': 'Formatiert aktuellen Block als Absatz (P-Tag)',
        'formatH1': 'Formatiert aktuellen Block als H1',
        'formatH2': 'Formatiert aktuellen Block als H2',
        'formatH3': 'Formatiert aktuellen Block als H3',
        'formatH4': 'Formatiert aktuellen Block als H4',
        'formatH5': 'Formatiert aktuellen Block als H5',
        'formatH6': 'Formatiert aktuellen Block als H6',
        'insertHorizontalRule': 'Fügt eine horizontale Linie ein',
        'linkDialog.show': 'Zeigt Linkdialog'
      },
      history: {
        undo: 'Rückgängig',
        redo: 'Wiederholen'
      },
      specialChar: {
        specialChar: 'Sonderzeichen',
        select: 'Zeichen auswählen'
      }
    }
  });
})(jQuery);
<|endoftext|>


<commit_before>/* jshint node: true */
var FRONTEND_DIR = 'frontend/';
var LIB_DIR = FRONTEND_DIR + 'lib/';
var SPEC_DIR = FRONTEND_DIR + 'spec/';
var SRC_DIR = FRONTEND_DIR + 'src/';
var DIST_DIR = FRONTEND_DIR + 'dist/';

module.exports = function (grunt) {

  grunt.initConfig({
    pkg: grunt.file.readJSON('package.json'),

    clean: {
      dist: {src: [DIST_DIR]}
    },

    concat: {
      dist: {
        src: [
          LIB_DIR + 'esprima/esprima.js',
          LIB_DIR + 'falafel/falafel.browser.js',
          LIB_DIR + 'noty/js/noty/jquery.noty.js',
          LIB_DIR + 'noty/js/noty/layouts/top.js',
          LIB_DIR + 'noty/js/noty/layouts/topCenter.js',
          LIB_DIR + 'noty/js/noty/themes/default.js',
          SRC_DIR + 'head.js',
          SRC_DIR + 'mws/**/*.js',
          SRC_DIR + 'tail.js'
        ],
        dest: DIST_DIR + 'mongoWebShell.js'
      }
    },

    jasmine: {
      dist: {
        src: DIST_DIR + '**/*.js',
        options: {
          specs: SPEC_DIR + '**/*.spec.js',
          helpers: [
            SPEC_DIR + 'disableConsole.js',
            SPEC_DIR + 'globals.js',
            SPEC_DIR + 'phantomJSWorkarounds.js'
          ],
          vendor: [
            'http://sinonjs.org/releases/sinon-1.6.0.js',
            'https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js',
            LIB_DIR + 'falafel/falafel.browser.js'
          ]
        }
      }
    },

    jshint: {
      gruntfile: {src: ['Gruntfile.js']},
      spec: {src: [SPEC_DIR + '**/*.js']},
      src: {src: [SRC_DIR + '**/*.js']},
      options: {
        jshintrc: FRONTEND_DIR + '.jshintrc'
      }
    },

    watch: {
      dist: {
        files: [SRC_DIR + '**/*'],
        tasks: ['default']
      }
    },

    shell: {
      pep8: {
        command: 'pep8 mongows tests run*.py',
        options: {
          stdout: true,
          stderr: true,
          failOnError: true
        }
      },
      unittest: {
        command: 'python run_tests.py',
        options: {
//          stdout: true,
//          stderr: true,
          failOnError: true
        }
      }
    }
  });

  grunt.loadNpmTasks('grunt-contrib-clean');
  grunt.loadNpmTasks('grunt-contrib-concat');
  grunt.loadNpmTasks('grunt-contrib-jasmine');
  grunt.loadNpmTasks('grunt-contrib-jshint');
  grunt.loadNpmTasks('grunt-contrib-watch');
  grunt.loadNpmTasks('grunt-shell');

  grunt.registerTask('default', ['concat']);
  grunt.registerTask('pep8', ['shell:pep8']);
  grunt.registerTask('unittest', ['shell:unittest']);
  grunt.registerTask(
    'test',
    ['jshint', 'concat', 'jasmine', 'pep8', 'unittest']
  );
};
<commit_msg>Remove commented lines.<commit_after>/* jshint node: true */
var FRONTEND_DIR = 'frontend/';
var LIB_DIR = FRONTEND_DIR + 'lib/';
var SPEC_DIR = FRONTEND_DIR + 'spec/';
var SRC_DIR = FRONTEND_DIR + 'src/';
var DIST_DIR = FRONTEND_DIR + 'dist/';

module.exports = function (grunt) {

  grunt.initConfig({
    pkg: grunt.file.readJSON('package.json'),

    clean: {
      dist: {src: [DIST_DIR]}
    },

    concat: {
      dist: {
        src: [
          LIB_DIR + 'esprima/esprima.js',
          LIB_DIR + 'falafel/falafel.browser.js',
          LIB_DIR + 'noty/js/noty/jquery.noty.js',
          LIB_DIR + 'noty/js/noty/layouts/top.js',
          LIB_DIR + 'noty/js/noty/layouts/topCenter.js',
          LIB_DIR + 'noty/js/noty/themes/default.js',
          SRC_DIR + 'head.js',
          SRC_DIR + 'mws/**/*.js',
          SRC_DIR + 'tail.js'
        ],
        dest: DIST_DIR + 'mongoWebShell.js'
      }
    },

    jasmine: {
      dist: {
        src: DIST_DIR + '**/*.js',
        options: {
          specs: SPEC_DIR + '**/*.spec.js',
          helpers: [
            SPEC_DIR + 'disableConsole.js',
            SPEC_DIR + 'globals.js',
            SPEC_DIR + 'phantomJSWorkarounds.js'
          ],
          vendor: [
            'http://sinonjs.org/releases/sinon-1.6.0.js',
            'https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js',
            LIB_DIR + 'falafel/falafel.browser.js'
          ]
        }
      }
    },

    jshint: {
      gruntfile: {src: ['Gruntfile.js']},
      spec: {src: [SPEC_DIR + '**/*.js']},
      src: {src: [SRC_DIR + '**/*.js']},
      options: {
        jshintrc: FRONTEND_DIR + '.jshintrc'
      }
    },

    watch: {
      dist: {
        files: [SRC_DIR + '**/*'],
        tasks: ['default']
      }
    },

    shell: {
      pep8: {
        command: 'pep8 mongows tests run*.py',
        options: {
          stdout: true,
          stderr: true,
          failOnError: true
        }
      },
      unittest: {
        command: 'python run_tests.py',
        options: {
          failOnError: true
        }
      }
    }
  });

  grunt.loadNpmTasks('grunt-contrib-clean');
  grunt.loadNpmTasks('grunt-contrib-concat');
  grunt.loadNpmTasks('grunt-contrib-jasmine');
  grunt.loadNpmTasks('grunt-contrib-jshint');
  grunt.loadNpmTasks('grunt-contrib-watch');
  grunt.loadNpmTasks('grunt-shell');

  grunt.registerTask('default', ['concat']);
  grunt.registerTask('pep8', ['shell:pep8']);
  grunt.registerTask('unittest', ['shell:unittest']);
  grunt.registerTask(
    'test',
    ['jshint', 'concat', 'jasmine', 'pep8', 'unittest']
  );
};
<|endoftext|>


<commit_before>'use strict';

module.exports = function (grunt) {

    /*
     Load npm tasks here.
     */
    grunt.loadNpmTasks('grunt-contrib-jshint');
    grunt.loadNpmTasks('grunt-contrib-watch');

    grunt.loadNpmTasks('grunt-karma');

    grunt.loadNpmTasks('grunt-contrib-less');
    grunt.loadNpmTasks('grunt-react');

    grunt.loadNpmTasks('grunt-contrib-concat');
    grunt.loadNpmTasks('grunt-ng-annotate');
    grunt.loadNpmTasks('grunt-contrib-uglify');
    grunt.loadNpmTasks('grunt-contrib-clean');

    var userConfig = require( './grunt.settings.js' );
    userConfig.pkg = grunt.file.readJSON('package.json');

    var taskConfig = require( './grunt.tasks.js' );
    grunt.initConfig( grunt.util._.extend( taskConfig, userConfig ) );

    /*
     Register tasks here
     */

    grunt.registerTask('checkAll',
        ['jshint','karma']);
};
<commit_msg>Step #10 Add aliased 'buildAll' task<commit_after>'use strict';

module.exports = function (grunt) {

    /*
     Load npm tasks here.
     */
    grunt.loadNpmTasks('grunt-contrib-jshint');
    grunt.loadNpmTasks('grunt-contrib-watch');

    grunt.loadNpmTasks('grunt-karma');

    grunt.loadNpmTasks('grunt-contrib-less');
    grunt.loadNpmTasks('grunt-react');

    grunt.loadNpmTasks('grunt-contrib-concat');
    grunt.loadNpmTasks('grunt-ng-annotate');
    grunt.loadNpmTasks('grunt-contrib-uglify');
    grunt.loadNpmTasks('grunt-contrib-clean');

    var userConfig = require( './grunt.settings.js' );
    userConfig.pkg = grunt.file.readJSON('package.json');

    var taskConfig = require( './grunt.tasks.js' );
    grunt.initConfig( grunt.util._.extend( taskConfig, userConfig ) );

    /*
     Register tasks here
     */

    grunt.registerTask('checkAll',
        ['jshint','karma']);

    grunt.registerTask('buildAll', [
        'clean',
        'checkAll',
        'less',
        'react',
        'concat',
        'ngAnnotate',
        'uglify',
        'clean:tmp'
    ]);
};
<|endoftext|>


<commit_before>'use strict';

module.exports = function (grunt) {
	grunt.initConfig({
		jshint: {
			all: [
				'Gruntfile.js',
				'tasks/*.js',
				'lib/*.js',
				'<%= nodeunit.tests %>'
			],
			options: {
				jshintrc: '.jshintrc'
			}
		},

		clean: [
			'.tmp'
		],

		excel_vocabulary: {
			convert: {
				expand: true,
				cwd: 'examples',
				dest: '.tmp'
			}
		},

		nodeunit: {
			tests: [ 'tests/*.js' ]
		}
	});

	grunt.registerTask('default', [
		'jshint',
		'clean',
		'excel_vocabulary',
		'nodeunit'
	]);

	gtunr.registerTask('test', [
		'default'
	]);

	grunt.loadTasks('tasks');
	grunt.loadNpmTasks('grunt-contrib-jshint');
	grunt.loadNpmTasks('grunt-contrib-clean');
	grunt.loadNpmTasks('grunt-contrib-nodeunit');
};
<commit_msg>fix typo in Gruntfile<commit_after>'use strict';

module.exports = function (grunt) {
	grunt.initConfig({
		jshint: {
			all: [
				'Gruntfile.js',
				'tasks/*.js',
				'lib/*.js',
				'<%= nodeunit.tests %>'
			],
			options: {
				jshintrc: '.jshintrc'
			}
		},

		clean: [
			'.tmp'
		],

		excel_vocabulary: {
			convert: {
				expand: true,
				cwd: 'examples',
				dest: '.tmp',
				ext: '.json',
				src: [
					'**/*.xlsx'
				]
			}
		},

		nodeunit: {
			tests: [ 'tests/*.js' ]
		}
	});

	grunt.registerTask('default', [
		'jshint',
		'clean',
		'excel_vocabulary',
		'nodeunit'
	]);

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

	grunt.loadTasks('tasks');
	grunt.loadNpmTasks('grunt-contrib-jshint');
	grunt.loadNpmTasks('grunt-contrib-clean');
	grunt.loadNpmTasks('grunt-contrib-nodeunit');
};
<|endoftext|>