Alexander Wels has uploaded a new change for review. Change subject: branding: Allow templates to be replaced ......................................................................
branding: Allow templates to be replaced - Allowed themes the ability to override the default behaviour of append their templates to previous template. This allows themes to almost completely replace the entire welcome page. Change-Id: Id3376500d1ceece80132089d90174e092992d36d Signed-off-by: Alexander Wels <aw...@redhat.com> --- M README.branding M backend/manager/modules/branding/src/main/java/org/ovirt/engine/core/branding/BrandingManager.java M backend/manager/modules/branding/src/main/java/org/ovirt/engine/core/branding/BrandingTheme.java M packaging/branding/ovirt.brand/branding.properties 4 files changed, 25 insertions(+), 0 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/95/21195/1 diff --git a/README.branding b/README.branding index 80fa3eb..4d38d6c 100644 --- a/README.branding +++ b/README.branding @@ -136,6 +136,14 @@ The output will be: <a href="/fr_FR/documenation">Documenation</a> +If you want to completely replace any previous templates you can add a new key to +the branding.properties file called template_replace with a value of true. This +will cause the template engine to wipe out the template generated by processing +previous theme, and complete replace it with yours. Default behaviour is to append +your template to the end of the previous template(s). This flag allows you to +override that behaviour and just use your template. Any themes processed after +yours will default back to append unless they specify the flag as well. + INSTALLATION ------------ diff --git a/backend/manager/modules/branding/src/main/java/org/ovirt/engine/core/branding/BrandingManager.java b/backend/manager/modules/branding/src/main/java/org/ovirt/engine/core/branding/BrandingManager.java index 45572dc..0ccc1da 100644 --- a/backend/manager/modules/branding/src/main/java/org/ovirt/engine/core/branding/BrandingManager.java +++ b/backend/manager/modules/branding/src/main/java/org/ovirt/engine/core/branding/BrandingManager.java @@ -270,6 +270,10 @@ } } replacedTemplate = replacedTemplate.replaceAll(USER_LOCALE_HOLDER, locale.toString()); + if (theme.shouldReplaceWelcomePageSectionTemplate()) { + //Clear the template builder as the theme wants to replace instead of append to the template. + templateBuilder = new StringBuilder(); + } templateBuilder.append(replacedTemplate); } return templateBuilder.toString(); diff --git a/backend/manager/modules/branding/src/main/java/org/ovirt/engine/core/branding/BrandingTheme.java b/backend/manager/modules/branding/src/main/java/org/ovirt/engine/core/branding/BrandingTheme.java index 6b139f3..1fd4573 100644 --- a/backend/manager/modules/branding/src/main/java/org/ovirt/engine/core/branding/BrandingTheme.java +++ b/backend/manager/modules/branding/src/main/java/org/ovirt/engine/core/branding/BrandingTheme.java @@ -63,6 +63,12 @@ private static final String TEMPLATE_KEY = "welcome"; //$NON-NLS-1$ /** + * The key used to determine if this template should completely replace the template build from all + * previously processed themes. + */ + private static final String REPLACE_TEMPLATE_KEY = "welcome_replace"; //$NON-NLS-1$ + + /** * Property suffix for cascading resources file. */ private static final String FILE_SUFFIX = ".file"; //$NON-NLS-1$ @@ -241,6 +247,10 @@ return result; } + public boolean shouldReplaceWelcomePageSectionTemplate() { + return Boolean.valueOf(brandingProperties.getProperty(REPLACE_TEMPLATE_KEY)); + } + /** * Return the raw welcome template as a string. * @return The raw template string. diff --git a/packaging/branding/ovirt.brand/branding.properties b/packaging/branding/ovirt.brand/branding.properties index 1fc7561..3b524e1 100644 --- a/packaging/branding/ovirt.brand/branding.properties +++ b/packaging/branding/ovirt.brand/branding.properties @@ -25,6 +25,9 @@ # Welcome page template (optional, allows you to add things to the welcome page) welcome=welcome_page.template +# Set to 'true' if you want your template to completely replace the template build from +# all the templates of earlier processed themes. +#welcome_replace= # version (required, the theme will not be applied without this property) version=1 -- To view, visit http://gerrit.ovirt.org/21195 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Id3376500d1ceece80132089d90174e092992d36d Gerrit-PatchSet: 1 Gerrit-Project: ovirt-engine Gerrit-Branch: master Gerrit-Owner: Alexander Wels <aw...@redhat.com> _______________________________________________ Engine-patches mailing list Engine-patches@ovirt.org http://lists.ovirt.org/mailman/listinfo/engine-patches