rasputin 0.7.1 → 0.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.md +31 -5
- data/lib/rasputin/version.rb +1 -1
- metadata +2 -16
- data/vendor/assets/javascripts/bricks/current_user.js +0 -68
- data/vendor/assets/javascripts/bricks/images_error.js +0 -23
- data/vendor/assets/javascripts/bricks/layout_manager.js +0 -50
- data/vendor/assets/javascripts/bricks/local_storage_data_source.js +0 -174
- data/vendor/assets/javascripts/bricks/paginated_array.js +0 -63
- data/vendor/assets/javascripts/bricks/pagination_button.js +0 -22
- data/vendor/assets/javascripts/bricks/pane_view.js +0 -53
- data/vendor/assets/javascripts/bricks/rest_data_source.js +0 -119
- data/vendor/assets/javascripts/bricks/toggle_view.js +0 -28
- data/vendor/assets/javascripts/jquery-ui.js +0 -13804
- data/vendor/assets/javascripts/sproutcore-ajax.js +0 -1072
- data/vendor/assets/javascripts/sproutcore-jui.js +0 -973
- data/vendor/assets/stylesheets/aristo.css +0 -480
- data/vendor/assets/stylesheets/jquery-ui.css +0 -1444
data/README.md
CHANGED
@@ -8,13 +8,11 @@ It provide direct requires for official sproutcore packages :
|
|
8
8
|
* sproutcore
|
9
9
|
* sproutcore-datastore
|
10
10
|
* sproutcore-statechart
|
11
|
+
* sproutcore-touch
|
11
12
|
|
12
|
-
And it also provides
|
13
|
+
And it also provides one unnoficial package :
|
13
14
|
|
14
|
-
* sproutcore-jui (jQuery UI wrappers for sc 2.0)
|
15
|
-
* sproutcore-ajax (backport form sc 1.x API but using jQuery $.ajax)
|
16
15
|
* sproutcore-i18n (integration with i18n-js gem)
|
17
|
-
* sproutcore-bricks (some useful bricks extracted form my projects)
|
18
16
|
|
19
17
|
Rasputin also provide sprockets engine for handlebars templates. Any template in your
|
20
18
|
javascript assets folder with extention handlebars will be availabel in sproutcore.
|
@@ -24,7 +22,35 @@ Examples :
|
|
24
22
|
todos/templates/item.handlebars >> SC.TEMPLATES['todos_item']
|
25
23
|
todos/ui/templates/stats.handlebars >> SC.TEMPLATES['todos_ui_stats']
|
26
24
|
|
27
|
-
|
25
|
+
Install
|
26
|
+
-------
|
27
|
+
|
28
|
+
In Gemfile:
|
29
|
+
|
30
|
+
gem 'rasputin'
|
31
|
+
|
32
|
+
In your asset manifest (app/assets/javascripts/application.js) add the following:
|
33
|
+
|
34
|
+
//= require sproutcore
|
35
|
+
|
36
|
+
And and any of the following you want to include:
|
37
|
+
|
38
|
+
//= require sproutcore-datastore
|
39
|
+
//= require sproutcore-statechart
|
40
|
+
//= require sproutcore-touch
|
41
|
+
//= require sproutcore-i18n
|
42
|
+
|
43
|
+
ChangeLog
|
44
|
+
----------
|
45
|
+
|
46
|
+
0.8.0
|
47
|
+
|
48
|
+
* remove unofficial packages. Prepare for more stable releases in sync with upstream.
|
49
|
+
* sproutcore-jui will move in to it's own gem
|
50
|
+
|
51
|
+
0.7.1 :
|
52
|
+
|
53
|
+
* add sproutcore-touch
|
28
54
|
|
29
55
|
0.7.0 :
|
30
56
|
|
data/lib/rasputin/version.rb
CHANGED
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: rasputin
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.
|
5
|
+
version: 0.8.0
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Paul Chavard
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2011-08-
|
13
|
+
date: 2011-08-24 00:00:00 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: railties
|
@@ -65,25 +65,11 @@ files:
|
|
65
65
|
- lib/rasputin/handlebars_template.rb
|
66
66
|
- lib/rasputin/version.rb
|
67
67
|
- rasputin.gemspec
|
68
|
-
- vendor/assets/javascripts/bricks/current_user.js
|
69
|
-
- vendor/assets/javascripts/bricks/images_error.js
|
70
|
-
- vendor/assets/javascripts/bricks/layout_manager.js
|
71
|
-
- vendor/assets/javascripts/bricks/local_storage_data_source.js
|
72
|
-
- vendor/assets/javascripts/bricks/paginated_array.js
|
73
|
-
- vendor/assets/javascripts/bricks/pagination_button.js
|
74
|
-
- vendor/assets/javascripts/bricks/pane_view.js
|
75
|
-
- vendor/assets/javascripts/bricks/rest_data_source.js
|
76
|
-
- vendor/assets/javascripts/bricks/toggle_view.js
|
77
|
-
- vendor/assets/javascripts/jquery-ui.js
|
78
|
-
- vendor/assets/javascripts/sproutcore-ajax.js
|
79
68
|
- vendor/assets/javascripts/sproutcore-datastore.js
|
80
69
|
- vendor/assets/javascripts/sproutcore-i18n.js
|
81
|
-
- vendor/assets/javascripts/sproutcore-jui.js
|
82
70
|
- vendor/assets/javascripts/sproutcore-statechart.js
|
83
71
|
- vendor/assets/javascripts/sproutcore-touch.js
|
84
72
|
- vendor/assets/javascripts/sproutcore.js
|
85
|
-
- vendor/assets/stylesheets/aristo.css
|
86
|
-
- vendor/assets/stylesheets/jquery-ui.css
|
87
73
|
homepage: http://github.com/tchak/rasputin
|
88
74
|
licenses: []
|
89
75
|
|
@@ -1,68 +0,0 @@
|
|
1
|
-
// ==========================================================================
|
2
|
-
// Project: SproutCore Bricks
|
3
|
-
// Copyright: ©2011 Paul Chavard
|
4
|
-
// Author : Paul Chavard
|
5
|
-
//
|
6
|
-
// current_user.js
|
7
|
-
// ==========================================================================
|
8
|
-
SB = this.SB || {};
|
9
|
-
|
10
|
-
SB.CurrentUser = SC.Object.extend({
|
11
|
-
username: '',
|
12
|
-
password: '',
|
13
|
-
rememberMe: true,
|
14
|
-
|
15
|
-
url: '/authenticate',
|
16
|
-
authenticateMethod: 'HEAD',
|
17
|
-
|
18
|
-
isLoggedIn: false,
|
19
|
-
isLoggingIn: false,
|
20
|
-
|
21
|
-
didLoggedIn: SC.K,
|
22
|
-
didLoggedOut: SC.K,
|
23
|
-
loginSuccess: SC.K,
|
24
|
-
loginError: SC.K,
|
25
|
-
|
26
|
-
setCredentials: SC.K,
|
27
|
-
resetCredentials: SC.K,
|
28
|
-
|
29
|
-
login: function() {
|
30
|
-
if (this.get('isLoggedIn')) {return;}
|
31
|
-
this.set('isLoggingIn', true);
|
32
|
-
var username = this.get('username'),
|
33
|
-
password = this.get('password');
|
34
|
-
if (!SC.empty(username) && !SC.empty(password)) {
|
35
|
-
this.setCredentials(username, password);
|
36
|
-
}
|
37
|
-
var method = "%@Url".fmt(this.get('authenticateMethod').toLowerCase());
|
38
|
-
SC.Request[method](this.get('url')).json()
|
39
|
-
.notify(this, 'loginComplete')
|
40
|
-
.send();
|
41
|
-
},
|
42
|
-
|
43
|
-
logout: function() {
|
44
|
-
if (!this.get('isLoggedIn')) {return;}
|
45
|
-
this.setProperties({'username': '', 'password': ''});
|
46
|
-
this.resetCredentials();
|
47
|
-
this.set('isLoggedIn', false);
|
48
|
-
this.didLoggedOut();
|
49
|
-
},
|
50
|
-
|
51
|
-
/*
|
52
|
-
@private
|
53
|
-
*/
|
54
|
-
loginComplete: function(response) {
|
55
|
-
this.set('isLoggingIn', false);
|
56
|
-
if (SC.ok(response)) {
|
57
|
-
this.set('isLoggedIn', true);
|
58
|
-
this.loginSuccess(response);
|
59
|
-
this.didLoggedIn();
|
60
|
-
this.setProperties({'username': '', 'password': ''});
|
61
|
-
} else {
|
62
|
-
this.set('isLoggedIn', false);
|
63
|
-
this.set('password', '');
|
64
|
-
this.resetCredentials();
|
65
|
-
this.loginError(response);
|
66
|
-
}
|
67
|
-
}
|
68
|
-
});
|
@@ -1,23 +0,0 @@
|
|
1
|
-
// ==========================================================================
|
2
|
-
// Project: SproutCore Bricks
|
3
|
-
// Copyright: ©2011 Paul Chavard
|
4
|
-
// Author : Paul Chavard
|
5
|
-
//
|
6
|
-
// images_error.js
|
7
|
-
// ==========================================================================
|
8
|
-
SB = this.SB || {};
|
9
|
-
|
10
|
-
SB.ImagesErrorSupport = SC.Mixin.create({
|
11
|
-
didInsertElement: function() {
|
12
|
-
this._super();
|
13
|
-
var img = this.$('img[data-rescue-errors]'), self = this;
|
14
|
-
img.hide().error(function() {
|
15
|
-
if (self.imageLoadError(img)) {
|
16
|
-
img.show();
|
17
|
-
}
|
18
|
-
}).load(function() {
|
19
|
-
img.show();
|
20
|
-
});
|
21
|
-
},
|
22
|
-
imageLoadError: SC.K
|
23
|
-
});
|
@@ -1,50 +0,0 @@
|
|
1
|
-
// ==========================================================================
|
2
|
-
// Project: SproutCore Bricks
|
3
|
-
// Copyright: ©2011 Paul Chavard
|
4
|
-
// Author : Paul Chavard
|
5
|
-
//
|
6
|
-
// layout_manager.js
|
7
|
-
// ==========================================================================
|
8
|
-
SB = this.SB || {};
|
9
|
-
|
10
|
-
SB.layoutManager = SC.Object.create({
|
11
|
-
windowWidth: 0,
|
12
|
-
windowHeight: 0,
|
13
|
-
|
14
|
-
init: function() {
|
15
|
-
this._windowSize();
|
16
|
-
this._window.resize(SC.$.proxy(this, '_onResize'));
|
17
|
-
},
|
18
|
-
registerLayout: function(view) {
|
19
|
-
this._managedViews.pushObject(view);
|
20
|
-
this._callApplyLayout(view);
|
21
|
-
},
|
22
|
-
|
23
|
-
_managedViews: [],
|
24
|
-
_window: SC.$(window),
|
25
|
-
|
26
|
-
_onResize: function() {
|
27
|
-
this._windowSize();
|
28
|
-
this._managedViews.forEach(this._callApplyLayout, this);
|
29
|
-
},
|
30
|
-
_windowSize: function() {
|
31
|
-
this.set('windowWidth', this._window.width());
|
32
|
-
this.set('windowHeight', this._window.height());
|
33
|
-
},
|
34
|
-
_callApplyLayout: function(view) {
|
35
|
-
if (view && view.get('state') === 'inDOM'
|
36
|
-
&& view.get('hasLayout') === true
|
37
|
-
&& typeof view.applyLayout === 'function') {
|
38
|
-
view.applyLayout(this.windowWidth, this.windowHeight);
|
39
|
-
}
|
40
|
-
}
|
41
|
-
});
|
42
|
-
|
43
|
-
SB.ManagedLayoutSupport = SC.Mixin.create({
|
44
|
-
hasLayout: true,
|
45
|
-
|
46
|
-
didInsertElement: function() {
|
47
|
-
this._super();
|
48
|
-
SB.layoutManager.registerLayout(this);
|
49
|
-
}
|
50
|
-
});
|
@@ -1,174 +0,0 @@
|
|
1
|
-
// ==========================================================================
|
2
|
-
// Project: Todos.LocalStorage
|
3
|
-
// Copyright: ©2011 My Company, Inc.
|
4
|
-
// ==========================================================================
|
5
|
-
/*globals Todos */
|
6
|
-
|
7
|
-
/** @class
|
8
|
-
|
9
|
-
This data source serves as an adapter between SproutCore's data store and the
|
10
|
-
browser's local storage.
|
11
|
-
|
12
|
-
@extends SC.DataSource
|
13
|
-
*/
|
14
|
-
SB = this.SB || {};
|
15
|
-
|
16
|
-
(function() {
|
17
|
-
var supportsLocalStorage = false;
|
18
|
-
// HTML5 localStorage detection from http://diveintohtml5.org/storage.html
|
19
|
-
try {
|
20
|
-
supportsLocalStorage = ('localStorage' in window && window['localStorage'] !== null);
|
21
|
-
} catch (e) { }
|
22
|
-
|
23
|
-
if (!supportsLocalStorage) {
|
24
|
-
var warnMethod = function() {
|
25
|
-
console.log('Unable to use local storage data source because your browser does not support local storage.');
|
26
|
-
return false;
|
27
|
-
};
|
28
|
-
|
29
|
-
SB.LocalStorageDataSource = SC.DataSource.extend({
|
30
|
-
fetch: warnMethod,
|
31
|
-
retrieveRecord: warnMethod,
|
32
|
-
createRecord: warnMethod,
|
33
|
-
updateRecord: warnMethod,
|
34
|
-
destroyRecord: warnMethod
|
35
|
-
});
|
36
|
-
|
37
|
-
return;
|
38
|
-
}
|
39
|
-
|
40
|
-
SB.LocalStorageDataSource = SC.DataSource.extend(
|
41
|
-
/** @scope SC.LocalStorage.prototype */ {
|
42
|
-
/**
|
43
|
-
The string to prefix to the key used to store the data in the browser's
|
44
|
-
localStorage.
|
45
|
-
|
46
|
-
@type String
|
47
|
-
@default 'sproutcore-local-storage'
|
48
|
-
*/
|
49
|
-
storagePrefix: 'sproutcore.local.storage.',
|
50
|
-
|
51
|
-
// ..........................................................
|
52
|
-
// QUERY SUPPORT
|
53
|
-
//
|
54
|
-
|
55
|
-
fetch: function(store, query) {
|
56
|
-
var recordType = query.get('recordType');
|
57
|
-
var key = this._keyForRecordType(recordType);
|
58
|
-
var data = localStorage.getItem(key);
|
59
|
-
|
60
|
-
if (data) {
|
61
|
-
data = JSON.parse(data);
|
62
|
-
} else {
|
63
|
-
data = {};
|
64
|
-
}
|
65
|
-
|
66
|
-
data.__guid = data.__guid || 0;
|
67
|
-
|
68
|
-
var dataByRecordType = this.get('dataByRecordType') || {};
|
69
|
-
dataByRecordType[key] = data;
|
70
|
-
|
71
|
-
this.set('dataByRecordType', dataByRecordType);
|
72
|
-
|
73
|
-
var records = [];
|
74
|
-
for (key in data) {
|
75
|
-
if (data.hasOwnProperty(key) && key !== '__guid') {
|
76
|
-
records.push(data[key]);
|
77
|
-
}
|
78
|
-
}
|
79
|
-
|
80
|
-
store.loadRecords(recordType, records);
|
81
|
-
return true; // return true if you handled the query
|
82
|
-
},
|
83
|
-
|
84
|
-
_keyForRecordType: function(recordType) {
|
85
|
-
var recordTypeKey = recordType.localStorageKey;
|
86
|
-
return this.get('storagePrefix')+recordTypeKey;
|
87
|
-
},
|
88
|
-
|
89
|
-
// ..........................................................
|
90
|
-
// RECORD SUPPORT
|
91
|
-
//
|
92
|
-
|
93
|
-
retrieveRecord: function(store, storeKey, guid) {
|
94
|
-
var recordType = store.recordTypeFor(storeKey);
|
95
|
-
var data = this._dataForRecordType(recordType);
|
96
|
-
|
97
|
-
store.dataSourceDidComplete(storeKey, data[guid]);
|
98
|
-
|
99
|
-
return true; // return true if you handled the storeKey
|
100
|
-
},
|
101
|
-
|
102
|
-
createRecord: function(store, storeKey) {
|
103
|
-
var guid = store.idFor(storeKey);
|
104
|
-
var recordType = store.recordTypeFor(storeKey);
|
105
|
-
var data = store.readDataHash(storeKey);
|
106
|
-
|
107
|
-
if (guid === undefined || guid === null) {
|
108
|
-
guid = this._generateGuid(recordType);
|
109
|
-
}
|
110
|
-
|
111
|
-
this._writeRecord(data, recordType, guid);
|
112
|
-
this._writeDataToLocalStorage(recordType);
|
113
|
-
|
114
|
-
store.dataSourceDidComplete(storeKey, null, guid);
|
115
|
-
|
116
|
-
return true; // return true if you handled the storeKey
|
117
|
-
},
|
118
|
-
|
119
|
-
updateRecord: function(store, storeKey) {
|
120
|
-
var guid = store.idFor(storeKey);
|
121
|
-
var recordType = store.recordTypeFor(storeKey);
|
122
|
-
var data = store.readDataHash(storeKey);
|
123
|
-
|
124
|
-
this._writeRecord(data, recordType, guid);
|
125
|
-
this._writeDataToLocalStorage(recordType);
|
126
|
-
|
127
|
-
store.dataSourceDidComplete(storeKey, null, guid);
|
128
|
-
return true; // return true if you handled the storeKey
|
129
|
-
},
|
130
|
-
|
131
|
-
_writeRecord: function(hash, recordType, guid) {
|
132
|
-
var data = this._dataForRecordType(recordType);
|
133
|
-
var primaryKey = recordType.prototype.primaryKey;
|
134
|
-
|
135
|
-
|
136
|
-
data[guid] = hash;
|
137
|
-
hash[primaryKey] = guid;
|
138
|
-
},
|
139
|
-
|
140
|
-
destroyRecord: function(store, storeKey) {
|
141
|
-
var guid = store.idFor(storeKey);
|
142
|
-
var recordType = store.recordTypeFor(storeKey);
|
143
|
-
var data = this._dataForRecordType(recordType);
|
144
|
-
|
145
|
-
delete data[guid];
|
146
|
-
|
147
|
-
this._writeDataToLocalStorage(recordType);
|
148
|
-
|
149
|
-
store.dataSourceDidDestroy(storeKey);
|
150
|
-
|
151
|
-
return true; // return true if you handled the storeKey
|
152
|
-
},
|
153
|
-
|
154
|
-
_writeDataToLocalStorage: function(recordType) {
|
155
|
-
var dataByRecordType = this.get('dataByRecordType');
|
156
|
-
var key = this._keyForRecordType(recordType);
|
157
|
-
|
158
|
-
localStorage[key] = JSON.stringify(dataByRecordType[key]);
|
159
|
-
},
|
160
|
-
|
161
|
-
_dataForRecordType: function(recordType) {
|
162
|
-
var key = this._keyForRecordType(recordType);
|
163
|
-
var dataByRecordType = this.get('dataByRecordType');
|
164
|
-
|
165
|
-
return dataByRecordType[key];
|
166
|
-
},
|
167
|
-
|
168
|
-
_generateGuid: function(recordType) {
|
169
|
-
var data = this._dataForRecordType(recordType);
|
170
|
-
|
171
|
-
return ++data.__guid;
|
172
|
-
}
|
173
|
-
}) ;
|
174
|
-
})();
|
@@ -1,63 +0,0 @@
|
|
1
|
-
// ==========================================================================
|
2
|
-
// Project: SproutCore Bricks
|
3
|
-
// Copyright: ©2011 Paul Chavard
|
4
|
-
// Author : Paul Chavard
|
5
|
-
//
|
6
|
-
// paginated_array.js
|
7
|
-
// ==========================================================================
|
8
|
-
SB = this.SB || {};
|
9
|
-
|
10
|
-
SB.PaginatedArray = SC.ArrayProxy.extend({
|
11
|
-
content: [],
|
12
|
-
|
13
|
-
limit: 100,
|
14
|
-
offset: 0,
|
15
|
-
total: 0,
|
16
|
-
|
17
|
-
isLoading: false,
|
18
|
-
didRequireRange: SC.K,
|
19
|
-
|
20
|
-
reset: function() {
|
21
|
-
this.set('offset', 0);
|
22
|
-
this.set('total', 0);
|
23
|
-
this.set('content', []);
|
24
|
-
this._didRequireRange(this.limit, 0);
|
25
|
-
},
|
26
|
-
|
27
|
-
reload: function() {
|
28
|
-
this._didRequireRange(this.limit, this.offset);
|
29
|
-
},
|
30
|
-
|
31
|
-
_didRequireRange: function(limit, offset) {
|
32
|
-
this.set('isLoading', true);
|
33
|
-
this.didRequireRange(limit, offset);
|
34
|
-
},
|
35
|
-
|
36
|
-
rangeDidLoaded: function(total, content) {
|
37
|
-
this.set('total', total);
|
38
|
-
this.set('content', content);
|
39
|
-
this.set('isLoading', false);
|
40
|
-
},
|
41
|
-
|
42
|
-
nextPage: function() {
|
43
|
-
if (this.get('hasNextPage')) {
|
44
|
-
this.incrementProperty('offset');
|
45
|
-
this._didRequireRange(this.limit, this.offset);
|
46
|
-
}
|
47
|
-
},
|
48
|
-
|
49
|
-
previousPage: function() {
|
50
|
-
if (this.get('hasPreviousPage')) {
|
51
|
-
this.decrementProperty('offset');
|
52
|
-
this._didRequireRange(this.limit, this.offset);
|
53
|
-
}
|
54
|
-
},
|
55
|
-
|
56
|
-
hasNextPage: function() {
|
57
|
-
return (this.offset+1)*this.limit < this.total;
|
58
|
-
}.property('offset', 'limit', 'total').cacheable(),
|
59
|
-
|
60
|
-
hasPreviousPage: function() {
|
61
|
-
return this.offset > 0;
|
62
|
-
}.property('offset').cacheable()
|
63
|
-
});
|