💥 支持雙評論系統配置/評論配置整理

 增加mac light 代碼框
 增加文章過期提醒配置
 文章copyright 可單獨配置
 card-category 中category名稱和數字限制一行顯示
 簡繁轉換優化,placeholder文字也會被轉換
🐛 修復配置PWA參數時,如果網站是子目錄時,會出現加載不到文件的bugs
調整當card-category有收縮按鈕時的顯示佈局
This commit is contained in:
Jerry
2020-06-25 23:13:55 +08:00
parent 67b49c01ba
commit 4d34208391
47 changed files with 1098 additions and 817 deletions

View File

@@ -1,18 +1,28 @@
#disqus_thread
script.
var disqus_config = function () {
this.page.url = '!{ page.permalink }';
this.page.identifier = '!{ page.path }';
this.page.title = '!{ page.title }';
};
(function() {
function loadDisqus () {
var disqus_config = function () {
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 is_post() && theme.disqus.count
if ('!{defaultComment}' === 'Disqus' || !{theme.comments.load_begin}) {
window.addEventListener('load', loadDisqus)
}
else {
function loadOtherComment () {
loadDisqus()
}
}
if is_post() && theme.comments.count && defaultComment === 'Disqus'
script.
function getDisqusCount() {
var d = document, s = d.createElement('script');

View File

@@ -1,20 +1,38 @@
#disqus_thread
script(src=url_for(theme.CDN.disqusjs))
script.
var dsqjs = new DisqusJS({
shortname: '!{theme.disqusjs.shortname}',
siteName: '!{theme.disqusjs.siteName}',
identifier: '!{ page.path }',
url: '!{ page.permalink }',
title: '!{ page.title }',
api: '!{theme.disqusjs.api}',
apikey: '!{theme.disqusjs.apikey}',
nocomment: '!{theme.disqusjs.nocomment}',
admin: '!{theme.disqusjs.admin}',
adminLabel: '!{theme.disqusjs.adminLabel}'
});
function loadDisqusjs () {
const ele = document.createElement('link')
ele.rel = 'stylesheet'
ele.href= '!{url_for(theme.CDN.disqusjs_css)}'
document.getElementsByTagName('head')[0].appendChild(ele)
if is_post() && theme.disqusjs.count
loadScript('!{url_for(theme.CDN.disqusjs)}', function() {
var dsqjs = new DisqusJS({
shortname: '!{theme.disqusjs.shortname}',
siteName: '!{theme.disqusjs.siteName}',
identifier: '!{ page.path }',
url: '!{ page.permalink }',
title: '!{ page.title }',
api: '!{theme.disqusjs.api}',
apikey: '!{theme.disqusjs.apikey}',
nocomment: '!{theme.disqusjs.nocomment}',
admin: '!{theme.disqusjs.admin}',
adminLabel: '!{theme.disqusjs.adminLabel}'
});
})
}
if ('!{defaultComment}' === 'Disqusjs' || !{theme.comments.load_begin}) {
window.addEventListener('load', loadDisqusjs)
}
else {
function loadOtherComment () {
loadDisqusjs()
}
}
if is_post() && theme.comments.count && defaultComment === 'Disqusjs'
script.
function getDisqusCount() {
var d = document, s = d.createElement('script');

View File

@@ -1,11 +1,29 @@
#fb-root
script(async defer crossorigin="anonymous" src=`https://connect.facebook.net/${theme.facebook_comments.lang}/sdk.js#xfbml=1&version=v6.0`)
.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')
ele.setAttribute('src','https://connect.facebook.net/!{theme.facebook_comments.lang}/sdk.js#xfbml=1&version=v7.0')
ele.setAttribute('async', 'true')
ele.setAttribute('defer', 'true')
ele.setAttribute('crossorigin', 'anonymous')
document.getElementById('fb-root').insertAdjacentElement('afterbegin',ele)
}
if ('!{defaultComment}' === 'Facebook Comments' || !{theme.comments.load_begin}) {
window.addEventListener('load', loadFBComent)
}
else {
function loadOtherComment () {
loadFBComent()
}
}
if theme.darkmode.enable
script.
var themeNow = document.documentElement.getAttribute('data-theme') === 'dark' ? 'dark' : 'light'

View File

@@ -1,26 +1,46 @@
#gitalk-container
script.
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)),
language: '!{theme.gitalk.language}',
perPage: !{theme.gitalk.perPage},
distractionFreeMode: !{theme.gitalk.distractionFreeMode},
pagerDirection: '!{theme.gitalk.pagerDirection}',
createIssueManually: !{theme.gitalk.createIssueManually},
updateCountCallback: commentCount
})
gitalk.render('gitalk-container')
script(src=url_for(theme.CDN.blueimp_md5))
function commentCount(n){
try {
document.getElementsByClassName('gitalk-comment-count')[0].innerHTML= n
} catch (e) {
return false
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)
loadScript('!{url_for(theme.CDN.gitalk)}', function () {
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)),
language: '!{theme.gitalk.language}',
perPage: !{theme.gitalk.perPage},
distractionFreeMode: !{theme.gitalk.distractionFreeMode},
pagerDirection: '!{theme.gitalk.pagerDirection}',
createIssueManually: !{theme.gitalk.createIssueManually},
updateCountCallback: commentCount
})
gitalk.render('gitalk-container')
})
function commentCount(n){
try {
document.getElementsByClassName('gitalk-comment-count')[0].innerHTML= n
} catch (e) {
return false
}
}
}
if ('!{defaultComment}' === 'Gitalk' || !{theme.comments.load_begin}) {
window.addEventListener('load', loadGitalk)
}
else {
function loadOtherComment () {
loadGitalk()
}
}

View File

@@ -1,29 +1,36 @@
- var d = theme.disqus && theme.disqus.enable
- var dj = theme.disqusjs && theme.disqusjs.enable
- var l = theme.livere && theme.livere.enable
- var gt = theme.gitalk && theme.gitalk.enable
- var v = theme.valine && theme.valine.enable
- var u = theme.utterances && theme.utterances.enable
- var fb = theme.facebook_comments && theme.facebook_comments.enable
- var isComment = d || dj || l || gt || v || u || fb
if isComment
if theme.comments && theme.comments.use
- const defaultComment = theme.comments.use[0]
hr
#post-comment
.comment_headling
i.fas.fa-comments.fa-fw
span= ' ' + _p('comment')
if d
include ./disqus.pug
else if dj
include ./disqusjs.pug
else if l
include ./livere.pug
else if gt
include ./gitalk.pug
else if v
include ./valine.pug
else if u
include ./utterances.pug
else if fb
include ./facebook_comments.pug
.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

View File

@@ -1,10 +1,21 @@
#lv-container(data-id="city" data-uid=theme.livere.uid)
script.
(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');
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)
}
else {
function loadOtherComment () {
loadlivere()
}
}

View File

@@ -1,15 +1,30 @@
script#utterances_comment(src=theme.CDN.utterances
repo=theme.utterances.repo
issue-term=theme.utterances.issue_term
theme= theme.display_mode === 'dark' ? theme.utterances.dark_theme : theme.utterances.light_theme
crossorigin="anonymous"
async)
#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 ('!{defaultComment}' === 'Utterances' || !{theme.comments.load_begin}) {
window.addEventListener('load', loadUtterances)
}
else {
function loadOtherComment () {
loadUtterances()
}
}
if theme.darkmode.enable
script.
var themeNow = document.documentElement.getAttribute('data-theme') === 'dark' ? '#{theme.utterances.dark_theme}' : '#{theme.utterances.light_theme}'
document.getElementById('utterances_comment').setAttribute('theme',themeNow)
function utterancesTheme () {
var theme = document.documentElement.getAttribute('data-theme') === 'dark' ? '#{theme.utterances.dark_theme}' : '#{theme.utterances.light_theme}'
const message = {

View File

@@ -3,33 +3,47 @@ if site.data.valine
- emojiMaps = JSON.stringify(site.data.valine)
#vcomment.vcomment
script(src=url_for(theme.CDN.valine))
script.
var requestSetting = function (from,set) {
var from = from
var setting = set.split(',').filter(function(item){
return from.indexOf(item) > -1
});
setting = setting.length == 0 ? from :setting;
return setting
function loadvaline () {
var requestSetting = function (from,set) {
var from = from
var setting = set.split(',').filter(function(item){
return from.indexOf(item) > -1
});
setting = setting.length == 0 ? from :setting;
return setting
}
var guestInfo = requestSetting(['nick','mail','link'],'#{ theme.valine.guest_info }')
var requiredFields = requestSetting(['nick','mail'],'#{ theme.valine.requiredFields }')
function initValine () {
window.valine = new Valine({
el:'#vcomment',
appId: '#{theme.valine.appId}',
appKey: '#{theme.valine.appKey}',
placeholder: '#{theme.valine.placeholder}',
avatar: '#{theme.valine.avatar}',
meta: guestInfo,
pageSize: '#{theme.valine.pageSize}',
lang: '#{theme.valine.lang}',
recordIP: #{theme.valine.recordIP},
serverURLs: '#{theme.valine.serverURLs}',
emojiCDN: '#{theme.valine.emojiCDN}',
emojiMaps: !{emojiMaps},
enableQQ: #{theme.valine.enableQQ},
requiredFields: requiredFields
});
}
loadScript('!{url_for(theme.CDN.valine)}', initValine)
}
var guestInfo = requestSetting(['nick','mail','link'],'#{ theme.valine.guest_info }')
var requiredFields = requestSetting(['nick','mail'],'#{ theme.valine.requiredFields }')
if ('!{defaultComment}' === 'Valine' || !{theme.comments.load_begin}) {
window.addEventListener('load', loadvaline)
}
else {
function loadOtherComment () {
loadvaline()
}
}
window.valine = new Valine({
el:'#vcomment',
appId: '#{theme.valine.appId}',
appKey: '#{theme.valine.appKey}',
placeholder: '#{theme.valine.placeholder}',
avatar: '#{theme.valine.avatar}',
meta: guestInfo,
pageSize: '#{theme.valine.pageSize}',
lang: '#{theme.valine.lang}',
recordIP: #{theme.valine.recordIP},
serverURLs: '#{theme.valine.serverURLs}',
emojiCDN: '#{theme.valine.emojiCDN}',
emojiMaps: !{emojiMaps},
enableQQ: #{theme.valine.enableQQ},
requiredFields: requiredFields
});

View File

@@ -1,14 +1,5 @@
if (theme.facebook_comments.enable && page.comments !== false && !is_tag() && !is_category() && !is_archive() && !is_home())
if page.comments !== false && theme.comments.use && theme.comments.use.includes('Facebook Comments')
if theme.facebook_comments.app_id
meta(property="fb:app_id" content=theme.facebook_comments.app_id )
if theme.facebook_comments.user_id
meta(property="fb:admins" content=theme.facebook_comments.user_id)
if (theme.disqusjs && theme.disqusjs.enable && page.comments !== false && !is_tag() && !is_category() && !is_archive() && !is_home())
link(rel="stylesheet" type="text/css" href=url_for(theme.CDN.disqusjs_css))
if (theme.gitalk && theme.gitalk.enable && page.comments !== false && !is_tag() && !is_category() && !is_archive() && !is_home())
link(rel="stylesheet" type="text/css" href=url_for(theme.CDN.gitalk_css))
script(src=url_for(theme.CDN.gitalk))
script(src=url_for(theme.CDN.blueimp_md5))
meta(property="fb:admins" content=theme.facebook_comments.user_id)

View File

@@ -74,12 +74,23 @@
})
}
var noticeOutdate = 'undefined';
if (theme.noticeOutdate && theme.noticeOutdate.enable) {
noticeOutdate = JSON.stringify({
limitDay: theme.noticeOutdate.limit_day,
position: theme.noticeOutdate.position,
messagePrev: theme.noticeOutdate.message_prev,
messageNext: theme.noticeOutdate.message_next,
})
}
script.
var GLOBAL_CONFIG = {
root: '!{config.root}',
algolia: !{algolia},
localSearch: !{localSearch},
translate: !{translate},
noticeOutdate: !{noticeOutdate},
copy: {
success: '!{_p("copy.success")}',
error: '!{_p("copy.error")}',

View File

@@ -1,10 +1,10 @@
-
let isHighlightShrink
if (theme.highlight_shrink == 'none') isHighlightShrink = 'undefined'
else if (page.highlight_shrink !== null && page.toc !== undefined ) isHighlightShrink = page.highlight_shrink
else if (page.highlight_shrink === true || page.highlight_shrink === false) isHighlightShrink = page.highlight_shrink
else isHighlightShrink = theme.highlight_shrink
const pageToc = page.toc !== null && page.toc !== undefined ? page.toc : theme.toc.enable
const pageToc = page.toc === true || page.toc === false ? page.toc : theme.toc.enable
const showToc = is_post() && pageToc && (toc(page.content) !== '' || page.encrypt == true )
-
@@ -13,5 +13,6 @@ script.
isPost: !{is_post()},
isHome: !{is_home()},
isHighlightShrink: !{isHighlightShrink},
isSidebar: !{showToc}
}
isSidebar: !{showToc},
postUpdate: '!{full_date(page.updated)}'
}

View File

@@ -1,13 +1,13 @@
link(rel="manifest" href=theme.pwa.manifest)
link(rel="manifest" href=url_for(theme.pwa.manifest))
if(theme.pwa.theme_color)
meta(name="theme-color" content=theme.pwa.theme_color)
if(theme.pwa.theme_color)
meta(name="msapplication-TileColor" content=theme.pwa.theme_color)
if(theme.pwa.apple_touch_icon)
link(rel="apple-touch-icon" sizes="180x180" href=theme.pwa.apple_touch_icon)
link(rel="apple-touch-icon" sizes="180x180" href=url_for(theme.pwa.apple_touch_icon))
if(theme.pwa.favicon_32_32)
link(rel="icon" type="image/png" sizes="32x32" href=theme.pwa.favicon_32_32)
link(rel="icon" type="image/png" sizes="32x32" href=url_for(theme.pwa.favicon_32_32))
if(theme.pwa.favicon_16_16)
link(rel="icon" type="image/png" sizes="16x16" href=theme.pwa.favicon_16_16)
link(rel="icon" type="image/png" sizes="16x16" href=url_for(theme.pwa.favicon_16_16))
if(theme.pwa.mask_icon)
link(rel="mask-icon" href=theme.pwa.mask_icon color="#5bbad5")
link(rel="mask-icon" href=url_for(theme.pwa.mask_icon) color="#5bbad5")

View File

@@ -57,29 +57,32 @@
span=_p('post.page_pv') + ':'
span#busuanzi_value_page_pv
span.post-meta-commentcount
if ((theme.disqus && theme.disqus.enable && theme.disqus.count && page.comments !== false) || (theme.disqusjs && theme.disqusjs.enable && theme.disqusjs.count && page.comments !== false))
if page.comments !== false && theme.comments.use && theme.comments.count
span.post-meta-commentcount
- let whichCount = theme.comments.use[0]
if whichCount === 'Disqus' || whichCount === 'Disqusjs'
if (postWordcount || theme.busuanzi.page_pv)
span.post-meta__separator |
i.far.fa-comments.fa-fw.post-meta__icon
span= _p('post.comments') + ':'
span.disqus-comment-count.comment-count
a(href=full_url_for(page.path) + '#disqus_thread')
else if (theme.valine && theme.valine.enable && theme.valine.count && page.comments !== false)
else if whichCount === 'Valine'
if (postWordcount || theme.busuanzi.page_pv)
span.post-meta__separator |
i.far.fa-comments.fa-fw.post-meta__icon
span= _p('post.comments') + ':'
a(href=url_for(page.path) + '#post-comment' itemprop="discussionUrl")
span.valine-comment-count.comment-count(data-xid=url_for(page.path) itemprop="commentCount")
else if (theme.gitalk && theme.gitalk.enable && theme.gitalk.count && page.comments !== false)
else if whichCount === 'Gitalk'
if (postWordcount || theme.busuanzi.page_pv)
span.post-meta__separator |
i.far.fa-comments.fa-fw.post-meta__icon
span= _p('post.comments') + ':'
a(href=url_for(page.path) + '#post-comment')
span.gitalk-comment-count.comment-count
else if theme.facebook_comments.enable && theme.facebook_comments.count && page.comments !== false
else if whichCount === 'Facebook Comments'
if (postWordcount || theme.busuanzi.page_pv)
span.post-meta__separator |
i.far.fa-comments.fa-fw.post-meta__icon

View File

@@ -1,5 +1,5 @@
- var hideAside = !theme.aside.enable || page.aside === false ? 'hide-aside' : ''
- var pageHighlightShrinkSet = page.highlight_shrink !== undefined ? page.highlight_shrink : theme.highlight_shrink
- var pageHighlightShrinkSet = page.highlight_shrink === true || page.highlight_shrink === false ? page.highlight_shrink : theme.highlight_shrink
- var pageHighlightShrink = theme.highlight_shrink !== 'none' && pageHighlightShrinkSet ? 'code-close' : ''
doctype html

View File

@@ -1,13 +1,17 @@
if (theme.post_copyright && theme.post_copyright.enable && page.copyright != false)
if theme.post_copyright.enable && page.copyright !== false
- let author = page.copyright_author ? page.copyright_author : config.author
- let authorHref = page.copyright_author_href ? page.copyright_author_href : `mailto:${config.email}`
- let url = page.copyright_url ? page.copyright_url : page.permalink
- let info = page.copyright_info ? page.copyright_info : _p('post.copyright.copyright_content', theme.post_copyright.license_url, theme.post_copyright.license, config.url, config.title)
.post-copyright
.post-copyright__author
span.post-copyright-meta= _p('post.copyright.author') + ": "
span.post-copyright-info
a(href=`mailto:${config.email}`) #[=config.author]
a(href=authorHref)=author
.post-copyright__type
span.post-copyright-meta= _p('post.copyright.link') + ": "
span.post-copyright-info
a(href=url_for(page.permalink))= theme.post_copyright.decode ? decodeURI(page.permalink) : page.permalink
a(href=url_for(url))= theme.post_copyright.decode ? decodeURI(url) : url
.post-copyright__notice
span.post-copyright-meta= _p('post.copyright.copyright_notice') + ": "
span.post-copyright-info!= _p('post.copyright.copyright_content', theme.post_copyright.license_url, theme.post_copyright.license, config.url, config.title)
span.post-copyright-info!= info

View File

@@ -1,5 +1,5 @@
.post-reward
button.reward-button
button.reward-button(type="button")
i.fas.fa-qrcode
= ' ' + _p('donate')
.reward-main

View File

@@ -1,32 +1,32 @@
section#rightside.rightside
section#rightside
#rightside-config-hide
if is_post()
if theme.readmode
button#readmode(title=_p('rightside.readmode_title'))
button#readmode(type="button" title=_p('rightside.readmode_title'))
i.fas.fa-book-open
button#font_plus(title=_p('rightside.font_plus_title'))
button#font_plus(type="button" title=_p('rightside.font_plus_title'))
i.fas.fa-plus
button#font_minus(title=_p('rightside.font_minus_title'))
button#font_minus(type="button" title=_p('rightside.font_minus_title'))
i.fas.fa-minus
if theme.translate && theme.translate.enable
button#translateLink.translate_chn_to_cht(title=_p('rightside.translate_title'))= theme.translate.default
button#translateLink(type="button" title=_p('rightside.translate_title'))= theme.translate.default
if theme.darkmode.enable && theme.darkmode.button
button#darkmode(title=_p('rightside.night_mode_title'))
button#darkmode(type="button" title=_p('rightside.night_mode_title'))
i.fas.fa-adjust
#rightside-config-show
button#rightside_config(title=_p("rightside.setting"))
button#rightside_config(type="button" title=_p("rightside.setting"))
i.fas.fa-cog
if is_post() && page.comments !== false && isComment
if is_post() && page.comments !== false && theme.comments.use
a#to_comment(href="#post-comment" title=_p("rightside.scroll_to_comment"))
i.scroll_to_comment.fas.fa-comments
i.fas.fa-comments
if showToc
button#mobile-toc-button.close(title=_p("rightside.toc"))
button#mobile-toc-button.close(type="button" title=_p("rightside.toc"))
i.fas.fa-list-ul
if theme.chat_btn && (theme.chatra.enable || theme.tidio.enable || theme.daovoice.enable || theme.gitter.enable)
button#chat_btn(title=_p("rightside.chat_btn"))
button#chat_btn(type="button" title=_p("rightside.chat_btn"))
i.fas.fa-sms
button#go-up(title=_p("rightside.back_to_top"))
button#go-up(type="button" title=_p("rightside.back_to_top"))
i.fas.fa-arrow-up

View File

@@ -25,7 +25,7 @@
.length_num= site.categories.length
.card-info-bookmark.is-center
button#bookmark-it.button--animated(title= _p('aside.card_bookmark'))
button#bookmark-it.button--animated(type="button" title= _p('aside.card_bookmark'))
i.fas.fa-bookmark
span= _p('aside.card_bookmark') || 'Follow Me'