Commit 9ba0e1a8 authored by Daniel Dehennin's avatar Daniel Dehennin
Browse files

feat(themes): install themes during `discourse.setup`

The themes configurations are not yet managed but we provide an
example of what it may look like in `pillar.example`.
parent 4193c64d
......@@ -4,3 +4,4 @@
include:
- .settings
- .users
- .themes
---
# Automatically generated by SaltStack
# Do not edit
{{ salt['slsutil.serialize']('yaml', theme, default_flow_style=False) }}
...
# -*- coding: utf-8 -*-
# vim: ft=sls
include:
- .install
# -*- coding: utf-8 -*-
# vim: ft=sls
{#- Get the `tplroot` from `tpldir` #}
{%- set tplroot = tpldir.split('/')[0] %}
{%- set sls_service_running = tplroot ~ '.service.running' %}
{%- from tplroot | path_join("map.jinja") import discourse with context %}
{%- from tplroot | path_join("libtofs.jinja") import files_switch with context %}
include:
- {{ sls_service_running }}
{%- set themes = discourse | traverse('themes', {}) %}
{%- for name, params in themes.items() %}
{%- set theme_filename = name ~ '.yaml' %}
{%- set theme_contairer_path = '/shared' | path_join('themes',
theme_filename)
%}
{%- set theme_path = discourse.directory | path_join('shared',
'standalone',
'themes',
theme_filename)
%}
{%- set install_cmd = 'cd /var/www/discourse/ '
~ '&& rake themes:install '
~ '< ' ~ theme_contairer_path
%}
{%- set theme = {'theme_name': params.get('theme_name')} %}
{%- set install_lookup = 'discourse-setup-themes-install-' ~ name ~ '-install-file-managed' %}
discourse-setup-themes-install-{{ name }}-config-file-managed:
file.managed:
- name: {{ theme_path }}
- source: {{ files_switch(['theme.yaml.jinja'],
lookup=install_lookup,
use_subpath=True
)
}}
- mode: 644
- user: root
- group: root
- makedirs: True
- template: jinja
- context:
theme: {{ theme | tojson }}
- require:
- sls: {{ sls_service_running }}
discourse-setup-themes-install-{{ name }}-install-cmd-run:
cmd.run:
- name: {{ discourse | traverse('launcher:run_cmd')
~ " '"
~ install_cmd
~ "'"
}}
- cwd: {{ discourse.directory }}
- require:
- sls: {{ sls_service_running }}
- retry:
attempts: 5
until: True
interval: 5
splay: 2
{%- endfor %}
......@@ -129,6 +129,20 @@ This state will manage a set of users:
- set them active or not
- set them ``admin`` or not.
``discourse.setup.themes``
^^^^^^^^^^^^^^^^^^^^^^^^^^
*Meta-state (This is a state that includes other states)*.
This state will install a list of themes.
``discourse.setup.themes.install``
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
This state will install the themes.
It depends on ``discourse.service.running``.
``discourse.clean``
^^^^^^^^^^^^^^^^^^^
......
......@@ -44,6 +44,19 @@ discourse:
debug_auth: 'true'
button_title: OAuth Example
full_screen_login: 'true'
themes:
matomo:
theme_name:
# See https://github.com/discourse/discourse/blob/master/lib/tasks/themes.rake
url: https://github.com/discourse/discourse-matomo-analytics.git
settings:
# For future: this will be used to configure automatically the theme
# see https://github.com/discourse/discourse-matomo-analytics/blob/master/settings.yml
host_url: ~
website_id: ~
exclude_groups: ~
user_id_tracking: ~
subdomain_tracking: ~
users:
william:
# Password reset mail is sent by default
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment