diff --git a/.gitignore b/.gitignore index 0402acd7..c92d6eaa 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,4 @@ components/ bower_components/ node_modules/ sandbox/**/bundle.js +.build* diff --git a/Gruntfile.js b/Gruntfile.js index 4026fa2c..6e497ca1 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -54,6 +54,29 @@ module.exports = function( grunt ) { banner: banner } } + }, + + exec: { + 'meteor-init': { + command: [ + // Make sure Meteor is installed, per https://meteor.com/install. + // The curl'ed script is safe; takes 2 minutes to read source & check. + 'type meteor >/dev/null 2>&1 || { curl https://install.meteor.com/ | sh; }', + // Meteor expects package.js to be in the root directory of + // the checkout, so copy it there temporarily + 'cp meteor/package.js .' + ].join(';') + }, + 'meteor-cleanup': { + // remove build files and package.js + command: 'rm -rf .build.* versions.json package.js' + }, + 'meteor-test': { + command: 'spacejam --mongo-url mongodb:// test-packages ./' + }, + 'meteor-publish': { + command: 'meteor publish' + } } }); @@ -61,6 +84,7 @@ module.exports = function( grunt ) { grunt.loadNpmTasks('grunt-contrib-jshint'); grunt.loadNpmTasks('grunt-contrib-uglify'); grunt.loadNpmTasks('grunt-requirejs'); + grunt.loadNpmTasks('grunt-exec'); grunt.registerTask( 'pkgd-edit', function() { var outFile = grunt.config.get('requirejs.pkgd.options.out'); @@ -77,6 +101,11 @@ module.exports = function( grunt ) { grunt.log.writeln( 'Edited ' + outFile ); }); + // Meteor tasks + grunt.registerTask('meteor-test', ['exec:meteor-init', 'exec:meteor-test', 'exec:meteor-cleanup']); + grunt.registerTask('meteor-publish', ['exec:meteor-init', 'exec:meteor-publish', 'exec:meteor-cleanup']); + grunt.registerTask('meteor', ['exec:meteor-init', 'exec:meteor-test', 'exec:meteor-publish', 'exec:meteor-cleanup']); + grunt.registerTask( 'default', [ 'jshint', 'requirejs', diff --git a/meteor/README.md b/meteor/README.md new file mode 100644 index 00000000..f60a94e3 --- /dev/null +++ b/meteor/README.md @@ -0,0 +1,25 @@ +Packaging [Isotope](http://isotope.metafizzy.co/) for [Meteor.js](http://meteor.com). + + +# Meteor + +If you're new to Meteor, here's what the excitement is all about - +[watch the first two minutes](https://www.youtube.com/watch?v=fsi0aJ9yr2o); you'll be hooked by 1:28. + +That screencast is from 2012. In the meantime, Meteor has become a mature JavaScript-everywhere web +development framework. Read more at [Why Meteor](http://www.meteorpedia.com/read/Why_Meteor). + + +# Issues + +If you encounter an issue while using this package, please CC @dandv when you file it in this repo. + + +# DONE + +* Automated and visual test for the fitRows layout + + +# TODO + +* Add other tests; however, that is overkill, and the responsibiity of Isotope, not of the Meteor integration. diff --git a/meteor/export.js b/meteor/export.js new file mode 100644 index 00000000..9ff01af0 --- /dev/null +++ b/meteor/export.js @@ -0,0 +1,3 @@ +/*global Isotope:true*/ // Meteor.js creates a file-scope global for exporting. This comment prevents a potential JSHint warning. +Isotope = window.Isotope; +delete window.Isotope; diff --git a/meteor/package.js b/meteor/package.js new file mode 100644 index 00000000..49210ebf --- /dev/null +++ b/meteor/package.js @@ -0,0 +1,33 @@ +// package metadata file for Meteor.js +'use strict'; + +var packageName = 'isotope:isotope'; // http://atmospherejs.com/isotope/isotope +var where = 'client'; // where to install: 'client' or 'server'. For both, pass nothing. + +var packageJson = JSON.parse(Npm.require("fs").readFileSync('package.json')); + +Package.describe({ + name: packageName, + summary: 'Isotope (official): filter and sort magical layouts: fit rows, packery, masonry, fit columns etc.', // limited to 100 characters + version: packageJson.version, + git: 'https://github.com/metafizzy/isotope.git' +}); + +Package.onUse(function (api) { + api.versionsFrom(['METEOR@0.9.0', 'METEOR@1.0']); + api.export('Isotope'); + api.addFiles([ + 'dist/isotope.pkgd.js', + 'meteor/export.js' + ], where); +}); + +Package.onTest(function (api) { + api.use(packageName, where); + api.use(['tinytest', 'http'], where); + + api.addFiles([ + 'test/tests.css', + 'meteor/test.js' + ], where); +}); diff --git a/meteor/test.js b/meteor/test.js new file mode 100644 index 00000000..5612c048 --- /dev/null +++ b/meteor/test.js @@ -0,0 +1,58 @@ +'use strict'; + +Tinytest.addAsync('Isotope - fitRows', function (test, done) { + var isotopeDropZone = document.createElement('div'); + document.body.appendChild(isotopeDropZone); + + // TODO ideally we'd get the htmls straight from this repo, but no idea how to do this from TinyTest - http://stackoverflow.com/questions/27180892/pull-an-html-file-into-a-tinytest + HTTP.get('http://rawgit.com/metafizzy/isotope/master/test/index.html', function callback(error, result) { + + // adapted from test/fit-rows.js + function checkPosition(item, x, y) { + var elem = item.element; + var left = parseInt(elem.style.left, 10); + var top = parseInt(elem.style.top, 10); + test.equal([ left, top ], [ x, y ], 'item position ' + x + ', ' + y); + } + + if (error) { + test.fail({message: 'Error getting the test file. Do we have an Internet connection to rawgit.com?'}); + } else { + // [^] matches across newlines. Stay within the
, or else the fragment will attempt to load resources on its own. + isotopeDropZone.innerHTML = result.content.match(/