Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Being a good citizen, adding the jQuery license and a command line sc…

…ript to easily minify the jQuery based scripts.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@12371 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit 816fced5d728a13304a9d8b41f86a440c549b2f5 1 parent f839736
Jannis Leidel authored February 01, 2010
20  django/contrib/admin/media/js/LICENSE-JQUERY.txt
... ...
@@ -0,0 +1,20 @@
  1
+Copyright (c) 2010 John Resig, http://jquery.com/
  2
+ 
  3
+Permission is hereby granted, free of charge, to any person obtaining
  4
+a copy of this software and associated documentation files (the
  5
+"Software"), to deal in the Software without restriction, including
  6
+without limitation the rights to use, copy, modify, merge, publish,
  7
+distribute, sublicense, and/or sell copies of the Software, and to
  8
+permit persons to whom the Software is furnished to do so, subject to
  9
+the following conditions:
  10
+ 
  11
+The above copyright notice and this permission notice shall be
  12
+included in all copies or substantial portions of the Software.
  13
+ 
  14
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  15
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  16
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  17
+NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
  18
+LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
  19
+OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
  20
+WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
45  django/contrib/admin/media/js/compress.py
... ...
@@ -0,0 +1,45 @@
  1
+#!/usr/bin/env python
  2
+import os
  3
+import optparse
  4
+import subprocess
  5
+import sys
  6
+
  7
+here = os.path.dirname(__file__)
  8
+
  9
+def main():
  10
+    usage = "usage: %prog [file1..fileN]"
  11
+    description = """With no file paths given this script will automatically
  12
+compress all jQuery based files of the admin app."""
  13
+    parser = optparse.OptionParser(usage, description=description)
  14
+    parser.add_option("-c", dest="compiler", default="~/bin/compiler.jar",
  15
+                      help="path to closure compiler jar file")
  16
+    parser.add_option("-v", "--verbose",
  17
+                      action="store_true", dest="verbose")
  18
+    parser.add_option("-q", "--quiet",
  19
+                      action="store_false", dest="verbose")
  20
+    (options, args) = parser.parse_args()
  21
+
  22
+    compiler = os.path.expanduser(options.compiler)
  23
+    if not os.path.exists(compiler):
  24
+        sys.exit("Compiler jar file %s not found. Please use the -c option to specify the path." % compiler)
  25
+
  26
+    if not args:
  27
+        if options.verbose:
  28
+            sys.stdout.write("No filenames given; defaulting to admin scripts\n")
  29
+        args = [os.path.join(here, f) for f in ["actions.js", "collapse.js", "inlines.js"]]
  30
+
  31
+    for arg in args:
  32
+        if not arg.endswith(".js"):
  33
+            arg = arg + ".js"
  34
+        to_compress = os.path.expanduser(arg)
  35
+        if os.path.exists(to_compress):
  36
+            to_compress_min = "%s.min.js" % "".join(arg.rsplit(".js"))
  37
+            cmd = "java -jar %s --js %s --js_output_file %s" % (compiler, to_compress, to_compress_min)
  38
+            if options.verbose:
  39
+                sys.stdout.write("Running: %s\n" % cmd)
  40
+            subprocess.call(cmd.split())
  41
+        else:
  42
+            sys.stdout.write("File %s not found. Sure it exists?\n" % to_compress)
  43
+
  44
+if __name__ == '__main__':
  45
+    main()

0 notes on commit 816fced

Please sign in to comment.
Something went wrong with that request. Please try again.