roadie 2.4.3 → 3.0.0.pre1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +3 -0
- data/.travis.yml +9 -14
- data/.yardopts +1 -1
- data/Changelog.md +22 -10
- data/Gemfile +3 -0
- data/Guardfile +11 -1
- data/README.md +165 -163
- data/Rakefile +2 -19
- data/lib/roadie.rb +14 -69
- data/lib/roadie/asset_provider.rb +7 -58
- data/lib/roadie/asset_scanner.rb +92 -0
- data/lib/roadie/document.rb +103 -0
- data/lib/roadie/errors.rb +57 -0
- data/lib/roadie/filesystem_provider.rb +21 -62
- data/lib/roadie/inliner.rb +71 -218
- data/lib/roadie/markup_improver.rb +88 -0
- data/lib/roadie/null_provider.rb +13 -0
- data/lib/roadie/null_url_rewriter.rb +12 -0
- data/lib/roadie/provider_list.rb +67 -0
- data/lib/roadie/rspec.rb +1 -0
- data/lib/roadie/rspec/asset_provider.rb +49 -0
- data/lib/roadie/selector.rb +42 -18
- data/lib/roadie/style_block.rb +33 -0
- data/lib/roadie/style_properties.rb +29 -0
- data/lib/roadie/style_property.rb +93 -0
- data/lib/roadie/stylesheet.rb +65 -0
- data/lib/roadie/url_generator.rb +126 -0
- data/lib/roadie/url_rewriter.rb +84 -0
- data/lib/roadie/version.rb +1 -1
- data/roadie.gemspec +6 -10
- data/spec/fixtures/big_em.css +1 -0
- data/spec/fixtures/stylesheets/green.css +1 -0
- data/spec/integration_spec.rb +125 -95
- data/spec/lib/roadie/asset_scanner_spec.rb +153 -0
- data/spec/lib/roadie/css_not_found_spec.rb +16 -0
- data/spec/lib/roadie/document_spec.rb +123 -0
- data/spec/lib/roadie/filesystem_provider_spec.rb +25 -72
- data/spec/lib/roadie/inliner_spec.rb +105 -537
- data/spec/lib/roadie/markup_improver_spec.rb +78 -0
- data/spec/lib/roadie/null_provider_spec.rb +21 -0
- data/spec/lib/roadie/null_url_rewriter_spec.rb +19 -0
- data/spec/lib/roadie/provider_list_spec.rb +81 -0
- data/spec/lib/roadie/selector_spec.rb +7 -5
- data/spec/lib/roadie/style_block_spec.rb +35 -0
- data/spec/lib/roadie/style_properties_spec.rb +61 -0
- data/spec/lib/roadie/style_property_spec.rb +82 -0
- data/spec/lib/roadie/stylesheet_spec.rb +41 -0
- data/spec/lib/roadie/test_provider_spec.rb +29 -0
- data/spec/lib/roadie/url_generator_spec.rb +120 -0
- data/spec/lib/roadie/url_rewriter_spec.rb +79 -0
- data/spec/shared_examples/asset_provider.rb +11 -0
- data/spec/shared_examples/url_rewriter.rb +23 -0
- data/spec/spec_helper.rb +5 -60
- data/spec/support/have_node_matcher.rb +2 -2
- data/spec/support/have_selector_matcher.rb +1 -1
- data/spec/support/have_styling_matcher.rb +48 -14
- data/spec/support/test_provider.rb +13 -0
- metadata +73 -177
- data/Appraisals +0 -15
- data/gemfiles/rails_3.0.gemfile +0 -7
- data/gemfiles/rails_3.0.gemfile.lock +0 -123
- data/gemfiles/rails_3.1.gemfile +0 -7
- data/gemfiles/rails_3.1.gemfile.lock +0 -126
- data/gemfiles/rails_3.2.gemfile +0 -7
- data/gemfiles/rails_3.2.gemfile.lock +0 -124
- data/gemfiles/rails_4.0.gemfile +0 -7
- data/gemfiles/rails_4.0.gemfile.lock +0 -119
- data/lib/roadie/action_mailer_extensions.rb +0 -95
- data/lib/roadie/asset_pipeline_provider.rb +0 -28
- data/lib/roadie/css_file_not_found.rb +0 -22
- data/lib/roadie/railtie.rb +0 -39
- data/lib/roadie/style_declaration.rb +0 -42
- data/spec/fixtures/app/assets/stylesheets/integration.css +0 -10
- data/spec/fixtures/public/stylesheets/integration.css +0 -10
- data/spec/fixtures/views/integration_mailer/marketing.html.erb +0 -2
- data/spec/fixtures/views/integration_mailer/notification.html.erb +0 -8
- data/spec/fixtures/views/integration_mailer/notification.text.erb +0 -6
- data/spec/lib/roadie/action_mailer_extensions_spec.rb +0 -227
- data/spec/lib/roadie/asset_pipeline_provider_spec.rb +0 -65
- data/spec/lib/roadie/css_file_not_found_spec.rb +0 -29
- data/spec/lib/roadie/style_declaration_spec.rb +0 -49
- data/spec/lib/roadie_spec.rb +0 -101
- data/spec/shared_examples/asset_provider_examples.rb +0 -11
- data/spec/support/anonymous_mailer.rb +0 -21
- data/spec/support/change_url_options.rb +0 -5
- data/spec/support/parse_styling.rb +0 -25
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 8dbb2ff6110e3730b2c4b818bbfa1724ad8912ea
|
4
|
+
data.tar.gz: fe0bf94a18e731475ee8bcf1e16d4d6cd6692071
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 97d48f412f42884ab58afa39325178256bee9f81a5822e8415e746cd3181931048d982a607d12ec5cf11efd5ad11c439cf88f8165f05c7df781f02002641082c
|
7
|
+
data.tar.gz: bdb1604da3762385097b4e156fe38300580d4f3d899dda4d4ed66e5a8fd846405be0eb99df85e54c07cceda0f5a37f0af277773ecd3adf61050f0445ae6d947d
|
data/.gitignore
CHANGED
data/.travis.yml
CHANGED
@@ -1,22 +1,17 @@
|
|
1
|
-
|
2
|
-
before_install:
|
3
|
-
- gem install bundler --pre
|
4
|
-
|
1
|
+
language: ruby
|
5
2
|
rvm:
|
6
|
-
- 1.8.7
|
7
3
|
- 1.9.3
|
8
4
|
- 2.0.0
|
9
5
|
- jruby
|
6
|
+
- rbx
|
7
|
+
|
8
|
+
bundler_args: --without guard
|
9
|
+
script: "rake"
|
10
10
|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
- gemfiles/rails_3.2.gemfile
|
15
|
-
- gemfiles/rails_4.0.gemfile
|
11
|
+
env:
|
12
|
+
# Setup Coveralls
|
13
|
+
secure: "D1Uvi+a7W89k91zXVVwuuvv8O8qbDdyJ4g9i+3bGaSYySHxD8YuuG1QiQ4G/S2KLp/r3VPRpa8Wb1mSwb81tEBzXpzoZC7zSvgntPxRPhMg4zpodZ0O0AkK8/t1yZSkIe0V5sejFOQ1a5LJa3OorKBBjrqM5kPDOygTXtO3bQ6E="
|
16
14
|
|
17
15
|
matrix:
|
18
|
-
exclude:
|
19
|
-
- rvm: 1.8.7
|
20
|
-
gemfile: gemfiles/rails_4.0.gemfile
|
21
16
|
allow_failures:
|
22
|
-
- rvm:
|
17
|
+
- rvm: rbx
|
data/.yardopts
CHANGED
@@ -1 +1 @@
|
|
1
|
-
--no-private
|
1
|
+
--no-private --files Changelog.md
|
data/Changelog.md
CHANGED
@@ -1,15 +1,27 @@
|
|
1
1
|
### dev
|
2
2
|
|
3
|
-
[full changelog](https://github.com/Mange/roadie/compare/v2.4.
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
*
|
12
|
-
*
|
3
|
+
[full changelog](https://github.com/Mange/roadie/compare/v2.4.2...master)
|
4
|
+
|
5
|
+
Complete rewrite of most of the code and a new direction for the gem.
|
6
|
+
|
7
|
+
* Breaking changes:
|
8
|
+
* Removed Rails support into a separate Gem (`roadie-rails`).
|
9
|
+
* Removed Sprockets dependency and AssetPipelineProvider.
|
10
|
+
* Changed the entire public API.
|
11
|
+
* Changed the API of custom providers.
|
12
|
+
* Dropped support for Ruby 1.8.7.
|
13
|
+
* Change `data-immutable` to `data-roadie-ignore`.
|
14
|
+
* New features:
|
15
|
+
* Rewriting the URLs of `img[src]`.
|
16
|
+
* A way to inject stylesheets without having to adjust template.
|
17
|
+
* A before callback to compliment the after callback.
|
18
|
+
* Enhancements:
|
19
|
+
* Better support for stylesheets using CSS fallbacks.
|
20
|
+
This means that styles like this is now inlined: `width: 5em; width: 3rem;`, while Roadie would previously remove the first of the two.
|
21
|
+
This sadly means that the HTML file will be much larger than before if you're using a non-optimized stylesheet (for example including your application stylesheet to the email). This was a bad idea even before this change, and this might get you to change.
|
22
|
+
* Using HTML5 doctype instead of XHTML
|
23
|
+
* Full support for JRuby
|
24
|
+
* Experimental support for Rubinius
|
13
25
|
|
14
26
|
### 2.4.2
|
15
27
|
|
data/Gemfile
CHANGED
data/Guardfile
CHANGED
@@ -1,7 +1,17 @@
|
|
1
|
-
|
1
|
+
rspec_options = {
|
2
|
+
cmd: 'rspec -f nested',
|
3
|
+
keep_failed: true,
|
4
|
+
all_after_pass: true,
|
5
|
+
all_on_start: true,
|
6
|
+
run_all: {cmd: 'rspec -f progress'}
|
7
|
+
}
|
8
|
+
|
9
|
+
guard 'rspec', rspec_options do
|
2
10
|
watch(%r{^spec/.+_spec\.rb$})
|
3
11
|
watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
|
4
12
|
|
13
|
+
watch(%r{lib/roadie/rspec/.*\.rb}) { "spec" }
|
14
|
+
|
5
15
|
watch(%r{spec/support/.*\.rb}) { "spec" }
|
6
16
|
watch('spec/spec_helper.rb') { "spec" }
|
7
17
|
end
|
data/README.md
CHANGED
@@ -1,11 +1,18 @@
|
|
1
1
|
Roadie
|
2
2
|
======
|
3
3
|
|
4
|
-
|
4
|
+
[![Build history and status](https://secure.travis-ci.org/Mange/roadie.png)](http://travis-ci.org/#!/Mange/roadie)
|
5
|
+
[![Code Climate](https://codeclimate.com/github/Mange/roadie.png)](https://codeclimate.com/github/Mange/roadie)
|
6
|
+
[![Coverage Status](https://coveralls.io/repos/Mange/roadie/badge.png?branch=master)](https://coveralls.io/r/Mange/roadie?branch=master)
|
7
|
+
[![Gem Version](https://badge.fury.io/rb/roadie.png)](http://badge.fury.io/rb/roadie)
|
8
|
+
[![Dependency Status](https://gemnasium.com/Mange/roadie.png)](https://gemnasium.com/Mange/roadie)
|
9
|
+
|
10
|
+
**Note: This README details the prerelease 3.0 version of Roadie. You might be using 2.0, which is much older and only for Rails.**
|
11
|
+
|
12
|
+
> Making HTML emails comfortable for the Ruby rockstars
|
5
13
|
|
6
|
-
Roadie tries to make sending HTML emails a little less painful
|
14
|
+
Roadie tries to make sending HTML emails a little less painful by inlining stylesheets and rewriting relative URLs for you inside your emails.
|
7
15
|
|
8
|
-
If you want to have this in Rails 2, please see [MailStyle](https://www.github.com/purify/mail_style).
|
9
16
|
|
10
17
|
How does it work?
|
11
18
|
-----------------
|
@@ -18,226 +25,228 @@ Roadie also rewrites all relative URLs in the email to a absolute counterpart, m
|
|
18
25
|
|
19
26
|
¹: Of course, rules like `:hover` will not work by definition. Only static styles can be added.
|
20
27
|
|
21
|
-
Build Status
|
22
|
-
------------
|
23
|
-
|
24
|
-
[![Build history and status](https://secure.travis-ci.org/Mange/roadie.png)](http://travis-ci.org/#!/Mange/roadie)
|
25
|
-
|
26
|
-
Tested with [Travis CI](http://travis-ci.org) using [almost all combinations of](http://travis-ci.org/#!/Mange/roadie):
|
27
|
-
|
28
|
-
* Ruby:
|
29
|
-
* MRI 1.8.7
|
30
|
-
* MRI 1.9.3
|
31
|
-
* MRI 2.0.0
|
32
|
-
* Rails
|
33
|
-
* 3.0
|
34
|
-
* 3.1
|
35
|
-
* 3.2
|
36
|
-
* 4.0
|
37
|
-
|
38
|
-
Let me know if you want any other combination supported officially.
|
39
|
-
|
40
|
-
### Versioning ###
|
41
|
-
|
42
|
-
This project follows [Semantic Versioning](http://semver.org/) and has been since version 1.0.0.
|
43
|
-
|
44
28
|
Features
|
45
29
|
--------
|
46
30
|
|
47
|
-
* Supports Rails' Asset Pipeline and simple filesystem access out of the box
|
48
|
-
* You can add support for CSS from any place inside your apps
|
49
31
|
* Writes CSS styles inline
|
50
32
|
* Respects `!important` styles
|
51
33
|
* Does not overwrite styles already present in the `style` attribute of tags
|
52
34
|
* Supports the same CSS selectors as [Nokogiri](http://nokogiri.org/) (use CSS3 selectors in your emails!)
|
53
35
|
* Makes image urls absolute
|
54
36
|
* Hostname and port configurable on a per-environment basis
|
55
|
-
* Makes link `href`s absolute
|
37
|
+
* Makes link `href`s and `img` `src`s absolute
|
56
38
|
* Automatically adds proper html skeleton when missing (you don't have to create a layout for emails)²
|
39
|
+
* Allows you to inject stylesheets in a number of ways, at runtime
|
57
40
|
|
58
|
-
²: This might be removed in a future version, though. You really ought to create a good layout and not let Roadie guess how you want to have it structured
|
41
|
+
²: This might be removed in a future version, though. You really ought to create a good layout and not let Roadie guess how you want to have it structured.
|
59
42
|
|
60
|
-
Install
|
61
|
-
|
43
|
+
Install & Usage
|
44
|
+
---------------
|
62
45
|
|
63
|
-
Add
|
46
|
+
[Add this gem to your Gemfile as recommended by Rubygems](http://rubygems.org/gems/roadie) and run `bundle install`.
|
64
47
|
|
65
48
|
```ruby
|
66
|
-
gem 'roadie'
|
49
|
+
gem 'roadie', '~> x.y.0'
|
67
50
|
```
|
68
51
|
|
69
|
-
|
70
|
-
-----------
|
71
|
-
|
72
|
-
Roadie listens to the following options (set in `Application.rb` or in your environment's configuration files:
|
52
|
+
You may then create a new instance of a Roadie document:
|
73
53
|
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
54
|
+
```ruby
|
55
|
+
document = Roadie::Document.new "<html><body></body></html>"
|
56
|
+
document.add_css "body { color: green; }"
|
57
|
+
document.transform
|
58
|
+
# => "<html><body style=\"color:green;\"></body></html>"
|
59
|
+
```
|
79
60
|
|
80
|
-
|
81
|
-
-----
|
61
|
+
Your document instance can be configured several options:
|
82
62
|
|
83
|
-
|
63
|
+
* `url_options` - Dictates how absolute URLs should be built.
|
64
|
+
* `asset_providers` - A single (or list of) asset providers that are invoked when external CSS is referenced. See below.
|
65
|
+
* `before_transformation` - A callback run before inlining starts.
|
66
|
+
* `after_transformation` - A callback run after inlining is completed.
|
84
67
|
|
85
|
-
|
68
|
+
### Making URLs absolute ###
|
86
69
|
|
87
|
-
|
70
|
+
In order to make URLs absolute you need to first configure the URL options of the document.
|
88
71
|
|
89
72
|
```ruby
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
end
|
96
|
-
|
97
|
-
def newsletter
|
98
|
-
mail(:subject => 'Newsletter', :to => 'someone@example.com', :css => ['email', 'newsletter'])
|
99
|
-
end
|
100
|
-
end
|
73
|
+
html = "... <a href="/about-us">Read more!</a> ..."
|
74
|
+
document = Roadie::Document.new html
|
75
|
+
document.url_options = {host: "myapp.com", protocol: "https"}
|
76
|
+
document.transform
|
77
|
+
# => "... <a href="https://myapp.com/about-us">Read more!</a> ..."
|
101
78
|
```
|
102
79
|
|
103
|
-
|
80
|
+
The following URLs will be rewritten for you:
|
81
|
+
* `a[href]` (HTML)
|
82
|
+
* `img[src]` (HTML)
|
83
|
+
* `url()` (CSS)
|
104
84
|
|
105
|
-
###
|
85
|
+
### Referenced stylesheets ###
|
106
86
|
|
107
|
-
|
87
|
+
By default, `style` and `link` elements in the email document's `head` are processed along with the stylesheets and removed from the `head`.
|
108
88
|
|
109
|
-
|
89
|
+
You can set a special `data-roadie-ignore` attribute on `style` and `link` tags that you want to ignore (the attribute will be removed, however). This is the place to put things like `:hover` selectors that you want to have for email clients allowing them.
|
110
90
|
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
91
|
+
Style and link elements with `media="print"` are also ignored.
|
92
|
+
|
93
|
+
```html
|
94
|
+
<head>
|
95
|
+
<link rel="stylesheet" type="text/css" href="/assets/emails/rock.css"> <!-- Will be inlined -->
|
96
|
+
<link rel="stylesheet" type="text/css" href="http://www.metal.org/metal.css"> <!-- Will NOT be inlined; absolute URL -->
|
97
|
+
<link rel="stylesheet" type="text/css" href="/assets/jazz.css" media="print"> <!-- Will NOT be inlined; print style -->
|
98
|
+
<link rel="stylesheet" type="text/css" href="/ambient.css" data-roadie-ignore> <!-- Will NOT be inlined; ignored -->
|
99
|
+
<style></style> <!-- Will be inlined -->
|
100
|
+
<style data-roadie-ignore></style> <!-- Will NOT be inlined; ignored -->
|
101
|
+
</head>
|
115
102
|
```
|
116
103
|
|
117
|
-
If you
|
104
|
+
Roadie will use the given asset providers to look for the actual CSS that is referenced. If you don't change the default, it will use the `Roadie::FilesystemProvider` which looks for stylesheets on the filesystem, relative to the current working directory.
|
118
105
|
|
119
|
-
|
106
|
+
Example:
|
120
107
|
|
121
|
-
|
108
|
+
```ruby
|
109
|
+
# /home/user/foo/stylesheets/primary.css
|
110
|
+
body { color: blue; }
|
111
|
+
|
112
|
+
# /home/user/foo/script.rb
|
113
|
+
html = <<-HTML
|
114
|
+
<html>
|
115
|
+
<head>
|
116
|
+
<link rel="stylesheet" type="text/css" href="/stylesheets/primary.css">
|
117
|
+
</head>
|
118
|
+
<body>
|
119
|
+
</body>
|
120
|
+
</html>
|
121
|
+
HTML
|
122
|
+
|
123
|
+
Dir.pwd # => "/home/user/foo"
|
124
|
+
document = Roadie::Document.new html
|
125
|
+
document.transform # =>
|
126
|
+
# <!DOCTYPE html>
|
127
|
+
# <html>
|
128
|
+
# <head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"></head>
|
129
|
+
# <body style="color:green;"></body>
|
130
|
+
# </html>
|
131
|
+
```
|
122
132
|
|
123
|
-
|
133
|
+
If a referenced stylesheet cannot be found, the `#transform` method will raise an `Roadie::CssNotFound` error. If you instead want to ignore missing stylesheets, you can use the `NullProvider`.
|
124
134
|
|
125
|
-
|
135
|
+
### Configuring providers ###
|
126
136
|
|
127
|
-
|
137
|
+
You can write your own providers if you need very specific behavior for your app, or you can use the built-in providers.
|
128
138
|
|
129
|
-
|
139
|
+
Included providers:
|
140
|
+
* `FilesystemProvider` - Looks for files on the filesystem, relative to the given directory unless otherwise specified.
|
141
|
+
* `ProviderList` – Wraps a list of other providers and searches them in order. The `asset_providers` setting is an instance of this. It behaves a lot like an array, so you can push, pop, shift and unshift to it.
|
142
|
+
* `NullProvider` - Does not actually provide anything, it always finds empty stylesheets. Use this in tests or if you want to ignore stylesheets that cannot be found by your other providers.
|
130
143
|
|
131
|
-
If
|
144
|
+
If you want to search several locations on the filesystem, just declare that:
|
132
145
|
|
133
|
-
```
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
<link rel="stylesheet" type="text/css" href="/ambient.css" data-immutable> <!-- Will NOT be inlined -->
|
139
|
-
</head>
|
146
|
+
```ruby
|
147
|
+
document.asset_providers = [
|
148
|
+
Roadie::FilesystemProvider.new(App.root.join("resources", "stylesheets")),
|
149
|
+
Roadie::FilesystemProvider.new(App.root.join("system", "uploads", "stylesheets")),
|
150
|
+
]
|
140
151
|
```
|
141
152
|
|
142
|
-
|
143
|
-
-------------------------
|
153
|
+
If you want to ignore stylesheets that cannot be found instead of crashing, push the `NullProvider` to the end:
|
144
154
|
|
145
|
-
|
155
|
+
```ruby
|
156
|
+
document.asset_providers << Roadie::NullProvider.new
|
157
|
+
```
|
146
158
|
|
147
|
-
|
159
|
+
### Writing your own provider ###
|
160
|
+
|
161
|
+
Writing your own provider is also easy. You just need to provide:
|
162
|
+
* `#find_stylesheet(name)`, returning either a `Roadie::Stylesheet` or nil.
|
163
|
+
* `#find_stylesheet!(name)`, returning either a `Roadie::Stylesheet` or raising `Roadie::CssNotFound`.
|
148
164
|
|
149
165
|
```ruby
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
def
|
156
|
-
|
157
|
-
|
158
|
-
user.
|
159
|
-
else
|
160
|
-
super
|
166
|
+
class UserAssetsProvider
|
167
|
+
def initialize(user_collection)
|
168
|
+
@user_collection = user_collection
|
169
|
+
end
|
170
|
+
|
171
|
+
def find_stylesheet(name)
|
172
|
+
if name =~ %r{^/users/(\d+)\.css$}
|
173
|
+
user = @user_collection.find_user($1)
|
174
|
+
Roadie::Stylesheet.new("user #{user.id} stylesheet", user.stylesheet)
|
161
175
|
end
|
162
176
|
end
|
163
|
-
end
|
164
|
-
```
|
165
177
|
|
166
|
-
|
167
|
-
|
178
|
+
def find_stylesheet!(name)
|
179
|
+
find_stylesheet(name) or raise Roadie::CssNotFound.new(name)
|
180
|
+
end
|
168
181
|
|
169
|
-
|
182
|
+
# Instead of implementing #find_stylesheet!, you could also:
|
183
|
+
# include Roadie::AssetProvider
|
184
|
+
end
|
170
185
|
|
171
|
-
|
186
|
+
# Try to look for a user stylesheet first, then fall back to normal filesystem lookup.
|
187
|
+
document.asset_providers = [
|
188
|
+
UserAssetsProvider.new(app),
|
189
|
+
Roadie::FilesystemProvider.new('./stylesheets'),
|
190
|
+
]
|
191
|
+
```
|
172
192
|
|
173
|
-
|
193
|
+
You can test for compliance by using the built-in RSpec examples:
|
174
194
|
|
175
195
|
```ruby
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
196
|
+
require 'spec_helper'
|
197
|
+
require 'roadie/rspec'
|
198
|
+
|
199
|
+
describe MyOwnProvider do
|
200
|
+
# Will use the default `subject` (MyOwnProvider.new)
|
201
|
+
it_behaves_like "roadie asset provider", valid_name: "found.css", invalid_name: "does_not_exist.css"
|
202
|
+
|
203
|
+
# Extra setup just for these tests:
|
204
|
+
it_behaves_like "roadie asset provider", valid_name: "found.css", invalid_name: "does_not_exist.css" do
|
205
|
+
subject { MyOwnProvider.new(...) }
|
206
|
+
before { Whatever.stub ... }
|
180
207
|
end
|
181
208
|
end
|
182
209
|
```
|
183
210
|
|
184
|
-
|
211
|
+
### Callbacks ###
|
185
212
|
|
186
|
-
|
187
|
-
# application.rb
|
188
|
-
config.roadie.after_inlining = PromotionInliner.new
|
213
|
+
Callbacks allow you to do custom work on documents before they are inlined. The Nokogiri document tree is passed to the callable:
|
189
214
|
|
190
|
-
|
191
|
-
class
|
215
|
+
```ruby
|
216
|
+
class TrackNewsletterLinks
|
192
217
|
def call(document)
|
193
|
-
document.css("a
|
194
|
-
fix_link link
|
195
|
-
end
|
218
|
+
document.css("a").each { |link| fix_link(link) }
|
196
219
|
end
|
197
220
|
|
198
221
|
def fix_link(link)
|
199
|
-
|
200
|
-
|
201
|
-
end
|
222
|
+
divider = (link['href'] =~ /?/ ? '&' : '?')
|
223
|
+
link['href'] = link['href'] + divider + 'source=newsletter'
|
202
224
|
end
|
203
225
|
end
|
226
|
+
|
227
|
+
document.before_transformation = { |document| logger.debug "Inlining document with title #{document.at_css('head > title').try(:text)}" }
|
228
|
+
document.after_transformation = TrackNewsletterLinks.new
|
204
229
|
```
|
205
230
|
|
206
|
-
|
231
|
+
Build Status
|
232
|
+
------------
|
207
233
|
|
208
|
-
|
234
|
+
Tested with [Travis CI](http://travis-ci.org) using:
|
209
235
|
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
- **All HTML emails sent by a mailer**
|
236
|
+
* MRI 1.9.3
|
237
|
+
* MRI 2.0.0
|
238
|
+
* JRuby (latest)
|
239
|
+
* Rubinius >= 2.1 (experimental)
|
215
240
|
|
216
|
-
|
217
|
-
class MarketingMailer < ActionMailer::Base
|
218
|
-
# Custom inliner for all mailer methods.
|
219
|
-
default after_inlining: PromotionInliner.new
|
220
|
-
end
|
221
|
-
```
|
241
|
+
[(Build status)](http://travis-ci.org/#!/Mange/roadie)
|
222
242
|
|
223
|
-
|
243
|
+
Let me know if you want any other VM supported officially.
|
224
244
|
|
225
|
-
|
226
|
-
class UserMailer < ActionMailer::Base
|
227
|
-
def registration
|
228
|
-
# Custom inliner for registration emails
|
229
|
-
mail(after_inlining: MarketingMailer.new)
|
230
|
-
end
|
231
|
-
end
|
232
|
-
```
|
245
|
+
Rubinius support is experimental since it it currently hindered by a Rubinius bug that will probably be fixed shortly.
|
233
246
|
|
234
|
-
|
235
|
-
-----------
|
247
|
+
### Versioning ###
|
236
248
|
|
237
|
-
|
238
|
-
* Clean up stylesheet assignment code
|
239
|
-
* Assets referenced with digest URLs should be findable
|
240
|
-
* Roadie should be able to have multiple asset providers in a specific order
|
249
|
+
This project follows [Semantic Versioning](http://semver.org/) and has been since version 1.0.0.
|
241
250
|
|
242
251
|
FAQ
|
243
252
|
---
|
@@ -262,18 +271,23 @@ Put any styles using them in a separate stylesheet and make sure it is ignored.
|
|
262
271
|
Documentation
|
263
272
|
-------------
|
264
273
|
|
265
|
-
* [Online documentation for
|
274
|
+
* [Online documentation for gem](http://rubydoc.info/gems/roadie/frames)
|
266
275
|
* [Online documentation for master](http://rubydoc.info/github/Mange/roadie/master/frames)
|
267
276
|
* [Changelog](https://github.com/Mange/roadie/blob/master/Changelog.md)
|
268
277
|
|
269
278
|
Running specs
|
270
279
|
-------------
|
271
280
|
|
272
|
-
|
281
|
+
```bash
|
282
|
+
bundle install
|
283
|
+
rake
|
284
|
+
```
|
273
285
|
|
274
286
|
History and contributors
|
275
287
|
------------------------
|
276
288
|
|
289
|
+
This gem was previously tied to Rails. It is now framework-agnostic and supports any type of HTML documents. If you want to use it with Rails, check out [roadie-rails](https://github.com/Mange/roadie-rails).
|
290
|
+
|
277
291
|
Major contributors to Roadie:
|
278
292
|
|
279
293
|
* [Arttu Tervo (arttu)](https://github.com/arttu) - Original Asset pipeline support
|
@@ -281,17 +295,6 @@ Major contributors to Roadie:
|
|
281
295
|
|
282
296
|
You can [see all contributors](https://github.com/Mange/roadie/contributors) on GitHub.
|
283
297
|
|
284
|
-
This gem was originally developed for Rails 2 use on [Purify](http://purifyapp.com) under the name [MailStyle](https://www.github.com/purify/mail_style). However, the author stopped maintaining it and a fork took place to make it Rails 3+ compatible.
|
285
|
-
|
286
|
-
The following people have contributed to the orignal gem:
|
287
|
-
|
288
|
-
* [Jim Neath](http://jimneath.org) (Original author)
|
289
|
-
* [Lars Klevans](http://tastybyte.blogspot.com/)
|
290
|
-
* [Jonas Grimfelt](http://github.com/grimen)
|
291
|
-
* [Ben Johnson](http://www.binarylogic.com)
|
292
|
-
* [Istvan Hoka](http://istvanhoka.com/)
|
293
|
-
* [Voraz](http://blog.voraz.com.br)
|
294
|
-
|
295
298
|
License
|
296
299
|
-------
|
297
300
|
|
@@ -299,8 +302,7 @@ License
|
|
299
302
|
|
300
303
|
Copyright (c) 2009-2013
|
301
304
|
|
302
|
-
* [
|
303
|
-
* Magnus Bergmark <magnus.bergmark@gmail.com>
|
305
|
+
* [Magnus Bergmark](https://github.com/Mange) <magnus.bergmark@gmail.com>
|
304
306
|
|
305
307
|
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the ‘Software’), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
306
308
|
|