Author: jezdez
Date: 2010-02-01 08:16:01 -0600 (Mon, 01 Feb 2010)
New Revision: 12371

Added:
   django/trunk/django/contrib/admin/media/js/LICENSE-JQUERY.txt
   django/trunk/django/contrib/admin/media/js/compress.py
Log:
Being a good citizen, adding the jQuery license and a command line script to 
easily minify the jQuery based scripts.

Added: django/trunk/django/contrib/admin/media/js/LICENSE-JQUERY.txt
===================================================================
--- django/trunk/django/contrib/admin/media/js/LICENSE-JQUERY.txt               
                (rev 0)
+++ django/trunk/django/contrib/admin/media/js/LICENSE-JQUERY.txt       
2010-02-01 14:16:01 UTC (rev 12371)
@@ -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.
\ No newline at end of file

Added: django/trunk/django/contrib/admin/media/js/compress.py
===================================================================
--- django/trunk/django/contrib/admin/media/js/compress.py                      
        (rev 0)
+++ django/trunk/django/contrib/admin/media/js/compress.py      2010-02-01 
14:16:01 UTC (rev 12371)
@@ -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()

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en.

Reply via email to