Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
external assets: download or move to public section
- Loading branch information
Milan Matějček
committed
Jul 7, 2017
1 parent
4ac353e
commit 63a579e
Showing
18 changed files
with
270 additions
and
18 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
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
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 @@ | ||
<?php | ||
|
||
namespace h4kuna\Assets; | ||
|
||
abstract class AssetException extends \Exception {} | ||
|
||
class DirectoryIsNotWriteableException extends AssetException {} | ||
|
||
class DownloadFaildFromExternalUrlException extends AssetException {} | ||
|
||
class CompareTokensException extends AssetException {} | ||
|
||
class HeaderLastModifyException extends AssetException {} | ||
|
||
class InvalidArgumentException extends AssetException {} | ||
|
||
class InvalidStateException extends AssetException {} | ||
|
||
class DuplicityAssetNameException extends AssetException {} | ||
|
||
class FileNotFoundException extends AssetException {} |
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
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
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,83 @@ | ||
<?php | ||
|
||
namespace h4kuna\Assets\DI; | ||
|
||
use h4kuna\Assets, | ||
Nette\Utils, | ||
Tester\Assert; | ||
|
||
$container = require __DIR__ . '/../../bootsrap.php'; | ||
|
||
function configuratorFactory($neon, $subDirOff = FALSE) | ||
{ | ||
$configurator = new \Nette\Configurator; | ||
$tmp = __DIR__ . '/../../temp/test'; | ||
|
||
Utils\FileSystem::delete($tmp); | ||
Utils\FileSystem::createDir($tmp); | ||
|
||
$wwwDir = $tmp . '/../www'; | ||
$subWww = $wwwDir . '/temp'; | ||
|
||
@chmod($subWww, 0755); | ||
Utils\FileSystem::delete($subWww); | ||
Utils\FileSystem::createDir($subWww); | ||
if ($subDirOff) { | ||
chmod($subWww, 0000); | ||
} | ||
|
||
$configurator->enableDebugger($tmp); | ||
$configurator->addParameters([ | ||
'wwwDir' => $wwwDir | ||
]); | ||
$configurator->setTempDirectory($tmp); | ||
$configurator->addConfig(__DIR__ . '/assets/assets.neon'); | ||
$configurator->addConfig(__DIR__ . '/assets/' . $neon); | ||
return $configurator->createContainer(); | ||
} | ||
|
||
Assert::exception(function() { | ||
configuratorFactory('external-download-faild.neon'); | ||
}, Assets\DownloadFaildFromExternalUrlException::class); | ||
|
||
|
||
Assert::exception(function() { | ||
configuratorFactory('permission-denied.neon', TRUE); | ||
}, Assets\DirectoryIsNotWriteableException::class); | ||
|
||
|
||
Assert::exception(function() { | ||
configuratorFactory('bad-token.neon'); | ||
}, Assets\CompareTokensException::class); | ||
|
||
|
||
Assert::exception(function() { | ||
configuratorFactory('file-not-found.neon'); | ||
}, Assets\FileNotFoundException::class); | ||
|
||
Assert::exception(function() { | ||
configuratorFactory('fs-main.neon', TRUE); | ||
}, Assets\DirectoryIsNotWriteableException::class); | ||
|
||
$x = function() { | ||
touch(__DIR__ . '/assets/main.js', 123456789); | ||
$container = configuratorFactory('fs-main.neon'); | ||
$file = $container->getByType(Assets\File::class); | ||
/* @var $file \h4kuna\Assets\File */ | ||
Assert::same('/temp/main.js?123456789', $file->createUrl('temp/main.js')); | ||
}; | ||
$x(); | ||
|
||
$x = function() { | ||
touch(__DIR__ . '/assets/main.js', 123456789); | ||
$container = configuratorFactory('fs-main-alias.neon'); | ||
$file = $container->getByType(Assets\File::class); | ||
/* @var $file \h4kuna\Assets\File */ | ||
Assert::same('/temp/app/index.js?123456789', $file->createUrl('temp/app/index.js')); | ||
}; | ||
$x(); | ||
|
||
|
||
Assert::exception(function() { | ||
configuratorFactory('duplicity.neon'); | ||
}, Assets\DuplicityAssetNameException::class); |
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,8 @@ | ||
php: | ||
date.timezone: Europe/Prague | ||
|
||
application: | ||
scanDirs: FALSE | ||
|
||
extensions: | ||
assetsExtension: h4kuna\Assets\DI\AssetsExtension |
Oops, something went wrong.