diff --git a/.gitignore b/.gitignore index 2251b98d..4214507e 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ .DS_Store thirdparty/jwplayer.* +node_modules/ \ No newline at end of file diff --git a/Gruntfile.js b/Gruntfile.js new file mode 100644 index 00000000..dc2bd872 --- /dev/null +++ b/Gruntfile.js @@ -0,0 +1,101 @@ +module.exports = function(grunt) { + + grunt.loadNpmTasks('grunt-contrib-uglify'); + grunt.loadNpmTasks('grunt-contrib-concat'); + grunt.loadNpmTasks('grunt-contrib-copy'); + grunt.loadNpmTasks('grunt-contrib-cssmin'); + grunt.loadNpmTasks('grunt-contrib-clean'); + grunt.loadNpmTasks("grunt-remove-logging"); + grunt.loadNpmTasks('grunt-contrib-jshint'); + + grunt.initConfig({ + pkg: grunt.file.readJSON('package.json'), + concat: { + build: { + src: [ + // Ultimately this should be just 'scripts/*.js', + // but for now we're maintaining the order which was + // specified in the previous 'compile.sh' script + 'scripts/ableplayer-base.js', + 'scripts/initialize.js', + 'scripts/preference.js', + 'scripts/webvtt.js', + 'scripts/buildplayer.js', + 'scripts/track.js', + 'scripts/seekbar.js', + 'scripts/dialog.js', + 'scripts/misc.js', + 'scripts/description.js', + 'scripts/browser.js', + 'scripts/control.js', + 'scripts/caption.js', + 'scripts/metadata.js', + 'scripts/translation.js', + 'scripts/transcript.js', + 'scripts/search.js', + 'scripts/event.js' + ], + dest: 'build/<%= pkg.name %>.js' + }, + }, + removelogging: { + dist: { + src: [ + 'build/<%= pkg.name %>.js' + ], + dest: 'build/<%= pkg.name %>.dist.js' + }, + options: { + // Remove all console output (see https://www.npmjs.com/package/grunt-remove-logging) + } + }, + uglify: { + min: { + src : ['build/<%= pkg.name %>.dist.js'], + dest : 'build/<%= pkg.name %>.min.js', + }, + options: { + // Add a banner with the package name and version + // (no date, otherwise a new build is different even if the code didn't change!) + banner: '/*! <%= pkg.name %> V<%= pkg.version %> */\n', + // Preserve comments that start with a bang (like the file header) + preserveComments: "some" + } + }, + cssmin: { + min: { + src : [ + 'styles/ableplayer.css', + 'styles/ableplayer-playlist.css', + 'styles/ableplayer-search.css', + 'styles/ableplayer-transcript.css' + ], + dest : 'build/<%= pkg.name %>.min.css', + }, + options: { + // Add a banner with the package name and version + // (no date, otherwise a new build is different even if the code didn't change!) + // (oddly, here we don't need a '\n' at the end!) + banner: '/*! <%= pkg.name %> V<%= pkg.version %> */', + } + }, + jshint: { + files: ['Gruntfile.js', 'scripts/**/*.js'], + options: { + // options here to override JSHint defaults + globals: { + browser: true, + jquery: true, + devel: true, + } + } + }, + clean: { + build: ['build'], + }, + + }); + + grunt.registerTask('default', ['concat', 'removelogging', 'uglify', 'cssmin']); + grunt.registerTask('test', ['jshint']); +}; diff --git a/README.md b/README.md index 1b193150..2f374306 100644 --- a/README.md +++ b/README.md @@ -439,7 +439,34 @@ users can control the following: - Highlight transcript as video plays - Keyboard-enable transcript +Building the Able Player source +------------------------------- + +The source JavaScript files for the ableplayer are in the */scripts* directory, +and are combined into several different files (in the */build* directory) using +[npm][] and [Grunt][]: + +```sh +npm install +grunt +``` +The npm and Grunt build process is defined by the *Gruntfile.js* and *package.json* +files. (Note that the **version number** is specified in *package.json*, and must be +updated when a new version is released). + +Files created by the build process are put into the */build* directory: + +- **build/ableplayer.js** - + the default build of *ableplayer.js* +- **build/ableplayer.dist.js** - + a build of *ableplayer.js* without console logging +- **build/ableplayer.min.js** - + a minified version of the *dist* file +- **build/ableplayer.min.css** - + a minified version of the *styles/ableplayer.css* file + + [examples]: http://ableplayer.github.io/ableplayer/tests/ [jQuery]: http://jquery.com/ [Modernizr]: http://modernizr.com/ @@ -448,6 +475,7 @@ users can control the following: [WebAIM’s 2014 Screen Reader User Survey]: http://webaim.org/projects/screenreadersurvey5/#browsers [Configuring MIME Types in IIS 7]: http://technet.microsoft.com/en-us/library/17bda1f4-8a0d-440f-986a-5aaa9d40b74c.aspx [How to add MIME Types with IIS7 Web.config]: http://blogs.iis.net/bills/archive/2008/03/25/how-to-add-mime-types-with-iis7-web-config.aspx - + [npm]: https://www.npmjs.com/ + [grunt]: http://gruntjs.com/ diff --git a/compile.sh b/compile.sh deleted file mode 100755 index 3adc4dd7..00000000 --- a/compile.sh +++ /dev/null @@ -1,21 +0,0 @@ -#!/bin/sh - -rm build/ableplayer.js -cat scripts/ableplayer-base.js >> build/ableplayer.js -cat scripts/initialize.js >> build/ableplayer.js -cat scripts/preference.js >> build/ableplayer.js -cat scripts/webvtt.js >> build/ableplayer.js -cat scripts/buildplayer.js >> build/ableplayer.js -cat scripts/track.js >> build/ableplayer.js -cat scripts/seekbar.js >> build/ableplayer.js -cat scripts/dialog.js >> build/ableplayer.js -cat scripts/misc.js >> build/ableplayer.js -cat scripts/description.js >> build/ableplayer.js -cat scripts/browser.js >> build/ableplayer.js -cat scripts/control.js >> build/ableplayer.js -cat scripts/caption.js >> build/ableplayer.js -cat scripts/metadata.js >> build/ableplayer.js -cat scripts/translation.js >> build/ableplayer.js -cat scripts/transcript.js >> build/ableplayer.js -cat scripts/search.js >> build/ableplayer.js -cat scripts/event.js >> build/ableplayer.js diff --git a/package.json b/package.json new file mode 100644 index 00000000..09471618 --- /dev/null +++ b/package.json @@ -0,0 +1,18 @@ +{ + "name": "ableplayer", + "version": "2.03.0", + "repository": { + "type": "git", + "url": "https://github.com/ableplayer/ableplayer.git" + }, + "devDependencies": { + "grunt": "~0.4.1", + "grunt-contrib-clean": "~0.6.0", + "grunt-contrib-concat": "~0.3.0", + "grunt-contrib-copy": "~0.4.1", + "grunt-contrib-cssmin": "~0.6.1", + "grunt-contrib-jshint": "^0.10.0", + "grunt-contrib-uglify": "~0.2.2", + "grunt-remove-logging": "~0.2.0" + } +}