Support renderers and more configuration options.

This commit is contained in:
Andrea Dell'Amico 2021-06-24 19:03:17 +02:00
parent f87a24cb87
commit 5f5f1418f6
Signed by: adellam
GPG Key ID: 147ABE6CEB9E20FF
13 changed files with 26597 additions and 72 deletions

View File

@ -9,7 +9,7 @@ Role Variables
The most important variables are listed below:
``` yaml
gitea_version: 1.14.2
gitea_version: 1.14.3
gitea_local_postgresql: True
gitea_local_mysql: False
gitea_local_mariadb: False

View File

@ -52,7 +52,7 @@ gitea_required_packages:
gitea_db_name: gitea
gitea_db_user: gitea_u
#gitea_db_pwd: put it into a vault file
gitea_db_host: localhost
gitea_db_host: postgres.priv.isti.cnr.it
gitea_db_port: 5432
gitea_db_ssl_mode: 'disable'
@ -71,20 +71,64 @@ gitea_require_signin_view: 'false'
gitea_users_page_enabled: 'false'
gitea_install_viewer_addons: True
gitea_addons_deb_packages:
gitea_py3_env_dpkg:
- jupyter
- asciidoctor
- pandoc
- python3-matplotlib
- python3-pandas
- python3-geopandas
gitea_markup_asciidoc_enabled: True
gitea_markup_jupyter_enabled: True
gitea_markup_restructuredtext_enabled: True
gitea_markup_sanitizer_tex_enabled: True
gitea_markup_markdown_enabled: True
gitea_renderers_global_conf:
- { section: 'markdown', option: 'CUSTOM_URL_SCHEMES', value: 'data', state: 'present' }
gitea_prometheus_metrics: False
gitea_markup_asciidoc_enabled: 'true'
gitea_markup_asciidoc_conf:
- { section: 'markup.asciidoc', option: 'ENABLED', value: '{{ gitea_markup_asciidoc_enabled }}', state: 'present' }
- { section: 'markup.asciidoc', option: 'FILE_EXTENSIONS', value: '.adoc,.asciidoc', state: 'present' }
- { section: 'markup.asciidoc', option: 'RENDER_COMMAND', value: '"asciidoctor -s -a showtitle --out-file=- -"', state: 'present' }
- { section: 'markup.asciidoc', option: 'IS_INPUT_FILE', value: 'false', state: 'present' }
gitea_markup_jupyter_enabled: 'true'
gitea_markup_jupyter_conf:
- { section: 'markup.jupyter', option: 'ENABLED', value: '{{ gitea_markup_jupyter_enabled }}', state: 'present' }
- { section: 'markup.jupyter', option: 'FILE_EXTENSIONS', value: '.ipynb', state: 'present' }
- { section: 'markup.jupyter', option: 'RENDER_COMMAND', value: '"jupyter nbconvert --stdout --to html --template full"', state: 'present' }
- { section: 'markup.jupyter', option: 'IS_INPUT_FILE', value: 'true', state: 'present' }
- { section: 'markup.sanitizer.jupyter.rule1', option: 'ALLOW_ATTR', value: 'class', state: 'present' }
- { section: 'markup.sanitizer.jupyter.rule1', option: 'ELEMENT', value: 'div', state: 'present' }
- { section: 'markup.sanitizer.jupyter.rule1', option: 'REGEXP', value: '', state: 'present' }
gitea_markup_docx_enabled: 'true'
gitea_markup_docx_conf:
- { section: 'markup.docx', option: 'ENABLED', value: '{{ gitea_markup_docx_enabled }}', state: 'present' }
- { section: 'markup.docx', option: 'FILE_EXTENSIONS', value: '.docx', state: 'present' }
- { section: 'markup.docx', option: 'RENDER_COMMAND', value: '"pandoc --from docx --to html --self-contained --template {{ gitea_data_dir }}/custom/templates/docx-basic.html"', state: 'present' }
- { section: 'markup.sanitizer.docx', option: 'ALLOW_DATA_URI_IMAGES', value: 'true', state: 'present' }
gitea_markup_restructuredtext_enabled: 'true'
gitea_markup_restructuredtext_conf:
- { section: 'markup.restructuredtext', option: 'ENABLED', value: '{{ gitea_markup_restructuredtext_enabled }}', state: 'present' }
- { section: 'markup.restructuredtext', option: 'FILE_EXTENSIONS', value: '.rst', state: 'present' }
- { section: 'markup.restructuredtext', option: 'RENDER_COMMAND', value: '"timeout 30s pandoc +RTS -M512M -RTS -f rst"', state: 'present' }
- { section: 'markup.restructuredtext', option: 'IS_INPUT_FILE', value: 'false', state: 'present' }
gitea_markup_sanitizer_tex_enabled: 'true'
gitea_markup_sanitizer_tex_conf:
- { section: 'markup.sanitizer.TeX', option: 'ENABLED', value: '{{ gitea_markup_sanitizer_tex_enabled }}', state: 'present' }
- { section: 'markup.sanitizer.TeX', option: 'ELEMENT', value: 'span', state: 'present' }
- { section: 'markup.sanitizer.TeX', option: 'ALLOW_ATTR', value: 'class', state: 'present' }
- { section: 'markup.sanitizer.TeX', option: 'REGEXP', value: '^\s*((math(\s+|$)|inline(\s+|$)|display(\s+|$)))+', state: 'present' }
gitea_markup_markdown_enabled: 'true'
gitea_markup_markdown_conf:
- { section: 'markup.markdown', option: 'ENABLED', value: '{{ gitea_markup_markdown_enabled }}', state: 'present' }
- { section: 'markup.markdown', option: 'FILE_EXTENSIONS', value: '.md,.markdown', state: 'present' }
- { section: 'markup.markdown', option: 'RENDER_COMMAND', value: 'pandoc -f markdown -t html --katex', state: 'present' }
gitea_prometheus_metrics: 'false'
#gitea_prometheus_bearer_token: put it into a vault file
gitea_prometheus_bearer_token: ''
gitea_prometheus_conf:
- { section: 'metrics', option: 'ENABLED', value: '{{ gitea_prometheus_metrics }}', state: 'present' }
- { section: 'metrics', option: 'TOKEN', value: '{{ gitea_prometheus_bearer_token }}', state: 'present' }
gitea_log_level: Info
gitea_app_configurations:

3
files/header.tmpl Normal file
View File

@ -0,0 +1,3 @@
<!-- lets import the less stylesheet {{AppSubUrl}} is a variable that gitea will autofill -->
<link rel="stylesheet" type="text/css" href="{{AppSubUrl}}/css/jupyter.css" />

13333
files/jupyter.css Normal file

File diff suppressed because it is too large Load Diff

13013
files/jupyter.less Normal file

File diff suppressed because it is too large Load Diff

View File

@ -46,4 +46,9 @@ dependencies:
name: memcached
version: master
state: latest
- src: git+https://gitea-s2i2s.isti.cnr.it/ISTI-ansible-roles/ansible-role-python3-environment.git
when: gitea_install_viewer_addons
name: python3-environment
version: master
state: latest

View File

@ -1,10 +0,0 @@
---
- name: Install the packages required by the gitea viewers
block:
- name: Install the packages required by the gitea viewers
apt:
pkg: '{{ gitea_addons_deb_packages }}'
state: present
cache_valid_time: 1800
tags: [ 'git', 'gitea', 'gitea_addons' ]

View File

@ -77,6 +77,21 @@
notify: restart gitea
tags: [ 'git', 'gitea', 'gitea_conf' ]
- name: Prometheus metrics
ini_file:
path: '{{ gitea_conf_dir }}/app.ini'
section: '{{ item.section }}'
option: '{{ item.option }}'
value: '{{ item.value }}'
state: '{{ item.state }}'
owner: '{{ gitea_user }}'
group: '{{ gitea_group }}'
mode: '0640'
create: no
loop: '{{ gitea_prometheus_conf }}'
notify: restart gitea
tags: [ 'git', 'gitea', 'gitea_conf' ]
- name: Create the tmpfile entry for the gitea socket directory
template:
src: tmpfile_gitea.conf.j2
@ -85,8 +100,19 @@
group: root
mode: 0644
- name: Create some custom subdirectories
become: true
become_user: '{{ gitea_user }}'
file:
dest: '{{ gitea_data_dir }}/custom/{{ item }}'
state: directory
loop:
- 'templates/custom'
- 'public/css'
tags: [ 'git', 'gitea', 'gitea_conf' ]
- name: Install the gitea systemd unit
template: src=gitea.service.systemd dest=/etc/systemd/system/gitea.service
template: src=gitea.service.systemd.j2 dest=/etc/systemd/system/gitea.service
register: gitea_systemd_unit
- name: Reload the systemd configuration

View File

@ -1,4 +1,3 @@
---
- import_tasks: gitea.yml
- import_tasks: deb-addons.yml
when: ansible_distribution_file_variety == "Debian"
- import_tasks: renderers.yml

157
tasks/renderers.yml Normal file
View File

@ -0,0 +1,157 @@
---
- name: Global renderers config
block:
- name: Global renderers config
ini_file:
path: '{{ gitea_conf_dir }}/app.ini'
section: '{{ item.section }}'
option: '{{ item.option }}'
value: '{{ item.value }}'
state: '{{ item.state }}'
owner: '{{ gitea_user }}'
group: '{{ gitea_group }}'
mode: '0640'
create: no
loop: '{{ gitea_renderers_global_conf }}'
when: gitea_install_viewer_addons
notify: restart gitea
tags: [ 'git', 'gitea', 'gitea_addons', 'gitea_conf', 'gitea_renderers' ]
- name: Configure asciidoc
block:
- name: Configure asciidoc
ini_file:
path: '{{ gitea_conf_dir }}/app.ini'
section: '{{ item.section }}'
option: '{{ item.option }}'
value: '{{ item.value }}'
state: '{{ item.state }}'
owner: '{{ gitea_user }}'
group: '{{ gitea_group }}'
mode: '0640'
create: no
loop: '{{ gitea_markup_asciidoc_conf }}'
when: gitea_install_viewer_addons
notify: restart gitea
tags: [ 'git', 'gitea', 'gitea_addons', 'gitea_conf', 'gitea_asciidoc' ]
- name: Configure jupyter markup
block:
- name: Configure jupyter markup
ini_file:
path: '{{ gitea_conf_dir }}/app.ini'
section: '{{ item.section }}'
option: '{{ item.option }}'
value: '{{ item.value }}'
state: '{{ item.state }}'
owner: '{{ gitea_user }}'
group: '{{ gitea_group }}'
mode: '0640'
create: no
loop: '{{ gitea_markup_jupyter_conf }}'
when: gitea_install_viewer_addons
notify: restart gitea
- name: Install the jupyter CSS
become: true
become_user: '{{ gitea_user }}'
copy:
src: jupyter.css
dest: '{{ gitea_data_dir }}/custom/public/css/jupyter.css'
mode: 0444
- name: Install html template that loads the CSS
become: true
become_user: '{{ gitea_user }}'
copy:
src: header.tmpl
dest: '{{ gitea_data_dir }}/custom/templates/custom/header.tmpl'
mode: 0444
tags: [ 'git', 'gitea', 'gitea_addons', 'gitea_conf', 'gitea_jupyter' ]
- name: Configure restructuredtext markup
block:
- name: Configure restructuredtext markup
ini_file:
path: '{{ gitea_conf_dir }}/app.ini'
section: '{{ item.section }}'
option: '{{ item.option }}'
value: '{{ item.value }}'
state: '{{ item.state }}'
owner: '{{ gitea_user }}'
group: '{{ gitea_group }}'
mode: '0640'
create: no
loop: '{{ gitea_markup_restructuredtext_conf }}'
when: gitea_install_viewer_addons
notify: restart gitea
tags: [ 'git', 'gitea', 'gitea_addons', 'gitea_conf', 'gitea_restructuredtext' ]
- name: Configure sanitizer TeX markup
block:
- name: Configure sanitizer TeX markup
ini_file:
path: '{{ gitea_conf_dir }}/app.ini'
section: '{{ item.section }}'
option: '{{ item.option }}'
value: '{{ item.value }}'
state: '{{ item.state }}'
owner: '{{ gitea_user }}'
group: '{{ gitea_group }}'
mode: '0640'
create: no
loop: '{{ gitea_markup_sanitizer_tex_conf }}'
when: gitea_install_viewer_addons
notify: restart gitea
tags: [ 'git', 'gitea', 'gitea_addons', 'gitea_conf', 'gitea_sanitizer_tex' ]
- name: Configure markdown markup
block:
- name: Configure markdown markup
ini_file:
path: '{{ gitea_conf_dir }}/app.ini'
section: '{{ item.section }}'
option: '{{ item.option }}'
value: '{{ item.value }}'
state: '{{ item.state }}'
owner: '{{ gitea_user }}'
group: '{{ gitea_group }}'
mode: '0640'
create: no
loop: '{{ gitea_markup_markdown_conf }}'
when: gitea_install_viewer_addons
notify: restart gitea
tags: [ 'git', 'gitea', 'gitea_addons', 'gitea_conf', 'gitea_markdown' ]
- name: Configure docx markup
block:
- name: Configure the docx markup
ini_file:
path: '{{ gitea_conf_dir }}/app.ini'
section: '{{ item.section }}'
option: '{{ item.option }}'
value: '{{ item.value }}'
state: '{{ item.state }}'
owner: '{{ gitea_user }}'
group: '{{ gitea_group }}'
mode: '0640'
create: no
loop: '{{ gitea_markup_docx_conf }}'
notify: restart gitea
- name: Create the docx template
become: true
become_user: '{{ gitea_user }}'
copy:
content: "$body$"
dest: '{{ gitea_data_dir }}/custom/templates/docx-basic.html'
when: gitea_install_viewer_addons
tags: [ 'git', 'gitea', 'gitea_addons', 'gitea_conf', 'gitea_docx' ]

View File

@ -62,55 +62,6 @@ HOST = {{ gitea_cache_host }}
PROVIDER = {{ gitea_session_provider }}
PROVIDER_CONFIG = {{ gitea_session_config }}
{% if gitea_prometheus_metrics %}
[metrics]
ENABLED = true
TOKEN = '{{ gitea_prometheus_bearer_token }}'
{% endif %}
{% if gitea_install_viewer_addons %}
{% if gitea_markup_asciidoc_enabled %}
[markup.asciidoc]
ENABLED = true
FILE_EXTENSIONS = .adoc,.asciidoc
RENDER_COMMAND = "asciidoctor -s -a showtitle --out-file=- -"
; Input is not a standard input but a file
IS_INPUT_FILE = false
{%endif %}
{% if gitea_markup_jupyter_enabled %}
[markup.jupyter]
ENABLED = true
FILE_EXTENSIONS = .ipynb
RENDER_COMMAND = "jupyter nbconvert --stdout --to html --template basic "
IS_INPUT_FILE = true
{%endif %}
{% if gitea_markup_restructuredtext_enabled %}
[markup.restructuredtext]
ENABLED = true
FILE_EXTENSIONS = .rst
RENDER_COMMAND = "timeout 30s pandoc +RTS -M512M -RTS -f rst"
IS_INPUT_FILE = false
{%endif %}
{% if gitea_markup_sanitizer_tex_enabled %}
[markup.sanitizer.TeX]
; Pandoc renders TeX segments as <span>s with the "math" class, optionally
; with "inline" or "display" classes depending on context.
ELEMENT = span
ALLOW_ATTR = class
REGEXP = ^\s*((math(\s+|$)|inline(\s+|$)|display(\s+|$)))+
{%endif %}
{% if gitea_markup_markdown_enabled %}
[markup.markdown]
ENABLED = true
FILE_EXTENSIONS = .md,.markdown
RENDER_COMMAND = pandoc -f markdown -t html --katex
{%endif %}
{%endif %}
[other]
SHOW_FOOTER_VERSION = false
SHOW_FOOTER_TEMPLATE_LOAD_TIME = false

View File

@ -30,7 +30,10 @@ Group={{ gitea_user }}
WorkingDirectory={{ gitea_data_dir }}
ExecStart=/usr/local/bin/gitea web -c {{ gitea_conf_dir }}/app.ini
Restart=always
Environment=USER={{ gitea_user }} HOME=/srv/gitea GITEA_WORK_DIR={{ gitea_data_dir }}
Environment=USER={{ gitea_user }}
Environment=HOME=/srv/gitea
Environment=GITEA_WORK_DIR={{ gitea_data_dir }}
Environment=GITEA_CUSTOM={{ gitea_data_dir }}/custom
# If you want to bind Gitea to a port below 1024 uncomment
# the two values below
###

View File

@ -3,4 +3,5 @@ nginx_use_common_virthost: True
redis_install: True
http_port: 80
https_port: 443
py3_env_dpkg: '{{ gitea_py3_env_dpkg }}'