From 17455e5fbdfa69c0d0ae29858adf019df1ee7799 Mon Sep 17 00:00:00 2001 From: Steve Clay Date: Fri, 28 Mar 2008 00:41:16 +0000 Subject: [PATCH] + shortcut for specifying files in doc_root --- lib/Minify/Controller/Files.php | 13 +++++++++---- lib/Minify/Controller/Groups.php | 11 ++++++++--- 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/lib/Minify/Controller/Files.php b/lib/Minify/Controller/Files.php index fb7c8b8..187274a 100644 --- a/lib/Minify/Controller/Files.php +++ b/lib/Minify/Controller/Files.php @@ -11,16 +11,18 @@ require_once 'Minify/Controller/Base.php'; * * E.g. the following would serve the minified Javascript for a site * - * $dr = $_SERVER['DOCUMENT_ROOT']; * Minify::serve('Files', array( * 'files' => array( - * $dr . '/js/jquery.js' - * ,$dr . '/js/plugins.js' - * ,$dr . '/js/site.js' + * '//js/jquery.js' + * ,'//js/plugins.js' + * ,'/home/username/file.js' * ) * )); * * + * As a shortcut, the controller will replace "//" at the beginning + * of a filename with $_SERVER['DOCUMENT_ROOT'] . '/'. + * * @package Minify * @author Stephen Clay */ @@ -47,6 +49,9 @@ class Minify_Controller_Files extends Minify_Controller_Base { $sources[] = $file; continue; } + if (0 === strpos($file, '//')) { + $file = $_SERVER['DOCUMENT_ROOT'] . substr($file, 1); + } $file = realpath($file); if (file_exists($file)) { $sources[] = new Minify_Source(array( diff --git a/lib/Minify/Controller/Groups.php b/lib/Minify/Controller/Groups.php index 820c8de..64c9ca5 100644 --- a/lib/Minify/Controller/Groups.php +++ b/lib/Minify/Controller/Groups.php @@ -11,11 +11,10 @@ require_once 'Minify/Controller/Base.php'; * by PATH_INFO * * - * $dr = $_SERVER['DOCUMENT_ROOT']; * Minify::serve('Groups', array( * 'groups' => array( - * 'css' => array($dr . '/css/type.css', $dr . '/css/layout.css') - * ,'js' => array($dr . '/js/jquery.js', $dr . '/js/site.js') + * 'css' => array('//css/type.css', '//css/layout.css') + * ,'js' => array('//js/jquery.js', '//js/site.js') * ) * )); * @@ -23,6 +22,9 @@ require_once 'Minify/Controller/Base.php'; * If the above code were placed in /serve.php, it would enable the URLs * /serve.php/js and /serve.php/css * + * As a shortcut, the controller will replace "//" at the beginning + * of a filename with $_SERVER['DOCUMENT_ROOT'] . '/'. + * * @package Minify * @author Stephen Clay */ @@ -55,6 +57,9 @@ class Minify_Controller_Groups extends Minify_Controller_Base { $sources[] = $file; continue; } + if (0 === strpos($file, '//')) { + $file = $_SERVER['DOCUMENT_ROOT'] . substr($file, 1); + } $file = realpath($file); if (file_exists($file)) { $sources[] = new Minify_Source(array(