dart-rails 0.4.3 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +61 -36
- data/lib/dart/rails/generators/assets/templates/dart/dart_app.js.dart2js +1 -0
- data/lib/dart/rails/js_compat_engine.rb +2 -2
- data/lib/dart/rails/version.rb +1 -1
- metadata +29 -23
- data/lib/dart/rails/generators/assets/templates/dart/dart_app.js.dart2js +0 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bbdf41a1292b0971801be9a6590e613f89e04c4a
|
4
|
+
data.tar.gz: 02b67e794162054a0434faa1b38febaee137aeae
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8f9914bacd7b1312dc988cf1e440e9e0676a272e37cc49d1b9874f98d7ecc274c5efd9f915372207b0069bbe049869af51348da5a09a4dc1bbe76a22ba648434
|
7
|
+
data.tar.gz: c4ea14dac4a4ef2e4dde4f735fa6b4d6b2bd1f084d99636b9a62afed32b7c3eec9f193325a6a98478917675fc1920ca49f2e5a2cfbfab7985fbfc91c29b0fdd4
|
data/README.md
CHANGED
@@ -2,16 +2,12 @@
|
|
2
2
|
|
3
3
|
### Idea ###
|
4
4
|
|
5
|
-
Handle [dart](https://www.dartlang.org/ 'dartlang.org') scripts so they get compiled to js for browsers
|
6
|
-
without dart support. Currently there's only the `Dartium` browser from the development-kit that supports
|
7
|
-
dart natively.
|
5
|
+
Handle [dart](https://www.dartlang.org/ 'dartlang.org') scripts so they get compiled to js for browsers without dart support. Currently there's only the `Dartium` browser from the development-kit that supports dart natively.
|
8
6
|
|
9
7
|
For a working sample check [m0gg/dart-rails-sample](https://github.com/m0gg/dart-rails-sample 'm0gg/dart-rails-sample').
|
10
8
|
|
11
9
|
## Attention ##
|
12
|
-
If you're upgrading from versions prior `0.4.2` and use `sprockets >= 3.0.0` you need to replace your
|
13
|
-
`dart_app.js.dart2js` or `dart_app.js` (depends form which version you're upgrading) with a symlink pointing to
|
14
|
-
your `dart_app.dart` as `sprockets >= 3.0.0` no longer supports the `//= include` directive.
|
10
|
+
If you're upgrading from versions prior `0.4.2` and use `sprockets >= 3.0.0` you need to replace your `dart_app.js.dart2js` or `dart_app.js` (depends form which version you're upgrading) with a symlink pointing to your `dart_app.dart` as `sprockets >= 3.0.0` no longer supports the `//= include` directive.
|
15
11
|
|
16
12
|
example `ls app/assets/dart/`
|
17
13
|
```bash
|
@@ -25,49 +21,72 @@ app/assets/dart/dart_app.dart app/assets/dart/dart_app.js.dart2js
|
|
25
21
|
|
26
22
|
1. `Gemfile`
|
27
23
|
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
2.
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
24
|
+
```ruby
|
25
|
+
gem 'ruby-dart2js'
|
26
|
+
gem 'dart-rails'
|
27
|
+
```
|
28
|
+
|
29
|
+
2. `$ rails generate dart:assets`
|
30
|
+
|
31
|
+
```sh
|
32
|
+
rails g dart:assets
|
33
|
+
create app/assets/dart
|
34
|
+
create app/assets/dart/dart_app.dart
|
35
|
+
create app/assets/dart/dart_app.js.dart2js
|
36
|
+
create app/assets/dart/pubspec.yaml
|
37
|
+
```
|
38
|
+
|
39
|
+
|
40
|
+
|
41
|
+
* `app/assets/dart/dart_app.dart`
|
42
|
+
Your dart `main()` goes in here
|
43
|
+
* `app/assets/dart/dart_app.js.dart2js`
|
44
|
+
you don't want to touch this file unless you know exactly what you're doing
|
45
|
+
* `app/assets/dart/pubspec.yaml`
|
46
|
+
the pubspec for your dart-code used to gather dependencies, etc.
|
47
|
+
|
48
|
+
|
49
|
+
|
50
|
+
###### for those who are interested in the `app/assets/dart/dart_app.js.dart2js` ######
|
51
|
+
|
52
|
+
This file is crucial for the conversion of dart to js through the sprockets pipeline. `.dart2js` gets registered as a js template (just like `.coffee`) and runs through dart2js before beeing delivered as js. So if you request `/assets/dart_app.js` sprockets recognizes this file and passes it to dart2js. You could put dart code in here, but requests to `/assets/dart_app.dart` would deliver something different or nothing at all, that's why it should be a symlink to your actual `dart_app.dart` or, if you're on sprockets prior `3.0.0` and prefer that way, should contain `//= include dart_app.dart`. Note that `sprockets >= 3.0.0` does not support the `//= include` directive an you're pinned to the symlink-method.
|
53
|
+
|
43
54
|
3. asset links
|
44
55
|
|
45
|
-
|
46
|
-
|
56
|
+
Note: scripts in html get executed after they are loaded, that's why scripts that interact with the html and are loaded in the `<head>` will wait for the `ready` event. This is a quite unusual in dart applications but does not affect most of them because the `<script>` tag is located at the bottom of the body and thus gets loaded when the document is close enough to `ready`. Make sure your dart app waits for the `ready` event or put the corresponding tags at the bottom of the body. This applies for all 3 variants.
|
57
|
+
|
58
|
+
Now it's up to you wether you want to serve your `.dart` files and it's compiled `.js` variant side-by-side or only one of those variants.
|
47
59
|
|
48
|
-
- `.dart` and `.js`
|
60
|
+
- ##### `.dart` and `.js` #####
|
49
61
|
|
50
|
-
You'll need to add following to the bottom of your body in the layout
|
51
|
-
`layout.html.erb` (for instance)
|
62
|
+
You'll need to add following to the bottom of your body in the layout `layout.html.erb` (for instance)
|
52
63
|
|
53
64
|
```
|
54
65
|
<%= dart_include_tag 'dart_app' %>
|
55
66
|
<%= javascript_include_tag 'dart' %>
|
56
67
|
```
|
57
|
-
|
58
|
-
|
68
|
+
|
69
|
+
* `dart_include_tag 'dart_app'` adds your `dart_app.dart`
|
70
|
+
* `javascript_include_tag 'dart'` adds the `dart.js` from the gem for compatibility
|
71
|
+
|
72
|
+
As of rails 4 you'll need to turn asset digesting off, append `config.assets.digest = false` to the environment you like to use.
|
73
|
+
|
74
|
+
###### for those who are interested in the `javascript_include_tag 'dart'` ######
|
75
|
+
|
76
|
+
The `dart.js` will replace the `<script>` tags of the type `application/dart` to ones with type `application/javascript` and substitute the `.dart` extension of the src attribute with `.js` if the browser is not Dartium. This ensures that you are able to deliver native dart to Dartium and js to all others. Because we only have digested asset names in rails 4, you'll need to turn it off completely to ensure your renamed dart script will point to a non-digested js script. I know this is stupid but we don't have any browser besides Dartium that would support native dart anyways...
|
77
|
+
|
78
|
+
- ##### `.js` only #####
|
59
79
|
|
60
80
|
simply add this to your `application.js`
|
61
81
|
```
|
62
82
|
//= require dart_app
|
63
83
|
```
|
64
|
-
While this would enable you to add several dart programs, there is no guarantee
|
65
|
-
|
84
|
+
While this would enable you to add several dart programs, there is no guarantee it will work out. (untested)
|
85
|
+
Please pay attention to the former note about placement of the `<script>` tags in your layout. If in doubt move the default `<%= javascript_include_tag 'application' %>` to the bottom of the layouts body.
|
66
86
|
|
67
|
-
- `.dart` only
|
87
|
+
- ##### `.dart` only #####
|
68
88
|
|
69
|
-
You just need to add the `dart_include_tag` to the bottom of your body in the layout
|
70
|
-
`layout.html.erb` (for instance)
|
89
|
+
You just need to add the `dart_include_tag` to the bottom of your body in the layout `layout.html.erb` (for instance)
|
71
90
|
|
72
91
|
```
|
73
92
|
<%= dart_include_tag 'dart_app' %>
|
@@ -76,9 +95,7 @@ app/assets/dart/dart_app.dart app/assets/dart/dart_app.js.dart2js
|
|
76
95
|
|
77
96
|
4. `rake pub:get`
|
78
97
|
|
79
|
-
|
80
|
-
Initially the pubspec contains `rails_ujs` as dependency, this is just basic for now,
|
81
|
-
so you probably want to omit it if you're still using JQuery.
|
98
|
+
Run `rake pub:get` to respect the dependencies in your `pubspec.yaml`. Initially the pubspec contains `rails_ujs` as dependency, this is just basic for now, so you probably want to omit it if you're still using JQuery.
|
82
99
|
|
83
100
|
5. ruby-dart2js
|
84
101
|
|
@@ -128,6 +145,14 @@ additionally rewrite the manifests to use the non-digest files.~~
|
|
128
145
|
|
129
146
|
|
130
147
|
### Changelog ###
|
148
|
+
v0.4.4 - WIP:
|
149
|
+
* fix `append_path` in `js_compat_engine.rb`
|
150
|
+
* extend README
|
151
|
+
|
152
|
+
v0.4.3 - 17. Dec 2015:
|
153
|
+
* including several README updates
|
154
|
+
* remove section for non-stupid-digest-assets
|
155
|
+
|
131
156
|
v0.4.2 - 16. Dec 2015:
|
132
157
|
* full compat with sprockets 2 & 3 by switching to symlinked dart_app.js.dart2js
|
133
158
|
* fixed dart2js compilation by data
|
@@ -0,0 +1 @@
|
|
1
|
+
dart_app.dart
|
@@ -8,11 +8,11 @@ module Dart #:nodoc:
|
|
8
8
|
initializer :assets do |app|
|
9
9
|
|
10
10
|
# make dart.js compatibility-script accessible for sprockets
|
11
|
-
|
11
|
+
::Rails.application.config.assets.append_path(File.join(root, 'lib', 'assets', 'javascripts'))
|
12
12
|
|
13
13
|
# precompile compatibility-script(s)
|
14
14
|
::Rails.application.config.assets.precompile += %w(dart_app.js dart.js)
|
15
15
|
end
|
16
16
|
end
|
17
17
|
end
|
18
|
-
end
|
18
|
+
end
|
data/lib/dart/rails/version.rb
CHANGED
metadata
CHANGED
@@ -1,29 +1,35 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dart-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Marcel Sackermann
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-08-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '4.1'
|
20
|
+
- - "<"
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: '5.1'
|
20
23
|
type: :runtime
|
21
24
|
prerelease: false
|
22
25
|
version_requirements: !ruby/object:Gem::Requirement
|
23
26
|
requirements:
|
24
|
-
- - "
|
27
|
+
- - ">="
|
25
28
|
- !ruby/object:Gem::Version
|
26
29
|
version: '4.1'
|
30
|
+
- - "<"
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '5.1'
|
27
33
|
- !ruby/object:Gem::Dependency
|
28
34
|
name: ruby-dart2js
|
29
35
|
requirement: !ruby/object:Gem::Requirement
|
@@ -131,38 +137,38 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
131
137
|
version: '0'
|
132
138
|
requirements: []
|
133
139
|
rubyforge_project:
|
134
|
-
rubygems_version: 2.
|
140
|
+
rubygems_version: 2.5.1
|
135
141
|
signing_key:
|
136
142
|
specification_version: 4
|
137
143
|
summary: Provides Sprockets based handling of .dart files
|
138
144
|
test_files:
|
139
145
|
- test/test_helper.rb
|
140
|
-
- test/dummy/Rakefile
|
141
146
|
- test/dummy/config/application.rb
|
142
|
-
- test/dummy/config/locales/en.yml
|
143
|
-
- test/dummy/config/boot.rb
|
144
|
-
- test/dummy/config/routes.rb
|
145
147
|
- test/dummy/config/environment.rb
|
146
|
-
- test/dummy/config/
|
147
|
-
- test/dummy/config/
|
148
|
-
- test/dummy/config/
|
149
|
-
- test/dummy/config/database.yml
|
150
|
-
- test/dummy/config/initializers/secret_token.rb
|
148
|
+
- test/dummy/config/routes.rb
|
149
|
+
- test/dummy/config/boot.rb
|
150
|
+
- test/dummy/config/initializers/wrap_parameters.rb
|
151
151
|
- test/dummy/config/initializers/inflections.rb
|
152
|
+
- test/dummy/config/initializers/secret_token.rb
|
152
153
|
- test/dummy/config/initializers/mime_types.rb
|
153
154
|
- test/dummy/config/initializers/backtrace_silencers.rb
|
154
155
|
- test/dummy/config/initializers/session_store.rb
|
155
|
-
- test/dummy/config/
|
156
|
-
- test/dummy/
|
157
|
-
- test/dummy/config.
|
158
|
-
- test/dummy/
|
159
|
-
- test/dummy/
|
156
|
+
- test/dummy/config/locales/en.yml
|
157
|
+
- test/dummy/config/database.yml
|
158
|
+
- test/dummy/config/environments/production.rb
|
159
|
+
- test/dummy/config/environments/development.rb
|
160
|
+
- test/dummy/config/environments/test.rb
|
161
|
+
- test/dummy/Rakefile
|
160
162
|
- test/dummy/public/favicon.ico
|
161
|
-
- test/dummy/public/422.html
|
162
163
|
- test/dummy/public/404.html
|
163
|
-
- test/dummy/
|
164
|
-
- test/dummy/
|
165
|
-
- test/dummy/
|
164
|
+
- test/dummy/public/500.html
|
165
|
+
- test/dummy/public/422.html
|
166
|
+
- test/dummy/README.rdoc
|
166
167
|
- test/dummy/app/helpers/application_helper.rb
|
168
|
+
- test/dummy/app/controllers/application_controller.rb
|
167
169
|
- test/dummy/app/views/layouts/application.html.erb
|
170
|
+
- test/dummy/app/assets/stylesheets/application.css
|
171
|
+
- test/dummy/app/assets/javascripts/application.js
|
172
|
+
- test/dummy/config.ru
|
173
|
+
- test/dummy/script/rails
|
168
174
|
- test/dart-rails_test.rb
|