From 49376929fbce50d730a3379b7e250c8a9f77fe70 Mon Sep 17 00:00:00 2001 From: Travis Truman Date: Mon, 11 Jul 2016 12:46:54 -0400 Subject: [PATCH] Add support for custom Horizon themes Deployers can now configure their own custom themes and set them as the default theme using the Horizon configuration values AVAILABLE_THEMES and DEFAULT_THEME See http://docs.openstack.org/developer/horizon/topics/settings.html#available-themes for further details on the configuration. Change-Id: I90b1cb45c851eb654638d82b83af56f93a642895 Closes-Bug: #1590839 --- defaults/main.yml | 38 +++++++++++++++++++ ...orizon_custom_themes-4ee1fd9444b8a5ae.yaml | 6 +++ templates/horizon_local_settings.py.j2 | 14 +++++-- 3 files changed, 54 insertions(+), 4 deletions(-) create mode 100644 releasenotes/notes/horizon_custom_themes-4ee1fd9444b8a5ae.yaml diff --git a/defaults/main.yml b/defaults/main.yml index b11de287..5ad25d3f 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -164,6 +164,44 @@ horizon_default_panel: overview ## See http://docs.openstack.org/developer/horizon/topics/customizing.html#horizon-customization-module-overrides # horizon_customization_module: /local/path/to/customization_module.py +## Replace default theme files with your own +# horizon_custom_uploads: +# logo: +# src: "path_on_deployment_host_of_your_custom_logo.png" +# dest: "img/logo.png" +# logo_splash: +# src: "path_on_deployment_host_of_your_custom_logo-splash.png" +# dest: "img/logo-splash.png" + +_horizon_available_themes: + default: + theme_name: "default" + theme_label: "Default" + theme_path: "themes/default" + material: + theme_name: "material" + theme_label: "Material" + theme_path: "themes/material" + +# Add custom themes. Deployers need to place the theme directories +# and files on the horizon containers in: +# {{ horizon_lib_dir }}/openstack_dashboard/themes +# See http://docs.openstack.org/developer/horizon/topics/customizing.html#themes +# for more details on custom themes +# Example: +# +# horizon_custom_themes: +# custom_theme: +# theme_name: "custom" +# theme_label: "Custom" +# theme_path: "themes/custom" +# +horizon_custom_themes: {} + +# Which of the available themes will be used by default +# value is the theme_name from the vars above +horizon_default_theme: "default" + horizon_webroot: / horizon_listen_ports: diff --git a/releasenotes/notes/horizon_custom_themes-4ee1fd9444b8a5ae.yaml b/releasenotes/notes/horizon_custom_themes-4ee1fd9444b8a5ae.yaml new file mode 100644 index 00000000..35870124 --- /dev/null +++ b/releasenotes/notes/horizon_custom_themes-4ee1fd9444b8a5ae.yaml @@ -0,0 +1,6 @@ +--- +features: + - The ``os_horizon`` role now supports configuration of custom themes. + Deployers can use the new ``horizon_custom_themes`` and + ``horizon_default_theme`` variables to configure the dashboard with + custom themes and default to a specific theme respectively. diff --git a/templates/horizon_local_settings.py.j2 b/templates/horizon_local_settings.py.j2 index e30e6e70..85b2a4e7 100644 --- a/templates/horizon_local_settings.py.j2 +++ b/templates/horizon_local_settings.py.j2 @@ -428,10 +428,6 @@ ENFORCE_PASSWORD_CHECK = {{ horizon_enforce_password_check }} #TROVE_ADD_USER_PERMS = [] #TROVE_ADD_DATABASE_PERMS = [] -# Change this patch to the appropriate static directory containing -# two files: _variables.scss and _styles.scss -#CUSTOM_THEME_PATH = 'themes/default' - LOGGING = { 'version': 1, # When set to True this will disable all logging except @@ -729,6 +725,16 @@ SITE_BRANDING = '{{ horizon_site_name }}' HORIZON_CONFIG["customization_module"] = 'horizon_customization.overrides' {% endif %} +AVAILABLE_THEMES = [ +{% for key, value in _horizon_available_themes.iteritems() %} + ('{{ value.theme_name }}', '{{ value.theme_label }}', '{{ value.theme_path }}'), +{% endfor %} +{% for key, value in horizon_custom_themes.iteritems() %} + ('{{ value.theme_name }}', '{{ value.theme_label }}', '{{ value.theme_path }}'), +{% endfor %} +] + +DEFAULT_THEME = '{{ horizon_default_theme }}' # Set arbitrary horizon configuration options HORIZON_CONFIG.update({{ horizon_config_overrides }})