improvements to the asset pipeline thanks to @twinturbo
40
AssetFile
|
@ -18,7 +18,7 @@ Travis::Version.update
|
||||||
output 'public/scripts'
|
output 'public/scripts'
|
||||||
input paths[:scripts] do
|
input paths[:scripts] do
|
||||||
match '**/*.hbs' do
|
match '**/*.hbs' do
|
||||||
filter Travis::HandlebarsFilter
|
travis_handlebars
|
||||||
concat 'app/templates.js'
|
concat 'app/templates.js'
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -26,40 +26,48 @@ input paths[:scripts] do
|
||||||
coffee_script
|
coffee_script
|
||||||
end
|
end
|
||||||
|
|
||||||
match %r(^(?!vendor\/).*\.js$) do
|
|
||||||
modules = proc { |input| input.path.gsub(%r((^app/|^lib/|\.js$)), '') }
|
|
||||||
minispade(string: true, rewrite_requires: true, module_id_generator: modules)
|
|
||||||
concat [], ['dev/app.js', 'min/app.js']
|
|
||||||
end
|
|
||||||
|
|
||||||
match 'vendor/**/*.js' do
|
match 'vendor/**/*.js' do
|
||||||
precedence = %w(jquery.min minispade handlebars ember).map { |name| "vendor/#{name}.js" }
|
precedence = %w(jquery.min minispade handlebars ember).map { |name| "vendor/#{name}.js" }
|
||||||
concat precedence, ['dev/vendor.js', 'min/vendor.js']
|
safe_concat precedence, 'vendor.js'
|
||||||
end
|
end
|
||||||
|
|
||||||
match 'min/**/*.js' do
|
match '**/*.js' do
|
||||||
filter Travis::ProductionFilter
|
copy { |path| ["dev/#{path}", "min/#{path}"] }
|
||||||
uglify max_line_length: 32 * 1024, squeeze: true
|
end
|
||||||
filter Travis::SafeConcatFilter do
|
|
||||||
'app.min.js'
|
match %r(^dev/(?!vendor).*\.js$) do
|
||||||
end
|
modules = proc { |input| input.path.gsub(%r((^dev/|app/|lib/|\.js$)), '') }
|
||||||
|
minispade(string: true, rewrite_requires: true, module_id_generator: modules)
|
||||||
end
|
end
|
||||||
|
|
||||||
match 'dev/**/*.js' do
|
match 'dev/**/*.js' do
|
||||||
concat 'app.js'
|
concat ['dev/vendor.js'], 'app.js'
|
||||||
|
end
|
||||||
|
|
||||||
|
match %r(^min/(?!vendor).*\.js$) do
|
||||||
|
modules = proc { |input| input.path.gsub(%r((^min/|app/|lib/|\.js$)), '') }
|
||||||
|
minispade(string: false, rewrite_requires: true, module_id_generator: modules)
|
||||||
|
end
|
||||||
|
|
||||||
|
match 'min/**/*.js' do
|
||||||
|
concat ['min/vendor.js'], 'min/app.js'
|
||||||
|
strip_debug
|
||||||
|
uglify squeeze: true, max_line_length: 200
|
||||||
|
copy 'app.min.js'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
output 'public/styles'
|
output 'public/styles'
|
||||||
input paths[:styles] do
|
input paths[:styles] do
|
||||||
match '**/*.{scss,sass}' do
|
match '**/*.{scss,sass}' do
|
||||||
filter Rake::Pipeline::Web::Filters::SassFilter
|
sass
|
||||||
concat [], 'app.css'
|
concat [], 'app.css'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
output 'public/images'
|
output 'public/images'
|
||||||
input paths[:images] do
|
input paths[:images] do
|
||||||
|
skip %r(^ui/)
|
||||||
match '**/*' do
|
match '**/*' do
|
||||||
copy
|
copy
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,8 +1,9 @@
|
||||||
GIT
|
GIT
|
||||||
remote: git://github.com/livingsocial/rake-pipeline.git
|
remote: git://github.com/livingsocial/rake-pipeline.git
|
||||||
revision: 3465e0e3e134bf52ddf5d138e8c8262412080095
|
revision: 3914452278165b7eb3a79071d3b63b46fee59a2f
|
||||||
specs:
|
specs:
|
||||||
rake-pipeline (0.6.0)
|
rake-pipeline (0.6.0)
|
||||||
|
json
|
||||||
rake (~> 0.9.0)
|
rake (~> 0.9.0)
|
||||||
thor
|
thor
|
||||||
|
|
||||||
|
@ -42,7 +43,7 @@ GIT
|
||||||
|
|
||||||
GIT
|
GIT
|
||||||
remote: git://github.com/travis-ci/travis-api.git
|
remote: git://github.com/travis-ci/travis-api.git
|
||||||
revision: c9c9dc61d8e2f24b331fd0e1b1549aff32178b29
|
revision: f7c522278eb7fdc9ccbf96af711fe38fa4fb4674
|
||||||
specs:
|
specs:
|
||||||
travis-api (0.0.1)
|
travis-api (0.0.1)
|
||||||
backports (~> 2.5)
|
backports (~> 2.5)
|
||||||
|
@ -88,7 +89,7 @@ GIT
|
||||||
|
|
||||||
GIT
|
GIT
|
||||||
remote: git://github.com/wycats/rake-pipeline-web-filters.git
|
remote: git://github.com/wycats/rake-pipeline-web-filters.git
|
||||||
revision: e14e78ae70d0d25b1668c5273e80cd05a4ee52e6
|
revision: f28f5809d6a3e580401a0c589d54e6ad28f34a26
|
||||||
specs:
|
specs:
|
||||||
rake-pipeline-web-filters (0.6.0)
|
rake-pipeline-web-filters (0.6.0)
|
||||||
rack
|
rack
|
||||||
|
@ -223,7 +224,7 @@ GEM
|
||||||
rdoc (3.12)
|
rdoc (3.12)
|
||||||
json (~> 1.4)
|
json (~> 1.4)
|
||||||
redcarpet (2.1.1)
|
redcarpet (2.1.1)
|
||||||
redis (3.0.1)
|
redis (3.0.2)
|
||||||
rerun (0.7.1)
|
rerun (0.7.1)
|
||||||
listen
|
listen
|
||||||
rollout (1.1.0)
|
rollout (1.1.0)
|
||||||
|
|
527
assets/scripts/vendor/jquery.mockjax.js
vendored
|
@ -1,527 +0,0 @@
|
||||||
/*!
|
|
||||||
* MockJax - jQuery Plugin to Mock Ajax requests
|
|
||||||
*
|
|
||||||
* Version: 1.5.0pre
|
|
||||||
* Released:
|
|
||||||
* Home: http://github.com/appendto/jquery-mockjax
|
|
||||||
* Author: Jonathan Sharp (http://jdsharp.com)
|
|
||||||
* License: MIT,GPL
|
|
||||||
*
|
|
||||||
* Copyright (c) 2011 appendTo LLC.
|
|
||||||
* Dual licensed under the MIT or GPL licenses.
|
|
||||||
* http://appendto.com/open-source-licenses
|
|
||||||
*/
|
|
||||||
(function($) {
|
|
||||||
var _ajax = $.ajax,
|
|
||||||
mockHandlers = [],
|
|
||||||
CALLBACK_REGEX = /=\?(&|$)/,
|
|
||||||
jsc = (new Date()).getTime();
|
|
||||||
|
|
||||||
|
|
||||||
// Parse the given XML string.
|
|
||||||
function parseXML(xml) {
|
|
||||||
if ( window['DOMParser'] == undefined && window.ActiveXObject ) {
|
|
||||||
DOMParser = function() { };
|
|
||||||
DOMParser.prototype.parseFromString = function( xmlString ) {
|
|
||||||
var doc = new ActiveXObject('Microsoft.XMLDOM');
|
|
||||||
doc.async = 'false';
|
|
||||||
doc.loadXML( xmlString );
|
|
||||||
return doc;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
var xmlDoc = ( new DOMParser() ).parseFromString( xml, 'text/xml' );
|
|
||||||
if ( $.isXMLDoc( xmlDoc ) ) {
|
|
||||||
var err = $('parsererror', xmlDoc);
|
|
||||||
if ( err.length == 1 ) {
|
|
||||||
throw('Error: ' + $(xmlDoc).text() );
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
throw('Unable to parse XML');
|
|
||||||
}
|
|
||||||
} catch( e ) {
|
|
||||||
var msg = ( e.name == undefined ? e : e.name + ': ' + e.message );
|
|
||||||
$(document).trigger('xmlParseError', [ msg ]);
|
|
||||||
return undefined;
|
|
||||||
}
|
|
||||||
return xmlDoc;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Trigger a jQuery event
|
|
||||||
function trigger(s, type, args) {
|
|
||||||
(s.context ? jQuery(s.context) : jQuery.event).trigger(type, args);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check if the data field on the mock handler and the request match. This
|
|
||||||
// can be used to restrict a mock handler to being used only when a certain
|
|
||||||
// set of data is passed to it.
|
|
||||||
function isMockDataEqual( mock, live ) {
|
|
||||||
var identical = false;
|
|
||||||
// Test for situations where the data is a querystring (not an object)
|
|
||||||
if (typeof live === 'string') {
|
|
||||||
// Querystring may be a regex
|
|
||||||
return $.isFunction( mock.test ) ? mock.test(live) : mock == live;
|
|
||||||
}
|
|
||||||
$.each(mock, function(k, v) {
|
|
||||||
if ( live[k] === undefined ) {
|
|
||||||
identical = false;
|
|
||||||
return identical;
|
|
||||||
} else {
|
|
||||||
identical = true;
|
|
||||||
if ( typeof live[k] == 'object' ) {
|
|
||||||
return isMockDataEqual(mock[k], live[k]);
|
|
||||||
} else {
|
|
||||||
if ( $.isFunction( mock[k].test ) ) {
|
|
||||||
identical = mock[k].test(live[k]);
|
|
||||||
} else {
|
|
||||||
identical = ( mock[k] == live[k] );
|
|
||||||
}
|
|
||||||
return identical;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
return identical;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check the given handler should mock the given request
|
|
||||||
function getMockForRequest( handler, requestSettings ) {
|
|
||||||
// If the mock was registered with a function, let the function decide if we
|
|
||||||
// want to mock this request
|
|
||||||
if ( $.isFunction(handler) ) {
|
|
||||||
return handler( requestSettings );
|
|
||||||
}
|
|
||||||
|
|
||||||
// Inspect the URL of the request and check if the mock handler's url
|
|
||||||
// matches the url for this ajax request
|
|
||||||
if ( $.isFunction(handler.url.test) ) {
|
|
||||||
// The user provided a regex for the url, test it
|
|
||||||
if ( !handler.url.test( requestSettings.url ) ) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
// Look for a simple wildcard '*' or a direct URL match
|
|
||||||
var star = handler.url.indexOf('*');
|
|
||||||
if (handler.url !== requestSettings.url && star === -1 ||
|
|
||||||
!new RegExp(handler.url.replace(/[-[\]{}()+?.,\\^$|#\s]/g, "\\$&").replace('*', '.+')).test(requestSettings.url)) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Inspect the data submitted in the request (either POST body or GET query string)
|
|
||||||
if ( handler.data && requestSettings.data ) {
|
|
||||||
if ( !isMockDataEqual(handler.data, requestSettings.data) ) {
|
|
||||||
// They're not identical, do not mock this request
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// Inspect the request type
|
|
||||||
if ( handler && handler.type &&
|
|
||||||
handler.type.toLowerCase() != requestSettings.type.toLowerCase() ) {
|
|
||||||
// The request type doesn't match (GET vs. POST)
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
return handler;
|
|
||||||
}
|
|
||||||
|
|
||||||
// If logging is enabled, log the mock to the console
|
|
||||||
function logMock( mockHandler, requestSettings ) {
|
|
||||||
var c = $.extend({}, $.mockjaxSettings, mockHandler);
|
|
||||||
if ( c.log && $.isFunction(c.log) ) {
|
|
||||||
var url = requestSettings.url
|
|
||||||
if(requestSettings.data) {
|
|
||||||
params = []
|
|
||||||
for(key in requestSettings.data) params.push(key + '=' + requestSettings.data[key])
|
|
||||||
url = url + '?' + params.join('&')
|
|
||||||
}
|
|
||||||
c.log('MOCK ' + requestSettings.type.toUpperCase() + ': ' + url, $.extend({}, requestSettings));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Process the xhr objects send operation
|
|
||||||
function _xhrSend(mockHandler, requestSettings, origSettings) {
|
|
||||||
|
|
||||||
// This is a substitute for < 1.4 which lacks $.proxy
|
|
||||||
var process = (function(that) {
|
|
||||||
return function() {
|
|
||||||
return (function() {
|
|
||||||
// The request has returned
|
|
||||||
this.status = mockHandler.status;
|
|
||||||
this.statusText = mockHandler.statusText;
|
|
||||||
this.readyState = 4;
|
|
||||||
|
|
||||||
// We have an executable function, call it to give
|
|
||||||
// the mock handler a chance to update it's data
|
|
||||||
if ( $.isFunction(mockHandler.response) ) {
|
|
||||||
mockHandler.response(origSettings);
|
|
||||||
}
|
|
||||||
// Copy over our mock to our xhr object before passing control back to
|
|
||||||
// jQuery's onreadystatechange callback
|
|
||||||
if ( requestSettings.dataType == 'json' && ( typeof mockHandler.responseText == 'object' ) ) {
|
|
||||||
this.responseText = JSON.stringify(mockHandler.responseText);
|
|
||||||
} else if ( requestSettings.dataType == 'xml' ) {
|
|
||||||
if ( typeof mockHandler.responseXML == 'string' ) {
|
|
||||||
this.responseXML = parseXML(mockHandler.responseXML);
|
|
||||||
} else {
|
|
||||||
this.responseXML = mockHandler.responseXML;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
this.responseText = mockHandler.responseText;
|
|
||||||
}
|
|
||||||
if( typeof mockHandler.status == 'number' || typeof mockHandler.status == 'string' ) {
|
|
||||||
this.status = mockHandler.status;
|
|
||||||
}
|
|
||||||
if( typeof mockHandler.statusText === "string") {
|
|
||||||
this.statusText = mockHandler.statusText;
|
|
||||||
}
|
|
||||||
// jQuery < 1.4 doesn't have onreadystate change for xhr
|
|
||||||
if ( $.isFunction(this.onreadystatechange) ) {
|
|
||||||
if( mockHandler.isTimeout) {
|
|
||||||
this.status = -1;
|
|
||||||
}
|
|
||||||
this.onreadystatechange( mockHandler.isTimeout ? 'timeout' : undefined );
|
|
||||||
} else if ( mockHandler.isTimeout ) {
|
|
||||||
// Fix for 1.3.2 timeout to keep success from firing.
|
|
||||||
this.status = -1;
|
|
||||||
}
|
|
||||||
}).apply(that);
|
|
||||||
};
|
|
||||||
})(this);
|
|
||||||
|
|
||||||
if ( mockHandler.proxy ) {
|
|
||||||
// We're proxying this request and loading in an external file instead
|
|
||||||
_ajax({
|
|
||||||
global: false,
|
|
||||||
url: mockHandler.proxy,
|
|
||||||
type: mockHandler.proxyType,
|
|
||||||
data: mockHandler.data,
|
|
||||||
dataType: requestSettings.dataType === "script" ? "text/plain" : requestSettings.dataType,
|
|
||||||
complete: function(xhr, txt) {
|
|
||||||
mockHandler.responseXML = xhr.responseXML;
|
|
||||||
mockHandler.responseText = xhr.responseText;
|
|
||||||
mockHandler.status = xhr.status;
|
|
||||||
mockHandler.statusText = xhr.statusText;
|
|
||||||
this.responseTimer = setTimeout(process, mockHandler.responseTime || 0);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
// type == 'POST' || 'GET' || 'DELETE'
|
|
||||||
if ( requestSettings.async === false ) {
|
|
||||||
// TODO: Blocking delay
|
|
||||||
process();
|
|
||||||
} else {
|
|
||||||
this.responseTimer = setTimeout(process, mockHandler.responseTime || 50);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Construct a mocked XHR Object
|
|
||||||
function xhr(mockHandler, requestSettings, origSettings, origHandler) {
|
|
||||||
// Extend with our default mockjax settings
|
|
||||||
mockHandler = $.extend({}, $.mockjaxSettings, mockHandler);
|
|
||||||
|
|
||||||
if (typeof mockHandler.headers === 'undefined') {
|
|
||||||
mockHandler.headers = {};
|
|
||||||
}
|
|
||||||
if ( mockHandler.contentType ) {
|
|
||||||
mockHandler.headers['content-type'] = mockHandler.contentType;
|
|
||||||
}
|
|
||||||
|
|
||||||
return {
|
|
||||||
status: mockHandler.status,
|
|
||||||
statusText: mockHandler.statusText,
|
|
||||||
readyState: 1,
|
|
||||||
open: function() { },
|
|
||||||
send: function() {
|
|
||||||
origHandler.fired = true;
|
|
||||||
_xhrSend.call(this, mockHandler, requestSettings, origSettings);
|
|
||||||
},
|
|
||||||
abort: function() {
|
|
||||||
clearTimeout(this.responseTimer);
|
|
||||||
},
|
|
||||||
setRequestHeader: function(header, value) {
|
|
||||||
mockHandler.headers[header] = value;
|
|
||||||
},
|
|
||||||
getResponseHeader: function(header) {
|
|
||||||
// 'Last-modified', 'Etag', 'content-type' are all checked by jQuery
|
|
||||||
if ( mockHandler.headers && mockHandler.headers[header] ) {
|
|
||||||
// Return arbitrary headers
|
|
||||||
return mockHandler.headers[header];
|
|
||||||
} else if ( header.toLowerCase() == 'last-modified' ) {
|
|
||||||
return mockHandler.lastModified || (new Date()).toString();
|
|
||||||
} else if ( header.toLowerCase() == 'etag' ) {
|
|
||||||
return mockHandler.etag || '';
|
|
||||||
} else if ( header.toLowerCase() == 'content-type' ) {
|
|
||||||
return mockHandler.contentType || 'text/plain';
|
|
||||||
}
|
|
||||||
},
|
|
||||||
getAllResponseHeaders: function() {
|
|
||||||
var headers = '';
|
|
||||||
$.each(mockHandler.headers, function(k, v) {
|
|
||||||
headers += k + ': ' + v + "\n";
|
|
||||||
});
|
|
||||||
return headers;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
// Process a JSONP mock request.
|
|
||||||
function processJsonpMock( requestSettings, mockHandler, origSettings ) {
|
|
||||||
// Handle JSONP Parameter Callbacks, we need to replicate some of the jQuery core here
|
|
||||||
// because there isn't an easy hook for the cross domain script tag of jsonp
|
|
||||||
|
|
||||||
processJsonpUrl( requestSettings );
|
|
||||||
|
|
||||||
requestSettings.dataType = "json";
|
|
||||||
if(requestSettings.data && CALLBACK_REGEX.test(requestSettings.data) || CALLBACK_REGEX.test(requestSettings.url)) {
|
|
||||||
createJsonpCallback(requestSettings, mockHandler);
|
|
||||||
|
|
||||||
// We need to make sure
|
|
||||||
// that a JSONP style response is executed properly
|
|
||||||
|
|
||||||
var rurl = /^(\w+:)?\/\/([^\/?#]+)/,
|
|
||||||
parts = rurl.exec( requestSettings.url ),
|
|
||||||
remote = parts && (parts[1] && parts[1] !== location.protocol || parts[2] !== location.host);
|
|
||||||
|
|
||||||
requestSettings.dataType = "script";
|
|
||||||
if(requestSettings.type.toUpperCase() === "GET" && remote ) {
|
|
||||||
var newMockReturn = processJsonpRequest( requestSettings, mockHandler, origSettings );
|
|
||||||
|
|
||||||
// Check if we are supposed to return a Deferred back to the mock call, or just
|
|
||||||
// signal success
|
|
||||||
if(newMockReturn) {
|
|
||||||
return newMockReturn;
|
|
||||||
} else {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Append the required callback parameter to the end of the request URL, for a JSONP request
|
|
||||||
function processJsonpUrl( requestSettings ) {
|
|
||||||
if ( requestSettings.type.toUpperCase() === "GET" ) {
|
|
||||||
if ( !CALLBACK_REGEX.test( requestSettings.url ) ) {
|
|
||||||
requestSettings.url += (/\?/.test( requestSettings.url ) ? "&" : "?") +
|
|
||||||
(requestSettings.jsonp || "callback") + "=?";
|
|
||||||
}
|
|
||||||
} else if ( !requestSettings.data || !CALLBACK_REGEX.test(requestSettings.data) ) {
|
|
||||||
requestSettings.data = (requestSettings.data ? requestSettings.data + "&" : "") + (requestSettings.jsonp || "callback") + "=?";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Process a JSONP request by evaluating the mocked response text
|
|
||||||
function processJsonpRequest( requestSettings, mockHandler, origSettings ) {
|
|
||||||
// Synthesize the mock request for adding a script tag
|
|
||||||
var callbackContext = origSettings && origSettings.context || requestSettings,
|
|
||||||
newMock = null;
|
|
||||||
|
|
||||||
|
|
||||||
// If the response handler on the moock is a function, call it
|
|
||||||
if ( mockHandler.response && $.isFunction(mockHandler.response) ) {
|
|
||||||
mockHandler.response(origSettings);
|
|
||||||
} else {
|
|
||||||
|
|
||||||
// Evaluate the responseText javascript in a global context
|
|
||||||
if( typeof mockHandler.responseText === 'object' ) {
|
|
||||||
$.globalEval( '(' + JSON.stringify( mockHandler.responseText ) + ')');
|
|
||||||
} else {
|
|
||||||
$.globalEval( '(' + mockHandler.responseText + ')');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Successful response
|
|
||||||
jsonpSuccess( requestSettings, mockHandler );
|
|
||||||
jsonpComplete( requestSettings, mockHandler );
|
|
||||||
|
|
||||||
// If we are running under jQuery 1.5+, return a deferred object
|
|
||||||
if(jQuery.Deferred){
|
|
||||||
newMock = new jQuery.Deferred();
|
|
||||||
if(typeof mockHandler.responseText == "object"){
|
|
||||||
newMock.resolve( mockHandler.responseText );
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
newMock.resolve( jQuery.parseJSON( mockHandler.responseText ) );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return newMock;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// Create the required JSONP callback function for the request
|
|
||||||
function createJsonpCallback( requestSettings, mockHandler ) {
|
|
||||||
jsonp = requestSettings.jsonpCallback || ("jsonp" + jsc++);
|
|
||||||
|
|
||||||
// Replace the =? sequence both in the query string and the data
|
|
||||||
if ( requestSettings.data ) {
|
|
||||||
requestSettings.data = (requestSettings.data + "").replace(CALLBACK_REGEX, "=" + jsonp + "$1");
|
|
||||||
}
|
|
||||||
|
|
||||||
requestSettings.url = requestSettings.url.replace(CALLBACK_REGEX, "=" + jsonp + "$1");
|
|
||||||
|
|
||||||
|
|
||||||
// Handle JSONP-style loading
|
|
||||||
window[ jsonp ] = window[ jsonp ] || function( tmp ) {
|
|
||||||
data = tmp;
|
|
||||||
jsonpSuccess( requestSettings, mockHandler );
|
|
||||||
jsonpComplete( requestSettings, mockHandler );
|
|
||||||
// Garbage collect
|
|
||||||
window[ jsonp ] = undefined;
|
|
||||||
|
|
||||||
try {
|
|
||||||
delete window[ jsonp ];
|
|
||||||
} catch(e) {}
|
|
||||||
|
|
||||||
if ( head ) {
|
|
||||||
head.removeChild( script );
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
// The JSONP request was successful
|
|
||||||
function jsonpSuccess(requestSettings, mockHandler) {
|
|
||||||
// If a local callback was specified, fire it and pass it the data
|
|
||||||
if ( requestSettings.success ) {
|
|
||||||
requestSettings.success.call( callbackContext, ( mockHandler.response ? mockHandler.response.toString() : mockHandler.responseText || ''), status, {} );
|
|
||||||
}
|
|
||||||
|
|
||||||
// Fire the global callback
|
|
||||||
if ( requestSettings.global ) {
|
|
||||||
trigger(requestSettings, "ajaxSuccess", [{}, requestSettings] );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// The JSONP request was completed
|
|
||||||
function jsonpComplete(requestSettings, mockHandler) {
|
|
||||||
// Process result
|
|
||||||
if ( requestSettings.complete ) {
|
|
||||||
requestSettings.complete.call( callbackContext, {} , status );
|
|
||||||
}
|
|
||||||
|
|
||||||
// The request was completed
|
|
||||||
if ( requestSettings.global ) {
|
|
||||||
trigger( "ajaxComplete", [{}, requestSettings] );
|
|
||||||
}
|
|
||||||
|
|
||||||
// Handle the global AJAX counter
|
|
||||||
if ( requestSettings.global && ! --jQuery.active ) {
|
|
||||||
jQuery.event.trigger( "ajaxStop" );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// The core $.ajax replacement.
|
|
||||||
function handleAjax( url, origSettings ) {
|
|
||||||
var mockRequest, requestSettings, mockHandler;
|
|
||||||
|
|
||||||
// If url is an object, simulate pre-1.5 signature
|
|
||||||
if ( typeof url === "object" ) {
|
|
||||||
origSettings = url;
|
|
||||||
url = undefined;
|
|
||||||
} else {
|
|
||||||
// work around to support 1.5 signature
|
|
||||||
origSettings.url = url;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Extend the original settings for the request
|
|
||||||
requestSettings = jQuery.extend(true, {}, jQuery.ajaxSettings, origSettings);
|
|
||||||
|
|
||||||
// Iterate over our mock handlers (in registration order) until we find
|
|
||||||
// one that is willing to intercept the request
|
|
||||||
for(var k = 0; k < mockHandlers.length; k++) {
|
|
||||||
if ( !mockHandlers[k] ) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
mockHandler = getMockForRequest( mockHandlers[k], requestSettings );
|
|
||||||
if(!mockHandler) {
|
|
||||||
// No valid mock found for this request
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Handle console logging
|
|
||||||
logMock( mockHandler, requestSettings );
|
|
||||||
|
|
||||||
|
|
||||||
if ( requestSettings.dataType === "jsonp" ) {
|
|
||||||
if ((mockRequest = processJsonpMock( requestSettings, mockHandler, origSettings ))) {
|
|
||||||
// This mock will handle the JSONP request
|
|
||||||
return mockRequest;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// Removed to fix #54 - keep the mocking data object intact
|
|
||||||
//mockHandler.data = requestSettings.data;
|
|
||||||
|
|
||||||
mockHandler.cache = requestSettings.cache;
|
|
||||||
mockHandler.timeout = requestSettings.timeout;
|
|
||||||
mockHandler.global = requestSettings.global;
|
|
||||||
|
|
||||||
(function(mockHandler, requestSettings, origSettings, origHandler) {
|
|
||||||
mockRequest = _ajax.call($, $.extend(true, {}, origSettings, {
|
|
||||||
// Mock the XHR object
|
|
||||||
xhr: function() { return xhr( mockHandler, requestSettings, origSettings, origHandler ) }
|
|
||||||
}));
|
|
||||||
})(mockHandler, requestSettings, origSettings, mockHandlers[k]);
|
|
||||||
|
|
||||||
return mockRequest;
|
|
||||||
}
|
|
||||||
|
|
||||||
// We don't have a mock request, trigger a normal request
|
|
||||||
return _ajax.apply($, [origSettings]);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// Public
|
|
||||||
|
|
||||||
$.extend({
|
|
||||||
ajax: handleAjax
|
|
||||||
});
|
|
||||||
|
|
||||||
$.mockjaxSettings = {
|
|
||||||
//url: null,
|
|
||||||
//type: 'GET',
|
|
||||||
log: function(msg) {
|
|
||||||
window['console'] && window.console.log && window.console.log(msg);
|
|
||||||
},
|
|
||||||
status: 200,
|
|
||||||
statusText: "OK",
|
|
||||||
responseTime: 500,
|
|
||||||
isTimeout: false,
|
|
||||||
contentType: 'text/plain',
|
|
||||||
response: '',
|
|
||||||
responseText: '',
|
|
||||||
responseXML: '',
|
|
||||||
proxy: '',
|
|
||||||
proxyType: 'GET',
|
|
||||||
|
|
||||||
lastModified: null,
|
|
||||||
etag: '',
|
|
||||||
headers: {
|
|
||||||
etag: 'IJF@H#@923uf8023hFO@I#H#',
|
|
||||||
'content-type' : 'text/plain'
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
$.mockjax = function(settings) {
|
|
||||||
var i = mockHandlers.length;
|
|
||||||
mockHandlers[i] = settings;
|
|
||||||
return i;
|
|
||||||
};
|
|
||||||
$.mockjaxClear = function(i) {
|
|
||||||
if ( arguments.length == 1 ) {
|
|
||||||
mockHandlers[i] = null;
|
|
||||||
} else {
|
|
||||||
mockHandlers = [];
|
|
||||||
}
|
|
||||||
};
|
|
||||||
$.mockjax.handler = function(i) {
|
|
||||||
if ( arguments.length == 1 ) {
|
|
||||||
return mockHandlers[i];
|
|
||||||
}
|
|
||||||
};
|
|
||||||
})(jQuery);
|
|
|
@ -1,6 +1,9 @@
|
||||||
module Travis
|
require 'rake-pipeline'
|
||||||
autoload :HandlebarsFilter, 'rake-pipeline/travis/filters'
|
|
||||||
autoload :SafeConcatFilter, 'rake-pipeline/travis/filters'
|
module Rake::Pipeline::Travis
|
||||||
autoload :ProductionFilter, 'rake-pipeline/travis/filters'
|
autoload :Filters, 'rake-pipeline/travis/filters'
|
||||||
autoload :Version, 'rake-pipeline/travis/version'
|
autoload :Helpers, 'rake-pipeline/travis/helpers'
|
||||||
|
autoload :Version, 'rake-pipeline/travis/version'
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Rake::Pipeline::DSL::PipelineDSL.send(:include, Rake::Pipeline::Travis::Helpers)
|
||||||
|
|
|
@ -1,70 +1,95 @@
|
||||||
require 'rake-pipeline'
|
require 'rake-pipeline'
|
||||||
|
|
||||||
require 'execjs'
|
require 'execjs'
|
||||||
require 'uglifier'
|
require 'uglifier'
|
||||||
require 'pathname'
|
require 'pathname'
|
||||||
|
|
||||||
module Travis
|
class Rake::Pipeline
|
||||||
class HandlebarsFilter < Rake::Pipeline::Filter
|
module Travis
|
||||||
class << self
|
module Filters
|
||||||
def source
|
class Drop < Matcher
|
||||||
[
|
def output_files
|
||||||
File.read(root.join('lib/rake-pipeline/ember-headless.js')),
|
input_files.reject { |f| f.path =~ @pattern }
|
||||||
File.read(root.join('assets/scripts/vendor/handlebars.js')),
|
end
|
||||||
File.read(root.join('assets/scripts/vendor/ember.js'))
|
|
||||||
].join("\n")
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def root
|
class Handlebars < Filter
|
||||||
@root ||= Pathname.new(File.expand_path('../../../../', __FILE__))
|
class << self
|
||||||
|
def source
|
||||||
|
[
|
||||||
|
File.read(root.join('lib/rake-pipeline/ember-headless.js')),
|
||||||
|
File.read(root.join('assets/scripts/vendor/handlebars.js')),
|
||||||
|
File.read(root.join('assets/scripts/vendor/ember.js'))
|
||||||
|
].join("\n")
|
||||||
|
end
|
||||||
|
|
||||||
|
def root
|
||||||
|
@root ||= Pathname.new(File.expand_path('../../../../', __FILE__))
|
||||||
|
end
|
||||||
|
|
||||||
|
def context
|
||||||
|
@@context ||= ExecJS.compile(source)
|
||||||
|
end
|
||||||
|
|
||||||
|
def compile(source)
|
||||||
|
context.call('compileHandlebarsTemplate', source + "\n")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def generate_output(inputs, output)
|
||||||
|
inputs.each do |input|
|
||||||
|
source = self.class.compile(input.read)
|
||||||
|
source = wrap(name(input.path), source)
|
||||||
|
output.write source
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def wrap(name, source)
|
||||||
|
"\nEmber.TEMPLATES['#{name}'] = Ember.Handlebars.template(#{source});\n"
|
||||||
|
end
|
||||||
|
|
||||||
|
def name(path)
|
||||||
|
path.gsub(%r(app/|templates/|.hbs), '')
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def context
|
class SafeConcat < ConcatFilter
|
||||||
@@context ||= ExecJS.compile(source)
|
def generate_output(inputs, output)
|
||||||
|
inputs.each do |input|
|
||||||
|
output.write File.read(input.fullpath) + ";"
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def compile(source)
|
class OrderingSafeConcat < SafeConcat
|
||||||
context.call('compileHandlebarsTemplate', source + "\n")
|
def initialize(ordering, string = nil, &block)
|
||||||
|
@ordering = ordering
|
||||||
|
super(string, &block)
|
||||||
|
end
|
||||||
|
|
||||||
|
def generate_output(inputs, output)
|
||||||
|
@ordering.reverse.each do |name|
|
||||||
|
file = inputs.find { |i| i.path == name }
|
||||||
|
inputs.unshift(inputs.delete(file)) if file
|
||||||
|
end
|
||||||
|
super
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
def generate_output(inputs, output)
|
class StripDebug < Filter
|
||||||
inputs.each do |input|
|
def generate_output(inputs, output)
|
||||||
source = self.class.compile(input.read)
|
inputs.each do |input|
|
||||||
source = wrap(name(input.path), source)
|
source = File.read(input.fullpath)
|
||||||
output.write source
|
source = strip_debug(source)
|
||||||
|
source = Uglifier.compile(source)
|
||||||
|
output.write source
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def strip_debug(source)
|
||||||
|
source.gsub(%r{^(\s)*Ember\.(assert|deprecate|warn)\((.*)\).*$}, "")
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def wrap(name, source)
|
|
||||||
"\nEmber.TEMPLATES['#{name}'] = Ember.Handlebars.template(#{source});\n"
|
|
||||||
end
|
|
||||||
|
|
||||||
def name(path)
|
|
||||||
path.gsub(%r(app/|templates/|.hbs), '')
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
class SafeConcatFilter < Rake::Pipeline::Filter
|
|
||||||
def generate_output(inputs, output)
|
|
||||||
inputs.each do |input|
|
|
||||||
source = File.read(input.fullpath) + ";"
|
|
||||||
output.write source
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
class ProductionFilter < Rake::Pipeline::Filter
|
|
||||||
def generate_output(inputs, output)
|
|
||||||
inputs.each do |input|
|
|
||||||
source = File.read(input.fullpath)
|
|
||||||
source = strip_debug(source)
|
|
||||||
source = Uglifier.compile(source)
|
|
||||||
output.write source
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def strip_debug(source)
|
|
||||||
source.gsub(%r{^(\s)*Ember\.(assert|deprecate|warn)\((.*)\).*$}, "")
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
32
lib/rake-pipeline/travis/helpers.rb
Normal file
|
@ -0,0 +1,32 @@
|
||||||
|
require 'rake-pipeline/dsl'
|
||||||
|
|
||||||
|
class Rake::Pipeline
|
||||||
|
module Travis
|
||||||
|
module Helpers
|
||||||
|
def travis_handlebars(*args, &block)
|
||||||
|
filter(Filters::Handlebars, *args, &block)
|
||||||
|
end
|
||||||
|
|
||||||
|
def strip_debug(*args, &block)
|
||||||
|
filter(Filters::StripDebug, *args, &block)
|
||||||
|
end
|
||||||
|
|
||||||
|
def safe_concat(*args, &block)
|
||||||
|
if args.first.kind_of?(Array)
|
||||||
|
filter(Filters::OrderingSafeConcat, *args, &block)
|
||||||
|
else
|
||||||
|
filter(Filters::SafeConcat, *args, &block)
|
||||||
|
end
|
||||||
|
# filter(Filters::SafeConcat, *args, &block)
|
||||||
|
end
|
||||||
|
|
||||||
|
def drop(pattern)
|
||||||
|
matcher = pipeline.copy(Filters::Drop)
|
||||||
|
matcher.glob = pattern
|
||||||
|
pipeline.add_filter matcher
|
||||||
|
matcher
|
||||||
|
end
|
||||||
|
alias :skip :drop
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
|
@ -1,7 +1,7 @@
|
||||||
require 'pathname'
|
require 'pathname'
|
||||||
require 'digest/md5'
|
require 'digest/md5'
|
||||||
|
|
||||||
module Travis
|
module Rake::Pipeline::Travis
|
||||||
class Version
|
class Version
|
||||||
FILE_NAME = 'public/version'
|
FILE_NAME = 'public/version'
|
||||||
SOURCES = %w(AssetFile Gemfile.lock assets)
|
SOURCES = %w(AssetFile Gemfile.lock assets)
|
||||||
|
|
Before Width: | Height: | Size: 1.1 KiB |
Before Width: | Height: | Size: 1.1 KiB |
Before Width: | Height: | Size: 1.1 KiB |
Before Width: | Height: | Size: 1.1 KiB |
Before Width: | Height: | Size: 1.0 KiB |
Before Width: | Height: | Size: 1.0 KiB |
Before Width: | Height: | Size: 1.0 KiB |
Before Width: | Height: | Size: 1.0 KiB |
Before Width: | Height: | Size: 1.0 KiB |
Before Width: | Height: | Size: 1.0 KiB |
Before Width: | Height: | Size: 2.9 KiB |
Before Width: | Height: | Size: 1.3 KiB |
Before Width: | Height: | Size: 1.4 KiB |
Before Width: | Height: | Size: 1.2 KiB |
Before Width: | Height: | Size: 1.0 KiB |
Before Width: | Height: | Size: 972 B |
Before Width: | Height: | Size: 972 B |
Before Width: | Height: | Size: 1.7 KiB |
Before Width: | Height: | Size: 1.7 KiB |
Before Width: | Height: | Size: 972 B |
Before Width: | Height: | Size: 1.4 KiB |
Before Width: | Height: | Size: 1.1 KiB |
Before Width: | Height: | Size: 972 B |
Before Width: | Height: | Size: 970 B |
3116
public/scripts/app.min.js
vendored
|
@ -1 +1 @@
|
||||||
56cfce1b
|
d2d014c4
|
|
@ -1,4 +1,4 @@
|
||||||
require 'spec_helper'
|
require 'lib/spec_helper'
|
||||||
|
|
||||||
describe Travis::Web::App::Config do
|
describe Travis::Web::App::Config do
|
||||||
let(:config) { Travis::Web::App::Config.new }
|
let(:config) { Travis::Web::App::Config.new }
|
||||||
|
|