mirror of
https://github.com/gethinode/hinode.git
synced 2025-10-18 07:23:09 +00:00
Test cky integration
This commit is contained in:
@@ -41,7 +41,7 @@
|
||||
|
||||
# toml-docs-start debugging
|
||||
[debugging]
|
||||
showJS = false
|
||||
showJS = true
|
||||
showSCSS = false
|
||||
purgeHTMLComments = false
|
||||
includeSVGOrigin = true
|
||||
|
48
exampleSite/assets/js/critical/_cookie.js
Normal file
48
exampleSite/assets/js/critical/_cookie.js
Normal file
@@ -0,0 +1,48 @@
|
||||
/* eslint-disable no-undef, no-unused-vars */
|
||||
|
||||
let _manager
|
||||
|
||||
function loadScriptSync (src) {
|
||||
const s = document.createElement('script')
|
||||
s.src = src
|
||||
s.type = 'text/javascript'
|
||||
s.async = false
|
||||
document.getElementsByTagName('head')[0].appendChild(s)
|
||||
}
|
||||
|
||||
function hasConsent (category) {
|
||||
if (typeof _manager !== 'undefined' && _manager !== null) {
|
||||
return _manager.hasConsent(category)
|
||||
} else {
|
||||
console.log('no mgr defined: ' + category)
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
function getLocalStorage (key, def, category) {
|
||||
if (hasConsent(category)) {
|
||||
return localStorage.getItem(key)
|
||||
} else {
|
||||
return def
|
||||
}
|
||||
}
|
||||
|
||||
function setLocalStorage (key, val, category) {
|
||||
if (hasConsent(category)) {
|
||||
localStorage.setItem(key, val)
|
||||
}
|
||||
}
|
||||
|
||||
function getSessionStorage (key, def, category) {
|
||||
if (hasConsent(category)) {
|
||||
return sessionStorage.getItem(key)
|
||||
} else {
|
||||
return def
|
||||
}
|
||||
}
|
||||
|
||||
function setSessionStorage (key, val, category) {
|
||||
if (hasConsent(category)) {
|
||||
sessionStorage.setItem(key, val)
|
||||
}
|
||||
}
|
35
exampleSite/assets/js/critical/_cookie2.js
Normal file
35
exampleSite/assets/js/critical/_cookie2.js
Normal file
@@ -0,0 +1,35 @@
|
||||
// TODO: move to module
|
||||
|
||||
/* eslint-disable no-undef, no-unused-vars */
|
||||
{{- if or site.Params.modules.cookieyes.force (not hugo.IsServer) -}}
|
||||
{{ with site.Params.modules.cookieyes.id }}
|
||||
|
||||
class CookieYesManager {
|
||||
#consent
|
||||
|
||||
updateConsent () {
|
||||
this.#consent = getCkyConsent()
|
||||
}
|
||||
|
||||
constructor () {
|
||||
loadScriptSync('https://cdn-cookieyes.com/client_data/{{ (. | urlize) }}/script.js')
|
||||
this.updateConsent()
|
||||
}
|
||||
|
||||
hasConsent (category) {
|
||||
if (typeof this.#consent !== 'undefined' && this.#consent !== null) {
|
||||
console.log('invoke cky consent: ' + category + this.#consent)
|
||||
return true
|
||||
} else {
|
||||
console.log('cky consent undefined: ' + category)
|
||||
return false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
_manager = new CookieYesManager()
|
||||
|
||||
{{ else }}
|
||||
{{ warnf "Cannot find CookieYes ID, check 'params.modules.cookieyes.id'" }}
|
||||
{{ end }}
|
||||
{{ end }}
|
@@ -15,7 +15,7 @@
|
||||
transpiler = "dartsass"
|
||||
|
||||
[debugging]
|
||||
showJS = false
|
||||
showJS = true
|
||||
showSCSS = false
|
||||
purgeHTMLComments = true # prevents a Goldmark warning when processing HTML comments (as used by markdownlint)
|
||||
includeSVGOrigin = true
|
||||
|
@@ -7,15 +7,15 @@ for = '/**'
|
||||
X-XSS-Protection = "1; mode=block"
|
||||
Content-Security-Policy = """\
|
||||
default-src 'self'; \
|
||||
script-src 'self' https://*.google-analytics.com https://*.googletagmanager.com; \
|
||||
style-src 'self' https://fonts.googleapis.com https://www.youtube.com; \
|
||||
script-src 'self' cdn-cookieyes.com https://*.google-analytics.com https://*.googletagmanager.com; \
|
||||
style-src 'self' 'unsafe-inline' https://fonts.googleapis.com https://www.youtube.com; \
|
||||
object-src 'none'; \
|
||||
base-uri 'self'; \
|
||||
connect-src 'self'
|
||||
connect-src 'self' *.cookieyes.com cdn-cookieyes.com \
|
||||
https://*.google-analytics.com https://*.analytics.google.com https://*.googletagmanager.com; \
|
||||
font-src 'self' https://fonts.gstatic.com; \
|
||||
frame-src 'self' https://player.cloudinary.com https://player.vimeo.com https://www.youtube-nocookie.com https://www.youtube.com; \
|
||||
img-src 'self' data: https://*.imgix.net https://*.imagekit.io https://*.cloudinary.com https://i.vimeocdn.com https://i.ytimg.com https://*.google-analytics.com https://*.googletagmanager.com https://tile.openstreetmap.org; \
|
||||
img-src 'self' data: cdn-cookieyes.com https://*.imgix.net https://*.imagekit.io https://*.cloudinary.com https://i.vimeocdn.com https://i.ytimg.com https://*.google-analytics.com https://*.googletagmanager.com https://tile.openstreetmap.org; \
|
||||
manifest-src 'self'; \
|
||||
media-src 'self' \
|
||||
"""
|
||||
|
@@ -21,19 +21,19 @@
|
||||
Content-Security-Policy = """\
|
||||
default-src 'self'; \
|
||||
child-src 'self' app.netlify.com; \
|
||||
script-src 'self' \
|
||||
script-src 'self' cdn-cookieyes.com \
|
||||
https://*.netlify.app app.netlify.com netlify-cdp-loader.netlify.app \
|
||||
https://*.google-analytics.com https://*.googletagmanager.com; \
|
||||
style-src 'self' \
|
||||
style-src 'self' 'unsafe-inline' \
|
||||
https://*.netlify.app https://fonts.googleapis.com https://www.youtube.com; \
|
||||
object-src 'none'; \
|
||||
base-uri 'self'; \
|
||||
connect-src 'self'
|
||||
connect-src 'self' *.cookieyes.com cdn-cookieyes.com \
|
||||
https://*.google-analytics.com https://*.analytics.google.com https://*.googletagmanager.com; \
|
||||
font-src 'self' https://*.netlify.app https://fonts.gstatic.com; \
|
||||
frame-src 'self' https://player.cloudinary.com https://player.vimeo.com https://www.youtube-nocookie.com https://www.youtube.com \
|
||||
app.netlify.com; \
|
||||
img-src 'self' data: https://*.imgix.net https://*.imagekit.io https://*.cloudinary.com https://*.netlify.app https://i.vimeocdn.com https://i.ytimg.com https://*.google-analytics.com https://*.googletagmanager.com https://tile.openstreetmap.org; \
|
||||
img-src 'self' data: cdn-cookieyes.com https://*.imgix.net https://*.imagekit.io https://*.cloudinary.com https://*.netlify.app https://i.vimeocdn.com https://i.ytimg.com https://*.google-analytics.com https://*.googletagmanager.com https://tile.openstreetmap.org; \
|
||||
manifest-src 'self'; \
|
||||
media-src 'self' \
|
||||
"""
|
||||
|
Reference in New Issue
Block a user