commit
1be1de39e5
|
@ -270,9 +270,6 @@ let halo = {
|
||||||
e.batchSend(t, !0);
|
e.batchSend(t, !0);
|
||||||
else {
|
else {
|
||||||
let n = [];
|
let n = [];
|
||||||
function a(e) {
|
|
||||||
return e = (e = (e = (e = (e = e.replace(/<\/*br>|[\s\uFEFF\xA0]+/g, "")).replace(/<img.*?>/g, "[图片]")).replace(/<a.*?>.*?<\/a>/g, "[链接]")).replace(/<pre.*?>.*?<\/pre>/g, "[代码块]")).replace(/<.*?>/g, "")
|
|
||||||
}
|
|
||||||
if(GLOBAL_CONFIG.source.comments.use == 'Twikoo'){
|
if(GLOBAL_CONFIG.source.comments.use == 'Twikoo'){
|
||||||
fetch(GLOBAL_CONFIG.source.twikoo.twikooUrl, {
|
fetch(GLOBAL_CONFIG.source.twikoo.twikooUrl, {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
|
@ -290,7 +287,7 @@ let halo = {
|
||||||
null == e.avatar && (e.avatar = "https://cravatar.cn/avatar/d615d5793929e8c7d70eab5f00f7f5f1?d=mp"),
|
null == e.avatar && (e.avatar = "https://cravatar.cn/avatar/d615d5793929e8c7d70eab5f00f7f5f1?d=mp"),
|
||||||
n.push({
|
n.push({
|
||||||
avatar: e.avatar,
|
avatar: e.avatar,
|
||||||
content: e.nick + ":" + a(e.comment),
|
content: e.nick + ":" + btf.changeContent(e.comment),
|
||||||
href: e.url + '#' + e.id
|
href: e.url + '#' + e.id
|
||||||
|
|
||||||
})
|
})
|
||||||
|
@ -319,7 +316,7 @@ let halo = {
|
||||||
t.forEach((e=>{
|
t.forEach((e=>{
|
||||||
n.push({
|
n.push({
|
||||||
avatar: 'https://cravatar.cn/avatar/' + e.email_encrypted + '?d=mp&s=240',
|
avatar: 'https://cravatar.cn/avatar/' + e.email_encrypted + '?d=mp&s=240',
|
||||||
content: e.nick + ":" + a(e.content_marked),
|
content: e.nick + ":" + btf.changeContent(e.content_marked),
|
||||||
href: e.page_url + '#atk-comment-' + e.id
|
href: e.page_url + '#atk-comment-' + e.id
|
||||||
|
|
||||||
})
|
})
|
||||||
|
@ -338,7 +335,7 @@ let halo = {
|
||||||
}).then(({ comments }) => {
|
}).then(({ comments }) => {
|
||||||
const walineArray = comments.map(e => {
|
const walineArray = comments.map(e => {
|
||||||
return {
|
return {
|
||||||
'content': e.nick + ":" + a(e.comment),
|
'content': e.nick + ":" + btf.changeContent(e.comment),
|
||||||
'avatar': e.avatar,
|
'avatar': e.avatar,
|
||||||
'href': e.url + '#' + e.objectId,
|
'href': e.url + '#' + e.objectId,
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,6 +22,12 @@ var heo = {
|
||||||
// 首页bb
|
// 首页bb
|
||||||
initIndexEssay: function() {
|
initIndexEssay: function() {
|
||||||
if (document.querySelector("#bber-talk"))
|
if (document.querySelector("#bber-talk"))
|
||||||
|
$(".swiper-wrapper .swiper-slide").each(function () {
|
||||||
|
var text = $(this)[0].innerText;
|
||||||
|
if (text != 'undefined') {
|
||||||
|
$(this).text(btf.changeContent(text));
|
||||||
|
}
|
||||||
|
})
|
||||||
new Swiper(".swiper-container",{
|
new Swiper(".swiper-container",{
|
||||||
direction: "vertical",
|
direction: "vertical",
|
||||||
loop: !0,
|
loop: !0,
|
||||||
|
|
|
@ -331,6 +331,23 @@ var btf = {
|
||||||
}
|
}
|
||||||
|
|
||||||
return actualTop
|
return actualTop
|
||||||
|
},
|
||||||
|
//过滤标签
|
||||||
|
changeContent: (content,length = null)=>{
|
||||||
|
if (content === '') return content
|
||||||
|
|
||||||
|
content = content.replace(/<img.*?src="(.*?)"?[^\>]+>/ig, '[图片]') // replace image link
|
||||||
|
content = content.replace(/<a[^>]+?href=["']?([^"']+)["']?[^>]*>([^<]+)<\/a>/gi, '[链接]') // replace url
|
||||||
|
content = content.replace(/<pre><code>.*?<\/pre>/gi, '[代码]') // replace code
|
||||||
|
content = content.replace(/<[^>]+>/g, "") // remove html tag
|
||||||
|
|
||||||
|
if (length!=null){
|
||||||
|
if (content.length > length) {
|
||||||
|
content = content.substring(0, length) + '...'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return content
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,19 +10,6 @@
|
||||||
<!-- 最近评论 -->
|
<!-- 最近评论 -->
|
||||||
<script>
|
<script>
|
||||||
window.addEventListener('load', () => {
|
window.addEventListener('load', () => {
|
||||||
const changeContent = (content) => {
|
|
||||||
if (content === '') return content
|
|
||||||
|
|
||||||
content = content.replace(/<img.*?src="(.*?)"?[^\>]+>/ig, '[图片]') // replace image link
|
|
||||||
content = content.replace(/<a[^>]+?href=["']?([^"']+)["']?[^>]*>([^<]+)<\/a>/gi, '[链接]') // replace url
|
|
||||||
content = content.replace(/<pre><code>.*?<\/pre>/gi, '[代码]') // replace code
|
|
||||||
content = content.replace(/<[^>]+>/g, "") // remove html tag
|
|
||||||
|
|
||||||
if (content.length > 150) {
|
|
||||||
content = content.substring(0, 150) + '...'
|
|
||||||
}
|
|
||||||
return content
|
|
||||||
}
|
|
||||||
const generateHtml = array => {
|
const generateHtml = array => {
|
||||||
let result = ''
|
let result = ''
|
||||||
|
|
||||||
|
@ -126,7 +113,7 @@
|
||||||
const artalk = d.data.map(function (e) {
|
const artalk = d.data.map(function (e) {
|
||||||
return {
|
return {
|
||||||
'avatar': 'https://cravatar.cn/avatar/' + e.email_encrypted + '?d=mp&s=240',
|
'avatar': 'https://cravatar.cn/avatar/' + e.email_encrypted + '?d=mp&s=240',
|
||||||
'content': changeContent(e.content_marked),
|
'content': btf.changeContent(e.content_marked,150),
|
||||||
'nick': e.nick,
|
'nick': e.nick,
|
||||||
'url': e.page_url + '#atk-comment-' + e.id,
|
'url': e.page_url + '#atk-comment-' + e.id,
|
||||||
'date': e.date,
|
'date': e.date,
|
||||||
|
|
|
@ -9,20 +9,6 @@ not #strings.isEmpty(theme.config.comments.twikoos.envId)}">
|
||||||
<!-- 最近评论 -->
|
<!-- 最近评论 -->
|
||||||
<script>
|
<script>
|
||||||
window.addEventListener('load', () => {
|
window.addEventListener('load', () => {
|
||||||
const changeContent = (content) => {
|
|
||||||
if (content === '') return content
|
|
||||||
|
|
||||||
content = content.replace(/<img.*?src="(.*?)"?[^\>]+>/ig, '[图片]') // replace image link
|
|
||||||
content = content.replace(/<a[^>]+?href=["']?([^"']+)["']?[^>]*>([^<]+)<\/a>/gi, '[链接]') // replace url
|
|
||||||
content = content.replace(/<pre><code>.*?<\/pre>/gi, '[代码]') // replace code
|
|
||||||
content = content.replace(/<[^>]+>/g, "") // remove html tag
|
|
||||||
|
|
||||||
if (content.length > 150) {
|
|
||||||
content = content.substring(0, 150) + '...'
|
|
||||||
}
|
|
||||||
return content
|
|
||||||
}
|
|
||||||
|
|
||||||
const getComment = () => {
|
const getComment = () => {
|
||||||
const runTwikoo = () => {
|
const runTwikoo = () => {
|
||||||
twikoo.getRecentComments({
|
twikoo.getRecentComments({
|
||||||
|
@ -33,7 +19,7 @@ not #strings.isEmpty(theme.config.comments.twikoos.envId)}">
|
||||||
}).then(function (res) {
|
}).then(function (res) {
|
||||||
const twikooArray = res.map(e => {
|
const twikooArray = res.map(e => {
|
||||||
return {
|
return {
|
||||||
'content': changeContent(e.comment),
|
'content': btf.changeContent(e.comment,150),
|
||||||
'avatar': e.avatar,
|
'avatar': e.avatar,
|
||||||
'nick': e.nick,
|
'nick': e.nick,
|
||||||
'url': e.url + '#' + e.id,
|
'url': e.url + '#' + e.id,
|
||||||
|
|
|
@ -8,20 +8,6 @@
|
||||||
</div>
|
</div>
|
||||||
<script>
|
<script>
|
||||||
window.addEventListener('load', () => {
|
window.addEventListener('load', () => {
|
||||||
const changeContent = (content) => {
|
|
||||||
if (content === '') return content
|
|
||||||
|
|
||||||
content = content.replace(/<img.*?src="(.*?)"?[^\>]+>/ig, '[图片]') // replace image link
|
|
||||||
content = content.replace(/<a[^>]+?href=["']?([^"']+)["']?[^>]*>([^<]+)<\/a>/gi, '[链接]') // replace url
|
|
||||||
content = content.replace(/<pre><code>.*?<\/pre>/gi, '[代码]') // replace code
|
|
||||||
content = content.replace(/<[^>]+>/g, "") // remove html tag
|
|
||||||
|
|
||||||
if (content.length > 150) {
|
|
||||||
content = content.substring(0, 150) + '...'
|
|
||||||
}
|
|
||||||
return content
|
|
||||||
}
|
|
||||||
|
|
||||||
const generateHtml = array => {
|
const generateHtml = array => {
|
||||||
let result = ''
|
let result = ''
|
||||||
|
|
||||||
|
@ -63,7 +49,7 @@
|
||||||
}).then(({ comments }) => {
|
}).then(({ comments }) => {
|
||||||
const walineArray = comments.map(e => {
|
const walineArray = comments.map(e => {
|
||||||
return {
|
return {
|
||||||
'content': changeContent(e.comment),
|
'content': btf.changeContent(e.comment,150),
|
||||||
'avatar': e.avatar,
|
'avatar': e.avatar,
|
||||||
'nick': e.nick,
|
'nick': e.nick,
|
||||||
'url': e.url + '#' + e.objectId,
|
'url': e.url + '#' + e.objectId,
|
||||||
|
|
|
@ -14,8 +14,6 @@
|
||||||
|
|
||||||
<script th:src="${assets_link + '/js/heo.js' + theme_version}"></script>
|
<script th:src="${assets_link + '/js/heo.js' + theme_version}"></script>
|
||||||
|
|
||||||
<script th:src="${assets_link + '/js/halo.js' + theme_version}"></script>
|
|
||||||
|
|
||||||
<link rel="stylesheet" th:href="${assets_link + '/zhheo/zhheoblog.css' + theme_version}">
|
<link rel="stylesheet" th:href="${assets_link + '/zhheo/zhheoblog.css' + theme_version}">
|
||||||
|
|
||||||
<link rel="stylesheet" th:href="${assets_link + '/zhheo/custom.css' + theme_version}">
|
<link rel="stylesheet" th:href="${assets_link + '/zhheo/custom.css' + theme_version}">
|
||||||
|
|
|
@ -56,6 +56,7 @@
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
<script th:src="${assets_link + '/js/utils.js' + theme_version}"></script>
|
<script th:src="${assets_link + '/js/utils.js' + theme_version}"></script>
|
||||||
|
<script th:src="${assets_link + '/js/halo.js' + theme_version}"></script>
|
||||||
<script th:src="${assets_link + '/js/main.js' + theme_version}"></script>
|
<script th:src="${assets_link + '/js/main.js' + theme_version}"></script>
|
||||||
<script charset="utf-8" data-pjax th:src="${assets_link + '/zhheo/blogex.js' + theme_version}"></script>
|
<script charset="utf-8" data-pjax th:src="${assets_link + '/zhheo/blogex.js' + theme_version}"></script>
|
||||||
<script th:src="${assets_link + '/js/tw_cn.js' + theme_version}"></script>
|
<script th:src="${assets_link + '/js/tw_cn.js' + theme_version}"></script>
|
||||||
|
|
Loading…
Reference in New Issue