Permalink
Browse files

Removed superfluous outer containing directory (update your include p…

…aths)

Renamed 'macros' to the more general 'plugins' and split them into their own files
Added changelog
  • Loading branch information...
peteboere committed Oct 29, 2011
1 parent 8d424ea commit f2c144bec4ab464aac92a85cc977e9931cc5dea4
View
@@ -0,0 +1,66 @@
+1.3.4 (8d424ea)
+---------------
+Added output_filename option
+Added vendor_target option
+Renamed 'macros' to the more general 'plugins' and split them into their own files
+Removed superfluous outer containing directory (update your include paths)
+
+
+1.3.3 (c68012b)
+---------------
+Fixed regression with absolute URL file imports (issue #12)
+Fixed minification bug (issue #13)
+
+
+1.3.2 (c68012b)
+---------------
+Updated variable syntax
+Fixed minification bug
+
+
+1.3.1 (07fabec)
+---------------
+Added support for svg and svgz data uris
+Added animation shorthand alias
+Added user-select alias
+
+
+1.3 (07fabec)
+-------------
+Added the public function CssCrush::string for processing raw strings of CSS
+Added color functions
+Added aliases for IE10
+
+
+1.2 (b405f9e)
+-------------
+Rewritten the file importer
+
+
+1.1 (0d2463e)
+-------------
+Added global variables support
+Added support for variable interpolation within string literals
+Added 'tag' method for outputting an html link tag instead of returning a filename
+Added values aliases, dynamic 'runtime' variables
+Added RGBA macro
+Added IE clip macro
+Added data uri function
+Minor correction to WAMP support
+Minor fix to rule API
+
+
+1.0 (360f587)
+-------------
+Major refactoring
+Custom functions
+Optional boilerplate
+Double colon syntax shim
+Resolved document root issues
+Minification improvements
+
+
+0.9 (7de4a6c)
+-------------
+Initial commit
+
@@ -1,3 +1,7 @@
+;----------------------------------------------------------------------------
+; Enable/disable aliases by commenting them (with semicolons)
+;----------------------------------------------------------------------------
+
;----------------------------------------------------------------------------
;-- Property aliases
File renamed without changes.
@@ -4,7 +4,7 @@
* CSS Crush
* Extensible CSS preprocessor
*
- * @version 1.3.3
+ * @version 1.3.4
* @license http://www.opensource.org/licenses/mit-license.php (MIT)
* @copyright Copyright 2010-2011 Pete Boere
*
View
@@ -0,0 +1,21 @@
+;----------------------------------------------------------------
+; Enable/disable plugins by commenting them (with semicolons)
+;----------------------------------------------------------------
+
+; min-height shim for IE < 7
+plugins[] = ie-min-height.php
+
+; inline-block shim for IE < 8
+plugins[] = ie-inline-block.php
+
+; clip property shim for IE < 8
+plugins[] = ie-clip.php
+
+; IE filter shorthand
+plugins[] = ie-filter.php
+
+; Opaque fallback colors for clients that don't support RGBA
+plugins[] = rgba-fallback.php
+
+; HSL shim - converts HSL values to hex codes
+plugins[] = hsl-to-hex.php
@@ -1,210 +0,0 @@
-<?php
-
-################################################################################################
-# Comment out/in as required
-
-// IE 6 shims
-CssCrush::addRuleMacro( 'csscrush_minheight' );
-
-// IE 6/7 shims
-CssCrush::addRuleMacro( 'csscrush_clip' );
-CssCrush::addRuleMacro( 'csscrush_display_inlineblock' );
-
-// IE filter
-CssCrush::addRuleMacro( 'csscrush_filter' );
-
-// RGBA fallback
-CssCrush::addRuleMacro( 'csscrush_rgba' );
-
-// HSL for all browsers
-CssCrush::addRuleMacro( 'csscrush_hsl' );
-
-
-################################################################################################
-
-/**
- * Simulate inline-block in IE < 8
- *
- * Before:
- * display: inline-block;
- *
- * After:
- * display: inline-block;
- * *display: inline;
- * *zoom: 1;
- */
-function csscrush_display_inlineblock ( CssCrush_Rule $rule ) {
- if ( $rule->propertyCount( 'display' ) < 1 ) {
- return;
- }
- $new_set = array();
- foreach ( $rule as $declaration ) {
- $new_set[] = $declaration;
- $is_display = $declaration->property === 'display';
- if ( !$is_display or $is_display and $declaration->value !== 'inline-block' ) {
- continue;
- }
- $new_set[] = $rule->createDeclaration( '*display', 'inline' );
- $new_set[] = $rule->createDeclaration( '*zoom', 1 );
- }
- $rule->declarations = $new_set;
-}
-
-/**
- * Fix min-height in IE 6
- *
- * Before:
- * min-height: 100px;
- *
- * After:
- * min-height: 100px;
- * _height: 100px;
- */
-function csscrush_minheight ( CssCrush_Rule $rule ) {
- if ( $rule->propertyCount( 'min-height' ) < 1 ) {
- return;
- }
- $new_set = array();
- foreach ( $rule as $declaration ) {
- $new_set[] = $declaration;
- if ( $declaration->property !== 'min-height' ) {
- continue;
- }
- $new_set[] = $rule->createDeclaration( '_height', $declaration->value );
- }
- $rule->declarations = $new_set;
-}
-
-/**
- * Fix clip syntax for IE < 8
- *
- * Before:
- * clip: rect(1px,1px,1px,1px);
- *
- * After:
- * clip: rect(1px,1px,1px,1px);
- * *clip: rect(1px 1px 1px 1px);
- */
-function csscrush_clip ( CssCrush_Rule $rule ) {
- // Assume it's been dealt with if the property occurs more than once
- if ( $rule->propertyCount( 'clip' ) !== 1 ) {
- return;
- }
- $new_set = array();
- foreach ( $rule as $declaration ) {
- $new_set[] = $declaration;
- if ( $declaration->property !== 'clip' ) {
- continue;
- }
- $new_set[] = $rule->createDeclaration(
- '*clip', str_replace( ',', ' ', $rule->getDeclarationValue( $declaration ) ) );
- }
- $rule->declarations = $new_set;
-}
-
-/**
- * IE filter without the cruft
- */
-function csscrush_filter ( CssCrush_Rule $rule ) {
- if ( $rule->propertyCount( 'filter' ) < 1 ) {
- return;
- }
- $filter_prefix = 'progid:DXImageTransform.Microsoft.';
- $new_set = array();
- foreach ( $rule as $declaration ) {
- if ( $declaration->property !== 'filter' ) {
- $new_set[] = $declaration;
- continue;
- }
- $list = array_map( 'trim', explode( ',', $declaration->value ) );
- foreach ( $list as &$item ) {
- if (
- strpos( $item, $filter_prefix ) !== 0 and
- strpos( $item, 'alpha' ) !== 0 // Shortcut syntax permissable on alpha
- ) {
- $item = $filter_prefix . ucfirst( $item );
- }
- }
- $declaration->value = implode( ',', $list );
- if ( !$rule->propertyCount( 'zoom' ) ) {
- // Filters need hazLayout
- $new_set[] = $rule->createDeclaration( 'zoom', 1 );
- }
- $new_set[] = $declaration;
- $new_set[] = $rule->createDeclaration( '-ms-filter', "\"$declaration->value\"" );
- }
- $rule->declarations = $new_set;
-}
-
-/**
- * RGBA fallback
- * Only works with background shorthand IE < 8
- * (http://css-tricks.com/2151-rgba-browser-support/)
- *
- * Before:
- * background: rgba(0,0,0,.5);
- *
- * After:
- * background: rgb(0,0,0);
- * background: rgba(0,0,0,.5);
- */
-function csscrush_rgba ( CssCrush_Rule $rule ) {
- $props = array_keys( $rule->properties );
-
- // Determine which properties apply
- $rgba_props = array();
- foreach ( $props as $prop ) {
- if ( $prop === 'background' or strpos( $prop, 'color' ) !== false ) {
- $rgba_props[] = $prop;
- }
- }
- if ( empty( $rgba_props ) ) {
- return;
- }
-
- $new_set = array();
- foreach ( $rule as $declaration ) {
- $is_viable = in_array( $declaration->property, $rgba_props );
- if (
- !$is_viable or
- $is_viable and !preg_match( '!^rgba___p\d+___$!', $declaration->value )
- ) {
- $new_set[] = $declaration;
- continue;
- }
- // Create rgb value from rgba
- $raw_value = $rule->getDeclarationValue( $declaration );
- $raw_value = substr( $raw_value, 5, strlen( $raw_value ) - 1 );
- list( $r, $g, $b, $a ) = explode( ',', $raw_value );
-
- // Add rgb value to the stack, followed by rgba
- $new_set[] = $rule->createDeclaration( $declaration->property, "rgb($r,$g,$b)" );
- $new_set[] = $declaration;
- }
- $rule->declarations = $new_set;
-}
-
-/**
- * HSL shim
- * Converts HSL values into hex code that works in all browsers
- *
- * Before:
- * color: hsl( 100, 50%, 50% )
- *
- * After:
- * color: #6abf40
- */
-function csscrush_hsl ( CssCrush_Rule $rule ) {
- foreach ( $rule as &$declaration ) {
- if ( !empty( $declaration->functions ) and in_array( 'hsl', $declaration->functions ) ) {
- while ( preg_match( '!hsl(___p\d+___)!', $declaration->value, $m ) ) {
- $full_match = $m[0];
- $token = $m[1];
- $hsl = trim( $rule->parens[ $token ], '()' );
- $hsl = array_map( 'trim', explode( ',', $hsl ) );
- $hex = CssCrush_Color::cssHslToHex( $hsl );
- $declaration->value = str_replace( $full_match, $hex, $declaration->value );
- }
- }
- }
-}
File renamed without changes.
@@ -126,10 +126,23 @@ protected static function loadAssets () {
trigger_error( __METHOD__ . ": Aliases file not found.\n", E_USER_NOTICE );
}
- // Load macros file if it exists
- $macros_file = self::$location . '/' . __CLASS__ . '.macros.php';
- if ( file_exists( $macros_file ) ) {
- require_once $macros_file;
+ // Load plugins
+ $plugins_file = self::$location . '/' . __CLASS__ . '.plugins';
+ if ( file_exists( $plugins_file ) ) {
+ if ( $result = parse_ini_file( $plugins_file ) ) {
+ foreach ( $result[ 'plugins' ] as $plugin_file ) {
+ $path = self::$location . "/plugins/$plugin_file";
+ if ( file_exists( $path ) ) {
+ require_once $path;
+ }
+ else {
+ trigger_error( __METHOD__ . ": Plugin file $plugin_file not found.\n", E_USER_NOTICE );
+ }
+ }
+ }
+ else {
+ trigger_error( __METHOD__ . ": Plugins file was not parsed correctly (syntax error).\n", E_USER_NOTICE );
+ }
}
}
@@ -457,8 +470,8 @@ protected static function parseOptions ( $options ) {
'cache' => true,
// Output file. Defaults the host-filename
'output_file' => null,
- // Vendor target. Only apply prefixes for a specific vendor, set false for no prefixes
- 'vendor_target' => null,
+ // Vendor target. Only apply prefixes for a specific vendor, set to 'none' for no prefixes
+ 'vendor_target' => 'all',
// Keeping track of global vars internally
'_globalVars' => self::$globalVars,
);
@@ -473,14 +486,14 @@ protected static function pruneAliases () {
// If a vendor target is given, we prune the aliases array
$vendor = self::$options[ 'vendor_target' ];
- // For expicit false vendor argument turn off aliases
- if ( $vendor === false ) {
+ // For expicit 'none' argument turn off aliases
+ if ( 'none' === $vendor ) {
self::$aliases = null;
return;
}
- // Null vendor argument, use all aliases as normal
- if ( empty( $vendor ) ) {
+ // Default vendor argument, use all aliases as normal
+ if ( 'all' === $vendor ) {
return;
}
@@ -1010,7 +1023,7 @@ protected static function cb_printRule ( $match ) {
$block = implode( ";\n\t", $block );
// Include pre rule comments
$comments = implode( "\n", $rule->comments );
- return "$comments\n$selectors {\n\t$block;\n}\n";
+ return "$comments\n$selectors {\n\t$block;\n\t}\n";
}
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Oops, something went wrong.

0 comments on commit f2c144b

Please sign in to comment.