• 
      

    Add support for defining, packaging and using static media bundles.

    Review Request #4757 — Created Oct. 15, 2013 and submitted — Latest diff uploaded

    Information

    Djblets
    master

    Reviewers

    Add support for defining, packaging and using static media bundles.

    Static media in extensions has been pretty bad. It took work on the
    developer's side to get static media installed and used, and there was
    no consistency.

    Now, the extension framework handles all this.

    Extensions can define css_bundles and js_bundles attributes. These
    follow the Django Pipeline bundle format, with all paths being relative
    to the extension's static directory. The extension framework will
    handle transforming these into paths that can be looked up using the new
    static finders, which will find them correctly whether they're in a
    'setup.py develop' environment, or from an installed package.

    Bundle names won't conflict, as they'll also be transformed to be
    namespaced by the extension ID.

    If a bundle's name is "default", it will appear on all pages by default
    (assuming thet template for the page loads extension bundles). This is
    the replacement for the newly introduced js_files list.

    The new ext_compressed_js and ext_compressed_css template tags allow
    other bundles to be loaded. They're passed the extension and bundle
    name. TemplateHook now passes the extension to the context of any
    rendered templates, so these can be passed in.

    This improves packaging as well. A project implementing the extension
    support subclasses djblets.extensions.packaging.BuildStaticFiles and
    defines a couple properties, and then a setup.py just needs to fetch the
    cmdclasses provided by the project. Once done, any defined bundles in
    any extension will be automatically run through Pipeline and placed into
    the resulting package (or installed, if using setup.py install). This
    makes it extremely simple to deal with static media in an extension.

    Tested locally with an extension in develop mode and as an installed
    package.

    Tested with a devel server and a "production" server.

    All tests were with a related Review Board change.

    Unit tests pass.