1
0
mirror of https://github.com/mrclay/minify.git synced 2025-08-16 11:03:59 +02:00

do some trivial codestyle fixes

unix newlines, trailing spaces
This commit is contained in:
Elan Ruusamäe
2016-01-22 00:30:38 +02:00
parent 90bf31f53b
commit 379feaba99
40 changed files with 1424 additions and 1327 deletions

View File

@@ -1,14 +1,14 @@
<?php
/**
* Class Minify_Controller_Base
* Class Minify_Controller_Base
* @package Minify
*/
/**
* Base class for Minify controller
*
*
* The controller class validates a request and uses it to create a configuration for Minify::serve().
*
*
* @package Minify
* @author Stephen Clay <steve@mrclay.org>
*/
@@ -36,13 +36,13 @@ abstract class Minify_Controller_Base implements Minify_ControllerInterface {
/**
* Create controller sources and options for Minify::serve()
*
*
* @param array $options controller and Minify options
*
*
* @return Minify_ServeConfiguration
*/
abstract public function createConfiguration(array $options);
/**
* Send message to the Minify logger
*

View File

@@ -1,12 +1,12 @@
<?php
/**
* Class Minify_Controller_Files
* Class Minify_Controller_Files
* @package Minify
*/
/**
* Controller class for minifying a set of files
*
*
* E.g. the following would serve the minified Javascript for a site
* <code>
* $options = [
@@ -40,17 +40,17 @@ class Minify_Controller_Files extends Minify_Controller_Base {
/**
* Set up file sources
*
*
* @param array $options controller and Minify options
* @return Minify_ServeConfiguration
*
*
* Controller options:
*
*
* 'files': (required) array of complete file paths, or a single path
*/
public function createConfiguration(array $options) {
// strip controller options
$files = $options['files'];
// if $files is a single object, casting will break it
if (is_object($files)) {
@@ -59,7 +59,7 @@ class Minify_Controller_Files extends Minify_Controller_Base {
$files = (array)$files;
}
unset($options['files']);
$sources = array();
foreach ($files as $file) {
if ($file instanceof Minify_SourceInterface) {
@@ -72,9 +72,11 @@ class Minify_Controller_Files extends Minify_Controller_Base {
));
} catch (Minify_Source_FactoryException $e) {
$this->log($e->getMessage());
return new Minify_ServeConfiguration($options);
}
}
return new Minify_ServeConfiguration($options, $sources);
}
}

View File

@@ -1,33 +1,33 @@
<?php
/**
* Class Minify_Controller_Groups
* Class Minify_Controller_Groups
* @package Minify
*/
/**
* Controller class for serving predetermined groups of minimized sets, selected
* by PATH_INFO
*
*
* <code>
* Minify::serve('Groups', array(
* Minify::serve('Groups', array(
* 'groups' => array(
* 'css' => array('//css/type.css', '//css/layout.css')
* ,'js' => array('//js/jquery.js', '//js/site.js')
* )
* ));
* </code>
*
*
* If the above code were placed in /serve.php, it would enable the URLs
* /serve.php/js and /serve.php/css
*
*
* @package Minify
* @author Stephen Clay <steve@mrclay.org>
*/
class Minify_Controller_Groups extends Minify_Controller_Files {
/**
* Set up groups of files as sources
*
*
* @param array $options controller and Minify options
*
* 'groups': (required) array mapping PATH_INFO strings to arrays
@@ -41,7 +41,7 @@ class Minify_Controller_Groups extends Minify_Controller_Files {
unset($options['groups']);
$server = $this->env->server();
// mod_fcgid places PATH_INFO in ORIG_PATH_INFO
$pathInfo = isset($server['ORIG_PATH_INFO'])
? substr($server['ORIG_PATH_INFO'], 1)
@@ -52,6 +52,7 @@ class Minify_Controller_Groups extends Minify_Controller_Files {
if (false === $pathInfo || ! isset($groups[$pathInfo])) {
// no PATH_INFO or not a valid group
$this->log("Missing PATH_INFO or no group set for \"$pathInfo\"");
return new Minify_ServeConfiguration($options);
}

View File

@@ -6,7 +6,7 @@
/**
* Controller class for requests to /min/index.php
*
*
* @package Minify
* @author Stephen Clay <steve@mrclay.org>
*/
@@ -14,7 +14,7 @@ class Minify_Controller_MinApp extends Minify_Controller_Base {
/**
* Set up groups of files as sources
*
*
* @param array $options controller and Minify options
*
* @return array Minify options
@@ -59,11 +59,13 @@ class Minify_Controller_MinApp extends Minify_Controller_Base {
$keys = explode(',', $get['g']);
if ($keys != array_unique($keys)) {
$this->log("Duplicate group key found.");
return new Minify_ServeConfiguration($options);
}
foreach ($keys as $key) {
if (! isset($localOptions['groups'][$key])) {
$this->log("A group configuration for \"{$key}\" was not found");
return new Minify_ServeConfiguration($options);
}
$files = $localOptions['groups'][$key];
@@ -91,6 +93,7 @@ class Minify_Controller_MinApp extends Minify_Controller_Base {
} else {
$secondMissingResource = basename($file);
$this->log("More than one file was missing: '$firstMissingResource', '$secondMissingResource'");
return new Minify_ServeConfiguration($options);
}
}
@@ -101,7 +104,7 @@ class Minify_Controller_MinApp extends Minify_Controller_Base {
// try user files
// The following restrictions are to limit the URLs that minify will
// respond to.
if (// verify at least one file, files are single comma separated,
if (// verify at least one file, files are single comma separated,
// and are all same extension
! preg_match('/^[^,]+\\.(css|less|js)(?:,[^,]+\\.\\1)*$/', $get['f'], $m)
// no "//"
@@ -110,12 +113,14 @@ class Minify_Controller_MinApp extends Minify_Controller_Base {
|| strpos($get['f'], '\\') !== false
) {
$this->log("GET param 'f' was invalid");
return new Minify_ServeConfiguration($options);
}
$ext = ".{$m[1]}";
$files = explode(',', $get['f']);
if ($files != array_unique($files)) {
$this->log("Duplicate files were specified");
return new Minify_ServeConfiguration($options);
}
if (isset($get['b'])) {
@@ -127,6 +132,7 @@ class Minify_Controller_MinApp extends Minify_Controller_Base {
$base = "/{$get['b']}/";
} else {
$this->log("GET param 'b' was invalid");
return new Minify_ServeConfiguration($options);
}
} else {
@@ -160,6 +166,7 @@ class Minify_Controller_MinApp extends Minify_Controller_Base {
} else {
$secondMissingResource = $uri;
$this->log("More than one file was missing: '$firstMissingResource', '$secondMissingResource`'");
return new Minify_ServeConfiguration($options);
}
}
@@ -172,6 +179,7 @@ class Minify_Controller_MinApp extends Minify_Controller_Base {
if (!$sources) {
$this->log("No sources to serve");
return new Minify_ServeConfiguration($options);
}

View File

@@ -1,34 +1,34 @@
<?php
/**
* Class Minify_Controller_Page
* Class Minify_Controller_Page
* @package Minify
*/
/**
* Controller class for serving a single HTML page
*
*
* @link http://code.google.com/p/minify/source/browse/trunk/web/examples/1/index.php#59
* @package Minify
* @author Stephen Clay <steve@mrclay.org>
*/
class Minify_Controller_Page extends Minify_Controller_Base {
/**
* Set up source of HTML content
*
*
* @param array $options controller and Minify options
* @return array Minify options
*
*
* Controller options:
*
*
* 'content': (required) HTML markup
*
*
* 'id': (required) id of page (string for use in server-side caching)
*
*
* 'lastModifiedTime': timestamp of when this content changed. This
* is recommended to allow both server and client-side caching.
*
* 'minifyAll': should all CSS and Javascript blocks be individually
*
* 'minifyAll': should all CSS and Javascript blocks be individually
* minified? (default false)
*/
public function createConfiguration(array $options) {