Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
jerryc127 committed Aug 17, 2022
2 parents 7e83095 + c866315 commit 8ee052e
Show file tree
Hide file tree
Showing 23 changed files with 335 additions and 70 deletions.
20 changes: 0 additions & 20 deletions .github/stale.yml

This file was deleted.

19 changes: 19 additions & 0 deletions .github/workflows/stale.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: 'Close stale issues and PRs'
on:
schedule:
- cron: '30 1 * * *'

jobs:
stale:
runs-on: ubuntu-latest
steps:
- uses: actions/stale@v5
with:
days-before-issue-stale: 30
days-before-pr-stale: -1
days-before-close: 7
stale-issue-message: 'This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.'
close-pr-message: 'This issue has not seen any activity since it was marked stale. Closing.'
stale-issue-label: 'Stale'
exempt-issue-labels: 'pinned,bug,enhancement,documentation,Plan'
operations-per-run: 1000
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,9 @@ npm i hexo-theme-butterfly
- [x] Related articles
- [x] Displays outdated notice for a post
- [x] Share (AddThis/Sharejs/Addtoany)
- [X] Comment (Disqus/Disqusjs/Livere/Gitalk/Valine/Waline/Utterances/Facebook Comments/Twikoo/Giscus/Remark42)
- [X] Comment (Disqus/Disqusjs/Livere/Gitalk/Valine/Waline/Utterances/Facebook Comments/Twikoo/Giscus/Remark42/artalk)
- [x] Multiple Comment System Support
- [x] Online Chats (Chatra/Tidio/Daovoice/Gitter/Crisp)
- [x] Online Chats (Chatra/Tidio/Daovoice/Gitter/Crisp/messenger)
- [x] Web analytics
- [x] Google AdSense
- [x] Webmaster Verification
Expand Down
4 changes: 2 additions & 2 deletions README_CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,9 @@ theme: butterfly
- [x] 顯示相關文章
- [x] 過期文章提醒
- [x] 多種分享系統(AddThis/Sharejs/Addtoany)
- [X] 多種評論系統(Disqus/Disqusjs/Livere/Gitalk/Valine/Waline/Utterances/Facebook Comments/Twikoo/Giscus/Remark42)
- [X] 多種評論系統(Disqus/Disqusjs/Livere/Gitalk/Valine/Waline/Utterances/Facebook Comments/Twikoo/Giscus/Remark42/artalk
- [x] 支持雙評論部署
- [x] 多種在線聊天(Chatra/Tidio/Daovoice/Gitter/Crisp)
- [x] 多種在線聊天(Chatra/Tidio/Daovoice/Gitter/Crisp/messenger
- [x] 多種分析系統
- [x] 谷歌廣告/手動廣告位置
- [x] 各種站長驗證(Google/Bing/Baidu/360/Yandex)
Expand Down
27 changes: 24 additions & 3 deletions _config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ addtoany:

comments:
# Up to two comments system, the first will be shown as default
# Choose: Disqus/Disqusjs/Livere/Gitalk/Valine/Waline/Utterances/Facebook Comments/Twikoo/Giscus/Remark42
# Choose: Disqus/Disqusjs/Livere/Gitalk/Valine/Waline/Utterances/Facebook Comments/Twikoo/Giscus/Remark42/Artalk
use: # Valine,Disqus
text: true # Display the comment name next to the button
# lazyload: The comment system will be load when comment element enters the browser's viewport.
Expand Down Expand Up @@ -333,7 +333,7 @@ facebook_comments:
user_id: # optional
pageSize: 10 # The number of comments to show
order_by: social # social/time/reverse_time
lang: en_US # Language en_US/zh_CN/zh_TW and so on
lang: zh_TW # Language en_US/zh_CN/zh_TW and so on

# Twikoo
# https://github.com/imaegoo/twikoo
Expand Down Expand Up @@ -361,6 +361,14 @@ remark42:
siteId: # Your Site ID
option:

# Artalk
# https://artalk.js.org/guide/frontend/config.html
artalk:
server:
site:
visitor: false
option:

# Chat Services
# --------------------------------------

Expand Down Expand Up @@ -401,6 +409,13 @@ crisp:
enable: false
website_id:

# messenger
# https://developers.facebook.com/docs/messenger-platform/discovery/facebook-chat-plugin/
messenger:
enable: false
pageID:
lang: zh_TW # Language en_US/zh_CN/zh_TW and so on

# Footer Settings
# --------------------------------------
footer:
Expand Down Expand Up @@ -604,6 +619,10 @@ subtitle:
enable: false
# Typewriter Effect (打字效果)
effect: true
# Effect Speed Options (打字效果速度參數)
startDelay: 300 # time before typing starts in milliseconds
typeSpeed: 150 # type speed in milliseconds
backSpeed: 50 # backspacing speed in milliseconds
# loop (循環打字)
loop: true
# source 調用第三方服務
Expand Down Expand Up @@ -911,4 +930,6 @@ CDN:
# meting_js:
# prismjs_js:
# prismjs_lineNumber_js:
# prismjs_autoloader:
# prismjs_autoloader:
# artalk_js:
# artalk_css:
10 changes: 9 additions & 1 deletion layout/includes/header/post-info.pug
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,10 @@
+pvBlock('','','')
span#twikoo_visitors
i.fa-solid.fa-spinner.fa-spin
else if commentUse[0] === 'Artalk' && theme.artalk.visitor
+pvBlock('','','')
span#ArtalkPV
i.fa-solid.fa-spinner.fa-spin
else if theme.busuanzi.page_pv
+pvBlock('','post-meta-pv-cv','')
span#busuanzi_value_page_pv
Expand Down Expand Up @@ -130,9 +134,13 @@
+countBlock
a(href=url_for(page.path) + '#post-comment')
span.fb-comments-count(data-href=urlNoIndex())
i.fa-solid.fa-spinner.fa-spin
when 'Remark42'
+countBlock
a(href=url_for(page.path) + '#post-comment')
span.remark42__counter(data-url=urlNoIndex())
i.fa-solid.fa-spinner.fa-spin
when 'Artalk'
+countBlock
a(href=url_for(page.path) + '#post-comment')
span.artalk-count
i.fa-solid.fa-spinner.fa-spin
6 changes: 5 additions & 1 deletion layout/includes/mixins/post-ui.pug
Original file line number Diff line number Diff line change
Expand Up @@ -96,12 +96,16 @@ mixin postUI(posts)
+countBlockInIndex
a(href=url_for(link) + '#post-comment')
span.fb-comments-count(data-href=urlNoIndex(article.permalink))
i.fa-solid.fa-spinner.fa-spin
when 'Remark42'
+countBlockInIndex
a(href=url_for(link) + '#post-comment')
span.remark42__counter(data-url=urlNoIndex(article.permalink))
i.fa-solid.fa-spinner.fa-spin
when 'Artalk'
+countBlockInIndex
a(href=url_for(link) + '#post-comment')
span.artalk-count(data-page-key=url_for(link))
i.fa-solid.fa-spinner.fa-spin

//- Display the article introduction on homepage
case theme.index_post_content.method
Expand Down
20 changes: 20 additions & 0 deletions layout/includes/third-party/card-post-count/artalk.pug
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
- const { server, site } = theme.artalk

script.
(() => {
const getArtalkCount = () => {
const runWidget = () => {
Artalk.LoadCountWidget({
server: '!{server}',
site: '!{site}',
countEl: '.artalk-count'
})
}

if (typeof Artalk === 'function') runWidget()
else getScript('!{theme.asset.artalk_js}').then(runWidget)
}


window.pjax ? getArtalkCount() : window.addEventListener('load', getArtalkCount)
})()
7 changes: 5 additions & 2 deletions layout/includes/third-party/card-post-count/fb.pug
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
- const fbSDKVer = 'v14.0'
- const fbSDK = theme.messenger.enable ? `https://connect.facebook.net/${theme.facebook_comments.lang}/sdk/xfbml.customerchat.js#xfbml=1&version=${fbSDKVer}` : `https://connect.facebook.net/${theme.facebook_comments.lang}/sdk.js#xfbml=1&version=${fbSDKVer}`

script.
(()=>{
function loadFBComment () {
if (typeof FB === 'object') FB.XFBML.parse()
if (typeof FB === 'object') FB.XFBML.parse(document.getElementById('recent-posts'))
else {
let ele = document.createElement('script')
ele.setAttribute('src','https://connect.facebook.net/!{theme.facebook_comments.lang}/sdk.js#xfbml=1&version=v9.0')
ele.setAttribute('src','!{fbSDK}')
ele.setAttribute('async', 'true')
ele.setAttribute('defer', 'true')
ele.setAttribute('crossorigin', 'anonymous')
Expand Down
4 changes: 3 additions & 1 deletion layout/includes/third-party/card-post-count/index.pug
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,6 @@ case theme.comments.use[0]
when 'Facebook Comments'
include ./fb.pug
when 'Remark42'
include ./remark42.pug
include ./remark42.pug
when 'Artalk'
include ./artalk.pug
4 changes: 3 additions & 1 deletion layout/includes/third-party/chat/index.pug
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,6 @@ else if theme.daovoice && theme.daovoice.enable
else if theme.gitter && theme.gitter.enable
include ./gitter.pug
else if theme.crisp && theme.crisp.enable
include ./crisp.pug
include ./crisp.pug
else if theme.messenger && theme.messenger.enable
include ./messenger.pug
42 changes: 42 additions & 0 deletions layout/includes/third-party/chat/messenger.pug
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
- let { pageID, lang } = theme.messenger
- lang = theme.comments.use && theme.comments.use.includes('Facebook Comments') ? theme.facebook_comments.lang : lang

#fb-customer-chat.fb-customerchat(page_id=pageID attribution='biz_inbox')

script.
document.getElementById('fb-root') ? '' : document.body.insertAdjacentHTML('afterend', '<div id="fb-root"></div>')

window.fbAsyncInit = function() {
FB.init({
xfbml: true,
version: 'v14.0'
});
};

(function(d, s, id) {
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) return;
js = d.createElement(s); js.id = id;
js.src = 'https://connect.facebook.net/!{lang}/sdk/xfbml.customerchat.js';
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));

if (!{theme.chat_btn}) {
var chatBtnFn = () => {
var chatBtn = document.getElementById("chat_btn")
chatBtn.addEventListener("click", function(){
FB.CustomerChat.show();
});
}
chatBtnFn()
} else {
if (!{theme.chat_hide_show}) {
function chatBtnHide () {
FB.CustomerChat.hide()
}
function chatBtnShow () {
FB.CustomerChat.show(false)
}
}
}

45 changes: 45 additions & 0 deletions layout/includes/third-party/comments/artalk.pug
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
- const { server, site, option } = theme.artalk

script.
function addArtalkSource () {
const ele = document.createElement('link')
ele.rel = 'stylesheet'
ele.href= '!{theme.asset.artalk_css}'
document.getElementsByTagName('head')[0].appendChild(ele)
}

function loadArtalk () {
function initArtalk () {
window.artalkItem = new Artalk(Object.assign({
el: '#artalk-wrap',
server: '!{server}',
site: '!{site}',
pageKey: location.pathname,
darkMode: document.documentElement.getAttribute('data-theme') === 'dark',
countEl: '.artalk-count'
},!{JSON.stringify(option)}))
}

if (typeof window.artalkItem === 'object') setTimeout(()=>{initArtalk()},200)
else {
addArtalkSource()
typeof Artalk !== 'function' ? getScript('!{theme.asset.artalk_js}').then(initArtalk)
: setTimeout(()=>{initArtalk()},200)
}
}

document.getElementById('darkmode').addEventListener('click',()=> {
if (typeof window.artalkItem !== 'object') return
let isDark = document.documentElement.getAttribute('data-theme') === 'dark'
window.artalkItem.setDarkMode(!isDark)
})


if ('!{theme.comments.use[0]}' === 'Artalk' || !!{theme.comments.lazyload}) {
if (!{theme.comments.lazyload}) btf.loadComment(document.getElementById('artalk-wrap'), loadArtalk)
else loadArtalk()
} else {
function loadOtherComment () {
loadArtalk()
}
}
20 changes: 15 additions & 5 deletions layout/includes/third-party/comments/facebook_comments.pug
Original file line number Diff line number Diff line change
@@ -1,16 +1,26 @@
#fb-root
- const fbSDKVer = 'v14.0'
- const fbSDK = theme.messenger.enable ? `https://connect.facebook.net/${theme.facebook_comments.lang}/sdk/xfbml.customerchat.js#xfbml=1&version=${fbSDKVer}` : `https://connect.facebook.net/${theme.facebook_comments.lang}/sdk.js#xfbml=1&version=${fbSDKVer}`

script.
function loadFBComment () {
var themeNow = document.documentElement.getAttribute('data-theme') === 'dark' ? 'dark' : 'light'
document.getElementsByClassName('fb-comments')[0].setAttribute('data-colorscheme',themeNow)
document.getElementById('fb-root') ? '' : document.body.insertAdjacentHTML('afterend', '<div id="fb-root"></div>')

const themeNow = document.documentElement.getAttribute('data-theme') === 'dark' ? 'dark' : 'light'
const $fbComment = document.getElementsByClassName('fb-comments')[0]
$fbComment.setAttribute('data-colorscheme',themeNow)
$fbComment.setAttribute('data-href', '!{urlNoIndex(page.permalink)}')

if (typeof FB === 'object') FB.XFBML.parse()
if (typeof FB === 'object') {
FB.XFBML.parse(document.getElementsByClassName('post-meta-commentcount')[0])
FB.XFBML.parse(document.getElementById('post-comment'))
}
else {
let ele = document.createElement('script')
ele.setAttribute('src','https://connect.facebook.net/!{theme.facebook_comments.lang}/sdk.js#xfbml=1&version=v13.0&appId=!{theme.facebook_comments.app_id}&autoLogAppEvents=1')
ele.setAttribute('src','!{fbSDK}')
ele.setAttribute('async', 'true')
ele.setAttribute('defer', 'true')
ele.setAttribute('crossorigin', 'anonymous')
ele.setAttribute('id', 'facebook-jssdk')
document.getElementById('fb-root').insertAdjacentElement('afterbegin',ele)
}
}
Expand Down
2 changes: 2 additions & 0 deletions layout/includes/third-party/comments/index.pug
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,5 @@ hr
data-width="100%")
when 'Remark42'
#remark42
when 'Artalk'
#artalk-wrap
4 changes: 3 additions & 1 deletion layout/includes/third-party/comments/js.pug
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ each name in theme.comments.use
when 'Giscus'
!=partial('includes/third-party/comments/giscus', {}, {cache: true})
when 'Facebook Comments'
!=partial('includes/third-party/comments/facebook_comments', {}, {cache: true})
include ./facebook_comments.pug
when 'Remark42'
!=partial('includes/third-party/comments/remark42', {}, {cache: true})
when 'Artalk'
!=partial('includes/third-party/comments/artalk', {}, {cache: true})
Loading

0 comments on commit 8ee052e

Please sign in to comment.