hyde / hyde-old

Static website generator inspired by Jekyll
http://ringce.com/hyde
MIT License
876 stars 82 forks source link

issue with yuicompressor and clevercss #12

Open solsticedhiver opened 14 years ago

solsticedhiver commented 14 years ago

hi. i was trying to use a clevercss template in media/css and after ./hyde.py -g, i noticed only a .ccss and a .ccss.z-tmp in my deploy/media/css

it seems the command running the yuicompressor failed because the file deploy/media/css/base.ccss.z-tmp contains:

Usage: java -jar yuicompressor-x.y.z.jar [options] [input file]

Global Options
  -h, --help                Displays this information
  --type            Specifies the type of the input file
  --charset        Read the input file using 
  --line-break      Insert a line break after the specified column number
  -v, --verbose             Display informational messages and warnings
  -o                  Place the output into . Defaults to stdout.

JavaScript Options
  --nomunge                 Minify only, do not obfuscate
  --preserve-semi           Preserve all semicolons
  --disable-optimizations   Disable all micro optimizations

If no input file is specified, it defaults to stdin. In this case, the 'type'
option is required. Otherwise, the 'type' option is required only if the input
file extension is neither 'js' nor 'css'.

it seems to fail because the input file has .ccss extension one need to use --type css if the extension is not .css

there seems to be an issue with the pipe processing of media processor.

base.ccss is converted to base.ccss by clevercss (wouldn't it be better to be base.css), then yuicompressor use base.ccss but fails because the extension is not .js or .css.

also, if i remove the yuicompressor from the pipe for ccss in my settings.py, i end up with a base.ccss in my deploy/media/css, that file containing css and not clevercss, and then should have been called base.css.

ghost commented 13 years ago

This can be fixed by adding a simple check to hydeengine.media_processors.YUICompressor (since that's usually the last processor in each "chain" in the MEDIA_PROCESSORS setting), whereby if the given file's extension is one of ccss, sass, less, or hss, it sets a local variable was_processed to True and sets thecommand to the usual command string but with --type=css after the first %s . thecommand would then be used as the argument to commands.get_status_output . The value of was_processed would then be checked once again, and if it was set to True, the temp file would be moved to an altered filename, with the extension properly altered. Otherwise, it would write back into the just-deleted source file as usual.