rails-js 0.0.5 → 0.0.6
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.
- checksums.yaml +4 -4
- data/Gemfile.lock +32 -32
- data/README.md +8 -4
- data/app/assets/javascripts/rails.js +11 -2
- data/lib/rails/js/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 40d367a9365cc097fe49241548e82f2954324cad
|
|
4
|
+
data.tar.gz: f474d9c3bdcb32b81eafb2dabf0e4cb50585d06f
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: c4b26bd324915f9b66f8a3e235425b6bdbf8b397476d3da37acc76c52c5826f2d76b0b4551be0451c130fa3a025b1258fefd50ff02ad8c38895b762ca8d8e81f
|
|
7
|
+
data.tar.gz: 64eb74d182dcb1a9ecf6c2a2ba8ee8795a04ed16085de6ed3eb92d80b7205ed6b68ff3b30f6aeca1d6d103cca8b201c4a26518c6ef3b28dce1af94d1d19bab83
|
data/Gemfile.lock
CHANGED
|
@@ -1,33 +1,33 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: .
|
|
3
3
|
specs:
|
|
4
|
-
rails-js (0.0.
|
|
4
|
+
rails-js (0.0.6)
|
|
5
5
|
rails (~> 4)
|
|
6
6
|
|
|
7
7
|
GEM
|
|
8
8
|
remote: https://rubygems.org/
|
|
9
9
|
specs:
|
|
10
|
-
actionmailer (4.1.
|
|
11
|
-
actionpack (= 4.1.
|
|
12
|
-
actionview (= 4.1.
|
|
10
|
+
actionmailer (4.1.7)
|
|
11
|
+
actionpack (= 4.1.7)
|
|
12
|
+
actionview (= 4.1.7)
|
|
13
13
|
mail (~> 2.5, >= 2.5.4)
|
|
14
|
-
actionpack (4.1.
|
|
15
|
-
actionview (= 4.1.
|
|
16
|
-
activesupport (= 4.1.
|
|
14
|
+
actionpack (4.1.7)
|
|
15
|
+
actionview (= 4.1.7)
|
|
16
|
+
activesupport (= 4.1.7)
|
|
17
17
|
rack (~> 1.5.2)
|
|
18
18
|
rack-test (~> 0.6.2)
|
|
19
|
-
actionview (4.1.
|
|
20
|
-
activesupport (= 4.1.
|
|
19
|
+
actionview (4.1.7)
|
|
20
|
+
activesupport (= 4.1.7)
|
|
21
21
|
builder (~> 3.1)
|
|
22
22
|
erubis (~> 2.7.0)
|
|
23
|
-
activemodel (4.1.
|
|
24
|
-
activesupport (= 4.1.
|
|
23
|
+
activemodel (4.1.7)
|
|
24
|
+
activesupport (= 4.1.7)
|
|
25
25
|
builder (~> 3.1)
|
|
26
|
-
activerecord (4.1.
|
|
27
|
-
activemodel (= 4.1.
|
|
28
|
-
activesupport (= 4.1.
|
|
26
|
+
activerecord (4.1.7)
|
|
27
|
+
activemodel (= 4.1.7)
|
|
28
|
+
activesupport (= 4.1.7)
|
|
29
29
|
arel (~> 5.0.0)
|
|
30
|
-
activesupport (4.1.
|
|
30
|
+
activesupport (4.1.7)
|
|
31
31
|
i18n (~> 0.6, >= 0.6.9)
|
|
32
32
|
json (~> 1.7, >= 1.7.7)
|
|
33
33
|
minitest (~> 5.1)
|
|
@@ -35,7 +35,7 @@ GEM
|
|
|
35
35
|
tzinfo (~> 1.1)
|
|
36
36
|
arel (5.0.1.20140414130214)
|
|
37
37
|
builder (3.2.2)
|
|
38
|
-
capybara (2.4.
|
|
38
|
+
capybara (2.4.4)
|
|
39
39
|
mime-types (>= 1.16)
|
|
40
40
|
nokogiri (>= 1.3.3)
|
|
41
41
|
rack (>= 1.0.0)
|
|
@@ -53,13 +53,13 @@ GEM
|
|
|
53
53
|
hike (1.2.3)
|
|
54
54
|
i18n (0.6.11)
|
|
55
55
|
json (1.8.1)
|
|
56
|
-
mail (2.6.
|
|
56
|
+
mail (2.6.3)
|
|
57
57
|
mime-types (>= 1.16, < 3)
|
|
58
|
-
mime-types (2.4.
|
|
58
|
+
mime-types (2.4.3)
|
|
59
59
|
mini_portile (0.6.0)
|
|
60
60
|
minitest (5.4.2)
|
|
61
61
|
multi_json (1.10.1)
|
|
62
|
-
netrc (0.
|
|
62
|
+
netrc (0.8.0)
|
|
63
63
|
nokogiri (1.6.3.1)
|
|
64
64
|
mini_portile (= 0.6.0)
|
|
65
65
|
poltergeist (1.5.1)
|
|
@@ -70,19 +70,19 @@ GEM
|
|
|
70
70
|
rack (1.5.2)
|
|
71
71
|
rack-test (0.6.2)
|
|
72
72
|
rack (>= 1.0)
|
|
73
|
-
rails (4.1.
|
|
74
|
-
actionmailer (= 4.1.
|
|
75
|
-
actionpack (= 4.1.
|
|
76
|
-
actionview (= 4.1.
|
|
77
|
-
activemodel (= 4.1.
|
|
78
|
-
activerecord (= 4.1.
|
|
79
|
-
activesupport (= 4.1.
|
|
73
|
+
rails (4.1.7)
|
|
74
|
+
actionmailer (= 4.1.7)
|
|
75
|
+
actionpack (= 4.1.7)
|
|
76
|
+
actionview (= 4.1.7)
|
|
77
|
+
activemodel (= 4.1.7)
|
|
78
|
+
activerecord (= 4.1.7)
|
|
79
|
+
activesupport (= 4.1.7)
|
|
80
80
|
bundler (>= 1.3.0, < 2.0)
|
|
81
|
-
railties (= 4.1.
|
|
81
|
+
railties (= 4.1.7)
|
|
82
82
|
sprockets-rails (~> 2.0)
|
|
83
|
-
railties (4.1.
|
|
84
|
-
actionpack (= 4.1.
|
|
85
|
-
activesupport (= 4.1.
|
|
83
|
+
railties (4.1.7)
|
|
84
|
+
actionpack (= 4.1.7)
|
|
85
|
+
activesupport (= 4.1.7)
|
|
86
86
|
rake (>= 0.8.7)
|
|
87
87
|
thor (>= 0.18.1, < 2.0)
|
|
88
88
|
rake (10.3.2)
|
|
@@ -94,7 +94,7 @@ GEM
|
|
|
94
94
|
multi_json (~> 1.0)
|
|
95
95
|
simplecov-html (~> 0.8.0)
|
|
96
96
|
simplecov-html (0.8.0)
|
|
97
|
-
sprockets (2.12.
|
|
97
|
+
sprockets (2.12.3)
|
|
98
98
|
hike (~> 1.2)
|
|
99
99
|
multi_json (~> 1.0)
|
|
100
100
|
rack (~> 1.0)
|
|
@@ -103,7 +103,7 @@ GEM
|
|
|
103
103
|
actionpack (>= 3.0)
|
|
104
104
|
activesupport (>= 3.0)
|
|
105
105
|
sprockets (>= 2.8, < 4.0)
|
|
106
|
-
sqlite3 (1.3.
|
|
106
|
+
sqlite3 (1.3.10)
|
|
107
107
|
teaspoon (0.8.0)
|
|
108
108
|
railties (>= 3.2.5, < 5)
|
|
109
109
|
term-ansicolor (1.3.0)
|
data/README.md
CHANGED
|
@@ -5,6 +5,10 @@ rails-js
|
|
|
5
5
|
[](https://rubygems.org/gems/rails-js)
|
|
6
6
|
[](http://tonekk.mit-license.org)
|
|
7
7
|
|
|
8
|
+
|
|
9
|
+
[Check out the blog post!](http://finn.heemeyer.net/2014/10/18/rails-js/)
|
|
10
|
+
|
|
11
|
+
|
|
8
12
|
I worked on several Rails projects and there were many cases when it felt overkill to use a framework like ``Angular`` or ``Ember``, because javascript was only needed in some parts of the application.
|
|
9
13
|
But by not using these frameworks I had to think of a way to *structure* the code by myself.
|
|
10
14
|
I came up with the conclusion to organize the javascript code like the ruby code is organized, that means: __Split up in controllers, which are split up in actions.__
|
|
@@ -18,7 +22,7 @@ I came up with the conclusion to organize the javascript code like the ruby code
|
|
|
18
22
|
#### You start by creating an app.
|
|
19
23
|
|
|
20
24
|
```js
|
|
21
|
-
//= rails
|
|
25
|
+
//= require rails
|
|
22
26
|
|
|
23
27
|
/*
|
|
24
28
|
* app/assets/javascripts/application.js
|
|
@@ -29,7 +33,7 @@ Rails.app({
|
|
|
29
33
|
helper: function() {
|
|
30
34
|
}
|
|
31
35
|
},
|
|
32
|
-
|
|
36
|
+
// Put in initial data
|
|
33
37
|
{
|
|
34
38
|
foo: 'bar'
|
|
35
39
|
},
|
|
@@ -61,7 +65,7 @@ Rails.controller('users', {
|
|
|
61
65
|
},
|
|
62
66
|
{
|
|
63
67
|
// helpers here
|
|
64
|
-
function
|
|
68
|
+
awesomeHelper: function() {
|
|
65
69
|
}
|
|
66
70
|
});
|
|
67
71
|
|
|
@@ -135,7 +139,7 @@ In your layouts, put this line into the ``head``:
|
|
|
135
139
|
```erb
|
|
136
140
|
<%= rails_js %>
|
|
137
141
|
```
|
|
138
|
-
Also make sure to include ``rails`` in your ``application.js``.
|
|
142
|
+
Also make sure to include ``rails`` in your ``application.js``. If you are using [Turbolinks](https://github.com/rails/turbolinks), make sure to include ``rails`` after ``turbolinks``.
|
|
139
143
|
|
|
140
144
|
Testing
|
|
141
145
|
=======
|
|
@@ -47,14 +47,23 @@
|
|
|
47
47
|
* DOM-related js (e.g. javascript unit-tests).
|
|
48
48
|
* Set Rails.config.test to disable action execution.
|
|
49
49
|
*/
|
|
50
|
-
|
|
50
|
+
listener = function(event) {
|
|
51
51
|
|
|
52
52
|
if(Rails.config && Rails.config.test) {
|
|
53
53
|
return;
|
|
54
54
|
}
|
|
55
55
|
|
|
56
56
|
Rails.execute();
|
|
57
|
-
}
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
document.addEventListener("DOMContentLoaded", listener);
|
|
60
|
+
|
|
61
|
+
/*
|
|
62
|
+
* Add support to Turbolinks page changes
|
|
63
|
+
*/
|
|
64
|
+
if(typeof Turbolinks !== 'undefined') {
|
|
65
|
+
document.addEventListener("page:load", listener);
|
|
66
|
+
}
|
|
58
67
|
};
|
|
59
68
|
|
|
60
69
|
/*
|
data/lib/rails/js/version.rb
CHANGED