-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* New version with query string fallback * Add travis config file * Update readme * Add build status badge
- Loading branch information
1 parent
7a9829c
commit 0dc9b68
Showing
24 changed files
with
1,074 additions
and
100 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/tests/vendor |
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,40 @@ | ||
language: php | ||
|
||
php: | ||
- 5.6 | ||
- 7.0 | ||
- 7.1 | ||
|
||
env: | ||
global: | ||
- setup=basic | ||
|
||
matrix: | ||
include: | ||
- php: 5.6 | ||
env: setup=lowest | ||
- php: 5.6 | ||
env: setup=stable | ||
|
||
sudo: false | ||
|
||
services: | ||
- memcached | ||
- redis-server | ||
|
||
before_install: | ||
- if [[ $TRAVIS_PHP_VERSION != 7.1 ]] ; then phpenv config-rm xdebug.ini; fi | ||
- travis_retry composer self-update | ||
|
||
install: | ||
- cd tests | ||
- if [[ $setup = 'basic' ]]; then travis_retry composer install --no-interaction --prefer-dist --no-suggest; fi | ||
- if [[ $setup = 'stable' ]]; then travis_retry composer update --prefer-dist --no-interaction --prefer-stable --no-suggest; fi | ||
- if [[ $setup = 'lowest' ]]; then travis_retry composer update --prefer-dist --no-interaction --prefer-lowest --prefer-stable --no-suggest; fi | ||
|
||
script: vendor/bin/phpunit | ||
|
||
matrix: | ||
allow_failures: | ||
- php: 7.1 | ||
fast_finish: true |
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,12 @@ | ||
{ | ||
"name": "clubstudioltd/club-asset-rev", | ||
"description": "Craft CMS plugin to aid cache-busting", | ||
"keywords": ["craftcms", "cache-busting"], | ||
"license": "MIT", | ||
"type": "project", | ||
"autoload": { | ||
"psr-4": { | ||
"AssetRev\\Utilities\\": "utilities/" | ||
} | ||
} | ||
} |
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 |
---|---|---|
@@ -1,5 +1,22 @@ | ||
<?php | ||
return array( | ||
'manifestPath' => 'resources/assets/assets.json', | ||
'assetsBasePath' => null, | ||
|
||
// The path to your asset manifest, most likely have been generated by a | ||
// task runner such as Gulp or Grunt. Paths will be relative to your craft | ||
// base directory, unless you supply an absolute directory path. | ||
|
||
'manifestPath' => 'resources/assets/assets.json', | ||
|
||
// The base path to your assets. Again, this is relative to your craft base | ||
// directory, unless you supply an absolute directory path. The path will | ||
// always be appended to the filename that is passed though the `rev()`. | ||
|
||
'assetsBasePath' => null, | ||
|
||
// A prefix to apply to your assets when they are output from the plugin. It | ||
// would be useful to set this if the paths in your manifest file are likely | ||
// to be different to the final asset url different | ||
|
||
'assetUrlPrefix' => null, | ||
|
||
); |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,41 @@ | ||
<?php | ||
namespace Craft; | ||
|
||
use InvalidArgumentException; | ||
use AssetRev\Utilities\FilenameRev; | ||
|
||
class AssetRevService extends BaseApplicationComponent | ||
{ | ||
/** | ||
* Get the filename of a asset | ||
* | ||
* @param $file | ||
* @throws InvalidArgumentException | ||
* @return string | ||
*/ | ||
public function getAssetFilename($file) | ||
{ | ||
$revver = new FilenameRev( | ||
$this->parseEnvironmentString(craft()->config->get('manifestPath', 'assetrev')), | ||
$this->parseEnvironmentString(craft()->config->get('assetsBasePath', 'assetrev')), | ||
$this->parseEnvironmentString(craft()->config->get('assetPrefix', 'assetrev')) | ||
); | ||
|
||
$revver->setBasePath(CRAFT_BASE_PATH); | ||
|
||
return $revver->rev($file); | ||
} | ||
|
||
/** | ||
* Build an asset's URL | ||
* | ||
* @param string $basePath Base path to assets as defined in the plugin settings | ||
* @param string $file Asset filename | ||
* | ||
* @return string Path to the asset - environment variables having been replaced with their values. | ||
*/ | ||
protected function parseEnvironmentString($string) | ||
{ | ||
return craft()->config->parseEnvironmentString($string); | ||
} | ||
} |
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
Oops, something went wrong.