1
0
mirror of https://github.com/mrclay/minify.git synced 2025-08-07 14:46:29 +02:00

Changes to enable building URIs w/o querystrings

Minify/Build.php : + $forceAmpersand argument to uri()
min/utils.php : Minify_groupUri : removed $ampersand, added $forceAmpersand
This commit is contained in:
Steve Clay
2008-10-05 23:42:17 +00:00
parent b626952f93
commit 986caa3838
3 changed files with 24 additions and 9 deletions

View File

@@ -93,6 +93,7 @@ source control revision number. If not, the utility function Minify_groupUri()
will return "versioned" Minify URIs for use in your HTML. E.g.: will return "versioned" Minify URIs for use in your HTML. E.g.:
<?php <?php
// add /min/lib to your include_path first!
require $_SERVER['DOCUMENT_ROOT'] . '/min/utils.php'; require $_SERVER['DOCUMENT_ROOT'] . '/min/utils.php';
$jsUri = Minify_groupUri('js'); $jsUri = Minify_groupUri('js');

View File

@@ -65,12 +65,14 @@ class Minify_Build {
* </code> * </code>
* *
* @param string $uri * @param string $uri
* @param boolean $forceAmpersand (default = false) Force the use of ampersand to
* append the timestamp to the URI.
* @return string * @return string
*/ */
public function uri($uri) { public function uri($uri, $forceAmpersand = false) {
$sep = strpos($uri, '?') === false $sep = ($forceAmpersand || strpos($uri, '?') !== false)
? '?' ? self::$ampersand
: self::$ampersand; : '?';
return "{$uri}{$sep}{$this->lastModified}"; return "{$uri}{$sep}{$this->lastModified}";
} }

View File

@@ -1,11 +1,13 @@
<?php <?php
/** /**
* Utility functions for generating group URIs in HTML files * Utility functions for generating group URIs in HTML files
*
* Before including this file, /min/lib must be in your include_path.
* *
* @package Minify * @package Minify
*/ */
require_once dirname(__FILE__) . '/lib/Minify/Build.php'; require_once 'Minify/Build.php';
/** /**
@@ -16,14 +18,24 @@ require_once dirname(__FILE__) . '/lib/Minify/Build.php';
* <script type="text/javascript" src="<?php echo Minify_groupUri('js'); ?>"></script> * <script type="text/javascript" src="<?php echo Minify_groupUri('js'); ?>"></script>
* </code> * </code>
* *
* If you do not want ampersands as HTML entities, set Minify_Build::$ampersand = "&"
* before using this function.
*
* @param string $group a key from groupsConfig.php * @param string $group a key from groupsConfig.php
* @param string $ampersand '&' or '&amp;' (default '&amp;') * @param boolean $forceAmpersand (default false) Set to true if the RewriteRule
* directives in .htaccess are functional. This will remove the "?" from URIs, making them
* more cacheable by proxies.
* @return string * @return string
*/ */
function Minify_groupUri($group, $ampersand = '&amp;') function Minify_groupUri($group, $forceAmpersand = false)
{ {
Minify_Build::$ampersand = $ampersand; $path = $forceAmpersand
return _Minify_getBuild($group)->uri('/' . basename(dirname(__FILE__)) . '/?g=' . $group); ? "/g={$group}"
: "/?g={$group}";
return _Minify_getBuild($group)->uri(
'/' . basename(dirname(__FILE__)) . $path
,$forceAmpersand
);
} }