rasputin 0.11.3 → 0.12.1
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile.lock +36 -34
- data/README.md +7 -3
- data/lib/rasputin/haml.rb +11 -0
- data/lib/rasputin/handlebars/compiler.rb +12 -4
- data/lib/rasputin/version.rb +1 -1
- data/lib/rasputin.rb +2 -1
- data/vendor/assets/javascripts/ember-data.js +1400 -0
- data/vendor/assets/javascripts/ember-precompiler.js +31 -0
- data/vendor/assets/javascripts/ember-routing.js +111 -92
- metadata +13 -12
- data/lib/rasputin/handlebars/handlebars.js +0 -1673
- data/vendor/assets/javascripts/ember-datastore.js +0 -11632
@@ -0,0 +1,31 @@
|
|
1
|
+
// DOM
|
2
|
+
var Element = {};
|
3
|
+
Element.firstChild = function () { return Element; };
|
4
|
+
Element.innerHTML = function () { return Element; };
|
5
|
+
|
6
|
+
var document = { createRange: false, createElement: function() { return Element; } };
|
7
|
+
var window = this;
|
8
|
+
this.document = document;
|
9
|
+
|
10
|
+
// Console
|
11
|
+
var console = window.console = {};
|
12
|
+
console.log = console.info = console.warn = console.error = function(){};
|
13
|
+
|
14
|
+
// jQuery
|
15
|
+
var jQuery = function() { return jQuery; };
|
16
|
+
jQuery.ready = function() { return jQuery; };
|
17
|
+
jQuery.inArray = function() { return jQuery; };
|
18
|
+
var $ = jQuery;
|
19
|
+
|
20
|
+
// Precompiler
|
21
|
+
var EmberHandlebars = {
|
22
|
+
precompile: function(string) {
|
23
|
+
// Copied from the Ember codebase. This will need to be updated as Ember updates...
|
24
|
+
var ast = Handlebars.parse(string);
|
25
|
+
var options = { data: true, stringParams: true };
|
26
|
+
var environment = new Ember.Handlebars.Compiler().compile(ast, options);
|
27
|
+
var templateSpec = new Ember.Handlebars.JavaScriptCompiler().compile(environment, options, undefined, true);
|
28
|
+
|
29
|
+
return templateSpec.toString();
|
30
|
+
}
|
31
|
+
};
|
@@ -1,33 +1,13 @@
|
|
1
|
-
// ==========================================================================
|
2
|
-
// Project: Ember - JavaScript Application Framework
|
3
|
-
// Copyright: ©2006-2011 Strobe Inc. and contributors.
|
4
|
-
// Portions ©2008-2011 Apple Inc. All rights reserved.
|
5
|
-
// License: Licensed under MIT license (see license.js)
|
6
|
-
// ==========================================================================
|
7
|
-
|
8
|
-
(function() {
|
9
|
-
|
10
|
-
var get = Ember.get, set = Ember.set;
|
11
|
-
|
12
|
-
/**
|
13
|
-
Wether the browser supports HTML5 history.
|
14
|
-
*/
|
15
|
-
var supportsHistory = !!(window.history && window.history.pushState);
|
16
|
-
|
17
|
-
/**
|
18
|
-
Wether the browser supports the hashchange event.
|
19
|
-
*/
|
20
|
-
var supportsHashChange = ('onhashchange' in window) && (document.documentMode === undefined || document.documentMode > 7);
|
21
1
|
|
2
|
+
(function(exports) {
|
22
3
|
/**
|
23
4
|
@class
|
24
5
|
|
25
|
-
Route is a class used internally by Ember.
|
6
|
+
Route is a class used internally by Ember.RoutesManager. The routes defined by your
|
26
7
|
application are stored in a tree structure, and this is the class for the
|
27
8
|
nodes.
|
28
9
|
*/
|
29
|
-
|
30
|
-
/** @scope Route.prototype */ {
|
10
|
+
Ember.Route = Ember.Object.extend({
|
31
11
|
|
32
12
|
target: null,
|
33
13
|
|
@@ -59,7 +39,7 @@ var Route = Ember.Object.extend(
|
|
59
39
|
case ':':
|
60
40
|
part = part.slice(1, part.length);
|
61
41
|
if (!this.dynamicRoutes) this.dynamicRoutes = {};
|
62
|
-
if (!this.dynamicRoutes[part]) this.dynamicRoutes[part] =
|
42
|
+
if (!this.dynamicRoutes[part]) this.dynamicRoutes[part] = Ember.Route.create();
|
63
43
|
nextRoute = this.dynamicRoutes[part];
|
64
44
|
break;
|
65
45
|
|
@@ -67,13 +47,13 @@ var Route = Ember.Object.extend(
|
|
67
47
|
case '*':
|
68
48
|
part = part.slice(1, part.length);
|
69
49
|
if (!this.wildcardRoutes) this.wildcardRoutes = {};
|
70
|
-
nextRoute = this.wildcardRoutes[part] =
|
50
|
+
nextRoute = this.wildcardRoutes[part] = Ember.Route.create();
|
71
51
|
break;
|
72
52
|
|
73
53
|
// 3. static routes
|
74
54
|
default:
|
75
55
|
if (!this.staticRoutes) this.staticRoutes = {};
|
76
|
-
if (!this.staticRoutes[part]) this.staticRoutes[part] =
|
56
|
+
if (!this.staticRoutes[part]) this.staticRoutes[part] = Ember.Route.create();
|
77
57
|
nextRoute = this.staticRoutes[part];
|
78
58
|
}
|
79
59
|
|
@@ -97,34 +77,57 @@ var Route = Ember.Object.extend(
|
|
97
77
|
|
98
78
|
// try to match a static route
|
99
79
|
if (this.staticRoutes && this.staticRoutes[part]) {
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
// else, try to match a dynamic route
|
105
|
-
for (key in this.dynamicRoutes) {
|
106
|
-
route = this.dynamicRoutes[key].routeForParts(parts, params);
|
107
|
-
if (route) {
|
108
|
-
params[key] = part;
|
109
|
-
return route;
|
110
|
-
}
|
80
|
+
route = this.staticRoutes[part].routeForParts(parts, params);
|
81
|
+
if (route) {
|
82
|
+
return route;
|
111
83
|
}
|
84
|
+
}
|
112
85
|
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
86
|
+
// else, try to match a dynamic route
|
87
|
+
for (key in this.dynamicRoutes) {
|
88
|
+
route = this.dynamicRoutes[key].routeForParts(parts, params);
|
89
|
+
if (route) {
|
90
|
+
params[key] = part;
|
91
|
+
return route;
|
118
92
|
}
|
93
|
+
}
|
119
94
|
|
120
|
-
|
121
|
-
|
95
|
+
// else, try to match a wilcard route
|
96
|
+
for (key in this.wildcardRoutes) {
|
97
|
+
parts.unshift(part);
|
98
|
+
params[key] = parts.join('/');
|
99
|
+
return this.wildcardRoutes[key].routeForParts(null, params);
|
122
100
|
}
|
101
|
+
|
102
|
+
// if nothing was found, it means that there is no match
|
103
|
+
return null;
|
123
104
|
}
|
124
105
|
}
|
125
106
|
|
126
107
|
});
|
127
108
|
|
109
|
+
})({});
|
110
|
+
|
111
|
+
|
112
|
+
(function(exports) {
|
113
|
+
// ==========================================================================
|
114
|
+
// Project: Ember - JavaScript Application Framework
|
115
|
+
// Copyright: ©2006-2011 Strobe Inc. and contributors.
|
116
|
+
// Portions ©2008-2011 Apple Inc. All rights reserved.
|
117
|
+
// License: Licensed under MIT license (see license.js)
|
118
|
+
// ==========================================================================
|
119
|
+
var get = Ember.get, set = Ember.set;
|
120
|
+
|
121
|
+
/**
|
122
|
+
Wether the browser supports HTML5 history.
|
123
|
+
*/
|
124
|
+
var supportsHistory = !!(window.history && window.history.pushState);
|
125
|
+
|
126
|
+
/**
|
127
|
+
Wether the browser supports the hashchange event.
|
128
|
+
*/
|
129
|
+
var supportsHashChange = ('onhashchange' in window) && (document.documentMode === undefined || document.documentMode > 7);
|
130
|
+
|
128
131
|
/**
|
129
132
|
@class
|
130
133
|
|
@@ -157,8 +160,7 @@ var Route = Ember.Object.extend(
|
|
157
160
|
Ember.routes also supports HTML5 history, which uses a '/' instead of a '#'
|
158
161
|
in the URLs, so that all your website's URLs are consistent.
|
159
162
|
*/
|
160
|
-
|
161
|
-
/** @scope Ember.routes.prototype */{
|
163
|
+
Ember.RoutesManager = Ember.Object.extend({
|
162
164
|
|
163
165
|
/**
|
164
166
|
Set this property to true if you want to use HTML5 history, if available on
|
@@ -178,7 +180,7 @@ var routes = Ember.routes = Ember.Object.create(
|
|
178
180
|
|
179
181
|
You will also need to make sure that baseURI is properly configured, as
|
180
182
|
well as your server so that your routes are properly pointing to your
|
181
|
-
|
183
|
+
Ember application.
|
182
184
|
|
183
185
|
@see http://dev.w3.org/html5/spec/history.html#the-history-interface
|
184
186
|
@property
|
@@ -244,13 +246,6 @@ var routes = Ember.routes = Ember.Object.create(
|
|
244
246
|
*/
|
245
247
|
_firstRoute: null,
|
246
248
|
|
247
|
-
/** @private
|
248
|
-
An internal reference to the Route class.
|
249
|
-
|
250
|
-
@property
|
251
|
-
*/
|
252
|
-
_Route: Route,
|
253
|
-
|
254
249
|
/** @private
|
255
250
|
Internal method used to extract and merge the parameters of a URL.
|
256
251
|
|
@@ -261,7 +256,8 @@ var routes = Ember.routes = Ember.Object.create(
|
|
261
256
|
route = obj.route || '',
|
262
257
|
separator, parts, i, len, crumbs, key;
|
263
258
|
|
264
|
-
separator = (route.indexOf('?') < 0 && route.indexOf('&') >= 0) ? '&' : '?';
|
259
|
+
//separator = (route.indexOf('?') < 0 && route.indexOf('&') >= 0) ? '&' : '?';
|
260
|
+
separator = '?';
|
265
261
|
parts = route.split(separator);
|
266
262
|
route = parts[0];
|
267
263
|
if (parts.length === 1) {
|
@@ -334,16 +330,13 @@ var routes = Ember.routes = Ember.Object.create(
|
|
334
330
|
will change the location to
|
335
331
|
http://domain.tld/my_app#notes/show/4?format=xml&language=fr.
|
336
332
|
|
337
|
-
The 'notes/show/4&format=xml&language=fr' syntax for passing parameters,
|
338
|
-
using a '&' instead of a '?', as used in SproutCore 1.0 is still supported.
|
339
|
-
|
340
333
|
@property
|
341
334
|
@type {String}
|
342
335
|
*/
|
343
|
-
location: function(key, value) {
|
336
|
+
location: Ember.computed(function(key, value) {
|
344
337
|
this._skipRoute = false;
|
345
338
|
return this._extractLocation(key, value);
|
346
|
-
}.property(),
|
339
|
+
}).property(),
|
347
340
|
|
348
341
|
_extractLocation: function(key, value) {
|
349
342
|
var crumbs, encodedValue;
|
@@ -358,7 +351,7 @@ var routes = Ember.routes = Ember.Object.create(
|
|
358
351
|
value = crumbs.route + crumbs.params;
|
359
352
|
}
|
360
353
|
|
361
|
-
if (!Ember.empty(value) || (this._location && this._location !== value)) {
|
354
|
+
if (!this._skipPush && (!Ember.empty(value) || (this._location && this._location !== value))) {
|
362
355
|
encodedValue = encodeURI(value);
|
363
356
|
|
364
357
|
if (this.usesHistory) {
|
@@ -366,7 +359,7 @@ var routes = Ember.routes = Ember.Object.create(
|
|
366
359
|
encodedValue = '/' + encodedValue;
|
367
360
|
}
|
368
361
|
window.history.pushState(null, null, get(this, 'baseURI') + encodedValue);
|
369
|
-
} else {
|
362
|
+
} else if (encodedValue.length > 0 || window.location.hash.length > 0) {
|
370
363
|
window.location.hash = encodedValue;
|
371
364
|
}
|
372
365
|
}
|
@@ -377,6 +370,11 @@ var routes = Ember.routes = Ember.Object.create(
|
|
377
370
|
return this._location;
|
378
371
|
},
|
379
372
|
|
373
|
+
updateLocation: function(loc){
|
374
|
+
this._skipRoute = true;
|
375
|
+
return this._extractLocation('location', loc);
|
376
|
+
},
|
377
|
+
|
380
378
|
/**
|
381
379
|
You usually don't need to call this method. It is done automatically after
|
382
380
|
the application has been initialized.
|
@@ -385,33 +383,49 @@ var routes = Ember.routes = Ember.Object.create(
|
|
385
383
|
timer that looks for location changes every 150ms.
|
386
384
|
*/
|
387
385
|
ping: function() {
|
388
|
-
var that;
|
389
|
-
|
390
386
|
if (!this._didSetup) {
|
391
387
|
this._didSetup = true;
|
392
388
|
|
389
|
+
var state;
|
393
390
|
if (get(this, 'wantsHistory') && supportsHistory) {
|
394
391
|
this.usesHistory = true;
|
395
392
|
|
396
|
-
|
397
|
-
|
393
|
+
// Move any hash state to url state
|
394
|
+
// TODO: Make sure we have a hash before adding slash
|
395
|
+
state = window.location.hash.slice(1);
|
396
|
+
if (state.length > 0) {
|
397
|
+
state = '/' + state;
|
398
|
+
window.history.replaceState(null, null, get(this, 'baseURI')+state);
|
399
|
+
}
|
400
|
+
|
401
|
+
popState.call(this);
|
402
|
+
Ember.$(window).bind('popstate', Ember.$.proxy(popState, this));
|
398
403
|
|
399
404
|
} else {
|
400
405
|
this.usesHistory = false;
|
401
406
|
|
407
|
+
if (get(this, 'wantsHistory')) {
|
408
|
+
// Move any url state to hash
|
409
|
+
var base = get(this, 'baseURI'),
|
410
|
+
loc = (base.charAt(0) === '/') ? document.location.pathname : document.location.href.replace(document.location.hash, '');
|
411
|
+
state = loc.slice(base.length+1);
|
412
|
+
if (state.length > 0) {
|
413
|
+
window.location.href = base+'#'+state;
|
414
|
+
}
|
415
|
+
}
|
416
|
+
|
402
417
|
if (supportsHashChange) {
|
403
|
-
hashChange();
|
404
|
-
|
418
|
+
hashChange.call(this);
|
419
|
+
Ember.$(window).bind('hashchange', Ember.$.proxy(hashChange, this));
|
405
420
|
|
406
421
|
} else {
|
407
422
|
// we don't use a Ember.Timer because we don't want
|
408
423
|
// a run loop to be triggered at each ping
|
409
|
-
|
410
|
-
|
411
|
-
|
412
|
-
|
413
|
-
|
414
|
-
this._invokeHashChange();
|
424
|
+
var invokeHashChange = Ember.$.proxy(function() {
|
425
|
+
hashChange.call(this);
|
426
|
+
setTimeout(invokeHashChange, 100);
|
427
|
+
}, this);
|
428
|
+
invokeHashChange();
|
415
429
|
}
|
416
430
|
}
|
417
431
|
}
|
@@ -451,7 +465,7 @@ var routes = Ember.routes = Ember.Object.create(
|
|
451
465
|
method = target[method];
|
452
466
|
}
|
453
467
|
|
454
|
-
if (!this._firstRoute) this._firstRoute = Route.create();
|
468
|
+
if (!this._firstRoute) this._firstRoute = Ember.Route.create();
|
455
469
|
this._firstRoute.add(route.split('/'), target, method);
|
456
470
|
|
457
471
|
return this;
|
@@ -461,9 +475,9 @@ var routes = Ember.routes = Ember.Object.create(
|
|
461
475
|
Observer of the 'location' property that calls the correct route handler
|
462
476
|
when the location changes.
|
463
477
|
*/
|
464
|
-
locationDidChange: function() {
|
478
|
+
locationDidChange: Ember.observer(function() {
|
465
479
|
this.trigger();
|
466
|
-
}
|
480
|
+
}, 'location'),
|
467
481
|
|
468
482
|
/**
|
469
483
|
Triggers a route even if already in that route (does change the location, if it
|
@@ -491,8 +505,8 @@ var routes = Ember.routes = Ember.Object.create(
|
|
491
505
|
|
492
506
|
getRoute: function(route, params) {
|
493
507
|
var firstRoute = this._firstRoute;
|
494
|
-
if (params
|
495
|
-
params = {}
|
508
|
+
if (Ember.none(params)) {
|
509
|
+
params = {};
|
496
510
|
}
|
497
511
|
|
498
512
|
return firstRoute.routeForParts(route.split('/'), params);
|
@@ -500,11 +514,13 @@ var routes = Ember.routes = Ember.Object.create(
|
|
500
514
|
|
501
515
|
exists: function(route, params) {
|
502
516
|
route = this.getRoute(route, params);
|
503
|
-
return route
|
517
|
+
return route !== null && route.method !== null;
|
504
518
|
}
|
505
519
|
|
506
520
|
});
|
507
521
|
|
522
|
+
Ember.routes = Ember.RoutesManager.create();
|
523
|
+
|
508
524
|
/**
|
509
525
|
Event handler for the hashchange event. Called automatically by the browser
|
510
526
|
if it supports the hashchange event, or by our timer if not.
|
@@ -520,30 +536,33 @@ function hashChange(event) {
|
|
520
536
|
loc = decodeURI(loc);
|
521
537
|
}
|
522
538
|
|
523
|
-
if (get(
|
524
|
-
Ember.run.once(function() {
|
525
|
-
|
539
|
+
if (get(this, 'location') !== loc && !this._skipRoute) {
|
540
|
+
Ember.run.once(this, function() {
|
541
|
+
this._skipPush = true;
|
542
|
+
set(this, 'location', loc);
|
543
|
+
this._skipPush = false;
|
526
544
|
});
|
527
545
|
}
|
528
|
-
|
546
|
+
this._skipRoute = false;
|
529
547
|
}
|
530
548
|
|
531
549
|
function popState(event) {
|
532
|
-
var base = get(
|
533
|
-
loc = document.location.href;
|
550
|
+
var base = get(this, 'baseURI'),
|
551
|
+
loc = (base.charAt(0) === '/') ? document.location.pathname : document.location.href;
|
534
552
|
|
535
553
|
if (loc.slice(0, base.length) === base) {
|
536
|
-
|
537
554
|
// Remove the base prefix and the extra '/'
|
538
555
|
loc = loc.slice(base.length + 1, loc.length);
|
539
556
|
|
540
|
-
if (get(
|
541
|
-
Ember.run.once(function() {
|
542
|
-
|
557
|
+
if (get(this, 'location') !== loc && !this._skipRoute) {
|
558
|
+
Ember.run.once(this, function() {
|
559
|
+
this._skipPush = true;
|
560
|
+
set(this, 'location', loc);
|
561
|
+
this._skipPush = false;
|
543
562
|
});
|
544
563
|
}
|
545
564
|
}
|
546
|
-
|
565
|
+
this._skipRoute = false;
|
547
566
|
}
|
548
567
|
|
549
|
-
})();
|
568
|
+
})({});
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rasputin
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.12.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2012-01-03 00:00:00.000000000Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: railties
|
16
|
-
requirement: &
|
16
|
+
requirement: &70163152645040 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ~>
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: 3.1.0
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70163152645040
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: actionpack
|
27
|
-
requirement: &
|
27
|
+
requirement: &70163152643820 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ~>
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: 3.1.0
|
33
33
|
type: :runtime
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *70163152643820
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: sprockets
|
38
|
-
requirement: &
|
38
|
+
requirement: &70163152643080 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ~>
|
@@ -43,10 +43,10 @@ dependencies:
|
|
43
43
|
version: 2.0.0
|
44
44
|
type: :runtime
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *70163152643080
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: jquery-rails
|
49
|
-
requirement: &
|
49
|
+
requirement: &70163152642360 !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
52
52
|
- - ~>
|
@@ -54,7 +54,7 @@ dependencies:
|
|
54
54
|
version: '1.0'
|
55
55
|
type: :runtime
|
56
56
|
prerelease: false
|
57
|
-
version_requirements: *
|
57
|
+
version_requirements: *70163152642360
|
58
58
|
description: Ember.js for the Rails asset pipeline.
|
59
59
|
email:
|
60
60
|
- paul@chavard.net
|
@@ -68,16 +68,17 @@ files:
|
|
68
68
|
- README.md
|
69
69
|
- Rakefile
|
70
70
|
- lib/rasputin.rb
|
71
|
+
- lib/rasputin/haml.rb
|
71
72
|
- lib/rasputin/handlebars/compiler.rb
|
72
|
-
- lib/rasputin/handlebars/handlebars.js
|
73
73
|
- lib/rasputin/handlebars/template.rb
|
74
74
|
- lib/rasputin/slim.rb
|
75
75
|
- lib/rasputin/version.rb
|
76
76
|
- rasputin.gemspec
|
77
77
|
- vendor/assets/javascripts/TransformJS.js
|
78
|
-
- vendor/assets/javascripts/ember-
|
78
|
+
- vendor/assets/javascripts/ember-data.js
|
79
79
|
- vendor/assets/javascripts/ember-datetime.js
|
80
80
|
- vendor/assets/javascripts/ember-i18n.js
|
81
|
+
- vendor/assets/javascripts/ember-precompiler.js
|
81
82
|
- vendor/assets/javascripts/ember-routing.js
|
82
83
|
- vendor/assets/javascripts/ember-touch.js
|
83
84
|
- vendor/assets/javascripts/ember.js
|