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

github.com/aerohub/hugo-identity-theme.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Grosser <development@stp-ip.net>2017-05-08 20:07:07 +0300
committerMichael Grosser <development@stp-ip.net>2017-05-08 20:25:05 +0300
commitd161b5e25f9893b36861590bc1cc370a4dd28736 (patch)
tree7f0be878a6dba54832ac55041f59602607f5124c
parentdeb2e49114230f0d4ffdac0ea9522e5794699f79 (diff)
Add invisible recaptcha
-rw-r--r--exampleSite/config.toml9
-rw-r--r--layouts/partials/contact.html3
-rw-r--r--layouts/partials/header.html3
-rw-r--r--static/assets/js/contact.js5
4 files changed, 16 insertions, 4 deletions
diff --git a/exampleSite/config.toml b/exampleSite/config.toml
index 89ca2c0..71647d8 100644
--- a/exampleSite/config.toml
+++ b/exampleSite/config.toml
@@ -9,7 +9,7 @@ themesDir = "../.."
disableKinds = ["page", "section", "taxonomy", "taxonomyTerm", "RSS", "sitemap", "robotsTXT", "404"]
# Enter your tracking code to enable Google Analytics
-googleAnalytics = "UA-XXXXX-Y"
+#googleAnalytics = "UA-XXXXX-Y"
[params]
@@ -54,8 +54,6 @@ googleAnalytics = "UA-XXXXX-Y"
biography = """Jane Powers is plain awesome. He worked at Corp A and B and is open for new work.
Even new lines and other markdown styles are working within the bio."""
-
-
# Contact form settings
[params.contact]
@@ -89,6 +87,11 @@ Even new lines and other markdown styles are working within the bio."""
success = "Thank you for contacting us."
error = "Message could not be send. Please contact us at "
+ # Google invisible captcha
+ #[params.contact.captcha]
+ # sitekey = ""
+
+
# Add optional form fields to identify contact forms.
#[[params.contact.fields.hidden]]
# name = "someID"
diff --git a/layouts/partials/contact.html b/layouts/partials/contact.html
index f7949df..54b1fd6 100644
--- a/layouts/partials/contact.html
+++ b/layouts/partials/contact.html
@@ -29,7 +29,8 @@
{{ end }}
</div>
<ul class="actions">
- <li><button type="submit">{{ .Site.Params.contact.buttonText }}</button></li>
+ <li><button type="submit" {{ with .Site.Params.contact.captcha }} class="g-recaptcha"
+data-sitekey="{{ .sitekey }}" data-callback="onSubmit" {{ end }}>{{ .Site.Params.contact.buttonText }}</button></li>
</ul>
{{ range .Site.Params.contact.fields.hidden }}
{{ if eq .name "site" }}
diff --git a/layouts/partials/header.html b/layouts/partials/header.html
index 6c84fae..59022e8 100644
--- a/layouts/partials/header.html
+++ b/layouts/partials/header.html
@@ -36,4 +36,7 @@
<!--[if lte IE 9]><link rel="stylesheet" href="/assets/css/ie9.css" /><![endif]-->
<noscript><link rel="stylesheet" href="/assets/css/noscript.css" /></noscript>
+ {{ with .Site.Params.contact.captcha }}
+ <script src='https://www.google.com/recaptcha/api.js' async defer></script>
+ {{ end }}
</head>
diff --git a/static/assets/js/contact.js b/static/assets/js/contact.js
index dde2b1d..4132e8a 100644
--- a/static/assets/js/contact.js
+++ b/static/assets/js/contact.js
@@ -19,3 +19,8 @@ $('form[id=contactForm]').submit(function(){
});
return false;
});
+
+// Callback function for captcha
+function onSubmit(token) {
+ $('form[id=contactForm]').submit();
+}