-
Notifications
You must be signed in to change notification settings - Fork 12
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
Add cache-busting path for webshims #22
Closed
Closed
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
b2dfd35
Add cache-busting path for webshims
jeremywadsack b3f81e3
Use Rack::File instead of custom code
jeremywadsack 9ea71e8
Clearer wording in README
jeremywadsack af357a0
Er.. there is no env in initialize
jeremywadsack 12a2d13
Do not need assets prefix if we are serving ourselves. Also was compe…
jeremywadsack 5eca61f
Add note about testing under Spork
jeremywadsack 18d062f
Also remove "assets" from view helper
jeremywadsack File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
Rails.application.routes.draw do | ||
mount Webshims::Rails::Rewrite.new, :at => "/webshims/shims" | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
module Webshims | ||
module Rails | ||
class Rewrite < Rack::File | ||
|
||
def initialize | ||
super(root) | ||
end | ||
|
||
def call(env) | ||
env["PATH_INFO"] = env["PATH_INFO"].gsub(%r(\A/[0-9.]+/), '') | ||
super(env) | ||
end | ||
|
||
private | ||
|
||
def root | ||
File.join(Gem.loaded_specs["webshims-rails"].full_gem_path, "vendor", "assets", "javascripts", "webshims", "shims") | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
module Webshims | ||
module Rails | ||
module ViewHelpers | ||
def webshims_path | ||
"/webshims/shims/#{Webshims::Rails::WEBSHIMS_VERSION}/" | ||
end | ||
end | ||
end | ||
end |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking at this change.. I don't think it's a good idea to hardcode the webshims version into the application. That's pretty much what we are trying to avoid in all this.
Maybe we should use the webshims_path helper here as an example.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree, which is why I created the
webshims_path
helper. However, in our case (and this seemed likely for most implementations), this line is in a JS file that's loaded and compressed with the rest of the JS intoapplication.js
and therefore doesn't run through ERB (or HAML or whatever).The problem I've found, running this branch, is that the webshims are no longer offloaded to nginx and so they use the rails server which they really shouldn't need to.
I think I like your approach of just writing webshims to public and letting the assets manager (nginx, CDN, etc.) take care of it from there.