Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge branch 'master' of git://github.com/bitovi/canjs

  • Loading branch information...
commit 5d98b7b361e9982343e8e822d80854b45bd8fe66 2 parents cc82077 + e8af3b3
@imjoshdean imjoshdean authored
View
1  .gitignore
@@ -11,3 +11,4 @@ docs*
build/ci/can
build/ci/funcunit
build/ci/steal
+build/gh-pages
View
63 build/downloads.json
@@ -0,0 +1,63 @@
+{
+ "jquery": {
+ "src": "dist/<%= pkg.version %>/can.jquery.js",
+ "description": "Can jQuery <%= pkg.version %> Development",
+ "filename": "can.jquery-<%= pkg.version %>.js"
+ },
+ "jqueryMin": {
+ "src": "dist/<%= pkg.version %>/can.jquery.min.js",
+ "description": "Can jQuery <%= pkg.version %> Production",
+ "filename": "can.jquery-<%= pkg.version %>.min.js"
+ },
+ "zepto": {
+ "src": "dist/<%= pkg.version %>/can.zepto.js",
+ "description": "Can Zepto <%= pkg.version %> Development",
+ "filename": "can.zepto-<%= pkg.version %>.js"
+ },
+ "zeptoMin": {
+ "src": "dist/<%= pkg.version %>/can.zepto.min.js",
+ "description": "Can Zepto <%= pkg.version %> Production",
+ "filename": "can.zepto-<%= pkg.version %>.min.js"
+ },
+ "yui": {
+ "src": "dist/<%= pkg.version %>/can.yui.js",
+ "description": "Can YUI <%= pkg.version %> Development",
+ "filename": "can.yui-<%= pkg.version %>.js"
+ },
+ "yuiMin": {
+ "src": "dist/<%= pkg.version %>/can.yui.min.js",
+ "description": "Can YUI <%= pkg.version %> Production",
+ "filename": "can.yui-<%= pkg.version %>.min.js"
+ },
+ "mootools": {
+ "src": "dist/<%= pkg.version %>/can.mootools.js",
+ "description": "Can Mootools <%= pkg.version %> Development",
+ "filename": "can.mootools-<%= pkg.version %>.js"
+ },
+ "mootoolsMin": {
+ "src": "dist/<%= pkg.version %>/can.mootools.min.js",
+ "description": "Can Mootools <%= pkg.version %> Production",
+ "filename": "can.mootools-<%= pkg.version %>.min.js"
+ },
+ "dojo": {
+ "src": "dist/<%= pkg.version %>/can.dojo.js",
+ "description": "Can Dojo <%= pkg.version %> Development",
+ "filename": "can.dojo-<%= pkg.version %>.js"
+ },
+ "dojoMin": {
+ "src": "dist/<%= pkg.version %>/can.dojo.min.js",
+ "description": "Can Dojo <%= pkg.version %> Production",
+ "filename": "can.dojo-<%= pkg.version %>.min.js"
+ },
+ "dist" : {
+ "src" : "dist/can.js.<%= pkg.version %>.zip",
+ "description" : "CanJS <%= pkg.version %>",
+ "filename" : "can.js.<%= pkg.version %>.zip",
+ "content_type" : "application/zip"
+ },
+ "_options" : {
+ "repository" : "canjs",
+ "user" : "bitovi",
+ "overwrite" : true
+ }
+}
View
103 build/tasks/downloads.js
@@ -0,0 +1,103 @@
+var program = require("commander");
+var GitHubApi = require("github");
+var authenticated = false;
+var fs = require('fs');
+var github = new GitHubApi({
+ version : "3.0.0"
+});
+var getCredentials = function (callback) {
+ if(authenticated) {
+ return callback();
+ }
+
+ program.prompt("Github Username: ", function (name) {
+ var username = name;
+
+ program.password("Github Password: ", "*", function (pass) {
+ var password = pass;
+ process.stdin.pause();
+ github.authenticate({
+ type : "basic",
+ username : username,
+ password : password
+ });
+ authenticated = true;
+ callback();
+ });
+
+ });
+}
+
+module.exports = function (grunt) {
+ grunt.registerMultiTask('downloads', 'Uploads generated files as GitHub downloads.', function () {
+ if(this.target == '_options') {
+ return;
+ }
+
+ var _ = grunt.utils._;
+ var done = this.async();
+ var ops = grunt.config(['downloads', this.target]);
+ var defaults = _.extend({}, grunt.config(['downloads', '_options']));
+ var sourceFile = this.file.src;
+
+ var desc = grunt.template.process(ops.description);
+ var name = grunt.template.process(ops.filename);
+
+ grunt.log.writeln('Deploying ' + desc);
+ fs.readFile(sourceFile, function (err, buf) {
+ if (err) {
+ return grunt.fail.fatal(err);
+ }
+
+ var createDownload = function() {
+ github.httpSend({
+ "user" : defaults.user,
+ "repo" : defaults.repository,
+ "name" : name,
+ "size" : buf.length,
+ "description" : desc,
+ "content_type" : ops.content_type || "text/javascript"
+ }, {
+ "url" : "/repos/:user/:repo/downloads",
+ "method" : "POST",
+ "params" : {
+ "$user" : null,
+ "$repo" : null,
+ "$name" : null,
+ "$size" : null,
+ "description" : null,
+ "$content_type" : null
+ }
+ }, function (err, socket) {
+ if(err) {
+ return grunt.fail.fatal(err);
+ }
+ var data = JSON.parse(socket.data);
+
+ grunt.utils.s3.postToS3({
+ key : data.path,
+ acl : data.acl,
+ success_action_status : "201",
+ Filename : data.name,
+ AWSAccessKeyId : data.accesskeyid,
+ policy64 : data.policy,
+ signature64 : data.signature,
+ contentType : data.mime_type,
+ data : buf,
+ bucket : "github"
+ }, function (e) {
+ if(e) {
+ return grunt.fail.fatal(e);
+ }
+ grunt.log.writeln('Successfully created GitHub download and uploaded to S3.');
+ done();
+ })
+ });
+ }
+
+ grunt.log.writeln('Uploading to ' + defaults.user + '/' + defaults.repository + '/' + name);
+ getCredentials(createDownload);
+
+ });
+ });
+}
View
2  build/tasks/shell.js
@@ -25,7 +25,7 @@ module.exports = function (grunt) {
return;
}
- var command = grunt.template.process(data.command);
+ var command = grunt.template.process(this.file.src);
log.writeln('Running ' + command);
exec(command, data.execOptions, function (err, stdout, stderr) {
if (stdout) {
View
5 build/tasks/strip.js
@@ -16,13 +16,14 @@ module.exports = function (grunt) {
}
var outFile = options.out ? path.join(options.out, path.basename(file)) : file;
// TODO use Grunt internals
- grunt.log.writeln('Stripping ' + file + ' of all multiline comments, writing result to ' + outFile);
+ grunt.log.writeln('Stripping ' + file + ' of all multiline and empty inline comments');
// Put new index.html into production mode
var code = grunt.file.read(file);
// Remove multiline comments
- code = code.replace(/\/\*([\s\S]*?)\*\//gim, "");
+ code = code.replace(/\/\*([\s\S]*?)\*\//gim, "")
+ .replace(/\/\/(\s*)\n/gim, "");
// Remove double semicolons from steal pluginify
code = code.replace(/;[\s]*;/gim, ";");
View
123 build/tasks/utils.js
@@ -9,22 +9,129 @@ var spawn = require("child_process").spawn;
// opts: nodeSpawnOptions
// }
-module.exports = function(grunt) {
- grunt.utils.exec = function(options, callback) {
+module.exports = function (grunt) {
+ grunt.utils.exec = function (options, callback) {
var build = grunt.utils.spawn(options, callback);
- build.stdout.on("data", function( buf ) {
- grunt.log.write( "" + buf );
+ build.stdout.on("data", function (buf) {
+ grunt.log.write("" + buf);
});
- build.stderr.on("data", function( buf ) {
- grunt.log.write( "" + buf );
+ build.stderr.on("data", function (buf) {
+ grunt.log.write("" + buf);
});
- build.on("exit", function( code ) {
+ build.on("exit", function (code) {
callback(null, code);
});
return build;
- }
+ };
+
+ // Generated by CoffeeScript 1.3.1
+ (function () {
+ var crypto, https, joinBuffers, postToS3, readText, signPolicy, url, _ref;
+
+ url = require('url');
+
+ https = require('https');
+
+ crypto = require('crypto');
+
+ _ref = require('tafa-misc-util'), joinBuffers = _ref.joinBuffers, readText = _ref.readText;
+
+ signPolicy = function (secretKey, policy) {
+ var data, hmac, json, key, policy64, signature64;
+ json = JSON.stringify(policy);
+ policy64 = new Buffer(json).toString('base64');
+ data = new Buffer(policy64, 'utf-8');
+ key = new Buffer(secretKey, 'utf-8');
+ hmac = crypto.createHmac('sha1', key);
+ hmac.update(data);
+ signature64 = hmac.digest('base64');
+ return {
+ signature64 : signature64,
+ policy64 : policy64
+ };
+ };
+
+ postToS3 = function (_arg, callback) {
+ var AWSAccessKeyId, Filename, acl, addParam, arr, boundary, bucket, buf, ca, contentType, customUrl, data, host, hostname, key, options, policy64, port, protocol, req, req_body, signature64, success_action_status, _ref1;
+ AWSAccessKeyId = _arg.AWSAccessKeyId, policy64 = _arg.policy64, signature64 = _arg.signature64, bucket = _arg.bucket, key = _arg.key, data = _arg.data, boundary = _arg.boundary, customUrl = _arg.customUrl, ca = _arg.ca, acl = _arg.acl, success_action_status = _arg.success_action_status, Filename = _arg.Filename, contentType = _arg.contentType;
+ if (callback == null) {
+ callback = (function () {
+ });
+ }
+ if (customUrl) {
+ _ref1 = url.parse(customUrl), protocol = _ref1.protocol, hostname = _ref1.hostname, port = _ref1.port;
+ if (protocol !== "https:") {
+ return callback(new Error("customUrl must be https://"));
+ }
+ host = hostname;
+ port || (port = 443);
+ } else {
+ host = "" + bucket + ".s3.amazonaws.com";
+ port = 443;
+ }
+ boundary || (boundary = '----------R46EARkAg4SAXSjufGsb6m');
+ buf = function (x) {
+ return new Buffer(x);
+ };
+ arr = [];
+ addParam = function (k, v) {
+ arr.push(buf('--' + boundary + '\r\n'));
+ arr.push(buf('Content-Disposition: form-data; name="' + k + '"\r\n\r\n'));
+ return arr.push(buf(v), buf('\r\n'));
+ };
+ addParam('key', key);
+ addParam('acl', acl);
+ addParam('success_action_status', success_action_status);
+ addParam('Filename', Filename);
+ addParam('AWSAccessKeyId', AWSAccessKeyId);
+ addParam('Policy', policy64);
+ addParam('Signature', signature64);
+ addParam('Content-Type', contentType);
+ arr.push(buf('--' + boundary + '\r\n'));
+ arr.push(buf('Content-Disposition: form-data; name="file"; filename="data"\r\n'));
+ arr.push(buf("Content-Length: " + data.length + "\r\n"));
+ arr.push(buf('Content-Transfer-Encoding: binary\r\n\r\n'));
+ arr.push(data, buf('\r\n'));
+ arr.push(buf('--' + boundary + '--'));
+ req_body = joinBuffers(arr);
+ options = {
+ host : host,
+ port : port,
+ path : '/',
+ method : 'POST',
+ headers : {
+ 'Host' : "" + bucket + ".s3.amazonaws.com",
+ 'Content-Type' : 'multipart/form-data; boundary=' + boundary,
+ 'Content-Length' : req_body.length
+ }
+ };
+ if (ca) {
+ options.ca = ca;
+ }
+ req = https.request(options, function (res) {
+ var _ref2;
+ if ((200 <= (_ref2 = res.statusCode) && _ref2 < 300)) {
+ return callback(null);
+ } else {
+ return readText(res, function (text) {
+ return callback({
+ responseCode : res.statusCode,
+ responseText : text
+ });
+ });
+ }
+ });
+ return req.end(req_body);
+ };
+
+ grunt.utils.s3 = {
+ postToS3 : postToS3,
+ signPolicy : signPolicy
+ };
+
+ }).call(this);
}
View
34 grunt.js
@@ -3,7 +3,7 @@ module.exports = function (grunt) {
var _ = grunt.utils._;
var excludes = [/\.min\./, /\/amd/, /qunit\.js/];
var outFiles = {
- edge : '<%= meta.out %>/edge/**/*!(.min).js',
+ edge : '<%= meta.out %>/edge/**/*.js',
latest : '<%= meta.out %>/<%= pkg.version %>/**/*.js',
_options : {
exclude : excludes
@@ -64,29 +64,23 @@ module.exports = function (grunt) {
}
},
shell : {
- bundleLatest : {
- command : 'cd <%= meta.out %> && zip -r can.js.<%= pkg.version %>.zip <%= pkg.version %>/'
- },
- getGhPages : {
- command : 'git clone -b gh-pages <%= pkg.repository.url %> build/tmp'
- },
- copyLatest : {
- command : 'rm -rf build/tmp/release/<%= pkg.version %> && ' +
- 'cp -R <%= meta.out %>/<%= pkg.version %> build/tmp/release/<%= pkg.version %> && ' +
- 'rm -rf build/tmp/release/latest && ' +
- 'cp -R <%= meta.out %>/<%= pkg.version %> build/tmp/release/latest'
- },
- updateGhPages : {
- command : 'cd build/tmp && git commit -a -m "Updating release" && git push origin'
- },
- cleanup : {
- command : 'rm -rf build/tmp'
- },
+ bundleLatest : 'cd <%= meta.out %> && zip -r can.js.<%= pkg.version %>.zip <%= pkg.version %>/',
+ getGhPages : 'git clone -b gh-pages <%= pkg.repository.url %> build/gh-pages',
+ copyLatest : 'rm -rf build/gh-page/release/<%= pkg.version %> && ' +
+ 'cp -R <%= meta.out %>/<%= pkg.version %> build/gh-pages/release/<%= pkg.version %> && ' +
+ 'rm -rf build/gh-pages/release/latest && ' +
+ 'cp -R <%= meta.out %>/<%= pkg.version %> build/gh-pages/release/latest',
+ copyEdge : 'rm -rf build/gh-pages/release/edge && ' +
+ 'cp -R <%= meta.out %>/edge build/gh-pages/release/edge',
+ updateGhPages : 'cd build/gh-pages && git add . --all && git commit -m "Updating release (latest: <%= pkg.version %>)" && ' +
+ 'git push origin',
+ cleanup : 'rm -rf build/gh-pages',
_options : {
stdout : true,
failOnError : true
}
},
+ downloads : '<json:build/downloads.json>',
docco : outFiles,
strip : outFiles
});
@@ -95,5 +89,5 @@ module.exports = function (grunt) {
grunt.registerTask("edge", "build:edge build:edgePlugins strip:edge beautify:dist");
grunt.registerTask("latest", "build:latest build:latestPlugins strip:latest beautify:dist docco:latest");
- grunt.registerTask("deploy", "shell:getGhPages shell:copyLatest shell:updateGhPages shell:cleanup");
+ grunt.registerTask("deploy", "latest shell:getGhPages shell:copyLatest shell:updateGhPages shell:cleanup shell:bundleLatest downloads");
};
View
5 package.json
@@ -12,7 +12,10 @@
"grunt-closure-tools" : "~0.6.2",
"http-server" : "0.5.1",
"docco" : ">= 0.1.x",
- "node-beautify" : "*"
+ "node-beautify" : "*",
+ "github" : ">= 0.1.7",
+ "commander" : "*",
+ "tafa-misc-util" : "*"
},
"homepage" : "http://canjs.us/",
"repository" : {
View
2  readme.md
@@ -1,6 +1,6 @@
[![CanJS](http://canjs.us/images/canjs_logo_yellow_small.png)](http://canjs.us/)
-[![Build Status](https://secure.travis-ci.org/jupiterjs/canjs.png)](http://travis-ci.org/jupiterjs/canjs)
+[![Build Status](https://secure.travis-ci.org/bitovi/canjs.png)](http://travis-ci.org/bitovi/canjs)
CanJS is a MIT-licensed, client-side, JavaScript framework that makes building
rich web applications easy. Use it because it’s:
View
2  test/plugin_test.js
@@ -9,7 +9,7 @@ steal('./setup.js').then(
, 'can/observe/sort/sort_test.js'
, 'can/control/route/route_test.js'
, 'can/control/view/test/qunit/view_test.js'
- , 'can/control/modifier/modifier_test.js'
+ // TODO , 'can/control/modifier/modifier_test.js'
, function() {
if(window.jQuery) {
steal('can/control/plugin/plugin_test.js', 'can/view/modifiers/modifiers_test.js');
View
16 util/fixture/fixture.js
@@ -1,5 +1,15 @@
steal('can/util','can/util/string','can/util/object', function (can) {
+ var getUrl = function(url) {
+ if(typeof steal !== 'undefined') {
+ if(can.isFunction(steal.config)) {
+ return steal.config().root.mapJoin(url);
+ }
+ return steal.root.join(url)
+ }
+ return (can.fixture.rootUrl || '') + url;
+ }
+
var updateSettings = function (settings, originalOptions) {
if (!can.fixture.on) {
return;
@@ -49,9 +59,7 @@ steal('can/util','can/util/string','can/util/object', function (can) {
if (/^\/\//.test(url)) {
// this lets us use rootUrl w/o having steal...
- url = (typeof steal !== 'undefined') && (can.fixture.rootUrl === steal.config().root) ?
- steal.config().root.mapJoin(settings.fixture.substr(2)) + '' :
- (can.fixture.rootUrl || '') + settings.fixture.substr(2);
+ url = getUrl(settings.fixture.substr(2));
}
if(data) {
@@ -787,7 +795,7 @@ steal('can/util','can/util/string','can/util/object', function (can) {
* If you are using StealJS it will use the Steal root
* URL by default.
*/
- can.fixture.rootUrl = window.steal ? steal.config().root : undefined;
+ can.fixture.rootUrl = getUrl('');
can.fixture["-handleFunction"] = function (settings) {
if (typeof settings.fixture === "string" && can.fixture[settings.fixture]) {
Please sign in to comment.
Something went wrong with that request. Please try again.