From 7ec61f45b36ccb47009cd5bf8b3ac926802dff18 Mon Sep 17 00:00:00 2001
From: Dario <dario@bauschutt.org>
Date: Mon, 17 Feb 2025 20:49:34 +0100
Subject: [PATCH 1/6] dokuwiki: add ability to checkout custom theme repo

---
 roles/dokuwiki/defaults/main.yml |  2 ++
 roles/dokuwiki/tasks/main.yml    | 15 +++++++++++++++
 2 files changed, 17 insertions(+)

diff --git a/roles/dokuwiki/defaults/main.yml b/roles/dokuwiki/defaults/main.yml
index 8358114..947cc84 100644
--- a/roles/dokuwiki/defaults/main.yml
+++ b/roles/dokuwiki/defaults/main.yml
@@ -3,3 +3,5 @@ dokuwiki__installpath: "/var/www/dokuwiki"
 dokuwiki__php_version: "{{ dokuwiki__php_versions[ansible_distribution + '-' + ansible_distribution_major_version] }}"
 dokuwiki__php_user: "www-data"
 dokuwiki__nginx_user: "nginx"
+dokuwiki__custom_theme_git_url: ""
+dokuwiki__custom_theme_name: ""
diff --git a/roles/dokuwiki/tasks/main.yml b/roles/dokuwiki/tasks/main.yml
index 664f159..ef64e92 100644
--- a/roles/dokuwiki/tasks/main.yml
+++ b/roles/dokuwiki/tasks/main.yml
@@ -42,3 +42,18 @@
     owner: root
     group: root
     mode: "0644"
+
+- name: checkout custom theme git repo
+  become: true
+  ansible.builtin.git:
+    repo: "{{ dokuwiki__custom_theme_git_url }}"
+    dest: "{{ dokuwiki__installpath }}/lib/tpl/{{ dokuwiki__custom_theme_name }}"
+    force: true
+    depth: 1
+    single_branch: true
+    track_submodules: true
+    accept_hostkey: true
+    accept_newhostkey: true
+  when:
+    - dokuwiki__custom_theme_git_url != ""
+    - dokuwiki__custom_theme_name != ""
-- 
2.47.2


From 0998111455351d5fff9f7b42ddff5f34edbbdc62 Mon Sep 17 00:00:00 2001
From: Dario <dario@bauschutt.org>
Date: Mon, 17 Feb 2025 21:09:06 +0100
Subject: [PATCH 2/6] dokuwiki: don't ignore hostkeys

---
 roles/dokuwiki/tasks/main.yml | 2 --
 1 file changed, 2 deletions(-)

diff --git a/roles/dokuwiki/tasks/main.yml b/roles/dokuwiki/tasks/main.yml
index ef64e92..5621a53 100644
--- a/roles/dokuwiki/tasks/main.yml
+++ b/roles/dokuwiki/tasks/main.yml
@@ -52,8 +52,6 @@
     depth: 1
     single_branch: true
     track_submodules: true
-    accept_hostkey: true
-    accept_newhostkey: true
   when:
     - dokuwiki__custom_theme_git_url != ""
     - dokuwiki__custom_theme_name != ""
-- 
2.47.2


From e943a541e5027ff9efbb77a0b8ecd11fd62c1141 Mon Sep 17 00:00:00 2001
From: Dario <dario@bauschutt.org>
Date: Mon, 17 Feb 2025 21:16:13 +0100
Subject: [PATCH 3/6] dokuwiki: document custom theme options in README

---
 roles/dokuwiki/README.md | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/roles/dokuwiki/README.md b/roles/dokuwiki/README.md
index 457dd45..956362f 100644
--- a/roles/dokuwiki/README.md
+++ b/roles/dokuwiki/README.md
@@ -22,6 +22,8 @@ None.
 - `dokuwiki__php_version`: Your PHP version, default `7.4` for Debian 11 and `8.2` for Debian 12
 - `dokuwiki__php_user`: User of your php-fpm process, default `www-data`
 - `dokuwiki__nginx_user`: User of your nginx process, default `nginx`
+- `dokuwiki__custom_theme_git_url`: Clone URL of custom theme (HTTPS only)
+- `dokuwiki__custom_theme_name`: Name of the directory into which the custom theme is cloned
 
 ## nginx Configuration
 
-- 
2.47.2


From b5ddebcada19e893a0eaf4c73fe51b7c8c85344f Mon Sep 17 00:00:00 2001
From: Dario <dario@bauschutt.org>
Date: Mon, 17 Feb 2025 21:34:01 +0100
Subject: [PATCH 4/6] dokouwiki: add option which theme branch to check out

---
 roles/dokuwiki/README.md         | 1 +
 roles/dokuwiki/defaults/main.yml | 1 +
 roles/dokuwiki/tasks/main.yml    | 1 +
 3 files changed, 3 insertions(+)

diff --git a/roles/dokuwiki/README.md b/roles/dokuwiki/README.md
index 956362f..abe718e 100644
--- a/roles/dokuwiki/README.md
+++ b/roles/dokuwiki/README.md
@@ -23,6 +23,7 @@ None.
 - `dokuwiki__php_user`: User of your php-fpm process, default `www-data`
 - `dokuwiki__nginx_user`: User of your nginx process, default `nginx`
 - `dokuwiki__custom_theme_git_url`: Clone URL of custom theme (HTTPS only)
+- `dokuwiki__custom_theme_version`: Version (git branch, tag, ...) to checkout, default main
 - `dokuwiki__custom_theme_name`: Name of the directory into which the custom theme is cloned
 
 ## nginx Configuration
diff --git a/roles/dokuwiki/defaults/main.yml b/roles/dokuwiki/defaults/main.yml
index 947cc84..33ba384 100644
--- a/roles/dokuwiki/defaults/main.yml
+++ b/roles/dokuwiki/defaults/main.yml
@@ -4,4 +4,5 @@ dokuwiki__php_version: "{{ dokuwiki__php_versions[ansible_distribution + '-' + a
 dokuwiki__php_user: "www-data"
 dokuwiki__nginx_user: "nginx"
 dokuwiki__custom_theme_git_url: ""
+dokuwiki__custom_theme_version: "main"
 dokuwiki__custom_theme_name: ""
diff --git a/roles/dokuwiki/tasks/main.yml b/roles/dokuwiki/tasks/main.yml
index 5621a53..0e6e5e6 100644
--- a/roles/dokuwiki/tasks/main.yml
+++ b/roles/dokuwiki/tasks/main.yml
@@ -48,6 +48,7 @@
   ansible.builtin.git:
     repo: "{{ dokuwiki__custom_theme_git_url }}"
     dest: "{{ dokuwiki__installpath }}/lib/tpl/{{ dokuwiki__custom_theme_name }}"
+    version: "{{ dokuwiki__custom_theme_version }}"
     force: true
     depth: 1
     single_branch: true
-- 
2.47.2


From d9b150eaf0a3ae2d1a74c232d093f37136dc006e Mon Sep 17 00:00:00 2001
From: Dario <dario@bauschutt.org>
Date: Mon, 17 Feb 2025 21:51:48 +0100
Subject: [PATCH 5/6] dokuwiki: add git to dependencies for custom theme

---
 roles/dokuwiki/tasks/main.yml | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/roles/dokuwiki/tasks/main.yml b/roles/dokuwiki/tasks/main.yml
index 0e6e5e6..8c836ce 100644
--- a/roles/dokuwiki/tasks/main.yml
+++ b/roles/dokuwiki/tasks/main.yml
@@ -1,4 +1,4 @@
-- name: Install php-fpm
+- name: Install dependencies
   become: true
   ansible.builtin.apt:
     name:
@@ -9,6 +9,7 @@
       - php-intl
       - php-gd
       - php-sqlite3
+      - git
   diff: false
 
 - name: Ensure `php-fpm` is enabled
-- 
2.47.2


From 4788d4d8196851861544342efccc291a4d7bbc04 Mon Sep 17 00:00:00 2001
From: Dario <dario@bauschutt.org>
Date: Mon, 17 Feb 2025 22:13:41 +0100
Subject: [PATCH 6/6] dokuwiki: add warning about custom theme directory

---
 roles/dokuwiki/README.md | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/roles/dokuwiki/README.md b/roles/dokuwiki/README.md
index abe718e..b6bd80d 100644
--- a/roles/dokuwiki/README.md
+++ b/roles/dokuwiki/README.md
@@ -26,6 +26,9 @@ None.
 - `dokuwiki__custom_theme_version`: Version (git branch, tag, ...) to checkout, default main
 - `dokuwiki__custom_theme_name`: Name of the directory into which the custom theme is cloned
 
+Warning: if a directory of the same name as `dokuwiki__custom_theme_name` already exists in the same directory, the task will fail.
+This needs to be manually deleted first before the first run with the the custom theme enabled.
+
 ## nginx Configuration
 
 This role does not configure your nginx server.
-- 
2.47.2