Added configuration_filters

This commit is contained in:
2025-02-19 13:46:45 +01:00
parent 7377aa9c20
commit 0c7af2ce89
16 changed files with 59 additions and 36 deletions

View File

@@ -7,10 +7,10 @@ This role enhances your Nginx configuration by conditionally injecting global Ma
## Features
- **Global Matomo Tracking**
When enabled (`global_matomo_tracking_enabled` is `true`), the role includes Matomo tracking configuration and injects the corresponding tracking script into your HTML.
The role includes Matomo tracking configuration and injects the corresponding tracking script into your HTML.
- **Global Theming**
When enabled (`global_theming_enabled` is `true`), the role injects a global CSS link for consistent theming across your site.
The role injects a global CSS link for consistent theming across your site.
- **Smart Injection**
Uses Nginx's `sub_filter` to insert the tracking and theming snippets right before the closing `</head>` tag of your HTML documents.

View File

@@ -1,2 +0,0 @@
dependencies:
- nginx-modifier-css # Just required to load once

View File

@@ -1,3 +1,8 @@
- name: "Activate Global CSS for {{domain}}"
include_role:
name: nginx-modifier-css
when: applications | get_css_enabled(application_id)
- name: "Activate Global Matomo Tracking for {{domain}}"
include_role:
name: nginx-modifier-matomo

View File

@@ -7,11 +7,11 @@ sub_filter_types text/html;
{% include 'roles/nginx-modifier-matomo/templates/matomo-tracking.conf.j2' %}
{% endif %}
{% if global_theming_enabled | bool or global_matomo_tracking_enabled | bool%}
sub_filter '</head>' '{% if global_matomo_tracking_enabled | bool %}{% include 'roles/nginx-modifier-matomo/templates/script.j2' %}{% endif %}{% if global_theming_enabled | bool %}{% include 'roles/nginx-modifier-css/templates/link.j2' %}{% endif %}</head>';
{% if applications | get_css_enabled(application_id) or global_matomo_tracking_enabled | bool%}
sub_filter '</head>' '{% if global_matomo_tracking_enabled | bool %}{% include 'roles/nginx-modifier-matomo/templates/script.j2' %}{% endif %}{% if applications | get_css_enabled(application_id) %}{% include 'roles/nginx-modifier-css/templates/link.j2' %}{% endif %}</head>';
{% endif %}
{% if global_theming_enabled | bool %}
{% if applications | get_css_enabled(application_id) %}
{# Include Global CSS Location #}
{% include 'roles/nginx-modifier-css/templates/location.conf.j2' %}
{% endif %}