mirror of https://github.com/django/django.git
Being a good citizen, adding the jQuery license and a command line script to easily minify the jQuery based scripts.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@12371 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
f839736c60
commit
816fced5d7
|
@ -0,0 +1,20 @@
|
|||
Copyright (c) 2010 John Resig, http://jquery.com/
|
||||
|
||||
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:
|
||||
|
||||
The above copyright notice and this permission notice shall be
|
||||
included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
@ -0,0 +1,45 @@
|
|||
#!/usr/bin/env python
|
||||
import os
|
||||
import optparse
|
||||
import subprocess
|
||||
import sys
|
||||
|
||||
here = os.path.dirname(__file__)
|
||||
|
||||
def main():
|
||||
usage = "usage: %prog [file1..fileN]"
|
||||
description = """With no file paths given this script will automatically
|
||||
compress all jQuery based files of the admin app."""
|
||||
parser = optparse.OptionParser(usage, description=description)
|
||||
parser.add_option("-c", dest="compiler", default="~/bin/compiler.jar",
|
||||
help="path to closure compiler jar file")
|
||||
parser.add_option("-v", "--verbose",
|
||||
action="store_true", dest="verbose")
|
||||
parser.add_option("-q", "--quiet",
|
||||
action="store_false", dest="verbose")
|
||||
(options, args) = parser.parse_args()
|
||||
|
||||
compiler = os.path.expanduser(options.compiler)
|
||||
if not os.path.exists(compiler):
|
||||
sys.exit("Compiler jar file %s not found. Please use the -c option to specify the path." % compiler)
|
||||
|
||||
if not args:
|
||||
if options.verbose:
|
||||
sys.stdout.write("No filenames given; defaulting to admin scripts\n")
|
||||
args = [os.path.join(here, f) for f in ["actions.js", "collapse.js", "inlines.js"]]
|
||||
|
||||
for arg in args:
|
||||
if not arg.endswith(".js"):
|
||||
arg = arg + ".js"
|
||||
to_compress = os.path.expanduser(arg)
|
||||
if os.path.exists(to_compress):
|
||||
to_compress_min = "%s.min.js" % "".join(arg.rsplit(".js"))
|
||||
cmd = "java -jar %s --js %s --js_output_file %s" % (compiler, to_compress, to_compress_min)
|
||||
if options.verbose:
|
||||
sys.stdout.write("Running: %s\n" % cmd)
|
||||
subprocess.call(cmd.split())
|
||||
else:
|
||||
sys.stdout.write("File %s not found. Sure it exists?\n" % to_compress)
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
Loading…
Reference in New Issue