1
0
mirror of https://github.com/mrclay/minify.git synced 2025-08-17 19:37:22 +02:00

Merge pull request #476 from mrclay/symlinks_3

Allow specifying files via $min_symlinks paths
This commit is contained in:
Steve Clay
2015-12-02 12:14:30 -05:00
3 changed files with 22 additions and 2 deletions

View File

@@ -54,6 +54,7 @@ $env = new Minify_Env(array(
// TODO probably should do this elsewhere...
$min_serveOptions['minifierOptions']['text/css']['docRoot'] = $env->getDocRoot();
$min_serveOptions['minifierOptions']['text/css']['symlinks'] = $min_symlinks;
$min_serveOptions['minApp']['symlinks'] = $min_symlinks;
// auto-add targets to allowDirs
foreach ($min_symlinks as $uri => $target) {
$min_serveOptions['minApp']['allowDirs'][] = $target;

View File

@@ -48,8 +48,8 @@ class Minify_CSS_UriRewriter {
);
self::$_currentDir = self::_realpath($currentDir);
self::$_symlinks = array();
// normalize symlinks
// normalize symlinks in order to map to link
foreach ($symlinks as $link => $target) {
$link = ($link === '//')
? self::$_docRoot

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,