Skip to content

Commit

Permalink
add privacy policy, cookie policy and cookie consent using osano
Browse files Browse the repository at this point in the history
  • Loading branch information
fethiozdol committed Jul 3, 2024
1 parent 336c66e commit 1da3ce8
Show file tree
Hide file tree
Showing 15 changed files with 375 additions and 26 deletions.
25 changes: 2 additions & 23 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -51,19 +51,11 @@ GEM
loofah (>= 2.3.1, < 3)
sax-machine (>= 1.0, < 2)
ffi (1.17.0-aarch64-linux-gnu)
ffi (1.17.0-arm64-darwin)
ffi (1.17.0-x86_64-linux-gnu)
forwardable-extended (2.6.0)
gemoji (4.1.0)
google-protobuf (4.27.2-aarch64-linux)
bigdecimal
rake (>= 13)
google-protobuf (4.27.2-arm64-darwin)
bigdecimal
rake (>= 13)
google-protobuf (4.27.2-x86_64-linux)
bigdecimal
rake (>= 13)
html-pipeline (2.14.3)
activesupport (>= 2)
nokogiri (>= 1.4)
Expand Down Expand Up @@ -143,8 +135,6 @@ GEM
kramdown (~> 2.0)
latex-decode (0.4.0)
libv8-node (21.7.2.0-aarch64-linux)
libv8-node (21.7.2.0-arm64-darwin)
libv8-node (21.7.2.0-x86_64-linux)
liquid (4.0.4)
listen (3.9.0)
rb-fsevent (~> 0.10, >= 0.10.3)
Expand All @@ -165,10 +155,6 @@ GEM
racc (~> 1.7)
nokogiri (1.16.5-aarch64-linux)
racc (~> 1.4)
nokogiri (1.16.5-arm64-darwin)
racc (~> 1.4)
nokogiri (1.16.5-x86_64-linux)
racc (~> 1.4)
pathutil (0.16.2)
forwardable-extended (~> 2.6)
public_suffix (6.0.0)
Expand All @@ -177,17 +163,12 @@ GEM
rb-fsevent (0.11.2)
rb-inotify (0.11.1)
ffi (~> 1.0)
rexml (3.3.1)
strscan
rexml (3.2.8)
rouge (4.3.0)
safe_yaml (1.0.5)
sass-embedded (1.77.5)
google-protobuf (>= 3.25, < 5.0)
rake (>= 13)
sass-embedded (1.77.5-arm64-darwin)
sass-embedded (1.77.5-aarch64-linux-gnu)
google-protobuf (>= 3.25, < 5.0)
sax-machine (1.3.2)
strscan (3.1.0)
terminal-table (3.0.2)
unicode-display_width (>= 1.1.1, < 3)
tzinfo (2.0.6)
Expand All @@ -200,8 +181,6 @@ GEM

PLATFORMS
aarch64-linux-gnu
arm64-darwin-23
x86_64-linux

DEPENDENCIES
classifier-reborn
Expand Down
4 changes: 4 additions & 0 deletions _config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ contact_note: >

# For Google Analytics, see https://support.google.com/analytics/answer/10447272?hl=en&ref_topic=14088998&sjid=5129943941510317771-SA#zippy=%2Cgoogle-sites
# and follow the instructions for Google Sites. You will need to create a Google Analytics property and copy the Google tag ID.
google_tag_manager: GTM-WRRMQF2G
google_analytics: G-BFVSGSW9BJ # your Google Analytics measurement ID (format: G-XXXXXXXXXX)
cronitor_analytics: # cronitor RUM analytics site ID (format: XXXXXXXXX)
pirsch_analytics: # your Pirsch analytics site ID (length 32 characters)
Expand Down Expand Up @@ -431,6 +432,9 @@ enable_project_categories: true # enables categorization of projects into multip
enable_medium_zoom: true # enables image zoom feature (as on medium.com)
enable_progressbar: true # enables a horizontal progress bar linked to the vertical scroll position
enable_video_embedding: false # enables video embedding for bibtex entries. If false, the button opens the video link in a new window.
enable_google_tag_manager: true

enable_osano: true

# -----------------------------------------------------------------------------
# Library versions
Expand Down
6 changes: 6 additions & 0 deletions _includes/footer.liquid
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@
Last updated: {{ 'now' | date: '%B %d, %Y' }}.
{% endif %}
</div>
{% if site.enable_osano %}
<div id="osano-cookieconsent"></div>
{% endif %}
</footer>
{% else %}
<footer class="sticky-bottom mt-5" role="contentinfo">
Expand All @@ -31,5 +34,8 @@
Last updated: {{ 'now' | date: '%B %d, %Y' }}.
{% endif %}
</div>
{% if site.enable_osano %}
<div id="osano-cookieconsent"></div>
{% endif %}
</footer>
{% endif %}
14 changes: 14 additions & 0 deletions _includes/head.liquid
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,20 @@
</script>
{% endif %}

<!-- Osano Cookie Consent -->
<link rel="stylesheet" type="text/css" href="https://cdn.jsdelivr.net/npm/cookieconsent@3/build/cookieconsent.min.css" />
<!-- Osano Cookie Consent -->

<!-- Google Tag Manager -->
{% if site.enable_google_tag_manager %}
<script>(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
})(window,document,'script','dataLayer','{{ site.google_tag_manager }}');</script>
{% endif %}
<!-- End Google Tag Manager -->

<!-- GeoJSON support via Leaflet -->
{% if page.map %}
<link
Expand Down
12 changes: 11 additions & 1 deletion _includes/scripts/analytics.liquid
Original file line number Diff line number Diff line change
@@ -1,11 +1,21 @@
{% if site.enable_google_analytics %}
<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id={{ site.google_analytics }}"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag() {
window.dataLayer.push(arguments);
}
gtag('consent', 'default', {
'ad_storage': 'denied',
'ad_user_data': 'denied',
'ad_personalization': 'denied',
'analytics_storage': 'denied'
});
</script>
<script async src="https://www.googletagmanager.com/gtag/js?id={{ site.google_analytics }}"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag() { window.dataLayer.push(arguments); }
gtag('js', new Date());
gtag('config', '{{ site.google_analytics }}');
</script>
Expand Down
6 changes: 6 additions & 0 deletions _includes/scripts/googletagmanager.liquid
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{% if site.enable_google_tag_manager %}
<!-- Google Tag Manager (noscript) -->
<noscript><iframe src="https://www.googletagmanager.com/ns.html?id={{ site.google_tag_manager }}"
height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>
<!-- End Google Tag Manager (noscript) -->
{% endif %}
82 changes: 82 additions & 0 deletions _includes/scripts/osano_cookieconsent.liquid
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
{% if site.enable_osano %}
<!-- Osano Cookie Consent -->
<script src="https://cdn.jsdelivr.net/npm/cookieconsent@3/build/cookieconsent.min.js"></script>
<script>
function consentAnalyticsStorage() {
gtag('consent', 'update', {
'analytics_storage': 'granted'
});
}
function denyAnalyticsStorage() {
gtag('consent', 'update', {
'analytics_storage': 'denied'
});
}
window.cookieconsent.initialise({
container: document.getElementById("osano-cookieconsent"),
palette: {
"popup": {
"background": "#e7c000",
"text": "#000"
},
"button": {
"background": "#009f06"
},
"highlight": {
"background": "#b71c1c"
}
},
content: {
allow: 'Allow All',
deny: 'Deny',
link: 'Privacy Policy',
href: '/terms/',
header: 'A note to visitors',
message: 'This website uses only necessary and statistics cookies to improve functionality and analyse traffic. It does not use marketing or tracking cookies and it does not process any personally identifiable information. Please visit Privacy Policy page for more details.'
},
elements: {
'messagelink': '<span id="cookieconsent:desc" class="cc-message-custom">\{\{message\}\} <strong><a aria-label="learn more about cookies" tabindex="0" class="cc-link" href="\{\{href\}\}" target="_self">\{\{link\}\}</a></strong></span>'
},
type: "opt-in",
revokable: true,
animateRevokable: false,
onInitialise: function (status) {
var type = this.options.type;
var didConsent = this.hasConsented();
if (type == 'opt-in' && didConsent) {
// enable cookies
consentAnalyticsStorage();
}
if (type == 'opt-out' && !didConsent) {
// disable cookies
}
},
onStatusChange: function (status, chosenBefore) {
var type = this.options.type;
var didConsent = this.hasConsented();
if (type == 'opt-in' && didConsent) {
// enable cookies
consentAnalyticsStorage();
}
if (type == 'opt-out' && !didConsent) {
// disable cookies
}
},
onRevokeChoice: function () {
var type = this.options.type;
if (type == 'opt-in') {
denyAnalyticsStorage();
}
if (type == 'opt-out') {
// enable cookies
consentAnalyticsStorage();
}
},
law: {
regionalLaw: false,
},
location: true,
});
</script>
<!-- Osano Cookie Consent -->
{% endif %}
2 changes: 2 additions & 0 deletions _layouts/default.liquid
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
{% include footer.liquid %}

<!-- JavaScripts -->
{% include scripts/googletagmanager.liquid %}
{% include scripts/jquery.liquid %}
{% include scripts/bootstrap.liquid %}
{% include scripts/masonry.liquid %}
Expand All @@ -67,6 +68,7 @@
{% include scripts/mathjax.liquid %}
{% include scripts/pseudocode.liquid %}
{% include scripts/analytics.liquid %}
{% include scripts/osano_cookieconsent.liquid %}
{% include scripts/progressBar.liquid %}
{% include scripts/wechatModal.liquid %}
{% include scripts/imageLayouts.liquid %}
Expand Down
7 changes: 5 additions & 2 deletions _layouts/page.liquid
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,11 @@ layout: default
---
<div class="post">
<header class="post-header">
<h1 class="post-title">{{ page.title }}</h1>
<p class="post-description">{{ page.description }}</p>
{% if page.custom_title %}
<h1 class="post-title">{{ page.custom_title }}</h1>
{% else %}
{% endif %}
{% if page.hide_description %}{% else %}<p class="post-description">{{ page.description }}</p>{% endif %}
</header>

<article>
Expand Down
Loading

0 comments on commit 1da3ce8

Please sign in to comment.