mirror of
https://github.com/jerryc127/hexo-theme-butterfly.git
synced 2026-04-16 20:30:53 +08:00
pjax
This commit is contained in:
@@ -1,20 +1,29 @@
|
||||
#disqus_thread
|
||||
script.
|
||||
function loadDisqus () {
|
||||
var disqus_config = function () {
|
||||
this.page.url = '!{ page.permalink }';
|
||||
this.page.identifier = '!{ page.path }';
|
||||
this.page.title = '!{ page.title }';
|
||||
this.page.url = '!{ page.permalink }'
|
||||
this.page.identifier = '!{ page.path }'
|
||||
this.page.title = '!{ page.title }'
|
||||
};
|
||||
|
||||
var d = document, s = d.createElement('script');
|
||||
s.src = 'https://!{theme.disqus.shortname}.disqus.com/embed.js';
|
||||
s.setAttribute('data-timestamp', +new Date());
|
||||
(d.head || d.body).appendChild(s);
|
||||
if (window.DISQUS) {
|
||||
DISQUS.reset({
|
||||
reload: true,
|
||||
config: disqus_config
|
||||
})
|
||||
} else {
|
||||
(function() {
|
||||
var d = document, s = d.createElement('script')
|
||||
s.src = 'https://!{theme.disqus.shortname}.disqus.com/embed.js'
|
||||
s.setAttribute('data-timestamp', +new Date())
|
||||
s.setAttribute('data-timestamp', +new Date());
|
||||
(d.head || d.body).appendChild(s);
|
||||
})();
|
||||
}
|
||||
}
|
||||
|
||||
if ('!{defaultComment}' === 'Disqus' || !{theme.comments.load_begin}) {
|
||||
window.addEventListener('load', loadDisqus)
|
||||
loadDisqus()
|
||||
}
|
||||
else {
|
||||
function loadOtherComment () {
|
||||
@@ -22,6 +31,7 @@ script.
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if is_post() && theme.comments.count && defaultComment === 'Disqus'
|
||||
script.
|
||||
function getDisqusCount() {
|
||||
@@ -31,4 +41,4 @@ if is_post() && theme.comments.count && defaultComment === 'Disqus'
|
||||
(d.head || d.body).appendChild(s);
|
||||
}
|
||||
|
||||
window.addEventListener('load', getDisqusCount, false);
|
||||
getDisqusCount()
|
||||
@@ -1,13 +1,15 @@
|
||||
#disqus_thread
|
||||
script.
|
||||
function loadDisqusjs () {
|
||||
const ele = document.createElement('link')
|
||||
ele.rel = 'stylesheet'
|
||||
ele.href= '!{url_for(theme.CDN.disqusjs_css)}'
|
||||
document.getElementsByTagName('head')[0].appendChild(ele)
|
||||
function addDisqusjsCSS () {
|
||||
const ele = document.createElement('link')
|
||||
ele.rel = 'stylesheet'
|
||||
ele.href= '!{url_for(theme.CDN.disqusjs_css)}'
|
||||
document.getElementsByTagName('head')[0].appendChild(ele)
|
||||
}
|
||||
|
||||
loadScript('!{url_for(theme.CDN.disqusjs)}', function() {
|
||||
var dsqjs = new DisqusJS({
|
||||
function initDiqusjs () {
|
||||
window.DISQUS = null
|
||||
new DisqusJS({
|
||||
shortname: '!{theme.disqusjs.shortname}',
|
||||
siteName: '!{theme.disqusjs.siteName}',
|
||||
identifier: '!{ page.path }',
|
||||
@@ -19,11 +21,18 @@ script.
|
||||
admin: '!{theme.disqusjs.admin}',
|
||||
adminLabel: '!{theme.disqusjs.adminLabel}'
|
||||
});
|
||||
})
|
||||
}
|
||||
|
||||
if (window.disqusjsload) initDiqusjs()
|
||||
else {
|
||||
addDisqusjsCSS()
|
||||
$.getScript('!{url_for(theme.CDN.disqusjs)}', initDiqusjs)
|
||||
window.disqusjsload = true
|
||||
}
|
||||
}
|
||||
|
||||
if ('!{defaultComment}' === 'Disqusjs' || !{theme.comments.load_begin}) {
|
||||
window.addEventListener('load', loadDisqusjs)
|
||||
loadDisqusjs()
|
||||
}
|
||||
else {
|
||||
function loadOtherComment () {
|
||||
@@ -40,4 +49,4 @@ if is_post() && theme.comments.count && defaultComment === 'Disqusjs'
|
||||
s.id = 'dsq-count-scr';
|
||||
(d.head || d.body).appendChild(s);
|
||||
}
|
||||
window.addEventListener('load', getDisqusCount, false);
|
||||
getDisqusCount()
|
||||
|
||||
@@ -1,10 +1,4 @@
|
||||
#fb-root
|
||||
.fb-comments(data-colorscheme = theme.display_mode === 'dark' ? 'dark' : 'light'
|
||||
data-href=urlNoIndex()
|
||||
data-numposts= theme.facebook_comments.pageSize || 10
|
||||
data-order-by= theme.facebook_comments.order_by || 'social'
|
||||
data-width="100%")
|
||||
|
||||
script.
|
||||
function loadFBComent () {
|
||||
let ele = document.createElement('script')
|
||||
@@ -13,10 +7,15 @@ script.
|
||||
ele.setAttribute('defer', 'true')
|
||||
ele.setAttribute('crossorigin', 'anonymous')
|
||||
document.getElementById('fb-root').insertAdjacentElement('afterbegin',ele)
|
||||
|
||||
var themeNow = document.documentElement.getAttribute('data-theme') === 'dark' ? 'dark' : 'light'
|
||||
document.getElementsByClassName('fb-comments')[0].setAttribute('data-colorscheme',themeNow)
|
||||
|
||||
if (typeof FB === 'object') FB.XFBML.parse()
|
||||
}
|
||||
|
||||
if ('!{defaultComment}' === 'Facebook Comments' || !{theme.comments.load_begin}) {
|
||||
window.addEventListener('load', loadFBComent)
|
||||
loadFBComent()
|
||||
}
|
||||
else {
|
||||
function loadOtherComment () {
|
||||
@@ -24,7 +23,3 @@ script.
|
||||
}
|
||||
}
|
||||
|
||||
if theme.darkmode.enable
|
||||
script.
|
||||
var themeNow = document.documentElement.getAttribute('data-theme') === 'dark' ? 'dark' : 'light'
|
||||
document.getElementsByClassName('fb-comments')[0].setAttribute('data-colorscheme',themeNow)
|
||||
|
||||
@@ -1,21 +1,20 @@
|
||||
#gitalk-container
|
||||
script(src=url_for(theme.CDN.blueimp_md5))
|
||||
|
||||
script.
|
||||
function loadGitalk () {
|
||||
const ele = document.createElement('link')
|
||||
ele.rel = 'stylesheet'
|
||||
ele.href= '!{url_for(theme.CDN.gitalk_css)}'
|
||||
document.getElementsByTagName('head')[0].appendChild(ele)
|
||||
function addGitalkSource () {
|
||||
const ele = document.createElement('link')
|
||||
ele.rel = 'stylesheet'
|
||||
ele.href= '!{url_for(theme.CDN.gitalk_css)}'
|
||||
document.getElementsByTagName('head')[0].appendChild(ele)
|
||||
}
|
||||
|
||||
loadScript('!{url_for(theme.CDN.gitalk)}', function () {
|
||||
function initGitalk () {
|
||||
var gitalk = new Gitalk({
|
||||
clientID: '!{theme.gitalk.client_id}',
|
||||
clientSecret: '!{theme.gitalk.client_secret}',
|
||||
repo: '!{theme.gitalk.repo}',
|
||||
owner: '!{theme.gitalk.owner}',
|
||||
admin: ['!{theme.gitalk.admin}'],
|
||||
id: md5(decodeURI(location.pathname)),
|
||||
id: '!{md5(page.path)}',
|
||||
language: '!{theme.gitalk.language}',
|
||||
perPage: !{theme.gitalk.perPage},
|
||||
distractionFreeMode: !{theme.gitalk.distractionFreeMode},
|
||||
@@ -24,7 +23,13 @@ script.
|
||||
updateCountCallback: commentCount
|
||||
})
|
||||
gitalk.render('gitalk-container')
|
||||
})
|
||||
}
|
||||
|
||||
if (typeof Gitalk === 'function') initGitalk()
|
||||
else {
|
||||
addGitalkSource()
|
||||
$.getScript('!{url_for(theme.CDN.gitalk)}', initGitalk)
|
||||
}
|
||||
|
||||
function commentCount(n){
|
||||
try {
|
||||
@@ -36,7 +41,7 @@ script.
|
||||
}
|
||||
|
||||
if ('!{defaultComment}' === 'Gitalk' || !{theme.comments.load_begin}) {
|
||||
window.addEventListener('load', loadGitalk)
|
||||
loadGitalk()
|
||||
}
|
||||
else {
|
||||
function loadOtherComment () {
|
||||
@@ -45,3 +50,4 @@ script.
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,36 +1,38 @@
|
||||
if theme.comments && theme.comments.use
|
||||
- const defaultComment = theme.comments.use[0]
|
||||
hr
|
||||
#post-comment
|
||||
.comment-head
|
||||
.comment-headling
|
||||
i.fas.fa-comments.fa-fw
|
||||
span= ' ' + _p('comment')
|
||||
|
||||
if theme.comments.use.length > 1
|
||||
.comment-switch
|
||||
span.first-comment=defaultComment
|
||||
label
|
||||
input#switch-comments-btn(type="checkbox")
|
||||
span.slider
|
||||
span.second-comment=theme.comments.use[1]
|
||||
- let defaultComment = theme.comments.use[0]
|
||||
hr
|
||||
#post-comment
|
||||
.comment-head
|
||||
.comment-headling
|
||||
i.fas.fa-comments.fa-fw
|
||||
span= ' ' + _p('comment')
|
||||
|
||||
if theme.comments.use.length > 1
|
||||
.comment-switch
|
||||
span.first-comment=defaultComment
|
||||
label
|
||||
input#switch-comments-btn(type="checkbox")
|
||||
span.slider
|
||||
span.second-comment=theme.comments.use[1]
|
||||
|
||||
|
||||
.comment-wrap
|
||||
each name, index in theme.comments.use
|
||||
div(class=`comments-items-${index+1}` data-name=`${name}`)
|
||||
case name
|
||||
when 'Disqus'
|
||||
include ./disqus.pug
|
||||
when 'Valine'
|
||||
include ./valine.pug
|
||||
when 'Disqusjs'
|
||||
include ./disqusjs.pug
|
||||
when 'Livere'
|
||||
include ./livere.pug
|
||||
when 'Gitalk'
|
||||
include ./gitalk.pug
|
||||
when 'Utterances'
|
||||
include ./utterances.pug
|
||||
when 'Facebook Comments'
|
||||
include ./facebook_comments.pug
|
||||
.comment-wrap
|
||||
each name in theme.comments.use
|
||||
div
|
||||
case name
|
||||
when 'Disqus'
|
||||
#disqus_thread
|
||||
when 'Valine'
|
||||
#vcomment.vcomment
|
||||
when 'Disqusjs'
|
||||
#disqus_thread
|
||||
when 'Livere'
|
||||
#lv-container(data-id="city" data-uid=theme.livere.uid)
|
||||
when 'Gitalk'
|
||||
#gitalk-container
|
||||
when 'Utterances'
|
||||
#utterances-wrap
|
||||
when 'Facebook Comments'
|
||||
.fb-comments(data-colorscheme = theme.display_mode === 'dark' ? 'dark' : 'light'
|
||||
data-numposts= theme.facebook_comments.pageSize || 10
|
||||
data-order-by= theme.facebook_comments.order_by || 'social'
|
||||
data-width="100%")
|
||||
|
||||
17
layout/includes/comments/js.pug
Normal file
17
layout/includes/comments/js.pug
Normal file
@@ -0,0 +1,17 @@
|
||||
- let defaultComment = theme.comments.use[0]
|
||||
each name in theme.comments.use
|
||||
case name
|
||||
when 'Disqus'
|
||||
include ./disqus.pug
|
||||
when 'Valine'
|
||||
include ./valine.pug
|
||||
when 'Disqusjs'
|
||||
include ./disqusjs.pug
|
||||
when 'Livere'
|
||||
include ./livere.pug
|
||||
when 'Gitalk'
|
||||
include ./gitalk.pug
|
||||
when 'Utterances'
|
||||
include ./utterances.pug
|
||||
when 'Facebook Comments'
|
||||
include ./facebook_comments.pug
|
||||
@@ -1,21 +1,23 @@
|
||||
#lv-container(data-id="city" data-uid=theme.livere.uid)
|
||||
script.
|
||||
function loadlivere () {
|
||||
(function(d, s) {
|
||||
var j, e = d.getElementsByTagName(s)[0];
|
||||
if (typeof LivereTower === 'function') { return; }
|
||||
j = d.createElement(s);
|
||||
j.src = 'https://cdn-city.livere.com/js/embed.dist.js';
|
||||
j.async = true;
|
||||
e.parentNode.insertBefore(j, e);
|
||||
})(document, 'script');
|
||||
}
|
||||
script.
|
||||
function loadlivere () {
|
||||
(function(d, s) {
|
||||
var j, e = d.getElementsByTagName(s)[0];
|
||||
if (typeof LivereTower === 'function') { return; }
|
||||
j = d.createElement(s);
|
||||
j.src = 'https://cdn-city.livere.com/js/embed.dist.js';
|
||||
j.async = true;
|
||||
e.parentNode.insertBefore(j, e);
|
||||
})(document, 'script');
|
||||
}
|
||||
|
||||
if ('!{defaultComment}' === 'Livere' || !{theme.comments.load_begin}) {
|
||||
window.addEventListener('load', loadlivere)
|
||||
if ('!{defaultComment}' === 'Livere' || !{theme.comments.load_begin}) {
|
||||
loadlivere()
|
||||
}
|
||||
else {
|
||||
function loadOtherComment () {
|
||||
loadlivere()
|
||||
}
|
||||
else {
|
||||
function loadOtherComment () {
|
||||
loadlivere()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
noscript.
|
||||
Please activate JavaScript for write a comment in LiveRe
|
||||
@@ -1,36 +1,36 @@
|
||||
#utterances-wrap
|
||||
|
||||
script.
|
||||
function loadUtterances () {
|
||||
let ele = document.createElement('script')
|
||||
ele.setAttribute('id', 'utterances_comment')
|
||||
ele.setAttribute('src', '!{url_for(theme.CDN.utterances)}')
|
||||
ele.setAttribute('repo', '!{theme.utterances.repo}')
|
||||
ele.setAttribute('issue-term', '!{theme.utterances.issue_term}')
|
||||
let nowTheme = document.documentElement.getAttribute('data-theme') === 'dark' ? '#{theme.utterances.dark_theme}' : '#{theme.utterances.light_theme}'
|
||||
ele.setAttribute('theme', nowTheme)
|
||||
ele.setAttribute('crossorigin', 'anonymous')
|
||||
ele.setAttribute('async', 'true')
|
||||
document.getElementById('utterances-wrap').insertAdjacentElement('afterbegin',ele)
|
||||
}
|
||||
if (document.getElementById('utterances-wrap')) {
|
||||
function loadUtterances () {
|
||||
let ele = document.createElement('script')
|
||||
ele.setAttribute('id', 'utterances_comment')
|
||||
ele.setAttribute('src', '!{url_for(theme.CDN.utterances)}')
|
||||
ele.setAttribute('repo', '!{theme.utterances.repo}')
|
||||
ele.setAttribute('issue-term', '!{theme.utterances.issue_term}')
|
||||
let nowTheme = document.documentElement.getAttribute('data-theme') === 'dark' ? '#{theme.utterances.dark_theme}' : '#{theme.utterances.light_theme}'
|
||||
ele.setAttribute('theme', nowTheme)
|
||||
ele.setAttribute('crossorigin', 'anonymous')
|
||||
ele.setAttribute('async', 'true')
|
||||
document.getElementById('utterances-wrap').insertAdjacentElement('afterbegin',ele)
|
||||
}
|
||||
|
||||
if ('!{defaultComment}' === 'Utterances' || !{theme.comments.load_begin}) {
|
||||
window.addEventListener('load', loadUtterances)
|
||||
}
|
||||
else {
|
||||
function loadOtherComment () {
|
||||
if ('!{defaultComment}' === 'Utterances' || !{theme.comments.load_begin}) {
|
||||
loadUtterances()
|
||||
}
|
||||
else {
|
||||
function loadOtherComment () {
|
||||
loadUtterances()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if theme.darkmode.enable
|
||||
script.
|
||||
function utterancesTheme () {
|
||||
var theme = document.documentElement.getAttribute('data-theme') === 'dark' ? '#{theme.utterances.dark_theme}' : '#{theme.utterances.light_theme}'
|
||||
const message = {
|
||||
type: 'set-theme',
|
||||
theme: theme
|
||||
};
|
||||
const iframe = document.querySelector('.utterances-frame');
|
||||
iframe.contentWindow.postMessage(message, 'https://utteranc.es');
|
||||
var theme = document.documentElement.getAttribute('data-theme') === 'dark' ? '#{theme.utterances.dark_theme}' : '#{theme.utterances.light_theme}'
|
||||
const message = {
|
||||
type: 'set-theme',
|
||||
theme: theme
|
||||
};
|
||||
const iframe = document.querySelector('.utterances-frame');
|
||||
iframe.contentWindow.postMessage(message, 'https://utteranc.es');
|
||||
}
|
||||
|
||||
@@ -2,10 +2,9 @@
|
||||
if site.data.valine
|
||||
- emojiMaps = JSON.stringify(site.data.valine)
|
||||
|
||||
#vcomment.vcomment
|
||||
script.
|
||||
function loadvaline () {
|
||||
var requestSetting = function (from,set) {
|
||||
function requestSetting (from, set) {
|
||||
var from = from
|
||||
var setting = set.split(',').filter(function(item){
|
||||
return from.indexOf(item) > -1
|
||||
@@ -22,6 +21,7 @@ script.
|
||||
el:'#vcomment',
|
||||
appId: '#{theme.valine.appId}',
|
||||
appKey: '#{theme.valine.appKey}',
|
||||
path: window.location.pathname,
|
||||
placeholder: '#{theme.valine.placeholder}',
|
||||
avatar: '#{theme.valine.avatar}',
|
||||
meta: guestInfo,
|
||||
@@ -35,11 +35,13 @@ script.
|
||||
requiredFields: requiredFields
|
||||
});
|
||||
}
|
||||
loadScript('!{url_for(theme.CDN.valine)}', initValine)
|
||||
|
||||
if (typeof window.valine ==='object') initValine()
|
||||
else $.getScript('!{url_for(theme.CDN.valine)}', initValine)
|
||||
}
|
||||
|
||||
if ('!{defaultComment}' === 'Valine' || !{theme.comments.load_begin}) {
|
||||
window.addEventListener('load', loadvaline)
|
||||
loadvaline()
|
||||
}
|
||||
else {
|
||||
function loadOtherComment () {
|
||||
|
||||
Reference in New Issue
Block a user