RETIRED, further work has moved to Debian project infrastructure
Go to file
Tyr Johanson fca46ab60f Pre-populate the Angular template cache and allow template overrides
This patch populates the Angular template cache from Django.
This eliminates the need for Angular to do an http get for every HTML
fragment.

In addition, now that we are filling the template cache, this patch
introduces the logic needed to override any Angular template HTML from
the current theme.

How it works:
A new template tag is created called "template_cache_preloads". This
tag is used in _scripts.html to generate a list of text/javascript
script tags, each one containing an Angular "run" method that loads
a template contents into the Angular template cache. The first time
any Horizon page is loaded after server start, the template cache
preloads are computed for the current theme.

The output of this tag is cached for 30 days in Django using the
"cache" tag. Further, that cached result is wrapped in a "compress js"
tag to collapse the individual <script> tags into 1 block of
javascript, and compress like all other javascript Horizon serves to
the client.

Finally, when using offline compression, the compressor evaluates the
nodelist (HTML content) of _scripts.html, notices the compress tag
and builds the template cache preloads for each possible theme. Later,
at runtime, when the preloads are generated for the current theme, the
compressor gets the result from the Django cache, and hashes the
contents to determine which manifest file to serve to the client.
Since the preloads generated at run-time are identical to those
generated off-line, the compressor hash matches an existing manifest
which is served to the client.

Notice that even though the template cache pre-loads are generated
off-line...the template_cache_preloads tag will be executed once
every 30 days anyway. However, since the result matches the off-line
compression, the existing manifest continues to be served to the client.

Finally, this patch ALSO watches for 'post_compress' signals. If it
detects that the angular template preloads have been re-compressed, it
clears the old version from the Django cache.

To test the template caching:
- Run horizon
- View page source
- Notice the new <script type="text/javascript"> tags contained in
  the body (only visible if COMPRESS_ENABLED=False
- Open the javascript inspector
- Load launch instance
- Notice there are no longer http calls to load each HTML fragment
  used by the Angular launch instance

To test the override:
- Set the DEFAULT_THEME='material'
- Create /horizon/openstack_dashboard/themes/material/\
static/templates/framework/widgets/help-panel/help-panel.html
- Set the content to <h1>TEST</h1>
- Run Horizon and open launch instance.
- The help content should contain "TEST"

To test the new template tag:
- set a breakpoint or print in angular.py:template_cache_preloads
  and observe when it is called during off-line or run-time use

Co-Authored-By: Diana Whitten <hurgleburgler@gmail.com>

Implements: blueprint angular-template-overrides
Change-Id: I0e4e2623be58abbc68c6e02b2e9c5d7cdaba8e4d
2016-07-13 15:38:07 -07:00
doc Pre-populate the Angular template cache and allow template overrides 2016-07-13 15:38:07 -07:00
horizon Pre-populate the Angular template cache and allow template overrides 2016-07-13 15:38:07 -07:00
openstack_dashboard Pre-populate the Angular template cache and allow template overrides 2016-07-13 15:38:07 -07:00
releasenotes Pre-populate the Angular template cache and allow template overrides 2016-07-13 15:38:07 -07:00
tools Hotfix the issue with too new Firefox version 2016-06-09 20:04:06 +00:00
.eslintignore bump eslint version to 1.10.3 2016-03-31 14:06:45 +00:00
.eslintrc Disabling warnings of 'quote-props' 2016-05-18 15:04:00 -06:00
.gitignore Update .gitignore for JetBrains(PyCharm) users 2016-06-12 21:24:09 +08:00
.gitreview Add .gitreview and rfc.sh. 2011-10-28 09:50:35 -04:00
.mailmap Update my mailmap 2013-10-25 14:49:23 +08:00
.pylintrc updating run_tests.sh to mimic other openstack projects, pep8, pylint, coverage 2011-08-31 14:41:36 -07:00
.testr.conf Add testr support 2015-12-10 09:45:41 +01:00
babel-django.cfg Added a django extract for .csv files 2015-09-15 21:57:42 +00:00
babel-djangojs.cfg Angular translation via babel (singular only) 2015-07-02 11:13:45 +10:00
CONTRIBUTING.rst Workflow documentation is now in infra-manual 2014-12-05 03:30:36 +00:00
HACKING.rst Eliminate mutable default arguments 2015-12-17 09:58:46 +00:00
LICENSE Initial commit 2011-01-12 13:43:31 -08:00
Makefile Unifies the project packaging into one set of modules. 2012-02-29 00:20:13 -08:00
manage.py Gate on H102 Apache 2.0 license header not found for pep8 2013-11-19 13:55:04 -05:00
MANIFEST.in Update MANIFEST for SCSS 2015-09-09 14:42:10 +01:00
package.json Updating package.json / npm packages 2016-05-31 10:34:38 +00:00
README.rst Add install guide for users and clean up README 2014-10-09 03:29:26 +09:00
requirements.txt Updated from global requirements 2016-06-14 21:05:18 +00:00
run_tests.sh Fix translation test 2016-05-07 10:36:05 +02:00
setup.cfg Enhances tox to not rely on run_tests 2016-04-20 12:56:53 +02:00
setup.py Updated from global requirements 2015-09-19 05:37:19 +00:00
test-requirements.txt Updated from global requirements 2016-06-21 17:59:33 +00:00
test-shim.js Fix bug where WEBROOT is not respected 2015-07-22 04:10:50 +00:00
tox.ini Fix coverage post job 2016-06-14 21:04:07 +02:00

Horizon (OpenStack Dashboard)

Horizon is a Django-based project aimed at providing a complete OpenStack Dashboard along with an extensible framework for building new dashboards from reusable components. The openstack_dashboard module is a reference implementation of a Django site that uses the horizon app to provide web-based interactions with the various OpenStack projects.

Using Horizon

See doc/source/topics/install.rst about how to install Horizon in your OpenStack setup. It describes the example steps and has pointers for more detailed settings and configurations.

It is also available at http://docs.openstack.org/developer/horizon/topics/install.html.

Getting Started for Developers

doc/source/quickstart.rst or http://docs.openstack.org/developer/horizon/quickstart.html describes how to setup Horizon development environment and start development.

Building Contributor Documentation

This documentation is written by contributors, for contributors.

The source is maintained in the doc/source directory using reStructuredText and built by Sphinx

  • Building Automatically:

    $ ./run_tests.sh --docs
  • Building Manually:

    $ tools/with_venv.sh sphinx-build doc/source doc/build/html

Results are in the doc/build/html directory