From a5365291db02fd91737ef3a0ce80a5d0c9a629ea Mon Sep 17 00:00:00 2001 From: TheYoungManLi Date: Tue, 1 Mar 2022 12:20:38 +0800 Subject: [PATCH] fix: Update subscribe url Signed-off-by: TheYoungManLi --- config/_default/config.toml | 4 +- config/upstream-zh/config.toml | 6 ++- config/upstream/config.toml | 3 +- i18n/en.yaml | 2 + i18n/zh.yaml | 4 ++ layouts/docs/single.html | 53 +----------------- layouts/partials/content.html | 56 ++++++++++++++++++- layouts/partials/footer.html | 46 +--------------- layouts/partials/subscribe.html | 96 +++++++++++++++++++++++++++++++++ 9 files changed, 168 insertions(+), 102 deletions(-) create mode 100644 layouts/partials/subscribe.html diff --git a/config/_default/config.toml b/config/_default/config.toml index 76819588a..97b13732d 100644 --- a/config/_default/config.toml +++ b/config/_default/config.toml @@ -47,6 +47,7 @@ title = "KubeSphere | The Kubernetes platform tailored for hybrid multicloud" description = "KubeSphere is a distributed operating system managing cloud native applications with Kubernetes as its kernel, and provides plug-and-play architecture for the seamless integration of third-party applications to boost its ecosystem." keywords = "KubeSphere, Kubernetes, container platform, DevOps, hybrid cloud, cloud native" snapshot = "/images/common/snapshot-en.png" +useSendcloud = false mailchimpSubscribeUrl = "https://kubesphere.us10.list-manage.com/subscribe/post?u=c85ea2b944b08b951f607bdd4&id=83f673a2d9" [[languages.en.menu.main]] @@ -194,7 +195,8 @@ title = "KubeSphere | 面向云原生应用的容器混合云" description = "KubeSphere 是在 Kubernetes 之上构建的以应用为中心的多租户容器平台,提供全栈的 IT 自动化运维的能力,简化企业的 DevOps 工作流。KubeSphere 提供了运维友好的向导式操作界面,帮助企业快速构建一个强大和功能丰富的容器云平台。" keywords = "KubeSphere, Kubernetes, 容器平台, DevOps, 混合云" snapshot = "/images/common/snapshot-zh.png" -mailchimpSubscribeUrl = "https://yunify.us2.list-manage.com/subscribe/post?u=f29f08cef80223b46bad069b5&id=4838e610c2" +useSendcloud = true +mailchimpSubscribeUrl = "https://www.sendcloud.net/v3/api/subInvite/subscription?invitecode=1dc5a4fb-894c-4470-b01d-ca7fa9d47a46" [[languages.zh.menu.main]] weight = 2 diff --git a/config/upstream-zh/config.toml b/config/upstream-zh/config.toml index c256e51ec..fda431197 100644 --- a/config/upstream-zh/config.toml +++ b/config/upstream-zh/config.toml @@ -9,7 +9,9 @@ addBaiduAnalytics = true bilibiliLink = "https://space.bilibili.com/438908638" [languages.en.params] -mailchimpSubscribeUrl = "https://yunify.us2.list-manage.com/subscribe/post?u=f29f08cef80223b46bad069b5&id=4838e610c2" +useSendcloud = true +mailchimpSubscribeUrl = "https://www.sendcloud.net/v3/api/subInvite/subscription?invitecode=1dc5a4fb-894c-4470-b01d-ca7fa9d47a46" [languages.zh.params] -mailchimpSubscribeUrl = "https://yunify.us2.list-manage.com/subscribe/post?u=f29f08cef80223b46bad069b5&id=4838e610c2" +useSendcloud = true +mailchimpSubscribeUrl = "https://www.sendcloud.net/v3/api/subInvite/subscription?invitecode=1dc5a4fb-894c-4470-b01d-ca7fa9d47a46" diff --git a/config/upstream/config.toml b/config/upstream/config.toml index c6645a781..ff2fa19aa 100644 --- a/config/upstream/config.toml +++ b/config/upstream/config.toml @@ -7,4 +7,5 @@ addGoogleTag = true hotjarTracking = true youtubeLink = "https://www.youtube.com/c/KubeSphere" addLinkedin = true -addTwitter = true \ No newline at end of file +addTwitter = true +useSendcloud = false \ No newline at end of file diff --git a/i18n/en.yaml b/i18n/en.yaml index 579c269b0..ed9858e07 100644 --- a/i18n/en.yaml +++ b/i18n/en.yaml @@ -26,6 +26,8 @@ translation: email is required! - id: Please enter a valid email address. translation: Please enter a valid email address! +- id: Email address already exists. + translation: Email address already exists! - id: news translation: news - id: Table of Contents diff --git a/i18n/zh.yaml b/i18n/zh.yaml index 0640e3133..7809d9053 100644 --- a/i18n/zh.yaml +++ b/i18n/zh.yaml @@ -26,6 +26,10 @@ translation: 请提供您的邮箱 - id: Please enter a valid email address. translation: 请输入有效的邮箱地址! +- id: Email address already exists. + translation: 邮箱地址已经存在 +- id: Subscription is successful, we promise not to send you spam + translation: 订阅成功啦,我们保证不会给你发垃圾邮件的啦 - id: news translation: 动态 - id: Table of Contents diff --git a/layouts/docs/single.html b/layouts/docs/single.html index ab21310f2..a18f54d82 100644 --- a/layouts/docs/single.html +++ b/layouts/docs/single.html @@ -137,22 +137,13 @@ - +

{{ i18n "Receive the latest news, articles and updates from KubeSphere" }}

-
-
- - -
-
- + {{ partial "subscribe.html" .}}
@@ -327,43 +318,6 @@ }) } - var bindSubmit = function () { - var input = $('#email-input') - $('#email-submit').click(function (event) { - event.stopPropagation() - var email = input.val() - var message1 = $('#message').data('message1') - var message2 = $('#message').data('message2') - if (!email) { - event.preventDefault() - showMessage(message1) - } else if (!validateEmail(email)) { - event.preventDefault() - showMessage(message2) - } - }) - } - var validateEmail = function (email) { - var reg = /^[A-Za-z0-9]+([_\.][A-Za-z0-9]+)*@([A-Za-z0-9\-]+\.)+[A-Za-z]{2,6}$/ - return reg.test(email) - } - - var showMessage = function (message) { - $('#message').html(message).show() - } - - var bindHideMessage = function () { - $(window).click(function () { - $('#message').hide() - }) - } - - var bindClose = function () { - $('.formBox .close').click(function (e) { - e.stopPropagation() - $('.formBox').fadeOut() - }) - } var useViewer = function () { var viewer = new Viewer(document.querySelector('.md-body'), { url: 'src' @@ -375,9 +329,6 @@ bindClickMenu() bindClickSecondMenu() useViewer() - bindSubmit() - bindClose() - bindHideMessage() } __main() diff --git a/layouts/partials/content.html b/layouts/partials/content.html index 7f6174422..4ebff2a02 100644 --- a/layouts/partials/content.html +++ b/layouts/partials/content.html @@ -65,15 +65,31 @@

{{ i18n "Receive the latest news, articles and updates from KubeSphere" }}

-
+ {{ if $Site.Params.useSendcloud }} +
+ + + + + + +
+ {{ else }} +
+ data-message2='{{ i18n "Please enter a valid email address." }}'>
+ {{ end }}
{{ partial "footer.html" $context }} @@ -97,12 +113,40 @@ var email = input.val() var message1 = $('#message_blog').data('message1') var message2 = $('#message_blog').data('message2') + var emailExisted = $('#message_blog').data('message3') + var successText = $('#message1_blog').data('success') + if (!email) { event.preventDefault() $('#message_blog').html(message1).show() } else if (!validateEmail(email)) { event.preventDefault() $('#message_blog').html(message2).show() + } else { + var useSendcloud = $('#blog_formAddress').data('usesendcloud') + if (!useSendcloud) { + return + } + + var address = $('#blog_formAddress').data('actionaddress') + $.post({ + type: 'post', + url: address, + data: { + email: email.toString() + }, + success: function (res) { + showSuccessMessage_blog(successText) + setTimeout(function () { + window.onscroll = '' + $('.SubscribeForm').hide() + $('#email-input-blog').val('') + }, 5000) + }, + error: function (error, textStatus) { + showMessage_blog(emailExisted) + } + }) } }) } @@ -126,6 +170,14 @@ }) } + var showMessage_blog = function (message) { + $('#message_blog').html(message).show() + } + + var showSuccessMessage_blog = function (message) { + $('#message1_blog').html(message).show() + } + window.onscroll = () => { var scrollTop = document.documentElement.scrollTop || document.body.scrollTop; var windowHeight = document.documentElement.clientHeight || document.body.clientHeight; diff --git a/layouts/partials/footer.html b/layouts/partials/footer.html index 640aafd42..6dca20ca8 100644 --- a/layouts/partials/footer.html +++ b/layouts/partials/footer.html @@ -6,17 +6,7 @@

{{ i18n "Receive the latest news, articles and updates from KubeSphere" }}

-
-
- - -
-
+ {{ partial "subscribe.html" .}}
@@ -105,38 +95,6 @@ diff --git a/layouts/partials/subscribe.html b/layouts/partials/subscribe.html new file mode 100644 index 000000000..0a62088ca --- /dev/null +++ b/layouts/partials/subscribe.html @@ -0,0 +1,96 @@ +{{ if .Site.Params.useSendcloud }} +
+ + +
+ + + + +{{ else }} +
+
+ + +
+
+ +{{ end }} + +