mirror of
https://github.com/mrclay/minify.git
synced 2025-08-07 06:36: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:
@@ -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.:
|
||||
|
||||
<?php
|
||||
// add /min/lib to your include_path first!
|
||||
require $_SERVER['DOCUMENT_ROOT'] . '/min/utils.php';
|
||||
|
||||
$jsUri = Minify_groupUri('js');
|
||||
|
@@ -65,12 +65,14 @@ class Minify_Build {
|
||||
* </code>
|
||||
*
|
||||
* @param string $uri
|
||||
* @param boolean $forceAmpersand (default = false) Force the use of ampersand to
|
||||
* append the timestamp to the URI.
|
||||
* @return string
|
||||
*/
|
||||
public function uri($uri) {
|
||||
$sep = strpos($uri, '?') === false
|
||||
? '?'
|
||||
: self::$ampersand;
|
||||
public function uri($uri, $forceAmpersand = false) {
|
||||
$sep = ($forceAmpersand || strpos($uri, '?') !== false)
|
||||
? self::$ampersand
|
||||
: '?';
|
||||
return "{$uri}{$sep}{$this->lastModified}";
|
||||
}
|
||||
|
||||
|
@@ -1,11 +1,13 @@
|
||||
<?php
|
||||
/**
|
||||
* Utility functions for generating group URIs in HTML files
|
||||
*
|
||||
* Before including this file, /min/lib must be in your include_path.
|
||||
*
|
||||
* @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>
|
||||
* </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 $ampersand '&' or '&' (default '&')
|
||||
* @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
|
||||
*/
|
||||
function Minify_groupUri($group, $ampersand = '&')
|
||||
function Minify_groupUri($group, $forceAmpersand = false)
|
||||
{
|
||||
Minify_Build::$ampersand = $ampersand;
|
||||
return _Minify_getBuild($group)->uri('/' . basename(dirname(__FILE__)) . '/?g=' . $group);
|
||||
$path = $forceAmpersand
|
||||
? "/g={$group}"
|
||||
: "/?g={$group}";
|
||||
return _Minify_getBuild($group)->uri(
|
||||
'/' . basename(dirname(__FILE__)) . $path
|
||||
,$forceAmpersand
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user