torchbox/wagtail — pull request #535 by gasman (2014-08-12 11:57:15+00:00)
Title: Refactor admin menu API to allow menu items to have bundled JS

This is a prelude for the work on #399 to add a 'settings' item to the menu. This PR adds a new hook `register_admin_menu_item` which is triggered on startup to build a 'master' list of menu items. This improves on the current `construct_main_menu` mechanism in two ways:

* Menu items can now define their own JS declarations; since the master list is a static list, `./manage.py compress` can pick these up and incorporate them into the compressed/cached JS. This means that the explorer and settings menu JS can be decoupled from core.js, and makes it possible for third-party apps to add JS behaviours to menu items without hacking wagtailadmin.

* It's (probably - I haven't formally measured) a marginal performance boost, since we're not constructing MenuItem objects and reversing URLs on every request.