Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Fixed #13290 - Added a section about minification of admin JavaScript…

… files to the contributing docs. Thanks to Gabriel Hurley for the report and patch.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@12969 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit b3390fede0286c8ff8ea2c096c7f1ba58bad6db3 1 parent 31f7ff1
Jannis Leidel authored April 13, 2010
7  django/contrib/admin/media/js/compress.py
@@ -9,10 +9,11 @@
9 9
 def main():
10 10
     usage = "usage: %prog [file1..fileN]"
11 11
     description = """With no file paths given this script will automatically
12  
-compress all jQuery based files of the admin app."""
  12
+compress all jQuery-based files of the admin app. Requires the Google Closure
  13
+Compiler library and Java version 6 or later."""
13 14
     parser = optparse.OptionParser(usage, description=description)
14 15
     parser.add_option("-c", dest="compiler", default="~/bin/compiler.jar",
15  
-                      help="path to closure compiler jar file")
  16
+                      help="path to Closure Compiler jar file")
16 17
     parser.add_option("-v", "--verbose",
17 18
                       action="store_true", dest="verbose")
18 19
     parser.add_option("-q", "--quiet",
@@ -21,7 +22,7 @@ def main():
21 22
 
22 23
     compiler = os.path.expanduser(options.compiler)
23 24
     if not os.path.exists(compiler):
24  
-        sys.exit("Closure compiler jar file %s not found. Please use the -c option to specify the path." % compiler)
  25
+        sys.exit("Google Closure compiler jar file %s not found. Please use the -c option to specify the path." % compiler)
25 26
 
26 27
     if not args:
27 28
         if options.verbose:
38  docs/internals/contributing.txt
@@ -433,6 +433,44 @@ translated, here's what to do:
433 433
 
434 434
 .. _Django i18n mailing list: http://groups.google.com/group/django-i18n/
435 435
 
  436
+Submitting javascript patches
  437
+=============================
  438
+
  439
+.. versionadded:: 1.2
  440
+
  441
+Django's admin system leverages the jQuery framework to increase the
  442
+capabilities of the admin interface. In conjunction, there is an emphasis on
  443
+admin javascript performance and minimizing overall admin media file size.
  444
+Serving compressed or "minified" versions of javascript files is considered
  445
+best practice in this regard.
  446
+
  447
+To that end, patches for javascript files should include both the original
  448
+code for future development (e.g. "foo.js"), and a compressed version for
  449
+production use (e.g. "foo.min.js"). Any links to the file in the codebase
  450
+should point to the compressed version.
  451
+
  452
+To simplify the process of providing optimized javascript code, Django
  453
+includes a handy script which should be used to create a "minified" version.
  454
+This script is located at ``/contrib/admin/media/js/compress.py``.
  455
+
  456
+Behind the scenes, ``compress.py`` is a front-end for Google's
  457
+`Closure Compiler`_ which is written in Java. However, the Closure Compiler
  458
+library is not bundled with Django directly, so those wishing to contribute
  459
+complete javascript patches will need to download and install the library
  460
+independently.
  461
+
  462
+The Closure Compiler library requires Java version 6 or higher (Java 1.6 or
  463
+higher on Mac OS X). Note that Mac OS X 10.5 and earlier did not ship with Java
  464
+1.6 by default, so it may be necessary to upgrade your Java installation before
  465
+the tool will be functional. Also note that even after upgrading Java, the
  466
+default `/usr/bin/java` command may remain linked to the previous Java
  467
+binary, so relinking that command may be necessary as well.
  468
+
  469
+Please don't forget to run ``compress.py`` and include the ``diff`` of the
  470
+minified scripts when submitting patches for Django's javascript.
  471
+
  472
+.. _Closure Compiler: http://code.google.com/closure/compiler/
  473
+
436 474
 Django conventions
437 475
 ==================
438 476
 

0 notes on commit b3390fe

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