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
Explicit marker to rewrite URLs in assets #25
Comments
That makes sense . In core we actually have a registered URL protocol for asset: Sent from my iPhone
|
Thanks. I'm not exactly sure about what you mean by "In core we actually have a registered URL protocol for asset:" Do you mean that Or do URLs with an "asset" scheme (scheme == protocol) already get processed at all by AP? Or both? Or something else? I don't want to break things by processing them differently in my new code than in the existing code. BTW, I don't have much experience with git, but it seems like something might be amiss with the When I My new code will be in a branch named Thanks. |
Is the base URL from the If so, is it available in the runtime of `Processor#process(String inputText, AssetFile assetFile)? I haven't had the time to track it down. The existing Some of my static files in S3 are partials that are loaded by GSPs in my Grails server. From what I know, URLs in the partials will be relative to the GSP's URL. This URL in on my Grails server, not on S3, so that URLs rewritten in the partials will point to the Grails server, unless I can somehow prepend the value of Thanks. |
AssetPipelineConfigHolder.config.url Sent from my iPhone
|
Thanks for the info about I'm almost done with my changes for this issue, so I'll have a pull request soon. Does the following list accurately describe how
If the above base URL algorithm is correct, then I will follow it for rewriting If it is incorrect, please let me know what is wrong so that I can adjust the code. Thanks. |
Your assumptions are correct. It is also important to note a url property can be a |
I revamped the existing relative URL rewriting code to streamline it. I'll try to finish testing it sometime this upcoming weekend (busy with work until then). I also wrote some code that starts to implement the I'll wait until the relative URL rewrite code is finished & tested, however, before continuing with the |
I'd like to add support for an explicit marker to rewrite URLs in assets.
I have some assets that will be easier to reference via absolute URLs, and AP currently only rewrites relative URLs; it doesn't rewrite absolute URLs.
I'm working on this in a branch in my AP fork.
I will also include some minor modifications that should improve the existing AP Processor code (factoring out duplicate code, simplifying & hopefully speeding up regex matching, properly handling URL etc.).
I'll create a pull request once the code is ready.
I propose to still rewrite relative URLs in both css & html files as before. I'll probably add URL rewriting capability for js files, too, if you don't mind.
The new code will also rewrite any URL that begins with "asset:", regardless if it's relative or absolute.
If the URL following "asset:" is:
How should URL schemes for relative URLs be handled? (e.g., in an asset file located at
http://host/path/asset.html
, there is a relative URL likeftp:this/is/a/relative/path
; I ignore cache digests for these examples)If no base URL has been specified, then I imagine that we could use the hostname of the asset file, and make the path relative to the path of the referring file. We could use the scheme from the relative URL (in the case of the example, the rewritten URL will be
ftp://host/path/this/is/a/relative/path
).The only problem is if a base URL has been specified and it has a scheme (e.g.,
http://cdn/base/path
). Can we replace the scheme from the base URL with the scheme from the relative URL (so, for the example, we'd useftp://cdn/base/path/this/is/a/relative/path
)?In the future, if you want to allow AP to be separately configured to enable / disable relative URL rewriting, and to enable / disable "asset:" scheme URL rewriting, I'll leave that config setup to you.
The text was updated successfully, but these errors were encountered: