Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Some updates to the command line application, a little cleaning up

  • Loading branch information...
commit a2c46f8b4d537b02aa6774b190123c696a7b981e 1 parent 0c51ab0
@peteboere authored
View
3  Aliases.ini
@@ -201,6 +201,9 @@
calc[] = -webkit-calc
calc[] = -moz-calc
+ ; Element
+ element[] = -moz-element
+
; Gradients
linear-gradient[] = -webkit-linear-gradient
linear-gradient[] = -moz-linear-gradient
View
34 cli.php
@@ -133,14 +133,6 @@
exit( 1 );
}
-// Check if specified output file is valid before processing
-if ( $output_file ) {
- if ( ! file_exists( $output_file ) ) {
- fwrite( $stdout, "can't find output file\n\n" );
- exit( 0 );
- }
-}
-
##################################################################
## Processing
@@ -159,17 +151,37 @@
$import_context = $input_file ? dirname( realpath( $input_file ) ) : null;
-$output = csscrush::string( $input, $process_opts, $import_context );
+// If there is an import context set it to the document root
+if ( $import_context ) {
+ $old_doc_root = csscrush::$config->docRoot;
+ csscrush::$config->docRoot = $import_context;
+ $process_opts[ 'import_context' ] = $import_context;
+}
+
+// Process the stream
+$output = csscrush::string( $input, $process_opts );
+
+// Reset the document root after processing
+if ( $import_context ) {
+ csscrush::$config->docRoot = $old_doc_root;
+}
##################################################################
## Output
if ( $output_file ) {
- file_put_contents( $output_file, $output );
+ if ( ! @file_put_contents( $output_file, $output ) ) {
+ fwrite( $stdout, "Could not write to path '$output_file'\n" );
+ if ( strpos( $output_file, '~' ) === 0 ) {
+ fwrite( $stdout, "No tilde expansion\n" );
+ }
+ exit( 0 );
+ }
}
else {
- fwrite( $stdout, $output . "\n" );
+ $output .= "\n";
+ fwrite( $stdout, $output );
}
exit( 1 );
View
12 lib/Core.php
@@ -361,17 +361,16 @@ public static function inline ( $file, $options = null, $attributes = array() )
*
* @param string $string CSS text
* @param mixed $options An array of options or null
- * @param string $import_context A context path for imports
* @return string CSS text
*/
- public static function string ( $string, $options = null, $import_context = null ) {
+ public static function string ( $string, $options = null ) {
// Reset for current process
self::reset();
self::getOptions( $options );
// Set the path context if one is given
- if ( $import_context ) {
- self::setPath( $import_context );
+ if ( isset( $options[ 'import_context' ] ) && ! empty( $options[ 'import_context' ] ) ) {
+ self::setPath( $options[ 'import_context' ] );
}
// It's not associated with a real file so we create an 'empty' hostfile object
@@ -380,6 +379,11 @@ public static function string ( $string, $options = null, $import_context = null
// Set the string on the object
$hostfile->string = $string;
+ // Import files may be ignored
+ if ( isset( $options[ 'no_import' ] ) ) {
+ $hostfile->importIgnore = true;
+ }
+
// Collate imports
$stream = csscrush_importer::hostfile( $hostfile );
View
6 lib/Function.php
@@ -335,10 +335,8 @@ public static function css_fn__data_uri ( $input ) {
$mime_type = $allowed_file_extensions[ $file_ext ];
$base64 = base64_encode( file_get_contents( $file ) );
$data_uri = "data:{$mime_type};base64,$base64";
- if ( strlen( $data_uri ) > 32000 ) {
- // Too big for IE
- }
- return "url($data_uri)";
+
+ return "url(\"$data_uri\")";
}
public static function css_fn__h_adjust ( $input ) {
View
6 lib/Importer.php
@@ -64,6 +64,12 @@ public static function hostfile ( $hostfile ) {
$preStatement = substr( $stream, 0, $matchStart );
$postStatement = substr( $stream, $matchEnd );
+ // If just stripping the import statements
+ if ( isset( $hostfile->importIgnore ) ) {
+ $stream = $preStatement . $postStatement;
+ continue;
+ }
+
$url = trim( $match[1][0] );
// Url may be a string token
Please sign in to comment.
Something went wrong with that request. Please try again.