Created
October 28, 2011 02:17
-
-
Save baryon/1321471 to your computer and use it in GitHub Desktop.
YUICompress for BBEdit 10
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python2.7 | |
""" | |
YUICompress for BBEdit 10 | |
A quick script to install into your `~/Library/Application Support/BBEdit/Scripts` folder. | |
This runs yuicompressor (requires yuicompressor to be installed at `/usr/local/bin` - | |
try ``/usr/bin/easy_install yuicompressor``) | |
How it works | |
1.Copy this script to a new file named 'YUICompress' and install the plugin. | |
2.Open the file you wish to compress (css or js). | |
3.Select YUICompress from the Scripts menu. | |
You should now have a compressed file with the name {filename}.min.{js|css} | |
in the same directory where the uncompressed file is located. | |
Author Long LI (lilong@gmail.com) | |
http://www.bbshare.com | |
Google Toolbar fo Safari | |
No! Flash for Safari & Chrome | |
""" | |
import os | |
import re | |
import sys | |
doc_file = os.environ['BB_DOC_PATH'] | |
yuicompressor = "/usr/local/bin/yuicompressor" | |
ext = '.css$|.js$' | |
if re.search(ext, doc_file, re.I): | |
newext = '.min.' | |
ytype = doc_file.split('.')[-1] | |
os.system("%s --type %s --charset utf8 -o '%s%s' '%s'" % | |
(yuicompressor, ytype, re.sub(ext,newext,doc_file,flags=re.I), ytype, doc_file)) | |
sys.exit(1) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment