From 076d5667417309d2eea33f581567fe7ad4c41633 Mon Sep 17 00:00:00 2001 From: panzhitian Date: Fri, 8 Apr 2016 22:36:31 +0800 Subject: [PATCH 1/2] add busuanzi counter with customization --- _config.yml | 17 +++++++++++ layout/_macro/post.swig | 6 ++++ layout/_partials/footer.swig | 12 ++++++++ .../css/_common/components/footer/footer.styl | 30 +++++++++++++++++++ 4 files changed, 65 insertions(+) diff --git a/_config.yml b/_config.yml index 79e2961cd..cee90c283 100755 --- a/_config.yml +++ b/_config.yml @@ -288,6 +288,23 @@ leancloud_visitors: app_id: # app_key: # +# Show PV/UV of the website/page with busuanzi. +# Get more information on http://ibruce.info/2015/04/04/busuanzi/ +busuanzi_count: + # count values only if the other configs are false + enable: false + # custom uv span for the whole site + site_uv: true + site_uv_header: + site_uv_footer: + # custom pv span for the whole site + site_pv: true + site_pv_header: + site_pv_footer: + # custom pv span for one page only + page_pv: true + page_pv_header: + page_pv_footer: # Tencent analytics ID # tencent_analytics: diff --git a/layout/_macro/post.swig b/layout/_macro/post.swig index c09bd9a9d..f825f579b 100644 --- a/layout/_macro/post.swig +++ b/layout/_macro/post.swig @@ -115,6 +115,12 @@ {% endif %} + {% if not is_index and theme.busuanzi_count.page_pv %} +   |   + {{ theme.busuanzi_count.page_pv_header }} + {{ theme.busuanzi_count.page_pv_footer }} + + {% endif %} {% endif %} diff --git a/layout/_partials/footer.swig b/layout/_partials/footer.swig index 69c27853f..4a4b1f956 100644 --- a/layout/_partials/footer.swig +++ b/layout/_partials/footer.swig @@ -19,4 +19,16 @@ +{% if theme.busuanzi_count.enable %} +
+ + {% if theme.busuanzi_count.site_uv %} + {{ theme.busuanzi_count.site_uv_header }}{{ theme.busuanzi_count.site_uv_footer }} + {% endif %} + {% if theme.busuanzi_count.site_pv %} + {{ theme.busuanzi_count.site_pv_header }}{{ theme.busuanzi_count.site_pv_footer }} + {% endif %} +
+{% endif %} + {% block footer %}{% endblock %} diff --git a/source/css/_common/components/footer/footer.styl b/source/css/_common/components/footer/footer.styl index 550704b33..97067b018 100644 --- a/source/css/_common/components/footer/footer.styl +++ b/source/css/_common/components/footer/footer.styl @@ -24,6 +24,36 @@ } } +.busuanzi-count { + &:before { + content: " "; + float: left; + width: 260px; + min-height: 25px; + } +} + +.site-uv, +.site-pv, +.page-pv { + display: inline-block; + + .busuanzi-value { + margin: 0 5px; + } +} + +if hexo-config("busuanzi_count.site_pv") and hexo-config("busuanzi_count.site_uv") + .site-uv + { + margin-right: 10px; + + &::after { + content: "|"; + padding-left: 10px; + } + } + .cc-license { margin-top: 10px; text-align: center; From fb1821034c356b3877d877ecab04669019f6d9ec Mon Sep 17 00:00:00 2001 From: panzhitian Date: Sat, 9 Apr 2016 20:42:01 +0800 Subject: [PATCH 2/2] busuanzi: hide page_pv while the counter is disabled --- layout/_macro/post.swig | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/layout/_macro/post.swig b/layout/_macro/post.swig index f825f579b..5cb880995 100644 --- a/layout/_macro/post.swig +++ b/layout/_macro/post.swig @@ -115,12 +115,12 @@ {% endif %} - {% if not is_index and theme.busuanzi_count.page_pv %} -   |   - {{ theme.busuanzi_count.page_pv_header }} - {{ theme.busuanzi_count.page_pv_footer }} - - {% endif %} + {% if not is_index and theme.busuanzi_count.enable and theme.busuanzi_count.page_pv %} +   |   + {{ theme.busuanzi_count.page_pv_header }} + {{ theme.busuanzi_count.page_pv_footer }} + + {% endif %} {% endif %}