Skip to content

Commit

Permalink
Moved core files into a vendor named directory for PSR-0 compliance.
Browse files Browse the repository at this point in the history
Moved license and version out of the bootstrap file.
  • Loading branch information
peteboere committed Jan 11, 2013
1 parent faefc01 commit 0541654
Show file tree
Hide file tree
Showing 30 changed files with 98 additions and 87 deletions.
2 changes: 1 addition & 1 deletion Aliases.ini
Expand Up @@ -114,7 +114,7 @@
; <flex> shorthand. ; <flex> shorthand.
; ;
; Support for the early 2012 syntax implemented in IE10 is achieved here in part with ; Support for the early 2012 syntax implemented in IE10 is achieved here in part with
; property aliases, and in part with property/value aliases later in this file. ; property aliases, and in part with declaration aliases later in this file.
; ;
align-content[] = -webkit-align-content align-content[] = -webkit-align-content
align-items[] = -webkit-align-items align-items[] = -webkit-align-items
Expand Down
72 changes: 42 additions & 30 deletions CHANGELOG.md
Expand Up @@ -3,43 +3,55 @@
* Added flexbox aliases for both 2009 and 2012 edition specs. * Added flexbox aliases for both 2009 and 2012 edition specs.
* Added a legacy-flexbox plugin for auto-generating the flexbox 2009 spec equivilant properties. * Added a legacy-flexbox plugin for auto-generating the flexbox 2009 spec equivilant properties.
* Updated selector aliases to take arguments at runtime. * Updated selector aliases to take arguments at runtime.
* Updated plugin API to use distinct 'enable' and 'disable' handlers. * Updated plugin API to use distinct "enable" and "disable" handlers.
* The disable option is now resolved before the enable option so you can easily disable all plugins * `disable` option is now resolved before the `enable` option so you can easily disable all plugins
and then specify the plugins you want to apply. and then specify the plugins you want to apply.
* Added functions API for defining custom functions inside plugins. * Added functions API for defining custom functions inside plugins.
* Improved gradient function aliasing to handle new angle keywords ('to left', 'at center' etc.). * Improved gradient function aliasing to handle new angle keywords (to left, at center, etc.).
* Added svg-gradients plugin for simulating CSS3 gradients with data-uris. * Added svg-gradients plugin for simulating CSS3 gradients with data-uris.
* Added formatting option so custom formatters can be defined for un-minified output (see wiki for options). * Added `formatting` option for un-minified output. Possible values (custom formatters can also be defined):
* Added newlines option to force the style of newlines in output (see wiki for options). * "block" (default) - Rules are block formatted.
* "single-line" - Rules are printed in single lines.
* "padded" - Rules are printed in single lines with right padded selectors.
Custom formatters can also be defined.
* Added `newlines` option to set the style of newlines in output. Possible values:
* "use-platform" (default)
* "unix"
* "windows" or "win"
* Updated command line utility to use the new options. * Updated command line utility to use the new options.
* Property/value aliases renamed as declaration aliases. * Property/value aliases expanded and renamed as declaration aliases.
* Classes now loaded via an autoloader, also some other refactoring for moving towards PSR-0 compliance. * Classes now loaded via an autoloader, also some other refactoring for moving towards PSR-0 compliance.


1.8 (13th November 2012) 1.8 (13th November 2012)
--- ---
* Added selector aliasing with the @selector-alias directive. * Added selector aliasing with the `@selector-alias` directive.
* Added output_dir option for specifying the destination of compiled files. * Added `output_dir` option for specifying the destination of compiled files.
* Added doc_root option for working around problems with server aliases or path rewrites. * Added `doc_root` option for working around problems with server aliases or path rewrites.
* Added viewport @-rule aliases. * Added viewport @-rule aliases.
* Debug option renamed to 'minify'; debug option will still work as before but is deprecated. * `debug` option renamed to `minify`; `debug` option will still work as before but is deprecated.
* New minify option optionally takes an array of advanced minification parameters. * `minify` option takes an optional array of advanced minification parameters. Possible values:
* Expanded trace option to take an optional array of log parameters; * `colors`
* log params available are stubs, selector_count, errors and compile_time. * Expanded `trace` option to take an optional array of log parameters. Possible values:
* Added CssCrush::stat method to retrieve logged parameters. * `stubs`
* `selector_count`
* `errors`
* `compile_time`
* Added `CssCrush::stat` method to retrieve logged parameters.
* Improved cross OS support. * Improved cross OS support.
* Improved minification. * Improved minification.
* Major refactoring. * Major refactoring.


1.7 (28th September 2012) 1.7 (28th September 2012)
--- ---
* Added trace option to output SASS compatible debug-info stubs for use with tools like FireSass. * Added `trace` option to output SASS compatible debug-info stubs for use with tools like FireSass.
* Added @ifdefine directive for dynamically including/excluding parts of a CSS file based on the existence of variables. * Added `@ifdefine` directive for dynamically including/excluding parts of a CSS file based on the
existence of variables.
* Updated plugin API. * Updated plugin API.
* Added options for enabling and disabling plugins at runtime. * Added options for enabling and disabling plugins at runtime.
* Added property sorter plugin. * Added property sorter plugin.
* Added support for SASS-like @include/@extend syntax for invoking mixins and extends. * Added support for SASS-like @include/@extend syntax for invoking mixins and extends.
* Boilerplate option now accepts a filename string as a boilerplate template. * Boilerplate option now accepts a filename string as a boilerplate template.
* CssCrush::string method now uses document_root as a default context for finding linked resources. * `CssCrush::string` method now uses document\_root as a default context for finding linked resources.
* Updated command line appication. * Updated command line appication.
* Updated aliases and initial value files. * Updated aliases and initial value files.
* Fixed parsing issue introduced in 1.6.1. * Fixed parsing issue introduced in 1.6.1.
Expand All @@ -51,14 +63,14 @@
1.6 (1st August 2012) 1.6 (1st August 2012)
--- ---
* Inheritance model improved to support adoption of pseudo classes and elements (see wiki). * Inheritance model improved to support adoption of pseudo classes and elements (see wiki).
* Added rule self-referencing function this() and complimentary data-- properties. * Added rule self-referencing function `this()` and complimentary data-* properties.
* Added rule referencing function query(). * Added rule referencing function `query()`.
* Added default value argument for variables. * Added default value argument for variables.
* Added hsl-adjust() and hsla-adjust() color functions. * Added `hsl-adjust()` and `hsla-adjust()` color functions.
* Mixin and fragment arg() function can now be nested. * Mixin and fragment `arg()` function can now be nested.
* Commas are now optional when specifying arguments for most custom functions. * Commas are now optional when specifying arguments for most custom functions.
* Double-colon plugin moved to core. * Double-colon plugin moved to core.
* Option rewrite_import_urls now defaults to true. * Option `rewrite_import_urls` now defaults to true.


1.5.3 (13th June 2012) 1.5.3 (13th June 2012)
----- -----
Expand All @@ -68,7 +80,7 @@
1.5.2 (8th June 2012) 1.5.2 (8th June 2012)
----- -----
* Resolved issue #32. * Resolved issue #32.
* CssCrush::inline method now defaults to not printing a boilerplate. * `CssCrush::inline` method now defaults to not printing a boilerplate.
* Updated aliases file. * Updated aliases file.


1.5.1 (1st June 2012) 1.5.1 (1st June 2012)
Expand All @@ -85,7 +97,7 @@
* Abstracted IO interface. * Abstracted IO interface.
* Added some error reporting. * Added some error reporting.
* Added spiffing.css plugin. * Added spiffing.css plugin.
* csscrush_tag method now uses media type 'all' by default. * `CssCrush::tag` method now uses media type 'all' by default.
* Updated alias and initial-value tables. * Updated alias and initial-value tables.
* Internal refactoring. * Internal refactoring.
* Resolved issues #23, #24, #27, #28 and #29. * Resolved issues #23, #24, #27, #28 and #29.
Expand All @@ -98,20 +110,20 @@
1.4.1 (10th February 2012) 1.4.1 (10th February 2012)
----- -----
* Added command line application. * Added command line application.
* Added 'rewrite_import_urls' option - Ability to rewrite relative url references inside imported css files. * Added `rewrite_import_urls` option - Ability to rewrite relative url references inside imported css files.
* Added Prepend.css - Optionally prepend css to every input. * Added Prepend.css - Optionally prepend css to every input.
* Fix for issue #21. * Fix for issue #21.
* Reorganized aliases file with some additions. * Reorganized aliases file with some additions.
* Initial-values updated. * Initial-values updated.
* Updated CssCrush::string method to correctly handle import statements. * Updated `CssCrush::string` method to correctly handle import statements.


1.4 (24th January 2012) 1.4 (24th January 2012)
--- ---
* Added initial-keyword plugin (shim for the CSS3 keyword). * Added initial-keyword plugin (shim for the CSS3 keyword).
* Added inline method (Issue #18). * Added inline method (Issue #18).
* Added ability to escape declarations from aliasing or plugins by prefixing with tilde. * Added ability to escape declarations from aliasing or plugins by prefixing with tilde.
* Added procedural style public API to mirror the static class API. * Added procedural style public API to mirror the static class API.
* Deprecated @variables syntax for @define. @variables still supported. * Deprecated `@variables` directive for `@define`. @variables still supported for next few releases.
* Adjusted color functions to accept a space delimiter (as well as comma) in the arguments list. * Adjusted color functions to accept a space delimiter (as well as comma) in the arguments list.
* Surpressed some benign PHP warning messages. * Surpressed some benign PHP warning messages.
* Some internal cleaning up. * Some internal cleaning up.
Expand All @@ -120,7 +132,7 @@
1.3.6 (9th November 2011) 1.3.6 (9th November 2011)
----- -----
* Improved color functions. * Improved color functions.
* Added a-adjust function for altering a color's opacity. * Added `a-adjust()` function for altering a color's opacity.
* Deprecated hsl-adjust function (you can use nested color functions instead). * Deprecated hsl-adjust function (you can use nested color functions instead).
* Added the ability to use local versions of alias and plugin files so pull updates don't clobber local settings. * Added the ability to use local versions of alias and plugin files so pull updates don't clobber local settings.


Expand Down Expand Up @@ -158,7 +170,7 @@


1.3 (20th September 2011) 1.3 (20th September 2011)
--- ---
* Added the public function CssCrush::string for processing raw strings of CSS. * Added the public function `CssCrush::string` for processing raw strings of CSS.
* Added color functions. * Added color functions.
* Added aliases for IE10. * Added aliases for IE10.


Expand All @@ -170,7 +182,7 @@
--- ---
* Added support for global variables. * Added support for global variables.
* Added support for variable interpolation within string literals. * Added support for variable interpolation within string literals.
* Added 'tag' method for outputting an html link tag instead of returning a filename. * Added `CssCrush::tag` method for outputting an html link tag instead of returning a filename.
* Added values aliases, dynamic 'runtime' variables. * Added values aliases, dynamic 'runtime' variables.
* Added RGBA macro. * Added RGBA macro.
* Added IE clip macro. * Added IE clip macro.
Expand Down
25 changes: 9 additions & 16 deletions CssCrush.php
@@ -1,24 +1,18 @@
<?php <?php
/** /**
* *
* CSS Crush * Bootstrap file with autoloader.
* Extensible CSS preprocessor. *
* */
* @version 1.9
* @link https://github.com/peteboere/css-crush
* @license http://www.opensource.org/licenses/mit-license.php (MIT)
* @copyright (c) 2010-2013 Pete Boere
*/

function csscrush_autoload ( $class ) { function csscrush_autoload ( $class ) {


// Only autoload classes with the library prefix. // Only autoload classes with the library prefix.
if ( stripos( $class, 'csscrush' ) !== 0 ) { if ( stripos( $class, 'csscrush' ) !== 0 ) {
return; return;
} }
$class = ltrim( substr( $class, 8 ), '_' );


// Tolerate some cases of lowercasing from external use. // Tolerate some cases of lowercasing.
$class = str_ireplace( 'csscrush', 'CssCrush', $class );
$subpath = implode( '/', array_map( 'ucfirst', explode( '_', $class ) ) ); $subpath = implode( '/', array_map( 'ucfirst', explode( '_', $class ) ) );


require_once dirname( __FILE__ ) . "/lib/$subpath.php"; require_once dirname( __FILE__ ) . "/lib/$subpath.php";
Expand All @@ -27,7 +21,6 @@ function csscrush_autoload ( $class ) {
spl_autoload_register( 'csscrush_autoload' ); spl_autoload_register( 'csscrush_autoload' );




// Core.php will also be PSR-0 autoloaded with API changes in v2.x // Core.php will also be autoloaded with API changes in v2.x.
require_once 'lib/Core.php'; require_once 'lib/CssCrush/Core.php';

require_once 'lib/functions.php';
CssCrush::init( __FILE__ );
2 changes: 1 addition & 1 deletion LICENSE.txt
@@ -1,4 +1,4 @@
Copyright (c) 2010-2012 Pete Boere Copyright (c) 2010-2013 Pete Boere


Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:


Expand Down
1 change: 0 additions & 1 deletion Prepend.css
Expand Up @@ -38,5 +38,4 @@ to every output file.
serif: $( times ); serif: $( times );
sans-serif: $( arial ); sans-serif: $( arial );
monospace: $( courier ); monospace: $( courier );

} }
2 changes: 1 addition & 1 deletion lib/ArgList.php → lib/CssCrush/ArgList.php
Expand Up @@ -18,7 +18,7 @@ class CssCrush_ArgList implements Countable
public function __construct ( $str ) public function __construct ( $str )
{ {
// Parse all arg function calls in the passed string, callback creates default values // Parse all arg function calls in the passed string, callback creates default values
CssCrush_Function::executeCustomFunctions( $str, CssCrush_Function::executeOnString( $str,
CssCrush_Regex::$patt->argFunction, array( CssCrush_Regex::$patt->argFunction, array(
'arg' => array( $this, 'store' ) 'arg' => array( $this, 'store' )
)); ));
Expand Down
File renamed without changes.
File renamed without changes.
24 changes: 9 additions & 15 deletions lib/Core.php → lib/CssCrush/Core.php
Expand Up @@ -6,24 +6,24 @@
*/ */
class CssCrush class CssCrush
{ {
const VERSION = '1.9';

// Global settings. // Global settings.
static public $config; static public $config;


// The current active process. // The current active process.
static public $process; static public $process;


// Init called once manually post class definition. // Init called once manually post class definition.
static public function init ( $seed_file ) static public function init ()
{ {
self::$config = new stdclass(); self::$config = new stdclass();


// Path to this installation. // Path to the project root folder.
self::$config->location = dirname( $seed_file ); self::$config->location = dirname(dirname(dirname(__FILE__)));


// Get version ID from seed file. // Establish version id.
$seed_file_contents = file_get_contents( $seed_file ); self::$config->version = new CssCrush_Version( self::VERSION );
$match_count = preg_match( '~@version\s+([\d\.\w-]+)~', $seed_file_contents, $version_match );
self::$config->version = $match_count ? new CssCrush_Version( $version_match[1] ) : null;


// Set the docRoot reference. // Set the docRoot reference.
self::setDocRoot(); self::setDocRoot();
Expand Down Expand Up @@ -90,14 +90,6 @@ static public function init ( $seed_file )


// Include and register stock formatters. // Include and register stock formatters.
require_once self::$config->location . '/misc/formatters.php'; require_once self::$config->location . '/misc/formatters.php';

// Include the procedural API functions.
require_once self::$config->location . '/misc/functions.php';

// Initialise other classes.
CssCrush_Regex::init();
CssCrush_Function::init();
CssCrush_PostAliasFix::init();
} }


static protected function setDocRoot ( $doc_root = null ) static protected function setDocRoot ( $doc_root = null )
Expand Down Expand Up @@ -545,3 +537,5 @@ static public function runStat ( $name )
} }
} }
} }

CssCrush::init();
4 changes: 3 additions & 1 deletion lib/Declaration.php → lib/CssCrush/Declaration.php
Expand Up @@ -27,6 +27,7 @@ public function __construct ( $prop, $value, $contextIndex = 0 )
// Check the input. // Check the input.
if ( $prop === '' || $value === '' || $value === null ) { if ( $prop === '' || $value === '' || $value === null ) {
$this->isValid = false; $this->isValid = false;

return; return;
} }


Expand Down Expand Up @@ -55,12 +56,13 @@ public function __construct ( $prop, $value, $contextIndex = 0 )
// Ignore declarations with null css values. // Ignore declarations with null css values.
if ( $value === false || $value === '' ) { if ( $value === false || $value === '' ) {
$this->isValid = false; $this->isValid = false;

return; return;
} }


// Apply custom functions. // Apply custom functions.
if ( ! $skip ) { if ( ! $skip ) {
CssCrush_Function::executeCustomFunctions( $value ); CssCrush_Function::executeOnString( $value );
} }


// Capture all remaining paren pairs. // Capture all remaining paren pairs.
Expand Down
File renamed without changes.
File renamed without changes.
4 changes: 3 additions & 1 deletion lib/Function.php → lib/CssCrush/Function.php
Expand Up @@ -30,7 +30,7 @@ static public function setMatchPatt ()
self::$functionPatt = CssCrush_Regex::createFunctionMatchPatt( array_keys( self::$customFunctions ), true ); self::$functionPatt = CssCrush_Regex::createFunctionMatchPatt( array_keys( self::$customFunctions ), true );
} }


static public function executeCustomFunctions ( &$str, $patt = null, $process_callback = null, $property = null ) static public function executeOnString ( &$str, $patt = null, $process_callback = null, $property = null )
{ {
// No bracketed expressions, early return. // No bracketed expressions, early return.
if ( false === strpos( $str, '(' ) ) { if ( false === strpos( $str, '(' ) ) {
Expand Down Expand Up @@ -217,3 +217,5 @@ function csscrush_fn__a_adjust ( $input ) {
list( $color, $a ) = array_pad( CssCrush_Function::parseArgs( $input, true ), 2, 0 ); list( $color, $a ) = array_pad( CssCrush_Function::parseArgs( $input, true ), 2, 0 );
return CssCrush_Function::colorAdjust( $color, array( 0, 0, 0, $a ) ); return CssCrush_Function::colorAdjust( $color, array( 0, 0, 0, $a ) );
} }

CssCrush_Function::init();
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
1 change: 1 addition & 0 deletions lib/PostAliasFix.php → lib/CssCrush/PostAliasFix.php
Expand Up @@ -114,3 +114,4 @@ function csscrush__post_alias_fix_radialgradients ( $declaration_copies, $fn_nam
} }
} }


CssCrush_PostAliasFix::init();
6 changes: 3 additions & 3 deletions lib/Process.php → lib/CssCrush/Process.php
Expand Up @@ -484,7 +484,7 @@ protected function calculateVariables ()


// Variable values can be escaped from function parsing with a tilde prefix. // Variable values can be escaped from function parsing with a tilde prefix.
if ( strpos( $value, '~' ) !== 0 ) { if ( strpos( $value, '~' ) !== 0 ) {
CssCrush_Function::executeCustomFunctions( $value ); CssCrush_Function::executeOnString( $value );
} }
} }
} }
Expand Down Expand Up @@ -519,7 +519,7 @@ static protected function placeVariables ( &$value )
if ( strpos( $value, '$(' ) !== false ) { if ( strpos( $value, '$(' ) !== false ) {


// Variables with default value. // Variables with default value.
CssCrush_Function::executeCustomFunctions( $value, $regex->varFunctionStart, CssCrush_Function::executeOnString( $value, $regex->varFunctionStart,
array( '$' => array( 'CssCrush_Process', 'cb_placeVariablesWithDefault' ) ) ); array( '$' => array( 'CssCrush_Process', 'cb_placeVariablesWithDefault' ) ) );


// Assume at least 1 replace. // Assume at least 1 replace.
Expand Down Expand Up @@ -735,7 +735,7 @@ protected function processRules ()
$rule->addFunctionAliases(); $rule->addFunctionAliases();
} }
if ( $aliases[ 'declarations' ] ) { if ( $aliases[ 'declarations' ] ) {
$rule->addPropertyValueAliases(); $rule->addDeclarationAliases();
} }


CssCrush_Hook::run( 'rule_postalias', $rule ); CssCrush_Hook::run( 'rule_postalias', $rule );
Expand Down
3 changes: 3 additions & 0 deletions lib/Regex.php → lib/CssCrush/Regex.php
Expand Up @@ -119,3 +119,6 @@ static public function createFunctionMatchPatt ( $list, $include_math_function =
return '~(?<![\w-])(' . implode( '|', $list ) . ')' . $question . '\(~iS'; return '~(?<![\w-])(' . implode( '|', $list ) . ')' . $question . '\(~iS';
} }
} }

CssCrush_Regex::init();

0 comments on commit 0541654

Please sign in to comment.