Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/jesselau76/hugo-w3-simple.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjesselau76 <jesselau76@gmail.com>2018-11-29 06:53:34 +0300
committerjesselau76 <jesselau76@gmail.com>2018-11-29 06:53:34 +0300
commit429beb3ec8e68d6e0edde6175d138f02d556cc3a (patch)
tree5e34e0492045070aa8a4d18edefedc9214cdc2df
parentcc3e6d467ed184af4c85c04942c3b4b5cecc3aec (diff)
cookie law support
-rw-r--r--README-zh.md2
-rw-r--r--README.md1
-rw-r--r--exampleSite/config.toml1
-rw-r--r--layouts/_default/baseof.html63
-rw-r--r--static/css/style.css11
5 files changed, 77 insertions, 1 deletions
diff --git a/README-zh.md b/README-zh.md
index f9219fd..a2fa837 100644
--- a/README-zh.md
+++ b/README-zh.md
@@ -31,6 +31,7 @@
- 社交按钮.
- 支持多语言.
- 辉光式LOGO,可选
+ - Cookie设置提醒,根据欧盟法律需显示提示站点采用cookie。
- Google Adsense autoads
- Lazy Load图片 - 异步加载网站上的图像 - 也就是说先用一个极小的图像文件占住位置,只有当用户滑动屏幕到该图片出现的位置时,才调用真实的图片。 如果页面有很多图片,启用此功能可以使页面加载速度非常快。 [实例演示](https://jesselau.com/21-wordpress-plugins-activated-in-my-website/). 这个网页含有21个图片。不用lazy load前文件大小为854kb,加载时间3.5s.![Before lazy load](https://raw.githubusercontent.com/jesselau76/hugo-w3-simple/master/images/beforelazyload.png)使用lazy load后文件大小为524kb,加载时间就只有2.8s
![After lazy load](https://raw.githubusercontent.com/jesselau76/hugo-w3-simple/master/images/afterlazyload.png)
@@ -96,3 +97,4 @@ git pull
+
diff --git a/README.md b/README.md
index a5b7a73..1652cae 100644
--- a/README.md
+++ b/README.md
@@ -34,6 +34,7 @@
- Glowing style logo
- Scroll indicator
- Google Adsense autoads
+ - Cookie law support.
- Lazy Load images - loading images on websites asynchronously — that is, after the above-the-fold content is fully loaded, or even conditionally, only when they appear in the browser's viewport. This means that if users don't scroll all the way down, images placed at the bottom of the page won't even be loaded. Enable this function to make the page load very fast if it has lots of images. [Live Demo Here](https://jesselau.com/21-wordpress-plugins-activated-in-my-website/). This page includes 21 images. Before lazy load the page size is 854kb and load time is 3.5s.![Before lazy load](https://raw.githubusercontent.com/jesselau76/hugo-w3-simple/master/images/beforelazyload.png)After lazy load the page size is 524kb and load time is 2.8s
![After lazy load](https://raw.githubusercontent.com/jesselau76/hugo-w3-simple/master/images/afterlazyload.png)
diff --git a/exampleSite/config.toml b/exampleSite/config.toml
index 63568d8..9af0599 100644
--- a/exampleSite/config.toml
+++ b/exampleSite/config.toml
@@ -18,6 +18,7 @@ contentDir = "content/english"
logotext = "HUGO W3 SIMPLE" # logo text
isso_baseurl="" #if you want to use isso as comment system,set your isso js baseurl here. It is like "https://isso.yourwebsite.com/" or "https://yourwebsite.com/isso/"
isso_langcode="en"
+ cookie_info = "This website uses cookies to ensure you get the best experience on our website. [Learn more](/privacy-policy/)"
[[languages.en.menu.main]]
name = "About"
diff --git a/layouts/_default/baseof.html b/layouts/_default/baseof.html
index b88c64c..f07a159 100644
--- a/layouts/_default/baseof.html
+++ b/layouts/_default/baseof.html
@@ -9,7 +9,9 @@
{{ . | safeHTML }}
{{ end }}
</head>
-<body class="w3-light-grey">
+<body {{ if .Site.Params.cookie_info }} onload="checkCookie()" {{ end }}
+
+class="w3-light-grey">
@@ -43,6 +45,65 @@
</div>
+<!-- cookie bar -->
+ {{ with .Site.Params.cookie_info }}
+ <div id="cookiebar" class="w3-bar w3-top w3-black w3-border " >
+ <span onclick="gotitcookiebar()"
+ class="w3-button w3-small w3-green w3-right">Got it</span>
+ <span class="w3-bar-item w3-small">{{ . | markdownify }}</span>
+ </div>
+
+
+<script>
+function gotitcookiebar() {
+ var x =document.getElementById("cookiebar");
+ x.style.display = "none";
+var x = document.getElementsByTagName("BODY")[0];
+ x.style.paddingTop = "0px";
+
+
+}
+
+
+
+function checkCookie() {
+ var user=getCookie("cookiebardisplayed");
+ if (user == "") {
+ var x =document.getElementById("cookiebar");
+ x.style.display = "block";
+ var h = document.getElementById('cookiebar').clientHeight;
+
+ var x = document.getElementsByTagName("BODY")[0];
+ x.style.paddingTop = h+"px";
+ setCookie("cookiebardisplayed","1",365);
+ }
+}
+function setCookie(cname,cvalue,exdays) {
+ var d = new Date();
+ d.setTime(d.getTime() + (exdays*24*60*60*1000));
+ var expires = "expires=" + d.toGMTString();
+ document.cookie = cname + "=" + cvalue + ";" + expires + ";path=/";
+}
+
+function getCookie(cname) {
+ var name = cname + "=";
+ var decodedCookie = decodeURIComponent(document.cookie);
+ var ca = decodedCookie.split(';');
+ for(var i = 0; i < ca.length; i++) {
+ var c = ca[i];
+ while (c.charAt(0) == ' ') {
+ c = c.substring(1);
+ }
+ if (c.indexOf(name) == 0) {
+ return c.substring(name.length, c.length);
+ }
+ }
+ return "";
+}
+
+
+</script>
+{{ end }}
<!-- Back to top -->
{{ if .Site.Params.backtotop }}
diff --git a/static/css/style.css b/static/css/style.css
index 0ece3f4..20db3fe 100644
--- a/static/css/style.css
+++ b/static/css/style.css
@@ -76,6 +76,17 @@ em {
font-style: normal;
color:crimson;
}
+/* cookie bar css */
+#cookiebar
+{
+display:none;
+}
+
+#cookiebar a
+{
+color: white;
+text-decoration: underline;
+}
/* social share css */