Added support for fetching remote assets. #112

Closed
wants to merge 5 commits into
from

Projects

None yet

2 participants

@afolgado
Contributor

The paths[] array now accepts remote paths.

For example:

[js]
paths[] = http://cdn.mysite.org/js

[mybuild.js]
files[] = jquery/latest/jquery.min.js

This will fetch http://cdn.mysite.org/js/jquery/latest/jquery.min.js and integrate it into mybuild.js. Build will fail if the file cannot be read, as it happens with local files.

Of course this is compatible with local paths, filters and any other stuff that worked previously.

For now, just HTTP is supported, but it can be easily upgraded. PHP5 is required, as stream_get_contents() is used.

@markstory markstory commented on an outdated diff May 22, 2012
Lib/AssetScanner.php
@@ -96,13 +114,26 @@ public function find($file) {
return $file;
}
foreach ($this->_paths as $path) {
- if (file_exists($path . $file)) {
- return $path . $file;
+ if ($ds = $this->isRemote($path)) {
+ $file = $this->_normalizePath($file, $ds);
+ $full_path = $path . $file;
@markstory
markstory May 22, 2012 Owner

Variables should be in camelBacked format.

@markstory markstory commented on an outdated diff May 22, 2012
Lib/AssetConfig.php
@@ -230,9 +230,9 @@ protected function _parseExtensionDef($target) {
* @return string constants replaced
*/
protected function _replacePathConstants($path) {
- $result = strtr($path, $this->constantMap);
- $result = str_replace('/', DS, $result);
- return $result;
+ $result = strtr($path, $this->constantMap);
+ //$result = str_replace('/', DS, $result); // If $path is remote this will screw it up. I've moved it to AssetScanner::_normalizePaths().
@markstory
markstory May 22, 2012 Owner

Just remove commented out code :)

@markstory
Owner

Merged in [ed2dd67]

@markstory markstory closed this May 28, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment