mirror of
https://github.com/kevinveenbirkenbach/computer-playbook.git
synced 2025-08-29 15:06:26 +02:00
Solved Matomo domain bug and refactored
This commit is contained in:
29
roles/nginx-modifier-all/README.md
Normal file
29
roles/nginx-modifier-all/README.md
Normal file
@@ -0,0 +1,29 @@
|
||||
# Nginx Global Matomo & Theming Modifier Role 🚀
|
||||
|
||||
This role enhances your Nginx configuration by conditionally injecting global Matomo tracking and theming elements into your HTML responses. It uses Nginx sub-filters to seamlessly add tracking scripts and CSS links to your web pages.
|
||||
|
||||
---
|
||||
|
||||
## 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.
|
||||
|
||||
- **Global Theming**
|
||||
When enabled (`global_theming_enabled` is `true`), 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.
|
||||
|
||||
|
||||
This will automatically activate Matomo tracking and/or global theming based on your configuration.
|
||||
|
||||
---
|
||||
|
||||
## Author
|
||||
|
||||
Developed by [Kevin Veen-Birkenbach](https://www.veen.world) 😎
|
||||
|
||||
---
|
||||
|
||||
Happy automating! 🎉
|
2
roles/nginx-modifier-all/meta/main.yml
Normal file
2
roles/nginx-modifier-all/meta/main.yml
Normal file
@@ -0,0 +1,2 @@
|
||||
dependencies:
|
||||
- nginx-modifier-css # Just required to load once
|
4
roles/nginx-modifier-all/tasks/main.yml
Normal file
4
roles/nginx-modifier-all/tasks/main.yml
Normal file
@@ -0,0 +1,4 @@
|
||||
- name: "Activate Global Matomo Tracking for {{domain}}"
|
||||
include_role:
|
||||
name: nginx-modifier-matomo
|
||||
when: global_matomo_tracking_enabled | bool
|
17
roles/nginx-modifier-all/templates/global.includes.conf.j2
Normal file
17
roles/nginx-modifier-all/templates/global.includes.conf.j2
Normal file
@@ -0,0 +1,17 @@
|
||||
# Allow multiple sub_filters
|
||||
sub_filter_once off;
|
||||
sub_filter_types text/html;
|
||||
|
||||
{% if global_matomo_tracking_enabled | bool %}
|
||||
# Include Global Matomo Tracking
|
||||
{% 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>';
|
||||
{% endif %}
|
||||
|
||||
{% if global_theming_enabled | bool %}
|
||||
# Include Global CSS Location
|
||||
{% include 'roles/nginx-modifier-css/templates/location.conf.j2' %}
|
||||
{% endif %}
|
Reference in New Issue
Block a user