Skip to content

Commit

Permalink
Update _includes/cookie-consent.html, _posts/2023-06-28-Gitlab.md
Browse files Browse the repository at this point in the history
  • Loading branch information
Carsten Stamm committed Jul 14, 2023
1 parent b9fb48f commit e375e4f
Show file tree
Hide file tree
Showing 2 changed files with 65 additions and 40 deletions.
104 changes: 65 additions & 39 deletions _includes/cookie-consent.html
Original file line number Diff line number Diff line change
@@ -1,46 +1,72 @@
<style>
#cookie-notice {padding: 0.5rem 1rem; display: none; text-align: center; position: fixed; bottom: 0; width: calc(100% - 2rem); background: #222; color: rgba(255,255,255,0.8);}
#cookie-notice a {display: inline-block; cursor: pointer; margin-left: 0.5rem;}
@media (max-width: 767px) {
#cookie-notice span {display: block; padding-top: 3px; margin-bottom: 1rem;}
#cookie-notice a {position: relative; bottom: 4px;}
}
</style>
<div id="cookie-notice"><span>We would like to use third party cookies and scripts to improve the functionality of this website.</span><a id="cookie-notice-accept" class="btn btn-primary btn-sm">Approve</a><a href="/privacy" class="btn btn-primary btn-sm">More info</a></div>
<!-- Only add all this in production, why would I analyse myself when writing the post anyway. -->
{% if jekyll.environment == 'production' %}

<!-- Add cookie consent css & js -->
<link rel="stylesheet"
type="text/css"
href="https://cdn.jsdelivr.net/npm/cookieconsent@3/build/cookieconsent.min.css"/>
<script src="https://cdn.jsdelivr.net/npm/cookieconsent@3/build/cookieconsent.min.js"
data-cfasync="false"></script>

<!-- Add google analytics -->
<!--
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-XXXXXXXX-X"></script>
-->


<script>
function createCookie(name,value,days) {
var expires = "";
if (days) {
var date = new Date();
date.setTime(date.getTime() + (days*24*60*60*1000));
expires = "; expires=" + date.toUTCString();
}
document.cookie = name + "=" + value + expires + "; path=/";
// Reads the value of a cookie by name or returns empty string
function getCookie(name) {
var b = document.cookie.match('(^|[^;]+)\\s*' + name + '\\s*=\\s*([^;]+)');
return b ? b.pop() : '';
}
function readCookie(name) {
var nameEQ = name + "=";
var ca = document.cookie.split(';');
for(var i=0;i < ca.length;i++) {
var c = ca[i];
while (c.charAt(0)==' ') c = c.substring(1,c.length);
if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);

// Actually starting analytics up
function addAnalytics() {
window.dataLayer = window.dataLayer || [];

function gtag() {
dataLayer.push(arguments);
}
return null;
}
function eraseCookie(name) {
createCookie(name,"",-1);
}

if(readCookie('cookie-notice-dismissed')=='true') {
//{% include ga.js %}
//{% include chatbutton.js %}
} else {
document.getElementById('cookie-notice').style.display = 'block';
gtag('js', new Date());
gtag('config', 'UA-XXXXXXXX-X');
}
document.getElementById('cookie-notice-accept').addEventListener("click",function() {
createCookie('cookie-notice-dismissed','true',31);
document.getElementById('cookie-notice').style.display = 'none';
location.reload();
});

// Waiting for the load event
window.addEventListener("load", function () {
// Reading "cookieconsent_status" cookie
const cookieConsent = getCookie('cookieconsent_status');

// Start analytics if user consented or did not deny
if (cookieConsent === 'allow' || cookieConsent === '') {
addAnalytics();
}

// Initialise cookie consent banner
window.cookieconsent.initialise({
"palette": {
"popup": {
"background": "#efefef",
"text": "#404040"
},
"button": {
"background": "#8ec760",
"text": "#ffffff"
}
},
"type": "opt-out",
"content": {
"allow": "Approve",
"dismiss": "Approve",
"deny": "Reject"
},
// Reload the page on user choice to make sure cookie is set
onStatusChange: function (status, chosenBefore) {
location.reload();
}
})
});
</script>

{% endif %}
1 change: 0 additions & 1 deletion _posts/2023-06-28-Gitlab.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,4 @@ Da ich einiges an Sourcecode besitze und sich mit der Zeit einige kleine Scripte
## ...ist das nicht zu viel?
Ja das mag sein, aber immerhin kann ich ziemlich genau meine Arbeit (und vorallem meine Zeit) zurück verfolgen die ich an einem Stück Code verbracht habe.

## Was macht Gitlab heute bei mir?

0 comments on commit e375e4f

Please sign in to comment.