add themes and external renderers (#27)
I completely rewrote the way we deploy themes because the way I did it before couldn't work for other repos than the forgejo-beetroot theme repo. I've checked lots of differents gitea theme repos, and they're all set differently. So now, this role clones repos, check if they're css files in them, copy those files in the right place and update the app.ini THEMES var. I've tried it with 10-15 different repos, it works with all of them. Co-authored-by: meaz <meaz@disroot.org> Co-authored-by: muppeth <muppeth@disroot.org> Reviewed-on: Disroot-Ansible/gitea#27 Reviewed-by: muppeth <muppeth@no-reply@disroot.org>
This commit is contained in:
parent
3359b9de89
commit
52b136833b
|
@ -25,6 +25,9 @@ gitea_download_url: 'https://github.com/go-gitea/gitea/releases/download/v{{ git
|
|||
The playbook includes postgresql role and deploys entire stack needed to run Gitea. Additional roles are also available in the Ansible roles repos in git.
|
||||
|
||||
## Customization
|
||||
Check https://docs.gitea.io/en-us/customizing-gitea/
|
||||
You can deploy custom themes with this role. To do so, uncomment `gitea_theme_dir` and `gitea_custom_themes` from `defaults/main.yml`. Add the theme repos' address and name there, enable them and then deploy with `ansible-playbook -b Playbooks/gitea.yml --tags theme`.
|
||||
|
||||
You can deploy custom themes with this role. To do so, check `gitea_custom_themes` var and add your theme's repo address there. The root path of the theme repo must have a `css` folder that includes the theme's css files. You can check https://git.disroot.org/Disroot-themes/forgejo-beetroot as an example.
|
||||
You can also add you own images like favicon, icons, etc. See https://docs.gitea.io/en-us/customizing-gitea/ to see how to prepare your images.
|
||||
Then, copy them in the `img` folder of this role and uncomment `gitea_extra_files_path` and `gitea_theme_dir` from `defaults/main.yml`. You can then deploy with `ansible-playbook -b Playbooks/gitea.yml --tags config`.
|
||||
|
||||
For more information about customizaton, check https://docs.gitea.io/en-us/customizing-gitea/.
|
||||
|
|
|
@ -7,17 +7,17 @@ gitea_group: 'git'
|
|||
gitea_confdir: '/etc/gitea/app.ini'
|
||||
|
||||
gitea_flavor: 'forgejo'
|
||||
gitea_version: '1.18.3-2'
|
||||
gitea_version: '1.18.5-0'
|
||||
gitea_arch: 'linux-amd64'
|
||||
#gitea_download_url: 'https://github.com/go-gitea/gitea/releases/download/v{{ gitea_version }}/gitea-{{ gitea_version }}-{{ gitea_arch }}'
|
||||
|
||||
#Uncomment below if you want to add custom themes
|
||||
# Uncomment below if you want to add custom themes or images
|
||||
#gitea_extra_files_path: '../img' # the folder name where you have the images you want to deploy
|
||||
#gitea_theme_dir: '{{ gitea_lib_dir }}/custom'
|
||||
#gitea_custom_themes:
|
||||
# - name: 'beetroot' #add name of the theme
|
||||
# repo: 'https://git.disroot.org/Disroot-themes/forgejo-beetroot.git' #add git repository of the theme
|
||||
# img: 'true' #set it to true if there is an img folder
|
||||
# Don't forget to also add those themes' names in the following THEMES var.
|
||||
# - name: '' #add name of the theme
|
||||
# repo: '' #add git repository of the theme
|
||||
# enable: 'true' #set it to false to remove it
|
||||
|
||||
#[CONFIG]
|
||||
# App.ini file variables
|
||||
|
@ -30,7 +30,7 @@ gitea_oauth2_config:
|
|||
- 'JWT_SECRET = ' #41 random chars
|
||||
|
||||
gitea_ui_config:
|
||||
- 'THEMES = auto,arc-green,gitea,forgejo-auto,forgejo-light,forgejo-dark'
|
||||
- 'THEMES = auto,arc-green,gitea,forgejo-auto,forgejo-light,forgejo-dark' # add only the default ones, not themes ones
|
||||
- 'DEFAULT_THEME = arc-green'
|
||||
|
||||
gitea_security_config:
|
||||
|
@ -104,13 +104,23 @@ gitea_log_config:
|
|||
- 'LEVEL = Info'
|
||||
- 'ROOT_PATH = /home/git/log'
|
||||
|
||||
# External renderers
|
||||
# See https://docs.gitea.io/en-us/external-renderers/
|
||||
gitea_markup_config:
|
||||
- name: 'asciidoc'
|
||||
apt: 'asciidoc'
|
||||
enable: 'false'
|
||||
- name: 'jupyter'
|
||||
apt: 'jupyter'
|
||||
enable: 'false'
|
||||
- name: 'html'
|
||||
apt: ''
|
||||
enable: 'false'
|
||||
|
||||
#apt
|
||||
gitea_apt_list:
|
||||
- git
|
||||
|
||||
|
||||
|
||||
# POSTGRES
|
||||
postgresql_version: 13
|
||||
postgresql_listen_addresses:
|
||||
|
|
|
@ -43,4 +43,31 @@
|
|||
owner: "{{ gitea_user }}"
|
||||
group: "{{ gitea_group }}"
|
||||
notify: Restart gitea
|
||||
tags: config
|
||||
tags: config
|
||||
|
||||
- name: "[CONF] - Create img folder"
|
||||
file:
|
||||
path: "{{ gitea_theme_dir }}/public/img/"
|
||||
state: 'directory'
|
||||
owner: '{{ gitea_user }}'
|
||||
group: '{{ gitea_group }}'
|
||||
when: gitea_theme_dir is defined
|
||||
tags: config
|
||||
|
||||
- name: "[CONF] - Deploy img folder"
|
||||
copy:
|
||||
src: '{{ gitea_extra_files_path }}/'
|
||||
dest: "{{ gitea_theme_dir }}/public/img/"
|
||||
owner: "{{ gitea_user }}"
|
||||
group: "{{ gitea_group }}"
|
||||
mode: 0755
|
||||
when: gitea_theme_dir is defined
|
||||
tags: config
|
||||
|
||||
- name: '[CONF] - Install dependencies for renderers'
|
||||
apt:
|
||||
name: "{{ item.apt }}"
|
||||
update_cache: yes
|
||||
loop: "{{ gitea_markup_config }}"
|
||||
when: item.enable == 'true' and item.apt != ""
|
||||
tags: config
|
||||
|
|
|
@ -2,50 +2,68 @@
|
|||
|
||||
- name: '[THEME] - Create public dir'
|
||||
file:
|
||||
path: '{{ gitea_lib_dir }}/custom/public/'
|
||||
path: '{{ gitea_theme_dir }}/public/'
|
||||
state: directory
|
||||
owner: "{{ gitea_user }}"
|
||||
group: "{{ gitea_group }}"
|
||||
tags: theme
|
||||
|
||||
# First, remove the css files from public folder, then theme repos
|
||||
- name: "[THEME] - Remove css files from the css folder"
|
||||
shell:
|
||||
cmd: find "{{ gitea_theme_dir }}/{{ item.name }}" -type f -name "*.css" -printf "%f\n" | xargs -I{} rm public/css/{}
|
||||
chdir: "{{ gitea_theme_dir }}"
|
||||
loop: "{{ gitea_custom_themes }}"
|
||||
when: item.enable == 'false'
|
||||
tags: theme
|
||||
|
||||
- name: "[THEME] - Remove theme repo"
|
||||
file:
|
||||
path: "{{ gitea_theme_dir }}/{{ item.name }}"
|
||||
state: absent
|
||||
owner: "{{ gitea_user }}"
|
||||
group: "{{ gitea_group }}"
|
||||
loop: "{{ gitea_custom_themes }}"
|
||||
when: item.enable == 'false'
|
||||
tags: theme
|
||||
|
||||
# Second, get theme repos and deploy css files in public folder
|
||||
- name: "[THEME] - Get repo"
|
||||
git:
|
||||
repo: "{{ item.repo }}"
|
||||
dest: "{{ gitea_theme_dir }}/{{ item.name }}"
|
||||
force: yes
|
||||
loop: "{{ gitea_custom_themes }}"
|
||||
when: item.enable == 'true'
|
||||
tags: theme
|
||||
|
||||
- name: "[THEME] - Sync css folder"
|
||||
synchronize:
|
||||
src: "{{ gitea_theme_dir }}/{{ item.name }}/css/"
|
||||
dest: "{{ gitea_lib_dir }}/custom/public/css"
|
||||
owner: yes
|
||||
group: yes
|
||||
recursive: yes
|
||||
delete: false
|
||||
delegate_to: "{{ inventory_hostname }}"
|
||||
loop: "{{ gitea_custom_themes }}"
|
||||
- name: "[THEME] - Find css files from different repos and copy them in the public folder"
|
||||
shell:
|
||||
cmd: find "{{ gitea_theme_dir }}" -type f -name "*.css" -not -path "{{ gitea_theme_dir }}/public/*" | xargs cp -t "{{ gitea_theme_dir }}/public/css"
|
||||
chdir: "{{ gitea_theme_dir }}"
|
||||
tags: theme
|
||||
|
||||
- name: "[THEME] - Sync img folder"
|
||||
synchronize:
|
||||
src: "{{ gitea_theme_dir }}/{{ item.name }}/img/"
|
||||
dest: "{{ gitea_lib_dir }}/custom/public/img"
|
||||
owner: yes
|
||||
group: yes
|
||||
recursive: yes
|
||||
delete: false
|
||||
delegate_to: "{{ inventory_hostname }}"
|
||||
when: item.img == "true"
|
||||
loop: "{{ gitea_custom_themes }}"
|
||||
# Lastly, update app.ini by adding the theme's name list.
|
||||
- name: "[THEME] - Get and prepare a list for app.ini of css files in public folder, register it"
|
||||
shell:
|
||||
cmd: ls "{{ gitea_theme_dir }}/public/css" | sed -e 's/theme-//g' | sed -e 's/.css//g' | paste -s -d,
|
||||
chdir: "{{ gitea_theme_dir }}"
|
||||
register: theme_name
|
||||
tags: theme
|
||||
|
||||
- name: "[THEME] - Add list of themes in app.ini"
|
||||
lineinfile:
|
||||
path: "{{ gitea_confdir }}"
|
||||
regexp: '^THEMES'
|
||||
line: "{{ gitea_ui_config[0] }},{{ theme_name.stdout }}"
|
||||
notify: Restart gitea
|
||||
tags: theme
|
||||
|
||||
- name: "[THEME] - Change repo ownership"
|
||||
file:
|
||||
path: "{{ gitea_lib_dir }}/custom"
|
||||
path: "{{ gitea_theme_dir }}"
|
||||
state: directory
|
||||
recurse: yes
|
||||
owner: "{{ gitea_user }}"
|
||||
group: "{{ gitea_group }}"
|
||||
tags: theme
|
||||
|
||||
tags: theme
|
|
@ -7,6 +7,9 @@
|
|||
include_tasks: configure.yml
|
||||
tags: config
|
||||
|
||||
- name: "[GITEA] - install"
|
||||
include_tasks: install.yml
|
||||
|
||||
- name: "[GITEA] - theme"
|
||||
include_tasks: custom_themes.yml
|
||||
when: gitea_custom_themes is defined
|
||||
|
@ -14,6 +17,3 @@
|
|||
|
||||
- name: "[GITEA] - systemd"
|
||||
include_tasks: systemd.yml
|
||||
|
||||
- name: "[GITEA] - install"
|
||||
include_tasks: install.yml
|
||||
|
|
|
@ -19,7 +19,6 @@
|
|||
{{ item }}
|
||||
{% endfor %}
|
||||
|
||||
|
||||
[database]
|
||||
{% for item in gitea_database_config %}
|
||||
{{ item }}
|
||||
|
@ -77,3 +76,32 @@
|
|||
{% for item in gitea_log_config %}
|
||||
{{ item }}
|
||||
{% endfor %}
|
||||
|
||||
[markup]
|
||||
{% for item in gitea_markup_config %}
|
||||
{% if item.name == 'asciidoc' and item.enable == 'true' %}
|
||||
[markup.asciidoc]
|
||||
ENABLED = true
|
||||
NEED_POSTPROCESS = true
|
||||
FILE_EXTENSIONS = .adoc,.asciidoc
|
||||
RENDER_COMMAND = "asciidoctor -s -a showtitle --out-file=- -"
|
||||
IS_INPUT_FILE = false
|
||||
RENDER_CONTENT_MODE = sanitized
|
||||
{% endif %}
|
||||
{% if item.name == 'jupyter' and item.enable == 'true' %}
|
||||
[markup.jupyter]
|
||||
ENABLED = true
|
||||
FILE_EXTENSIONS = .ipynb
|
||||
RENDER_COMMAND = "jupyter nbconvert --stdin --stdout --to html --template basic"
|
||||
IS_INPUT_FILE = false
|
||||
RENDER_CONTENT_MODE = sanitized
|
||||
{% endif %}
|
||||
{% if item.name == 'html' and item.enable == 'true' %}
|
||||
[markup.html]
|
||||
ENABLED = true
|
||||
FILE_EXTENSIONS = .html,.htm
|
||||
RENDER_COMMAND = cat
|
||||
IS_INPUT_FILE = true
|
||||
RENDER_CONTENT_MODE = sanitized
|
||||
{% endif %}
|
||||
{% endfor %}
|
Loading…
Reference in New Issue