Skip to content

Commit 8ec9239

Browse files
authored
Merge pull request #219 from galaxyproject/structured-themes
Make themes structured data instead of read from file
2 parents 793ce1c + caf1c89 commit 8ec9239

File tree

3 files changed

+90
-51
lines changed

3 files changed

+90
-51
lines changed

README.md

Lines changed: 35 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -95,60 +95,63 @@ Options below that control individual file or subdirectory placement can still o
9595
[custom]: vars/layout-custom.yml
9696
[fhs]: http://www.pathname.com/fhs/
9797

98-
**New options for Galaxy 22.01 and later**
98+
**Process control with Gravity**
9999

100-
The role can now manage the Galaxy service using [gravity][gravity]. This is the default for Galaxy 22.05 and later.
100+
The role can manage the Galaxy service using [gravity][gravity]. This is the default for Galaxy 22.05 and later.
101101
Additionally, support for the `galaxy_restart_handler_name` variable has been removed. If you need to enable your own
102-
custom restart handler, you can use the "`listen`" option to the handler as explained in the
103-
[handler documentation](https://docs.ansible.com/ansible/latest/user_guide/playbooks_handlers.html#using-variables-with-handlers).
102+
custom restart handler, you can use the "`listen`" option to the handler as explained in the [handler
103+
documentation](https://docs.ansible.com/ansible/latest/user_guide/playbooks_handlers.html#using-variables-with-handlers).
104104
The handler should "listen" to the topic `"restart galaxy"`.
105105

106106
[gravity]: https://github.com/galaxyproject/gravity
107107

108-
From release 22.01 Galaxy can serve different static content per host (e.g. subdomain) and you can set [themes][themes] per host.
108+
**Galaxy Themes**
109109

110-
By setting `galaxy_manage_subdomain_static: yes` you enable the creation of static directories and configuration per host and by setting `galaxy_manage_themes: yes` the role will append your themes_config.yml file specified under `galaxy_themes_conf_path` to your themes files after coping them over to your galaxy server and create the respective configuration.
110+
From release 22.01, Galaxy users can select between different UI [themes][themes]. You can define themes using the
111+
`galaxy_themes` variable, the syntax of which is the same as the `themes_conf.yml` file described [in the themes
112+
training][themes].
113+
114+
The `galaxy_manage_themes` variable controls whether the role manages theme configs and is automatically enabled if
115+
`galaxy_themes` is defined. If you just want to load the the sample themes from Galaxy's
116+
[themes_conf.yml.sample][themes_conf_sample] without defining your own, you can manually set `galaxy_manage_themes` to
117+
`true`.
118+
119+
[themes]: https://training.galaxyproject.org/training-material/topics/admin/tutorials/customization/tutorial.html
120+
[themes_conf_sample]: https://github.com/galaxyproject/galaxy/blob/dev/lib/galaxy/config/sample/themes_conf.yml.sample
121+
122+
**Galaxy Subdomains**
123+
124+
From release 22.01 Galaxy can serve different static content and themes per host (e.g. subdomain).
125+
126+
By setting `galaxy_manage_subdomain_static: yes` you enable the creation of static directories and configuration per host.
111127

112128
In order to use this feature, you need to create the following directory structure under files/ (customizable with the `galaxy_themes_ansible_file_path` variable):
113129

114130
~~~bash
115131
files/galaxy/static
116132
├──<subdomain-name-1>
117-
│   ├── static
118-
│   │   ├── dist (optional)
119-
│   │   │   └── some-image.png
120-
│   │   ├── images (optional)
121-
│   │   │   └── more-content.jpg
122-
│   │   └── welcome.html (optional, galaxyproject.org will be displayed otherwise.)
123-
│   └── themes
124-
│   └── <subdomain-name-1>.yml
133+
│   └── static
134+
│      ├── dist (optional)
135+
│      │   └── some-image.png
136+
│      ├── images (optional)
137+
│      │   └── more-content.jpg
138+
│      └── welcome.html (optional, galaxyproject.org will be displayed otherwise.)
125139
├── <subdomain-name-2>
126-
│   ├── static
127-
│   │   ├── dist (optional)
128-
│   │   │   ├── another-static-image.svg
129-
│   │   │   └── more-static-content-2.svg
130-
│   │   └── welcome.html (optional)
131-
│   └── themes
132-
│   └── <subdomain-name-2>.yml
140+
│   └── static
141+
│      ├── dist (optional)
142+
│      │   ├── another-static-image.svg
143+
│      │   └── more-static-content-2.svg
144+
│      └── welcome.html (optional)
133145
... (and many more subdomains)
134146
~~~
135147

136-
Where the <subdomain-name-1> should exactly match your subdomain's name. The subdirectories `static` and `themes` are mandatory, as well as the correctly named theme file (if you enabled `galaxy_manage_themes`), while all subdirectories in `static` are optional.
137-
Which subdirectories and files are copied is managed by the `static_galaxy_themes_keys` variable.
148+
Where the <subdomain-name-1> should exactly match your subdomain's name. The subdirectory `static` is mandatory, while all subdirectories in `static` are optional. Which subdirectories and files are copied is managed by the `static_galaxy_themes_keys` variable.
138149

139150
Also make sure that you set `galaxy_themes_welcome_url_prefix`, so your welcome pages are templated correctly.
140151

141152
It is mandatory to set the variables under `galaxy_themes_subdomains` as shown in the example in [defaults/main.yml](defaults/main.yml). If you enabled the `galaxy_manage_host_filters` variable, you can also specify the tool sections that should be shown for each individual subdomain.
142153

143-
144-
145-
[themes]: https://training.galaxyproject.org/training-material/topics/admin/tutorials/customization/tutorial.html
146-
**New options for Galaxy 18.01 and later**
147-
148-
- `galaxy_config_style` (default: `yaml`): The type of Galaxy configuration file to write, `yaml` for the YAML format supported by Gunicorn or `ini-paste` for the traditional PasteDeploy-style INI file
149-
- `galaxy_app_config_section` (default: depends on `galaxy_config_style`): The config file section under which the
150-
Galaxy config should be placed (and the key in `galaxy_config` in which the Galaxy config can be found. If
151-
`galaxy_config_style` is `yaml` the default is `galaxy`. If `galaxy_config_style` is `ini-paste`, the default is `app:main`.
154+
Each subdomain can be given its own theme, which is defined under the `theme` key of the subdomain's entry in `galaxy_themes_subdomains`. This theme will be the default for the subdomain, and any other themes defined globally for the server will also be available for the user to select. If a subdomain's `theme` is not defined, the global default is used. An example is provided in [defaults/main.yml](defaults/main.yml).
152155

153156
**Feature control**
154157

defaults/main.yml

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ galaxy_manage_gravity: "{{ false if __galaxy_major_version is version('22.05', '
2323
galaxy_manage_systemd: no # For Galaxy
2424
galaxy_manage_systemd_reports: no # For Reports
2525
galaxy_manage_cleanup: no
26-
galaxy_manage_themes: no
26+
galaxy_manage_themes: "{{ galaxy_manage_static_setup and (galaxy_themes is defined or galaxy_themes_subdomains) }}"
2727
galaxy_manage_subdomain_static: no
2828
galaxy_manage_host_filters: no
2929
galaxy_auto_brand: no # automatically sets the subdomain name as brand
@@ -271,6 +271,7 @@ galaxy_app_config_default:
271271
ucsc_build_sites: "{{ galaxy_server_dir }}/tool-data/shared/ucsc/ucsc_build_sites.txt.sample"
272272
tool_data_table_config_path: "{{ galaxy_server_dir }}/config/tool_data_table_conf.xml.sample"
273273
tool_sheds_config_file: "{{ galaxy_server_dir }}/config/tool_sheds_conf.xml.sample"
274+
themes_config_file: "{{ galaxy_config_dir }}/themes_conf.yml"
274275

275276
# Various cache and temporary directories
276277
data_dir: "{{ galaxy_mutable_data_dir }}"
@@ -344,10 +345,12 @@ galaxy_app_config_default:
344345
{% endfor %}
345346
{% endif %} }
346347
themes_config_file_by_host: >
347-
{ {% if galaxy_manage_themes %}
348-
'{{ galaxy_themes_instance_domain }}': '{{ galaxy_themes_conf_file_name }}',
348+
{ {% if galaxy_manage_themes and galaxy_themes_subdomains %}
349+
'{{ galaxy_themes_instance_domain }}': '{{ galaxy_config.galaxy.themes_config_file | default((galaxy_config_dir, "themes_conf.yml") | path_join) }}',
349350
{% for subdomain in galaxy_themes_subdomains %}
350-
'{{ subdomain.name }}.{{ galaxy_themes_instance_domain}}': '{{ subdomain.name }}.yml',
351+
{% if subdomain.theme is defined %}
352+
'{{ subdomain.name }}.{{ galaxy_themes_instance_domain}}': 'themes_conf-{{ subdomain.name }}.yml',
353+
{% endif %}
351354
{% endfor %}
352355
{% endif %} }
353356
brand_by_host: >
@@ -511,15 +514,26 @@ galaxy_themes_subdomains: []
511514
# - "multiple_alignments"
512515
# extra_tool_labels:
513516
# - "proteomics"
514-
galaxy_themes_conf_file_name: "{{ galaxy_themes_conf_path | basename }}"
517+
# # default theme (optional)
518+
# theme:
519+
# assembly:
520+
# masthead:
521+
# color: >
522+
# bottom -90px left / 1000px no-repeat url("/static/dist/flying-bird-1.svg"),
523+
# bottom -90px left / 1000px no-repeat url("/static/dist/flying-bird-2.svg"),
524+
# linear-gradient( 20deg,
525+
# rgb(7, 40, 98) 0%,
526+
# rgb(69, 122, 184) 48%,
527+
# rgba(165, 204, 210, 0.9676562309265136) 74%,
528+
# rgb(228, 195, 131) 92%,
529+
# rgb(203, 119, 79) 100%)
515530
galaxy_themes_static_keys:
516531
static_dir: ""
517532
static_images_dir: "images/"
518533
static_scripts_dir: "scripts/"
519534
static_welcome_html: "welcome.html/"
520535
static_favicon_dir: "favicon.ico"
521536
static_robots_txt: "robots.txt"
522-
galaxy_themes_conf_path: files/galaxy/config/themes_conf.yml
523537
galaxy_themes_static_path: "{{ galaxy_root }}/server"
524538
galaxy_themes_static_dir: "{{ galaxy_root }}/server/static"
525539
galaxy_themes_symlinks: true

tasks/themes.yml

Lines changed: 35 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,37 @@
11
---
2-
- name: Append themes_conf.yml to all files in galaxy/config/themes
3-
ansible.builtin.blockinfile:
4-
block: "{{ lookup('ansible.builtin.file', galaxy_themes_conf_path) }}"
5-
path: "{{ galaxy_themes_ansible_file_path }}/{{ subdomain.name }}/themes/{{ subdomain.name }}.yml"
6-
delegate_to: 127.0.0.1
7-
8-
- name: Copy themes files
9-
ansible.builtin.copy:
10-
src: "{{ galaxy_themes_ansible_file_path }}/{{ subdomain.name }}/themes/{{ subdomain.name }}.yml"
11-
dest: "{{ galaxy_config_dir }}"
12-
mode: '0644'
13-
owner: "{{ __galaxy_privsep_user_name }}"
14-
group: "{{ __galaxy_privsep_user_group }}"
152

3+
- name: Themes setup
4+
block:
5+
6+
- name: Default themes block
7+
when: galaxy_themes is not defined
8+
block:
9+
10+
- name: Load default themes if unset
11+
ansible.builtin.slurp:
12+
src: "{{ (galaxy_server_dir, 'lib/galaxy/config/sample/themes_conf.yml.sample') | path_join }}"
13+
register: __galaxy_themes_config_slurp
14+
15+
- name: Set galaxy_themes
16+
ansible.builtin.set_fact:
17+
galaxy_themes: "{{ __galaxy_themes_config_slurp.content | b64decode | from_yaml }}"
18+
19+
- name: Write base themes config
20+
ansible.builtin.copy:
21+
content: "{{ galaxy_themes | to_yaml }}"
22+
dest: "{{ galaxy_config_merged.galaxy.themes_config_file | default((galaxy_config_dir, 'themes_conf.yml') | path_join) }}"
23+
mode: "0644"
24+
25+
- name: Write subdomain themes configs
26+
ansible.builtin.copy:
27+
content: |
28+
{{ item.theme | to_yaml }}
29+
{{ galaxy_themes | to_yaml }}
30+
dest: "{{ galaxy_config_dir }}/themes_conf-{{ item.name }}.yml"
31+
mode: "0644"
32+
when: item.theme is defined
33+
loop: "{{ galaxy_themes_subdomains }}"
34+
35+
remote_user: "{{ galaxy_remote_users.privsep | default(__galaxy_remote_user) }}"
36+
become: "{{ true if galaxy_become_users.privsep is defined else __galaxy_become }}"
37+
become_user: "{{ galaxy_become_users.privsep | default(__galaxy_become_user) }}"

0 commit comments

Comments
 (0)