Skip to content

Commit

Permalink
Merge pull request #894 from zirreal/robonomics-wiki-test
Browse files Browse the repository at this point in the history
matomo update
  • Loading branch information
zirreal authored Sep 24, 2024
2 parents 903db40 + da230f3 commit e367e33
Show file tree
Hide file tree
Showing 19 changed files with 341 additions and 16 deletions.
24 changes: 24 additions & 0 deletions src/_includes/components/matomoOptOut.njk
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<div id="matomo-opt-out" style="font-size: 18px;"></div>

{# for tanslation
{{'Opt-out complete; your visits to this website will not be recorded by the Web Analytics tool.' | t}}
{{'Note that if you clear your cookies, delete the opt-out cookie, or if you change computers or Web browsers, you will need to perform the opt-out procedure again.' | t}}
{{'You may choose to prevent this website from aggregating and analyzing the actions you take here.' | t}}
{{'Doing so will protect your privacy, but will also prevent the owner from learning from your actions and creating a better experience for you and other users.' | t}}
{{'The tracking opt-out feature requires cookies to be enabled.' | t}}
{{'The tracking opt-out feature may not work because this site was not loaded over HTTPS. Please reload the page to check if your opt out status changed;' | t}}
{{'You are not opted out.' | t}}
{{'Uncheck this box to opt-out.' | t}}
{{'You are currently opted out.' | t}}
{{'Check this box to opt-in.' | t}}
#}
4 changes: 1 addition & 3 deletions src/_includes/privacy-content.njk
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,7 @@
<div class="privacy-policy__wrapper">
<h2 class="privacy-policy__subtitle">{{'Opt-out of website tracking' | t}}</h2>
<p class="privacy-police__descr">{{'You can opt out of being tracked by our Matomo Analytics instance below:' | t}}</p>

<div id="matomo-opt-out"></div>
<script src="https://matomo.robonomics.network/index.php?module=CoreAdminHome&action=optOutJS&divId=matomo-opt-out&language={{page.lang}}&showIntro=1"></script>
{% include "./components/matomoOptOut.njk" %}

</div>

Expand Down
23 changes: 23 additions & 0 deletions src/assets/css/components/matomo.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#matomo-opt-out {
position: relative;
margin-bottom: var(--space);
}

#matomo-opt-out strong {
display: block;
padding-left: 40px;
font-size: var(--base-font-size);
}

#matomo-opt-out label {
position: relative;
}

#matomo-opt-out #trackVisits:checked + .custom-checkbox__content::after {
opacity: 1;
}

.custom-checkbox__content::after, .custom-checkbox__content::before {
top: unset;
bottom: 0;
}
1 change: 1 addition & 0 deletions src/assets/css/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
@import './components/sidebar.css';
@import './components/breadcrumbs.css';
@import './components/checkbox.css';
@import "./components/matomo.css";

/* pages */
@import './pages/home.css';
Expand Down
122 changes: 122 additions & 0 deletions src/assets/js/components/matomo.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
const {translateLine} = require('../customLineTranslation.js');


document.addEventListener('DOMContentLoaded', function() {

const language = document.getElementsByTagName("html")[0].getAttribute("lang");

var settings = {"showIntro":true,"divId":"matomo-opt-out","useSecureCookies":true,"cookiePath":null,"cookieDomain":null,"cookieSameSite":"Lax","OptOutComplete": translateLine("Opt-out complete; your visits to this website will not be recorded by the Web Analytics tool.", language),"OptOutCompleteBis": translateLine("Note that if you clear your cookies, delete the opt-out cookie, or if you change computers or Web browsers, you will need to perform the opt-out procedure again.", language),"YouMayOptOut2": translateLine("You may choose to prevent this website from aggregating and analyzing the actions you take here.", language),"YouMayOptOut3": translateLine("Doing so will protect your privacy, but will also prevent the owner from learning from your actions and creating a better experience for you and other users.", language),"OptOutErrorNoCookies": translateLine("The tracking opt-out feature requires cookies to be enabled.", language), "OptOutErrorNotHttps": translateLine("The tracking opt-out feature may not work because this site was not loaded over HTTPS. Please reload the page to check if your opt out status changed.", language), "YouAreNotOptedOut": translateLine("You are not opted out.", language),"UncheckToOptOut": translateLine("Uncheck this box to opt-out.", language),"YouAreOptedOut": translateLine("You are currently opted out.", language),"CheckToOptIn": translateLine("Check this box to opt-in.", language)};


function showContent(consent, errorMessage = null, useTracker = false) {

var errorBlock = '<p style="color: red; font-weight: bold;">';

var div = document.getElementById(settings.divId);
if (!div) {
var warningDiv = document.createElement("div");
var msg = 'Unable to find opt-out content div: "'+settings.divId+'"';
warningDiv.id = settings.divId+'-warning';
warningDiv.innerHTML = errorBlock+msg+'</p>';
document.body.insertBefore(warningDiv, document.body.firstChild);
console.log(msg);
return;
}

if (!navigator || !navigator.cookieEnabled) {
div.innerHTML = errorBlock+settings.OptOutErrorNoCookies+'</p>';
return;
}

if (errorMessage !== null) {
div.innerHTML = errorBlock+errorMessage+'</p>';
return;
}

var content = '';

if (location.protocol !== 'https:') {
content += errorBlock + settings.OptOutErrorNotHttps + '</p>';
}

if (consent) {
if (settings.showIntro) {
content += '<p>'+settings.YouMayOptOut2+' '+settings.YouMayOptOut3+'</p>';
}
if (useTracker) {
content += '<input onclick="_paq.push([\'optUserOut\']);showContent(false, null, true);" id="trackVisits" type="checkbox" checked="checked" class="custom-checkbox__field" /><span class="custom-checkbox__content"></span>';
} else {
content += '<input onclick="window.MatomoConsent.consentRevoked();showContent(false);" id="trackVisits" type="checkbox" checked="checked" class="custom-checkbox__field" /><span class="custom-checkbox__content"></span>';
}
content += '<label class="custom-checkbox" for="trackVisits"><strong><span>'+settings.YouAreNotOptedOut+' '+settings.UncheckToOptOut+'</span></strong></label>';
} else {
if (settings.showIntro) {
content += '<p>'+settings.OptOutComplete+' '+settings.OptOutCompleteBis+'</p>';
}
if (useTracker) {
content += '<input onclick="_paq.push([\'forgetUserOptOut\']);showContent(true, null, true);" id="trackVisits" type="checkbox" class="custom-checkbox__field" /><span class="custom-checkbox__content"></span>';
} else {
content += '<input onclick="window.MatomoConsent.consentGiven();showContent(true);" id="trackVisits" type="checkbox" class="custom-checkbox__field" /><span class="custom-checkbox__content"></span>';
}
content += '<label class="custom-checkbox" for="trackVisits"><strong><span>'+settings.YouAreOptedOut+' '+settings.CheckToOptIn+'</span></strong></label>';
}
div.innerHTML = content;
};

window.MatomoConsent = {
cookiesDisabled: (!navigator || !navigator.cookieEnabled),
CONSENT_COOKIE_NAME: 'mtm_consent', CONSENT_REMOVED_COOKIE_NAME: 'mtm_consent_removed',
cookieIsSecure: false, useSecureCookies: true, cookiePath: '', cookieDomain: '', cookieSameSite: 'Lax',
init: function(useSecureCookies, cookiePath, cookieDomain, cookieSameSite) {
this.useSecureCookies = useSecureCookies; this.cookiePath = cookiePath;
this.cookieDomain = cookieDomain; this.cookieSameSite = cookieSameSite;
if(useSecureCookies && location.protocol !== 'https:') {
console.log('Error with setting useSecureCookies: You cannot use this option on http.');
} else {
this.cookieIsSecure = useSecureCookies;
}
},
hasConsent: function() {
var consentCookie = this.getCookie(this.CONSENT_COOKIE_NAME);
var removedCookie = this.getCookie(this.CONSENT_REMOVED_COOKIE_NAME);
if (!consentCookie && !removedCookie) {
return true; // No cookies set, so opted in
}
if (removedCookie && consentCookie) {
this.setCookie(this.CONSENT_COOKIE_NAME, '', -129600000);
return false;
}
return (consentCookie || consentCookie !== 0);
},
consentGiven: function() {
this.setCookie(this.CONSENT_REMOVED_COOKIE_NAME, '', -129600000);
this.setCookie(this.CONSENT_COOKIE_NAME, new Date().getTime(), 946080000000);
},
consentRevoked: function() {
this.setCookie(this.CONSENT_COOKIE_NAME, '', -129600000);
this.setCookie(this.CONSENT_REMOVED_COOKIE_NAME, new Date().getTime(), 946080000000);
},
getCookie: function(cookieName) {
var cookiePattern = new RegExp('(^|;)[ ]*' + cookieName + '=([^;]*)'), cookieMatch = cookiePattern.exec(document.cookie);
return cookieMatch ? window.decodeURIComponent(cookieMatch[2]) : 0;
},
setCookie: function(cookieName, value, msToExpire) {
var expiryDate = new Date();
expiryDate.setTime((new Date().getTime()) + msToExpire);
document.cookie = cookieName + '=' + window.encodeURIComponent(value) +
(msToExpire ? ';expires=' + expiryDate.toGMTString() : '') +
';path=' + (this.cookiePath || '/') +
(this.cookieDomain ? ';domain=' + this.cookieDomain : '') +
(this.cookieIsSecure ? ';secure' : '') +
';SameSite=' + this.cookieSameSite;
if ((!msToExpire || msToExpire >= 0) && this.getCookie(cookieName) !== String(value)) {
console.log('There was an error setting cookie `' + cookieName + '`. Please check domain and path.');
}
}
}

window.MatomoConsent.init(settings.useSecureCookies, settings.cookiePath, settings.cookieDomain, settings.cookieSameSite);
window.showContent= showContent;
showContent(window.MatomoConsent.hasConsent());

});
1 change: 1 addition & 0 deletions src/assets/js/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@ import './components/video.js';
import './components/breadcrumbs.js';
import './components/navButtons.js';
import './components/feedback.js';
import './components/matomo.js';
import './main.js';
14 changes: 13 additions & 1 deletion translations/pages/ar/ar.json
Original file line number Diff line number Diff line change
Expand Up @@ -128,5 +128,17 @@
"by": "بواسطة",
"breadcrumb.title": "عنوان الفتات",
"Document summary Explore Robonomics with guides": "ملخص الوثيقة: استكشاف روبونوميكس مع الدلائل",
"This page not found": "هذه الصفحة غير موجودة"
"This page not found": "هذه الصفحة غير موجودة",
"Opt-out complete; your visits to this website will not be recorded by the Web Analytics tool.": "تم إلغاء الاشتراك بنجاح؛ لن يتم تسجيل زياراتك إلى هذا الموقع عبر أداة تحليل الويب",
"Note that if you clear your cookies, delete the opt-out cookie, or if you change computers or Web browsers, you will need to perform the opt-out procedure again.": "يرجى ملاحظة أنه إذا قمت بمسح ملفات تعريف الارتباط الخاصة بك، أو حذف ملف تعريف الارتباط لإلغاء الاشتراك، أو إذا قمت بتغيير الحاسوب أو المتصفح الإلكتروني، فسيتعين عليك إجراء إجراء إلغاء الاشتراك مرة أخرى.",
"You may choose to prevent this website from aggregating and analyzing the actions you take here.": "قد تختار منع هذا الموقع من تجميع وتحليل الإجراءات التي تقوم بها هنا.",
"Doing so will protect your privacy, but will also prevent the owner from learning from your actions and creating a better experience for you and other users.": "بالقيام بذلك ستحمي خصوصيتك، ولكن ستمنع أيضًا المالك من التعلم من أفعالك وخلق تجربة أفضل لك وللمستخدمين الآخرين.",
"The tracking opt-out feature requires cookies to be enabled.": "يتطلب ميزة عدم التتبع تمكين ملفات تعريف الارتباط.",
"The tracking opt-out feature may not work because this site was not loaded over HTTPS. Please reload the page to check if your opt out status changed;": "قد لا يعمل ميزة عدم التتبع لأن هذا الموقع لم يتم تحميله عبر HTTPS. يرجى إعادة تحميل الصفحة للتحقق مما إذا كان حالة عدم التتبع الخاصة بك قد تغيرت؛",
"You are not opted out.": "أنت لم تختار الخروج.",
"Uncheck this box to opt-out.": "ألغِ تحديد هذه الخانة لإلغاء الاشتراك.",
"You are currently opted out.": "أنت حالياً مستبعد.",
"Check this box to opt-in.": "حدد هذه الخانة للموافقة.",
"{# for tanslation": "{# للترجمة",
"#}": "I'm sorry, but the string \"#}\" does not have a specific meaning in English. It appears to be a random combination of characters. Can you provide more context or clarify the meaning so I can assist you better?"
}
14 changes: 13 additions & 1 deletion translations/pages/de/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -128,5 +128,17 @@
"by": "durch",
"breadcrumb.title": "breadcrumb.title",
"Document summary Explore Robonomics with guides": "Dokumentenzusammenfassung: Entdecken Sie Robonomics mit Anleitungen",
"This page not found": "Diese Seite wurde nicht gefunden."
"This page not found": "Diese Seite wurde nicht gefunden.",
"Opt-out complete; your visits to this website will not be recorded by the Web Analytics tool.": "Opt-out abgeschlossen; Ihre Besuche auf dieser Website werden nicht vom Web-Analyse-Tool aufgezeichnet.",
"Note that if you clear your cookies, delete the opt-out cookie, or if you change computers or Web browsers, you will need to perform the opt-out procedure again.": "Bitte beachten Sie, dass Sie, wenn Sie Ihre Cookies löschen, das Opt-out-Cookie löschen oder wenn Sie Ihren Computer oder Webbrowser wechseln, das Opt-out-Verfahren erneut durchführen müssen.",
"You may choose to prevent this website from aggregating and analyzing the actions you take here.": "Sie können wählen, diese Website daran zu hindern, die Aktionen zu aggregieren und zu analysieren, die Sie hier ausführen.",
"Doing so will protect your privacy, but will also prevent the owner from learning from your actions and creating a better experience for you and other users.": "Indem du dies tust, schützt du deine Privatsphäre, verhinderst jedoch auch, dass der Besitzer aus deinen Handlungen lernt und ein besseres Erlebnis für dich und andere Benutzer schafft.",
"The tracking opt-out feature requires cookies to be enabled.": "Die Funktion zum Deaktivieren der Verfolgung erfordert, dass Cookies aktiviert sind.",
"The tracking opt-out feature may not work because this site was not loaded over HTTPS. Please reload the page to check if your opt out status changed;": "Die Tracking-Opt-Out-Funktion funktioniert möglicherweise nicht, da diese Website nicht über HTTPS geladen wurde. Bitte laden Sie die Seite erneut, um zu überprüfen, ob sich Ihr Opt-Out-Status geändert hat.",
"You are not opted out.": "Du hast nicht abgelehnt.",
"Uncheck this box to opt-out.": "Deaktivieren Sie dieses Kästchen, um sich abzumelden.",
"You are currently opted out.": "Sie sind derzeit abgemeldet.",
"Check this box to opt-in.": "Kreuzen Sie dieses Kästchen an, um zuzustimmen.",
"{# for tanslation": "{# für Übersetzung",
"#}": "This string does not contain any meaningful text in English."
}
14 changes: 13 additions & 1 deletion translations/pages/el/el.json
Original file line number Diff line number Diff line change
Expand Up @@ -132,5 +132,17 @@
"by": "με",
"breadcrumb.title": "Τίτλος breadcrumb",
"Document summary Explore Robonomics with guides": "Περίληψη εγγράφου: Εξερευνήστε το Robonomics με οδηγούς",
"This page not found": "Αυτή η σελίδα δεν βρέθηκε"
"This page not found": "Αυτή η σελίδα δεν βρέθηκε",
"Opt-out complete; your visits to this website will not be recorded by the Web Analytics tool.": "Η αποχώρηση ολοκληρώθηκε. Οι επισκέψεις σας σε αυτό τον ιστότοπο δεν θα καταγράφονται από το εργαλείο Web Analytics.",
"Note that if you clear your cookies, delete the opt-out cookie, or if you change computers or Web browsers, you will need to perform the opt-out procedure again.": "Σημειώστε ότι αν διαγράψετε τα cookies σας, διαγράψετε το opt-out cookie, ή αν αλλάξετε υπολογιστές ή προγράμματα περιήγησης στο διαδίκτυο, θα χρειαστεί να εκτελέσετε ξανά τη διαδικασία opt-out.",
"You may choose to prevent this website from aggregating and analyzing the actions you take here.": "Μπορείτε να επιλέξετε να αποτρέψετε αυτή την ιστοσελίδα από τον συγκεντρωτικό και αναλυτικό έλεγχο των ενεργειών που κάνετε εδώ.",
"Doing so will protect your privacy, but will also prevent the owner from learning from your actions and creating a better experience for you and other users.": "Κάνοντας αυτό θα προστατεύσετε την ιδιωτικότητά σας, αλλά θα εμποδίσετε επίσης τον ιδιοκτήτη να μάθει από τις ενέργειές σας και να δημιουργήσει μια καλύτερη εμπειρία για εσάς και άλλους χρήστες.",
"The tracking opt-out feature requires cookies to be enabled.": "Η λειτουργία απενεργοποίησης της παρακολούθησης απαιτεί την ενεργοποίηση των cookies.",
"The tracking opt-out feature may not work because this site was not loaded over HTTPS. Please reload the page to check if your opt out status changed;": "Η λειτουργία απενεργοποίησης παρακολούθησης ενδέχεται να μη λειτουργεί επειδή αυτό το site δεν φορτώθηκε μέσω HTTPS. Παρακαλώ επαναφορτώστε τη σελίδα για να ελέγξετε εάν άλλαξε η κατάσταση της απενεργοποίησης.",
"You are not opted out.": "Δεν έχετε επιλέξει να μην συμμετέχετε.",
"Uncheck this box to opt-out.": "Κάντε κλικ σε αυτό το πλαίσιο για να επιλέξετε να μην λαμβάνετε ενημερώσεις.",
"You are currently opted out.": "Αυτή τη στιγμή έχετε απενεργοποιηθεί.",
"Check this box to opt-in.": "Επιλέξτε αυτό το πλαίσιο για να εγγραφείτε.",
"{# for tanslation": "{# για μετάφραση",
"#}": "#}"
}
Loading

0 comments on commit e367e33

Please sign in to comment.