From 8a9fbcf89fc19fc1476bb7c24648a2bb64f27a77 Mon Sep 17 00:00:00 2001 From: Matthieu Marrast <38913120+matthieumarrast@users.noreply.github.com> Date: Fri, 23 Feb 2024 09:39:44 +0100 Subject: [PATCH] feat: handle autoindex format (#261) Close: #260 --- adm/plugins.py | 11 ++++++++++- .../plugins/default/{{cookiecutter.name}}/config.ini | 4 ++++ config/nginx.conf | 1 + 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/adm/plugins.py b/adm/plugins.py index 39198ff..339c0f8 100644 --- a/adm/plugins.py +++ b/adm/plugins.py @@ -57,7 +57,11 @@ def coerce_storage_forbidden_dav_methods(value): "storage_dav_access": { **NON_REQUIRED_STRING, "default": "" - } + }, + "storage_autoindex_format": { + **NON_REQUIRED_STRING, + "default": "html", + }, } } } @@ -130,3 +134,8 @@ def storage_satisfy(self): def storage_forbidden_dav_methods(self): self.load() return self._doc["general"]["storage_forbidden_dav_methods"] + + @property + def storage_autoindex_format(self): + self.load() + return self._doc["general"]["storage_autoindex_format"] diff --git a/adm/templates/plugins/default/{{cookiecutter.name}}/config.ini b/adm/templates/plugins/default/{{cookiecutter.name}}/config.ini index e2191c8..22ba4ad 100644 --- a/adm/templates/plugins/default/{{cookiecutter.name}}/config.ini +++ b/adm/templates/plugins/default/{{cookiecutter.name}}/config.ini @@ -69,3 +69,7 @@ storage_forbidden_dav_methods=null # - if _use_storage=1 : user:rw # - if _use_storage=0 : null storage_dav_access={% if cookiecutter.use_storage == "no" %}null{% else %}user:rw{% endif %} + +# If storage_autoindex = 1 (default) in module configuration, sets the format of directory listing +# (see http://nginx.org/en/docs/http/ngx_http_autoindex_module.html#autoindex_format) +storage_autoindex_format=html diff --git a/config/nginx.conf b/config/nginx.conf index 114e567..da1ce49 100644 --- a/config/nginx.conf +++ b/config/nginx.conf @@ -82,6 +82,7 @@ http { min_delete_depth {{MFBASE_NGINX_STORAGE_MIN_DELETE_DEPTH}}; {% if MFBASE_NGINX_STORAGE_AUTOINDEX == "1" %} autoindex on; + autoindex_format {{PLUGIN.configuration.storage_autoindex_format}}; {% endif %} satisfy {{PLUGIN.configuration.storage_satisfy}}; {% for ALLOW in PLUGIN.configuration.storage_access_allows.split(',') %}