Add solitude

This commit is contained in:
IF-chan
2024-07-05 21:01:19 +08:00
parent 26d71c4fbc
commit 71758b9fce
289 changed files with 23277 additions and 0 deletions
@@ -0,0 +1,61 @@
- const { server, site, option } = theme.artalk
- const { lazyload ,use} = theme.comment
script.
(() => {
let artalkItem = null
const initArtalk = () => {
artalkItem = Artalk.init({
el: '#artalk-wrap',
server: '!{server}',
site: "!{site}",
pageKey: location.pathname,
darkMode: document.documentElement.getAttribute('data-theme') === 'dark'
}, !{JSON.stringify(option)})
if (GLOBAL_CONFIG.lightbox === 'null') return
artalkItem.on('list-loaded', () => {
const array = []
artalkItem.ctx.get('list').getCommentNodes().forEach(comment => {
array.push({
nick: comment.data.nick,
content: comment.data.content_marked,
mailMd5: comment.data.email_encrypted,
})
const $content = comment.getRender().$content
GLOBAL_CONFIG.lightbox && utils.lightbox($content.querySelectorAll('img:not([atk-emoticon])'))
})
sco.owoBig({body: '.atk-grp', item: '.atk-item'})
!{commentBarrage} && barrageArtalk(array)
})
const destroyArtalk = () => artalkItem.destroy()
utils.addGlobalFn('pjax', destroyArtalk, 'destroyArtalk')
}
const loadArtalk = async () => {
if (typeof Artalk === 'object') initArtalk()
else {
await utils.getCSS('!{theme.cdn.artalk_css}')
await utils.getScript('!{theme.cdn.artalk_js}').then(initArtalk)
}
}
const artalkChangeMode = theme => {
const artalkWrap = document.getElementById('artalk-wrap')
if (!(artalkWrap && artalkWrap.children.length)) return
const isDark = theme === 'dark'
artalkItem.setDarkMode(isDark)
}
utils.addGlobalFn('themeChange', artalkChangeMode, 'artalk')
if ('!{use[0]}' === 'Artalk' || !{lazyload}) {
if (!{lazyload}) utils.loadComment(document.getElementById('artalk-wrap'), loadArtalk)
else loadArtalk()
} else {
window.loadTwoComment = loadArtalk
}
})()
if commentBarrage
script.
async function barrageArtalk(array) {
const init = () => initializeCommentBarrage(array)
if (typeof initializeCommentBarrage === "undefined") await utils.getScript('!{url_for(theme.cdn.commentBarrage)}').then(init)
else init()
}
@@ -0,0 +1,44 @@
- const {use,count} = theme.comment
#post-comment
.comment-head
.comment-headline
i.solitude.st-chat-fill
span=' ' + _p('comment.title')
if count && is_post()
span.count
= ' ('
each name in use
case name
when "Twikoo"
span.twikoo-count
i.solitude.st-loading-line
when "Waline"
span.waline-comment-count
i.solitude.st-loading-line
when "Valine"
span.valine-comment-count(data-xid=url_for(page.path) itemprop="commentCount")
i.solitude.st-loading-line
when "Artalk"
span.artalk-count
| )
if use.length > 1
.comment-switch
span.first=use[0]
span#switch-btn
span.second=use[1]
.comment-wrap
each name in use
case name
when 'Valine'
#vcomment.vcomment
when 'Twikoo'
#twikoo-wrap
when 'Waline'
#waline-wrap
when 'Artalk'
#artalk-wrap
when 'Giscus'
#giscus-wrap
@@ -0,0 +1,60 @@
- const { repo, repo_id, category_id, theme:themes, option } = theme.giscus
- const giscusUrl = theme.cdn.giscus || 'https://giscus.app/client.js'
- const giscusOriginUrl = new URL(giscusUrl).origin
- const { use, lazyload } = theme.comment
script.
(()=>{
const getGiscusTheme = theme => {
return theme === 'dark' ? '!{themes.dark}' : '!{themes.light}'
}
const loadGiscus = () => {
const config = Object.assign({
src: '!{giscusUrl}',
'data-repo': '!{repo}',
'data-repo-id': '!{repo_id}',
'data-category-id': '!{category_id}',
'data-mapping': 'pathname',
'data-theme': getGiscusTheme(document.documentElement.getAttribute('data-theme')),
'data-reactions-enabled': '1',
crossorigin: 'anonymous',
async: true
},!{JSON.stringify(option)})
const ele = document.createElement('script')
for (let key in config) {
ele.setAttribute(key, config[key])
}
document.getElementById('giscus-wrap').appendChild(ele)
}
const changeGiscusTheme = theme => {
const sendMessage = message => {
const iframe = document.querySelector('iframe.giscus-frame')
if (!iframe) return
iframe.contentWindow.postMessage({ giscus: message }, '!{giscusOriginUrl}')
}
sendMessage({
setConfig: {
theme: getGiscusTheme(theme)
}
});
}
utils.addGlobalFn('themeChange', changeGiscusTheme, 'giscus')
if ('!{use[0]}' === 'Giscus' || !!{lazyload}) {
if (!{lazyload}) {
const giscusWrap = document.getElementById('giscus-wrap')
if (giscusWrap) {
utils.loadComment(giscusWrap, loadGiscus)
}
} else {
loadGiscus()
}
} else {
window.loadOtherComment = loadGiscus
}
})()
@@ -0,0 +1,14 @@
- const {use} = theme.comment
each name in use
case name
when 'Twikoo'
!=partial('includes/widgets/third-party/comments/twikoo', {}, {cache: true})
when 'Waline'
!=partial('includes/widgets/third-party/comments/waline', {}, {cache: true})
when 'Valine'
!=partial('includes/widgets/third-party/comments/valine', {}, {cache: true})
when 'Artalk'
!=partial('includes/widgets/third-party/comments/artalk', {}, {cache: true})
when 'Giscus'
!=partial('includes/widgets/third-party/comments/giscus', {}, {cache: true})
@@ -0,0 +1,80 @@
- const { envId, region, option ,accessToken } = theme.twikoo
- const { lazyload, count, use,commentBarrage } = theme.comment
script().
(() => {
const getCount = () => {
const ele = document.querySelectorAll('.twikoo-count')
if (!ele) return
twikoo.getCommentsCount({
envId: '!{envId}',
region: '!{region}',
urls: [window.location.pathname],
includeReply: false
}).then(res => {
ele.forEach(item => item.textContent = res[0].count)
}).catch(err => {
console.error(err)
})
}
const init = () => {
twikoo.init(Object.assign({
el: '#twikoo-wrap',
envId: '!{envId}',
region: '!{region}',
path: window.location.pathname,
onCommentLoaded: () => {
GLOBAL_CONFIG.lightbox && utils.lightbox(document.querySelectorAll('#twikoo .tk-content img:not(.tk-owo-emotion)'))
}
}, !{JSON.stringify(option)}))
!{count ? ' && getCount()' : ''}
sco.owoBig({
body: '.OwO-body',
item: '.OwO-items li'
})
barrageTwikoo()
}
const loadTwikoo = () => {
if (typeof twikoo === 'object') setTimeout(init,0)
else utils.getScript('!{url_for(theme.cdn.twikoo)}').then(init)
}
if ('!{use[0]}' === 'Twikoo' || !{lazyload}) {
if (!{lazyload}) utils.loadComment(document.getElementById('twikoo-wrap'), loadTwikoo)
else loadTwikoo()
} else {
window.loadTwoComment = loadTwikoo
}
})()
if commentBarrage
script.
async function barrageTwikoo() {
await fetch("!{envId}", {
method: "POST",
headers: {
"Content-Type": "application/json"
},
body: JSON.stringify({
event: "COMMENT_GET",
accessToken: "!{accessToken}",
url: window.location.pathname
})
}).then(async res => {
if (!res.ok) throw new Error("HTTP error! status: " + res.status)
const data = await res.json();
const init = () => {
initializeCommentBarrage((data.data).map(item => Object.assign({
content: item.comment,
nick: item.nick,
mailMd5: item.mailMd5,
id: item.id
})))
}
if (typeof initializeCommentBarrage === "undefined") await utils.getScript('!{url_for(theme.cdn.commentBarrage)}').then(init)
else init()
}).catch(error => console.error("An error occurred while fetching comments: ", error))
}
@@ -0,0 +1,72 @@
- const { lazyload, count, use,commentBarrage } = theme.comment
- const { appId, appKey, avatar, serverURLs, visitor, option } = theme.valine
- let emojiMaps = '""'
if site.data.valine
- emojiMaps = JSON.stringify(site.data.valine)
script.
(() => {
const initValine = () => {
const valine = new Valine({
el: '#vcomment',
appId: '#{appId}',
appKey: '#{appKey}',
avatar: '#{avatar}',
serverURLs: '#{serverURLs}',
emojiMaps: !{emojiMaps},
path: window.location.pathname,
visitor: #{visitor},
...!{JSON.stringify(option)}
})
GLOBAL_CONFIG.lightbox && utils.lightbox(document.querySelectorAll('#comment .vcontent img:not(.vemoji)'))
sco.owoBig({body: '.vwrap', item: '.vemojis i'})
}
const loadValine = async () => {
if (typeof Valine === 'function') setTimeout(initValine, 0)
else {
await utils.getScript('!{url_for(theme.cdn.valine)}').then(initValine)
}
!{commentBarrage} && barrageValine()
}
if ('!{use[0]}' === 'Valine' || !{lazyload}) {
if (!{lazyload}) utils.loadComment(document.getElementById('vcomment'), loadValine)
else loadValine()
} else {
window.loadTwoComment = loadValine
}
})()
if commentBarrage
script.
async function barrageValine() {
const url = new URL('!{serverURLs}/1.1/classes/Comment')
const params = {
url: window.location.pathname,
order: '-createdAt'
}
Object.entries(params).forEach(([key, value]) => url.searchParams.append(key, value))
await fetch(url, {
method: "GET",
headers: {
"X-LC-Id": "#{appId}",
"X-LC-Key": "#{appKey}",
"Content-Type": "application/json"
},
}).then(async res => {
if (!res.ok) throw new Error(`HTTP error! status: ${res.status}`)
const data = await res.json()
const init = () =>
initializeCommentBarrage(data.results
.filter(item => item.url === window.location.pathname)
.map(item => ({
content: item.comment,
nick: item.nick,
mailMd5: md5(item.mail),
id: item.objectId
})))
if (typeof md5 === "undefined") await utils.getScript('!{url_for(theme.cdn.blueimp_md5)}')
if (typeof initializeCommentBarrage === "undefined") await utils.getScript('!{url_for(theme.cdn.commentBarrage)}').then(init)
else init()
}).catch(error => console.error("An error occurred while fetching comments: ", error))
}
@@ -0,0 +1,67 @@
- const { envId, option ,pageview } = theme.waline
- const { lazyload, count, commentBarrage,use } = theme.comment
script.
(() => {
let walineInitFunction = window.walineFn || null
function initWaline(initFn) {
const walineOptions = {
el: '#waline-wrap',
serverURL: '!{envId}',
pageview: !{pageview},
dark: 'html[data-theme="dark"]',
path: window.location.pathname,
comment: !{count},
...!{JSON.stringify(option)}
}
const walineInstance = initFn(walineOptions)
utils.addGlobalFn('pjax', () => walineInstance.destroy(), 'destroyWaline')
GLOBAL_CONFIG.lightbox && utils.lightbox(document.querySelectorAll('#comment .wl-content img:not(.wl-emoji)'))
sco.owoBig({
body: '.wl-emoji-popup',
item: '.wl-tab-wrapper button'
})
}
async function loadWaline() {
if (walineInitFunction) initWaline(walineInitFunction)
else {
await utils.getCSS('!{url_for(theme.cdn.waline_css)}')
const {init} = await import('!{url_for(theme.cdn.waline_js)}')
walineInitFunction = init || Waline.init
initWaline(walineInitFunction)
window.walineFn = walineInitFunction
}
!{commentBarrage} && barrageWaline()
}
if (!{use[0] === 'Waline'} || !{lazyload}) {
if (!{lazyload}) utils.loadComment(document.getElementById('waline-wrap'), loadWaline)
else loadWaline()
} else window.loadTwoComment = loadWaline
})()
if commentBarrage
script.
async function barrageWaline() {
const url = new URL('!{envId}/api/comment')
const params = {path: window.location.pathname, sortBy: 'insertedAt_asc'}
Object.entries(params).forEach(([key, value]) => url.searchParams.append(key, value))
await fetch(url).then(async res => {
if (!res.ok) throw new Error(`HTTP error! status: ${res.status}`)
const data = await res.json();
const regex = /<img [^>]*class="wl-emoji"[^>]*>/;
const init = () => {
initializeCommentBarrage(data.data.data
.map(item => ({
nick: item.nick,
mailId: item.avatar,
content: item.comment.replace(regex, ''),
id: item.objectId
})))
}
if (typeof initializeCommentBarrage === "undefined") await utils.getScript('!{url_for(theme.cdn.commentBarrage)}').then(init)
else init()
}).catch(error => console.error("An error occurred while fetching comments: ", error))
}
@@ -0,0 +1,3 @@
div.needEndHide#nav-music(onclick="sco.musicToggle()")
div#nav-music-hoverTips=__('music.hit')
meting-js(id=theme.capsule.id, server=theme.capsule.server, type="playlist", mutex="true", preload="none", data-lrctype="0", order="random", theme="var(--efu-main)")
@@ -0,0 +1,92 @@
- const { server, site, option } = theme.artalk
- const avatarCdn = theme.comment.avatar
script(pjax).
(() => {
const changeContent = content => {
if (content === '') return content;
const replacements = [
{
regex: /<img.*?src="(.*?)"?[^\>]+>/ig,
replacement: '[!{_p("console.newest_comment.image")}]'
},
{
regex: /<a[^>]+?href=["']?([^"']+)["']?[^>]*>([^<]+)<\/a>/gi,
replacement: '[!{_p("console.newest_comment.link")}]'
},
{
regex: /<pre><code>.*?<\/pre>/gi,
replacement: '[!{_p("console.newest_comment.code")}]'
},
{
regex: /<[^>]+>/g,
replacement: ''
}
];
content = replacements.reduce((str, {regex, replacement}) => str.replace(regex, replacement), content);
return content.length > 150 ? content.substring(0, 100) + '...' : content;
};
const generateHtml = (array, asideList) => {
asideList.innerHTML = array.length ? array.map(item => `
<div class='aside-list-item'>
<div class='thumbnail'>
<img src='${item.avatar}' alt='${item.nick}'>
</div>
<div class='content'>
<div class='comment' onclick='pjax.loadUrl("${item.url}")'>${item.content}</div>
<time class="datetime" datetime="${item.date}"></time>
</div>
</div>
`).join('') : "!{_p('newest_comment.zero')}";
window.lazyLoadInstance?.update();
window.pjax?.refresh();
sco?.changeTimeFormat(document.querySelectorAll('.aside-list-item time'));
};
const getSetting = async () => {
try {
const res = await fetch('!{server}/api/v2/conf', {method: 'GET'});
return await res.json();
} catch (e) {
console.error(e);
return null;
}
};
const getComment = async (asideList) => {
const searchParams = new URLSearchParams({'site_name': "!{site}", 'limit': '6'});
await fetch(`!{server}/api/v2/stats/latest_comments?${searchParams}`, {method: 'GET'}).then(async res => {
const result = await res.json();
const avatarConfig = await getSetting();
const avatarCdn = '!{avatarCdn}' + '/avatar/';
const params = avatarConfig?.gravatar?.params || '';
const artalk = result.data.map(e => ({
avatar: avatarCdn + e.email_encrypted + '?' + params,
content: changeContent(e.content_marked),
nick: e.nick,
url: e.page_key + `#atk-comment-${e.id}`,
date: e.date,
})).slice(0, !{limit});
utils.saveToLocal.set('artalk-newest-comments', artalk, !{theme.comment.newest_comment.storage});
generateHtml(artalk, asideList);
}).catch(error => {
console.error(error);
asideList.textContent = "!{_p('newest_comment.error')}";
});
};
const newestCommentInit = (asideList) => {
if (!asideList) return;
const data = utils.saveToLocal.get('artalk-newest-comments');
if (data) {
generateHtml(data, asideList);
} else {
getComment(asideList);
}
};
const $asideList = document.querySelector('.card-recent-comment .aside-list');
window.addEventListener('DOMContentLoaded', () => newestCommentInit($asideList), false)
window.addEventListener('pjax:complete', () => newestCommentInit(document.querySelector('.card-recent-comment .aside-list')), false);
})();
@@ -0,0 +1,11 @@
- var limit = theme.aside.newest_comment.limit ? theme.aside.newest_comment.limit : 5
if theme.comment.use
case theme.comment.use[0]
when 'Twikoo'
!=partial('includes/widgets/third-party/news-comment/twikoo', {limit}, {cache: true})
when 'Waline'
!=partial('includes/widgets/third-party/news-comment/waline', {limit}, {cache: true})
when 'Valine'
!=partial('includes/widgets/third-party/news-comment/valine', {limit}, {cache: true})
when 'Artalk'
!=partial('includes/widgets/third-party/news-comment/artalk', {limit}, {cache: true})
@@ -0,0 +1,69 @@
script.
(() => {
const changeContent = (content) => {
if (!content) return '';
const replacements = [
{regex: /<img.*?src="(.*?)"?[^\>]+>/ig, replacement: '[!{_p("console.newest_comment.image")}]'},
{
regex: /<a[^>]+?href=["']?([^"']+)["']?[^>]*>([^<]+)<\/a>/gi,
replacement: '[!{_p("console.newest_comment.link")}]'
},
{regex: /<pre><code>.*?<\/pre>/gi, replacement: '[!{_p("console.newest_comment.code")}]'},
{regex: /<[^>]+>/g, replacement: ''}
]
content = replacements.reduce((str, {regex, replacement}) => str.replace(regex, replacement), content)
return content.length > 150 ? `${content.substring(0, 100)}...` : content
}
const generateHtml = (array) => {
const html = array.map(item => `
<div class='aside-list-item'>
<div class='thumbnail'>
<img src='${item.avatar}' alt='${item.nick}'>
</div>
<div class='content'>
<div class='comment' onclick='pjax.loadUrl("${item.url}")'>${item.content}</div>
<time class="datetime" datetime="${item.date}"></time>
</div>
</div>
`).join('')
document.querySelector('.card-recent-comment .aside-list').innerHTML = array.length ? html : "!{_p('newest_comment.zero')}"
window.lazyLoadInstance?.update()
window.pjax?.refresh()
sco?.changeTimeFormat(document.querySelectorAll('.aside-list-item time'))
}
const getComment = async () => {
const runTwikoo = () => {
twikoo.getRecentComments({
envId: '!{theme.twikoo.envId}',
region: '',
pageSize: !{limit},
includeReply: true
}).then(res => {
const twikooArray = res.map(e => ({
content: changeContent(e.comment),
avatar: e.avatar,
nick: e.nick,
url: `${e.url}#${e.id}`,
date: new Date(e.created).toString()
})).slice(0, 6)
utils.saveToLocal.set('twikoo-newest-comment', twikooArray, !{theme.comment.newest_comment.storage})
generateHtml(twikooArray)
}).catch((err) => {
console.error(err);
document.querySelector('.card-recent-comment .aside-list').textContent = "!{_p('newest_comment.error')}"
})
}
if (typeof twikoo === 'object') {
runTwikoo()
} else {
utils.getScript('!{url_for(theme.cdn.twikoo)}').then(runTwikoo)
}
}
const newestCommentInit = () => {
if (!document.querySelector('.card-recent-comment')) return
const data = utils.saveToLocal.get('twikoo-newest-comment')
data ? generateHtml(data) : getComment()
}
window.addEventListener('DOMContentLoaded', newestCommentInit, false)
window.addEventListener('pjax:complete', newestCommentInit, false);
})()
@@ -0,0 +1,85 @@
script.
(() => {
const emojiReg = /:[a-z0-9_\u4e00-\u9fa5]+:/g
const changeContent = (content) => {
if (content === '') return content;
const replacements = [
{regex: /<img.*?src="(.*?)"?[^\>]+>/ig, replacement: '[!{_p("console.newest_comment.image")}]'},
{
regex: /<a[^>]+?href=["']?([^"']+)["']?[^>]*>([^<]+)<\/a>/gi,
replacement: '[!{_p("console.newest_comment.link")}]'
},
{regex: /```[\s\S]*?```/g, replacement: '[!{_p("console.newest_comment.code")}]'},
{regex: /<[^>]+>/g, replacement: ""}
];
content = replacements.reduce((str, {regex, replacement}) => str.replace(regex, replacement), content);
return content.length > 150 ? content.substring(0, 100) + '...' : content;
}
const $asideList = document.querySelector('.card-recent-comment .aside-list')
const newestCommentInit = () => {
if (!document.querySelector('.card-recent-comment')) return
const data = utils.saveToLocal.get('valine-newest-comment')
if (data) {
generateHtml(data)
} else {
getComment()
}
}
const getComment = async () => {
const settings = {
"method": "GET",
"headers": {
"X-LC-Id": '!{theme.valine.appId}',
"X-LC-Key": '!{theme.valine.appKey}',
"Content-Type": "application/json"
},
}
if (typeof md5 === "undefined") await utils.getScript('!{url_for(theme.cdn.blueimp_md5)}')
await fetch('!{theme.valine.serverURLs}/1.1/classes/Comment?limit=8&order=-createdAt', settings).then(res => res.json())
.then(async result => {
let ls = []
for (const i of result.results.slice(0, !{limit})) {
if (emojiReg.test(i.comment)) continue
ls.push({
content: changeContent(i.comment),
avatar: '!{theme.comment.avatar}' + '/avatar/' + md5(i.mail.toLowerCase()),
nick: i.nick,
url: i.url,
date: i.updatedAt || i.createdAt
})
}
utils.saveToLocal.set('valine-newest-comment', ls, !{theme.comment.newest_comment.storage})
generateHtml(ls)
}).catch(error => {
console.error(error);
$asideList.textContent = "!{_p('newest_comment.error')}"
})
}
const generateHtml = array => {
const $dom = document.querySelector('.card-recent-comment .aside-list')
$dom.innerHTML = array.length ? array.map(item => `
<div class='aside-list-item'>
<div onclick='pjax.loadUrl(\"${item.url}\")' class='thumbnail'>
<img src='${item.avatar}' alt='${item.nick}'>
<div class='name'><span>${item.nick}</span></div>
</div>
<div class='content'>
<div class='comment' onclick='pjax.loadUrl("${item.url}")'>${item.content}</div>
<time class="datetime" datetime="${item.date}"></time>
</div>
</div>
`).join('') : "!{_p('newest_comment.zero')}"
window.lazyLoadInstance?.update()
window.pjax?.refresh()
sco?.changeTimeFormat(document.querySelectorAll('.aside-list-item time'))
}
window.addEventListener('DOMContentLoaded', newestCommentInit, false)
window.addEventListener('pjax:complete', newestCommentInit, false);
})()
@@ -0,0 +1,73 @@
script.
(() => {
const changeContent = (content) => {
if (content === '') return content;
const replacements = [
{regex: /<img.*?src="(.*?)"?[^\>]+>/ig, replacement: '[!{_p("console.newest_comment.image")}]'},
{
regex: /<a[^>]+?href=["']?([^"']+)["']?[^>]*>([^<]+)<\/a>/gi,
replacement: '[!{_p("console.newest_comment.link")}]'
},
{regex: /<pre><code>.*?<\/pre>/gi, replacement: '[!{_p("console.newest_comment.code")}]'},
{regex: /<[^>]+>/g, replacement: ""}
];
content = replacements.reduce((str, {regex, replacement}) => str.replace(regex, replacement), content);
return content.length > 150 ? content.substring(0, 100) + '...' : content;
}
const $asideList = document.querySelector('.card-recent-comment .aside-list')
const newestCommentInit = () => {
if (!document.querySelector('.card-recent-comment')) return
const data = utils.saveToLocal.get('waline-newest-comment')
if (data) {
generateHtml(data)
} else {
getComment()
}
}
const getComment = async () => {
await fetch('!{theme.waline.envId}/api/comment?type=recent&count=!{limit}', {method: 'GET'}).then(async res => {
const result = await res.json()
const walineArray = result.data.map(e => {
return {
'content': changeContent(e.comment),
'avatar': e.avatar,
'nick': e.nick,
'url': e.url + '#' + e.objectId,
'date': new Date(e.time || e.insertedAt)
}
})
utils.saveToLocal.set('waline-newest-comment', walineArray, !{theme.comment.newest_comment.storage})
generateHtml(walineArray)
}).catch(error => {
console.error(error)
$asideList.textContent = "!{_p('newest_comment.error')}"
})
}
const generateHtml = array => {
const $dom = document.querySelector('.card-recent-comment .aside-list')
$dom.innerHTML = array.length ? array.map(item => `
<div class='aside-list-item'>
<div onclick='pjax.loadUrl("${item.url}")' class='thumbnail'>
<img src='${item.avatar}' alt='${item.nick}'>
<div class='name'><span>${item.nick}</span></div>
</div>
<div class='content'>
<div class='comment' onclick='pjax.loadUrl("${item.url}")'>${item.content}</div>
<time class="datetime" datetime="${item.date}"></time>
</div>
</div>
`).join('') : "!{_p('newest_comment.zero')}"
window.lazyLoadInstance?.update()
window.pjax?.refresh()
sco?.changeTimeFormat(document.querySelectorAll('.aside-list-item time'))
}
window.addEventListener('DOMContentLoaded', newestCommentInit, false)
window.addEventListener('pjax:complete', newestCommentInit, false);
})()
@@ -0,0 +1,39 @@
- const google_adsense = theme.google_adsense.enable
script.
const pjax = new Pjax({
elements: 'a:not([target="_blank"])',
selectors: ['title','#body-wrap','#site-config','meta[name="description"]','.js-pjax','meta[property^="og:"]','#config-diff'],
cacheBust: false,
analytics: !{google_adsense},
scrollRestoration: false
})
document.querySelectorAll('script[data-pjax]').forEach(item => {
const newScript = document.createElement('script')
const content = item.text || item.textContent || item.innerHTML || ""
Array.from(item.attributes).forEach(attr => newScript.setAttribute(attr.name, attr.value))
newScript.appendChild(document.createTextNode(content))
item.parentNode.replaceChild(newScript, item)
})
document.addEventListener('pjax:complete', () => {
window.refreshFn()
document.querySelectorAll('script[data-pjax]').forEach(item => {
const newScript = document.createElement('script')
const content = item.text || item.textContent || item.innerHTML || ""
Array.from(item.attributes).forEach(attr => newScript.setAttribute(attr.name, attr.value))
newScript.appendChild(document.createTextNode(content))
item.parentNode.replaceChild(newScript, item)
})
GLOBAL_CONFIG.islazyload && window.lazyLoadInstance.update()
})
document.addEventListener('pjax:error', (e) => {
if (e.request.status === 404) {
pjax.loadUrl('/404.html')
}
})
@@ -0,0 +1,20 @@
#algolia-search
.search-dialog
.algolia-navbar
.search-dialog__title#algolia-search-title=__('nav.search')
.algolia-tips
i.solitude.st-algolia-fill
span.algolia-tips-text='Algolia'
span.search-close-button
i.solitude.st-close-fill
#algolia-input-panel
#algolia-search-input
#search-results
#algolia-hits
each tag in theme.search.tags || []
a.tag-list(href='javascript:void(0);' onclick="pjax.loadUrl('" + url_for('/tags/' + tag) + "/')")=tag
#algolia-tips
#algolia-pagination
#algolia-stats
#search-mask
@@ -0,0 +1,8 @@
if theme.search.enable
case theme.search.type
when 'algolia'
include algolia-search
script(src=url_for(theme.cdn.algolia_js))
when 'local'
include local-search
script(src=url_for(theme.cdn.local_search))
@@ -0,0 +1,16 @@
#local-search
div.search-dialog
nav.search-nav
span.search-dialog-title=__('nav.search')
button.search-close-button
i.solitude.st-close-fill
div.search-wrap
div.search-box
input.search-box-input#search-input(type="text", autocomplete="off", spellcheck="false", autocorrect="off", autocapitalize="off", placeholder=__('search.placeholder'))
div#search-results
#search-hits
each tag in theme.search.tags || []
a.tag-list(href='javascript:void(0);' onclick="pjax.loadUrl('" + url_for('/tags/' + tag) + "/')")=tag
div#search-pagination
div#search-tips
div#search-mask
@@ -0,0 +1,26 @@
- const {key,option,title} = theme.tianli_talk
span.needEndHide#efuTalk(onclick="togglePostChatContainer(); return false;" title=title)
i.solitude.st-robot-fill
span.efuTalkTitle=title
script.
var postChatConfig = {
backgroundColor: "var(--efu-main)",
bottom: "60px",
...!{JSON.stringify(option)}
};
let b = true;
document.getElementById('efuTalk').addEventListener('click', function () {
this.classList.toggle('on');
let efu = this
b && setTimeout(() => {
document.getElementById('close-button').addEventListener('click', function () {
efu.classList.remove('on');
})
}, 0);
b = false
});
script(pjax data-postChat_key=key src="https://ai.tianli0.top/static/public/postChatUser.min.js")