From cb22739b3883abe880796b8305158dabed641a6e Mon Sep 17 00:00:00 2001 From: Dan Anglin Date: Tue, 12 Nov 2019 23:09:21 +0000 Subject: [PATCH] feat: allow owners to set the background image. This commit allows instance owners to set a background image for their Pleroma instances. It copies the image from the ansible controller onto the target host and updates the Pleroma configuration. Owners can set the value for pleroma.config.frontend.background to set the background image. The default image is used if this value is not set. --- roles/init/defaults/main.yml | 2 ++ roles/pleroma-backend/tasks/main.yml | 11 ++++++++++- .../templates/etc_pleroma_config.exs.j2 | 7 +++++++ 3 files changed, 19 insertions(+), 1 deletion(-) diff --git a/roles/init/defaults/main.yml b/roles/init/defaults/main.yml index 9b25ce9..369edf8 100644 --- a/roles/init/defaults/main.yml +++ b/roles/init/defaults/main.yml @@ -13,6 +13,8 @@ pleroma_defaults: healthCheck: "true" logLevel: info federating: "true" + frontend: + background: "" db: name: pleroma_db user: pleroma diff --git a/roles/pleroma-backend/tasks/main.yml b/roles/pleroma-backend/tasks/main.yml index c90c93d..5831f35 100644 --- a/roles/pleroma-backend/tasks/main.yml +++ b/roles/pleroma-backend/tasks/main.yml @@ -1,5 +1,4 @@ --- -# TODO: Do we need ncurses? - name: Ensure Pleroma dependencies are installed. apk: name: unzip, ncurses @@ -34,6 +33,7 @@ - "{{ pleroma_base_data_dir }}" - "{{ pleroma_uploads_dir }}" - "{{ pleroma_static_dir }}" + - "{{ pleroma_static_dir }}/images" - name: Ensuring that the release build of pleroma is downloaded. get_url: @@ -75,6 +75,15 @@ find {{ pleroma_user.home }} -mindepth 1 -maxdepth 1 -type d | xargs -I dir chmod 0700 dir find {{ pleroma_user.home }} -mindepth 1 -maxdepth 1 -type d | xargs -I dir chown -R {{ pleroma_user.name }}:{{ pleroma_user.group }} dir +- name: Uploading the background image to the static directory + copy: + src: "{{ pleroma.config.frontend.background }}" + dest: "{{ pleroma_static_dir }}/images/pleroma-background.png" + owner: "{{ pleroma_user.name }}" + group: "{{ pleroma_user.group }}" + mode: '0400' + when: pleroma.config.frontend.background|length + - name: Setting up the Pleroma service. copy: src: "{{ pleroma_user.home }}/installation/init.d/pleroma" diff --git a/roles/pleroma-backend/templates/etc_pleroma_config.exs.j2 b/roles/pleroma-backend/templates/etc_pleroma_config.exs.j2 index 150ae6a..983123e 100644 --- a/roles/pleroma-backend/templates/etc_pleroma_config.exs.j2 +++ b/roles/pleroma-backend/templates/etc_pleroma_config.exs.j2 @@ -71,3 +71,10 @@ config :web_push_encryption, :vapid_details, subject: "mailto:{{ pleroma.config.webPushEncryption.email }}", private_key: "{{ pleroma.config.webPushEncryption.privateKey }}", public_key: "{{ pleroma.config.webPushEncryption.publicKey }}" + +{% if pleroma.config.frontend.background|length %} +config :pleroma, :frontend_configurations, + pleroma_fe: %{ + background: "/images/pleroma-background.png" + } +{% endif %}