1
0
mirror of https://github.com/mrclay/minify.git synced 2025-08-12 00:54:35 +02:00

Allow specifying files via $min_symlinks paths

If you have an alias/symlink like "//~name" => "/full/path", then you can
now serve with the more logical URL http://example.com/min/?f=~name/foo.css

Fixes #137
This commit is contained in:
Steve Clay
2015-09-28 21:50:32 -04:00
parent db8915b2db
commit 7c607ff932
3 changed files with 22 additions and 2 deletions

View File

@@ -33,11 +33,22 @@ class Minify_Controller_MinApp extends Minify_Controller_Base {
array(
'groupsOnly' => false,
'groups' => array(),
'symlinks' => array(),
)
,(isset($options['minApp']) ? $options['minApp'] : array())
);
unset($options['minApp']);
// normalize $symlinks in order to map to target
$symlinks = array();
foreach ($localOptions['symlinks'] as $link => $target) {
if (0 === strpos($link, '//')) {
$link = rtrim(substr($link, 1), '/') . '/';
$target = rtrim($target, '/\\');
$symlinks[$link] = $target;
}
}
$sources = array();
$selectionId = '';
$firstMissingResource = null;
@@ -127,6 +138,14 @@ class Minify_Controller_MinApp extends Minify_Controller_Base {
$uri = $base . $file;
$path = $this->env->getDocRoot() . $uri;
// try to rewrite path
foreach ($symlinks as $link => $target) {
if (0 === strpos($uri, $link)) {
$path = $target . DIRECTORY_SEPARATOR . substr($uri, strlen($link));
break;
}
}
try {
$source = $this->sourceFactory->makeSource(array(
'filepath' => $path,