From 7e1aad1ff1b43bcb39e29f9e09f82a20ed9a613e Mon Sep 17 00:00:00 2001 From: Tim DiLauro Date: Tue, 28 Feb 2017 01:53:30 -0500 Subject: [PATCH] Use new admin settings-based UI customization approach (see https://github.com/IQSS/dataverse/issues/2003#issuecomment-278955920) (#2) --- dataverse.pb | 22 ++++++ roles/dataverse/defaults/main.yaml | 39 ++++++++++ ...es.logo.small.horizontal.white.cropped.png | Bin .../dv-4.6/Bundle.properties.patch | 21 ----- .../dv-4.6/dataverse_header.xhtml.patch | 14 ---- .../dv-4.6/dataverse_template.xhtml.patch | 20 ----- .../dv-4.6/instance_header.xhtml | 72 ------------------ .../tasks/dv-custom-ui-overrides.yaml | 34 +++++++++ roles/dataverse/tasks/dv-custom-ui.yaml | 47 +++++++----- 9 files changed, 121 insertions(+), 148 deletions(-) rename roles/dataverse/files/ui-customization/{dv-4.6 => common}/images/libraries.logo.small.horizontal.white.cropped.png (100%) delete mode 100644 roles/dataverse/files/ui-customization/dv-4.6/Bundle.properties.patch delete mode 100644 roles/dataverse/files/ui-customization/dv-4.6/dataverse_header.xhtml.patch delete mode 100644 roles/dataverse/files/ui-customization/dv-4.6/dataverse_template.xhtml.patch delete mode 100644 roles/dataverse/files/ui-customization/dv-4.6/instance_header.xhtml create mode 100644 roles/dataverse/tasks/dv-custom-ui-overrides.yaml diff --git a/dataverse.pb b/dataverse.pb index bd1260f..c08b1a0 100644 --- a/dataverse.pb +++ b/dataverse.pb @@ -17,5 +17,27 @@ vars: load_mdblocks: true mail_relay: smtp.johnshopkins.edu + dv_ui_use_custom_header: true + dv_ui_repo: + url: "https://github.com/jhu-sheridan-libraries/dataverse.git" + branch: "2003-instance-branding-on-v4.6" + dv_ui_custom_values: + - { prop: ":instanceLogoFile", + val: "/resources/images/libraries.logo.small.horizontal.white.cropped.png", + desc: "URL (relative or absolute) for instance logo file" } + - { prop: ":instanceNameFull", + val: "Johns Hopkins University Data Archive", + desc: "Full branded name for this Dataverse instance" } + - { prop: ":instanceNameShort", val: "JHU Data Archive", + desc: "Short branded name for this Dataverse instance" } + - { prop: ":instanceTextFull", + val: "Johns Hopkins University Data Management Services", + desc: "Full upper right-hand text for wider window" } + - { prop: ":instanceTextShort", val: "JHU DMS", + desc: "Short upper right-hand text for narrow window" } + - { prop: ":instanceTextLink", val: "http://dms.data.jhu.edu/", + desc: "Link for click on upper right-hand branding text" } + - { prop: ":instanceLogoLink", val: "http://www.library.jhu.edu/", + desc: "Link for click on instance branding logo" } roles: - role: dataverse diff --git a/roles/dataverse/defaults/main.yaml b/roles/dataverse/defaults/main.yaml index b4d06b8..655c5c7 100644 --- a/roles/dataverse/defaults/main.yaml +++ b/roles/dataverse/defaults/main.yaml @@ -124,6 +124,45 @@ rserve_user: rserve rserve_pass: "{{ rserve_pass_protected }}" rserve_port: 6311 + +############################################################################### +# Settings for UI instance branding configuration +# When any values are changed to override these variables, all +# properties associated with that variable will be overriden. So +# all desired values must be re-specified. +############################################################################### + +dv_ui_use_custom_header: false +dv_ui_use_custom_footer: false + +dv_ui_custom_values: + - { prop: ":instanceLogoFile", val: "http://dataverse.org/files/dataverseorg/files/dv-rings-tranparent.png", + desc: "URL (relative or absolute) for instance logo file" } +# If ":instanceBrandingHeader" is set to true, the following properties should +# should be set elsewhere. +# - { prop: ":instanceNameFull", val: "set :instanceNameFull", +# desc: "Full branded name for this Dataverse instance" } +# - { prop: ":instanceNameShort", val: "set :instanceNameShort", +# desc: "Short branded name for this Dataverse instance" } +# - { prop: ":instanceTextFull", val: "set :instanceTextFull", +# desc: "Full upper right-hand text for wider window" } +# - { prop: ":instanceTextShort", val: "set :instanceTextShort", +# desc: "Short upper right-hand text for narrow window" } +# - { prop: ":instanceTextLink", val: "set :instanceTextLink", +# desc: "Link for click on upper right-hand branding text" } +# - { prop: ":instanceLogoLink", val: "http://dataverse.example.org/", +# desc: "Link for click on instance branding logo" } +dv_ui_custom_css_classes: + - { prop: ":instanceNameFullClasses", val: "hidden-xs", + desc: "hide the instance fullname when window too narrow" } + - { prop: ":instanceNameShortClasses", val: "hidden-sm hidden-md hidden-lg hidden-xl", + desc: "hide the short version of the when window not too narrow for wide text" } + - { prop: ":instanceTextFullClasses", val: "hidden-xs hidden-sm", + desc: "hide the long version of right-hand text when window too narrow" } + - { prop: ":instanceTextShortClasses", val: "hidden-md hidden-lg hidden-xl", + desc: "hide the short version of right-hand text when window not too narrow for long text" } + + ############################################################################### # Mail configuration ############################################################################### diff --git a/roles/dataverse/files/ui-customization/dv-4.6/images/libraries.logo.small.horizontal.white.cropped.png b/roles/dataverse/files/ui-customization/common/images/libraries.logo.small.horizontal.white.cropped.png similarity index 100% rename from roles/dataverse/files/ui-customization/dv-4.6/images/libraries.logo.small.horizontal.white.cropped.png rename to roles/dataverse/files/ui-customization/common/images/libraries.logo.small.horizontal.white.cropped.png diff --git a/roles/dataverse/files/ui-customization/dv-4.6/Bundle.properties.patch b/roles/dataverse/files/ui-customization/dv-4.6/Bundle.properties.patch deleted file mode 100644 index b8c26fd..0000000 --- a/roles/dataverse/files/ui-customization/dv-4.6/Bundle.properties.patch +++ /dev/null @@ -1,21 +0,0 @@ ---- WEB-INF/classes/Bundle.properties.orig 2017-01-20 13:36:19.226248762 -0500 -+++ WEB-INF/classes/Bundle.properties 2016-12-15 09:58:16.121000000 -0500 -@@ -1,3 +1,18 @@ -+# instance branding parameters -+instance_branding_header=true -+instance_branding_footer=false -+instanceTextLink=http://dms.data.jhu.edu/ -+instanceTextFull=Johns Hopkins University Data Management Services -+instanceTextShort=JHUDMS -+instanceTextFullClasses=hidden-xs hidden-sm -+instanceTextShortClasses=hidden-md hidden-lg hidden-xl -+instanceLogoFile=/resources/images/libraries.logo.small.horizontal.white.cropped.png -+instanceLogoLink=http://www.library.jhu.edu/ -+instanceNameFull=Johns Hopkins University Data Archive -+instanceNameShort=JHU Data Archive -+instanceNameFullClasses=hidden-xs -+instanceNameShortClasses=hidden-sm hidden-md hidden-lg hidden-xl -+ - dataverse=Dataverse - newDataverse=New Dataverse - hostDataverse=Host Dataverse diff --git a/roles/dataverse/files/ui-customization/dv-4.6/dataverse_header.xhtml.patch b/roles/dataverse/files/ui-customization/dv-4.6/dataverse_header.xhtml.patch deleted file mode 100644 index b10121d..0000000 --- a/roles/dataverse/files/ui-customization/dv-4.6/dataverse_header.xhtml.patch +++ /dev/null @@ -1,14 +0,0 @@ ---- dataverse_header.xhtml.orig 2016-12-14 18:15:30.597000000 -0500 -+++ dataverse_header.xhtml 2016-12-14 20:57:22.949000000 -0500 -@@ -21,7 +21,10 @@ - - - -- #{bundle.dataverse} -+ -+ #{bundle.instanceNameFull} -+ #{bundle.instanceNameShort} -+ - - - #{!empty settingsWrapper.get(':StatusMessageHeader') ? settingsWrapper.get(':StatusMessageHeader') : bundle['header.status.header']} diff --git a/roles/dataverse/files/ui-customization/dv-4.6/dataverse_template.xhtml.patch b/roles/dataverse/files/ui-customization/dv-4.6/dataverse_template.xhtml.patch deleted file mode 100644 index 82d28ea..0000000 --- a/roles/dataverse/files/ui-customization/dv-4.6/dataverse_template.xhtml.patch +++ /dev/null @@ -1,20 +0,0 @@ ---- dataverse_template.xhtml 2017-01-28 17:42:24.108718494 -0500 -+++ dataverse_template.xhtml 2017-01-26 04:45:38.498692700 -0500 -@@ -36,7 +36,17 @@ - - - #{bundle['body.skip']} -+ -+ -+ -+ -+ - -+ -+ -+ -+ -+ - - - diff --git a/roles/dataverse/files/ui-customization/dv-4.6/instance_header.xhtml b/roles/dataverse/files/ui-customization/dv-4.6/instance_header.xhtml deleted file mode 100644 index e37061a..0000000 --- a/roles/dataverse/files/ui-customization/dv-4.6/instance_header.xhtml +++ /dev/null @@ -1,72 +0,0 @@ - - - - - - diff --git a/roles/dataverse/tasks/dv-custom-ui-overrides.yaml b/roles/dataverse/tasks/dv-custom-ui-overrides.yaml new file mode 100644 index 0000000..460adbb --- /dev/null +++ b/roles/dataverse/tasks/dv-custom-ui-overrides.yaml @@ -0,0 +1,34 @@ +# -*- mode: yaml -*- +# vi: set ft=yaml : + +--- + +############################################################################### +# These tasks are needed until such time as these/similar customizations +# make it into a Dataverse release. +############################################################################### + +- name: set some base directories for UI overrides + set_fact: + dv_repo_dir: "/tmp/dataverse/repo" + dv_repo_webapp_dir: "src/main/webapp" + +- name: (TEMPORARY) clone the dataverse repository with UI changes to overwrite distro + git: + repo: "{{ dv_ui_repo.url }}" + dest: "{{ dv_repo_dir }}" + version: "{{ dv_ui_repo.branch }}" + +- name: (TEMPORARY) copy relevant updated UI files + copy: src="{{ dv_repo_dir }}/{{ dv_repo_webapp_dir}}/{{ item }}" + dest="{{ dv_application_directory }}/{{ item }}" + owner="{{ dv_gf_user }}" group="{{ dv_gf_group }}" mode=0644 + remote_src=true + with_items: + - "instance_header.xhtml" + - "resources/css/instance-header-overrides.css" + - "dataverse_header.xhtml" + - "dataverse_template.xhtml" + +- name: (TEMPORARY) remove cloned dataverse repository + file: path="{{ dv_repo_dir }}" state=absent diff --git a/roles/dataverse/tasks/dv-custom-ui.yaml b/roles/dataverse/tasks/dv-custom-ui.yaml index bf50ef5..06c3ab4 100644 --- a/roles/dataverse/tasks/dv-custom-ui.yaml +++ b/roles/dataverse/tasks/dv-custom-ui.yaml @@ -4,40 +4,45 @@ --- ############################################################################### -# Branding & UI customization updates -# NB: These are brittle and may need to be fixed between releases +# Update UI settings ############################################################################### -- name: a note on these customizations - debug: msg="These UI customizations are brittle and may need to be updated for new releases." +- name: configure admin settings that drive UI customizations + become: yes + become_user: "{{ dv_gf_user }}" + uri: + url: "{{ instance_api }}/admin/settings/{{item.prop}}" + body: "{{ item.val }}" + method: PUT + validate_certs: no + with_items: + - { prop: ":instanceBrandingHeader", val: "{{ dv_ui_use_custom_header |lower }}", + desc: "whether or not to use a branding header" } + - { prop: ":instanceBrandingFooter", val: "{{ dv_ui_use_custom_footer |lower }}", + desc: "whether or not to use a branding footer" } + - "{{ dv_ui_custom_values }}" + - "{{ dv_ui_custom_css_classes }}" + + +############################################################################### +# Copy custom files into the application +############################################################################### - name: set some base directories for later use set_fact: - dv_customization_directory: "ui-customization/dv-{{ instance_ui_customization_version }}" dv_application_directory: "{{ dv_gf_root }}/glassfish/domains/{{ dv_gf_domain }}/applications/{{ dataverse_app_name }}" -- name: copy new custom files to the web site +- name: copy local custom files into the web app become: yes become_user: "{{ dv_gf_user }}" - copy: src="{{ dv_customization_directory }}/{{ item.src }}" + copy: src="ui-customization/{{ item.src }}" dest="{{ dv_application_directory }}/{{ item.dest }}" owner="{{ dv_gf_user }}" group="{{ dv_gf_user }}" mode=0644 with_items: - - { src: "instance_header.xhtml", dest: ""} - - { src: "images/", dest: "/resources/images"} - - -- name: apply custom UI patches - become: yes - become_user: "{{ dv_gf_user }}" - patch: src="{{ dv_customization_directory }}/{{ item }}.patch" - basedir="{{ dv_application_directory }}" - remote_src=no - with_items: - - Bundle.properties - - dataverse_header.xhtml - - dataverse_template.xhtml + - { src: "common/images/", dest: "/resources/images"} +# (Temporary) Some +- include: dv-custom-ui-overrides.yaml - name: clean up custom UI /tmp files file: name=/tmp/dv-custom-ui state=absent