-
Notifications
You must be signed in to change notification settings - Fork 66
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fully support asset_host #11
Comments
The fact that I have to set asset_host to nil is definitely annoying when you expect "image_tag", etc to work the way you expect as well :( |
If I'm not mistaken, I don't think issue 1) is fixed by using image_tag.
|
I'm expressing myself really bad up there. The point is that I don't want to build in support for Is that clearer? |
One thing I am a bit confused by... will Roadie options for host take the place of the asset host? Or can I only serve the inlined CSS directly from my application server? I guess it is inlined, so it would just be read off of disk? Thanks for all your hard work here, I really appreciate Roadie! |
Roadie's URL options is only applied to relative paths. The reason this could be useful is when you're generating emails outside of a Rails request cycle (crontab, background job, etc.) and Rails does not know which hostname the user visited and cannot generate urls with the Roadie aims to make this easier to the user. Just configure the hostname that should be used in one place, and all the URLs will be changed. Keep on using Since "Read more" links shouldn't go to asset hosts, the configured asset host is different from the Roadie URL options. Sure, relative paths inside CSS is also treated with the Roadie URL options to save you from trouble, but if you are among the asset host users, you already have a centralized config for where assets can be served from, and the full URL can be used in the email in the first place. Roadie isn't needed in that situation, so again, it does not need to use asset host. tl;dr: If you have an asset host, Roadie does not need it. If you don't have an asset host, Roadie does not need it. :-) Bullet 1 of this issue ("Asset host is not used") is out of scope / wontfix. Bullet 2 ("Cannot inline with an asset host") is the actual bug, being worked on in #30. I should make this clearer.
Yes, Roadie will not download stylesheets from the internet. You could write your own asset provider that does that, however[1]. You could even attach some caching layer if you wanted to. If you have the stylesheets on the application server it will inline the contents, so you don't need to serve the assets anywhere.
That warms my heart. Thank you! [1]: The inliner will only ask the provider about stylesheets with relative paths right now (someone needs to tell me if they need this). |
Version 3.1 of Roadie can do this. It's still just a RC, but 1.1 of |
Hi @Mange , thanks for all your hard work! Could you provide an update on the asset_host issue? Cheers! |
I've recently started working on a Rails 3 app with an asset_host, so I I still feel the best way out of this is to manually build the URL for your I'm still extremely open to good suggestions on how to handle this Den tor 23 juni 2016 01:15Joel Courtney [email protected] skrev:
|
Hi @Mange, thanks for the feedback! Good to know what the opinion is of the author :) I've managed to get it working for the time being using a workaround posted at #10 (comment) I think that you're almost there. I disagree that hand crafting is a good thing – but I'm also understanding that as the author you have valid reasons for your opinion, particularly with the underlying Roadie Gem being a non-rails implementation. Let me do some more thinking and document some more use cases where I believe there is a need (predominantly around image versus stylesheet collision issues). Cheers for all your hard work – it's very much appreciated! |
Thank you for your kind words. I look forward to hearing about your Den tor 30 juni 2016 00:13Joel Courtney [email protected] skrev:
|
When <%# Ensure the stylesheet is referenced without a host so that the local
version is read by Roadie even if asset_host is set. %>
<link rel="stylesheet" href="<%= stylesheet_path('email', host: '') %>" /> This seems like a better workaround than setting |
Here are my notes about this feature so people can contribute with ideas and feedback.
Current issues:
Asset host is not applied to assets that get full URLsstylesheet_link_tag
becomes an absolute URL and inlining will not happen1. Asset host is not applied
image_tag
, etc.2. Does not inline
stylesheet_link_tag
s withasset_host
asset_host
can beString
,Array
or callable.String
is easy to fix; see if full URL starts with this string and strip it.Array
is also pretty easy. Do theString
check for each item in the array.asset_host
?=~ %r{/assets/}
)? No. Error prone and too magic. Will break in all kinds of ways.asset_host
is a very common pattern.asset_host
is set to a callable, require a reversing proc or fail with an error message.<style>
elements or something. This requires them to work more.production
. That's a very bad experience.roadie
asset_provider.find_using_url(url) if asset_provider.respond_to?(:find_using_url)
perhaps? This does not require a major version bump; old implementations work like before.asset_host
to not do anything when encountering stylesheets.The text was updated successfully, but these errors were encountered: