Merge pull request #289 from chengzhongxue/main

评论代码优化,友联模板优化
This commit is contained in:
困困鱼 2023-07-15 02:41:17 +08:00 committed by GitHub
commit 85c647c640
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
13 changed files with 251 additions and 223 deletions

View File

@ -1080,6 +1080,15 @@ spec:
value: "https://moments.0206.ink/randomfriend"
label: 随机访问地址
help: 注意格式 (你的鱼塘token地址 + randomfriend)
- $formkit: url
name: fcircleUrl
value: "/fcircle"
label: 鱼塘链接
- $formkit: url
name: linksUrl
value: "/links"
label: 友链链接
- group: fcircle
label: 友链鱼塘

View File

@ -136,23 +136,11 @@
</div>
</div>
<hr>
<!-- 评论模块 -->
<!--/* 评论组件 */-->
<th:block
th:if="${theme.config.comments.twikooEnable && #strings.equals(theme.config.comments.use, 'Twikoo') && not #strings.isEmpty(theme.config.comments.twikoos.envId)}">
<div th:replace="~{modules/twikoo :: twikoo}"></div>
</th:block>
<div id="post-comment"
th:if="${pluginFinder.available('PluginCommentWidget') && #strings.equals(theme.config.comments.use, 'commentWidget')}">
<div class="comment-head">
<div class="comment-headline"><i class="iconfont icon-comment-alt"></i> <span>评论</span></div>
<div class="comment-privacy"><a href="/privacy">隐私政策</a></div>
<div class="comment-tips" id="comment-tips">
<span>你无需删除空行,直接评论以获取最佳展示效果</span>
</div>
</div>
<halo:comment group="content.halo.run" kind="SinglePage"
th:attr="name=${singlePage.metadata.name}" colorScheme="document.documentElement.getAttribute('data-theme')" />
</div>
th:replace="~{modules/comment :: comment(group = 'content.halo.run',
kind = 'SinglePage',
name = ${singlePage.metadata.name})}"/>
</div>

View File

@ -36,7 +36,9 @@
href="javascript:fetchRandomPost();"><i
class="haofont hao-icon-arrow-rotate-right"></i></a>
</div>
<div class="title-h2-a-right"><a class="random-post-all" href="/links">全部友链</a></div>
<div th:if="${not #strings.isEmpty(theme.config.link.linksUrl)}" class="title-h2-a-right">
<a class="random-post-all" th:href="${theme.config.link.linksUrl}">全部友链</a>
</div>
</div>
<div id="random-post"></div>
<script type="text/javascript">

View File

@ -11,165 +11,14 @@
</header>
<main class="layout hide-aside" id="content-inner">
<div id="page">
<div class="flink" id="banners">
<div class="banners-title">
<div class="banners-title-small">[[${theme.config.link.smallTitle}]]</div>
<div class="banners-title-big">[[${theme.config.link.bigTitle}]]</div>
</div>
<div class="banner-button-group">
<a class="banner-button secondary" data-pjax-state="" onclick="travelling()">
<i class="haofont hao-icon-paper-plane1"></i>
<span class="banner-button-text">随机访问</span>
</a>
<a class="banner-button" href="#post-comment" rel="external nofollow">
<i class="iconfont icon-link"></i>
<span class="banner-button-text">申请友链</span>
</a>
</div>
<div class="tags-group-all nowrapMove">
<div class="tags-group-wrapper">
<th:block th:each="group : ${groups}">
<th:block th:each="link,iterStat : ${group.links}" th:if="${group.links.size > 2}">
<div class="tags-group-icon-pair" th:if="${iterStat.even}">
<a class="tags-group-icon" target="_blank"
th:href="${linkOdd.spec.url}"
th:title="${linkOdd.spec.displayName}"
th:with="linkOdd = ${group.links.get(iterStat.index - 1)}">
<img th:src="@{${linkOdd.spec.logo}}"
th:title="${linkOdd.spec.displayName}">
</a>
<a class="tags-group-icon" target="_blank"
th:href="${linkEven.spec.url}"
th:title="${linkEven.spec.displayName}"
th:with="linkEven = ${link}">
<img th:src="@{${linkEven.spec.logo}}"
th:title="${linkEven.spec.displayName}">
</a>
</div>
</th:block>
</th:block>
</div>
</div>
</div>
<!--钓鱼-->
<th:block th:if="${not #lists.isEmpty(groups) && theme.config.fcircle.linksRandomFriendsEnable}" >
<div class="title-h2-a">
<div class="title-h2-a-left">
<h2 style="padding-top:0;margin:.6rem 0 .6rem">🎣 钓鱼</h2><a class="random-post-start"
href="javascript:fetchRandomPost();"><i class="haofont hao-icon-arrow-rotate-right"></i></a>
</div>
<div class="title-h2-a-right"><a class="random-post-all" href="/fcircle" data-pjax-state="">查看鱼塘</a></div>
</div>
<div id="random-post"></div>
<script type="text/javascript">
var fdataUser = {
apiurl: [[${theme.config.fcircle.apiurl}]],
defaultFish: 500,
hungryFish: 500,
}
</script>
<script th:src="${assets_link + '/libs/moments/random-friends-post.js'}"></script>
</th:block>
<div class="flink" id="article-container">
<th:block th:each="group,iterStat : ${groups}">
<h2 th:if="${not #lists.isEmpty(group.spec.displayName)}">
<a class="headerlink" th:href="'#'+${group.spec.displayName}+'-'+${group.links.size}" th:title="${group.spec.displayName}+ '('+${group.links.size}+')'"></a>
[[${group.spec.displayName}]] ([[${group.links.size}]])
</h2>
<div class="flink-desc">[[${group.spec.description}]]</div>
<!-- 第一个,使用卡片展示 -->
<div th:if="${#strings.equals(group.spec.displayStyle,'beautify') && not #lists.isEmpty(group.spec.displayStyle)}" class="site-card-group" >
<div class="site-card" th:each="link : ${group.links}">
<span th:if="${not #lists.isEmpty(link.spec.label)}" th:style="'background-color:' + ${link.spec.labelColor}" class="site-card-tag">[[${link.spec.label}]]</span>
<a class="img" target="_blank" th:href="${link.spec.url}"
th:title="${link.spec.displayName}">
<img class="flink-avatar" style="pointer-events: none;"
th:alt="${link.spec.displayName}" th:src="@{${#strings.isEmpty(link.spec.siteshot) ? link.spec.logo : link.spec.siteshot}}">
</a>
<a class="info cf-friends-link" target="_blank" th:href="${link.spec.url}"
th:title="${link.spec.displayName}">
<div class="site-card-avatar">
<img class="flink-avatar cf-friends-avatar"
th:alt="${link.spec.displayName}" th:src="${link.spec.logo}">
</div>
<div class="site-card-text">
<span class="title cf-friends-name" th:text="${link.spec.displayName}"></span>
<span class="desc" th:text="${link.spec.description}"
th:title="${link.spec.description}"></span>
</div>
</a>
</div>
</div>
<div class="flink-list" th:if="${#strings.equals(group.spec.displayStyle,'default') && not #lists.isEmpty(group.spec.displayStyle)}">
<div class="flink-list-item" th:each="link : ${group.links}">
<span th:if="${not #lists.isEmpty(link.spec.label)}" th:style="'background-color:' + ${link.spec.labelColor}" class="site-card-tag">[[${link.spec.label}]]</span>
<a class="cf-friends-link" rel="external nofollow"
target="_blank"
th:href="${link.spec.url}"
th:title="${link.spec.displayName}">
<img class="flink-avatar cf-friends-avatar"
th:alt="${link.spec.displayName}"
th:src="${link.spec.logo}">
<div class="flink-item-info">
<span class="flink-item-name cf-friends-name"
th:text="${link.spec.displayName}"></span>
<span class="flink-item-desc" th:text="${link.spec.description}"
th:title="${link.spec.description}"></span>
<img th:src="${link.spec.logo}"
class="entered loaded">
</div>
</a>
</div>
</div>
<div class="flink-list mini" th:if="${#strings.equals(group.spec.displayStyle,'deprecated') && not #lists.isEmpty(group.spec.displayStyle)}">
<div class="flink-list-item" th:each="link : ${group.links}">
<a class="cf-friends-link" rel="external nofollow"
target="_blank"
th:href="${link.spec.url}"
th:title="${link.spec.displayName}">
<img class="flink-avatar cf-friends-avatar entered loaded"
th:src="${link.spec.logo}"
th:alt="${link.spec.displayName}">
<div class="img-alt is-center">[[${link.spec.displayName}]]</div>
<div class="flink-item-info">
<span class="flink-item-name cf-friends-name">[[${link.spec.displayName}]]</span>
<span class="flink-item-desc" th:title="${link.spec.description}">[[${link.spec.description}]]</span>
</div>
</a>
</div>
</div>
</th:block>
</div>
<th:block th:replace="~{macro/content-links :: content-links(${htmlType})}" />
<hr/>
<!-- 评论模块 -->
<th:block th:if="${theme.config.comments.twikooEnable && #strings.equals(theme.config.comments.use, 'Twikoo') && not #strings.isEmpty(theme.config.comments.twikoos.envId)}">
<div th:replace="~{modules/twikoo :: twikoo}"></div>
</th:block>
<div id="post-comment" th:if="${pluginFinder.available('PluginCommentWidget') && #strings.equals(theme.config.comments.use, 'commentWidget')}">
<div class="comment-head">
<div class="comment-headline"><i class="iconfont icon-comment-alt"></i> <span>评论</span></div>
<div class="comment-privacy"><a href="/privacy">隐私政策</a></div>
<div class="comment-tips" id="comment-tips">
<span>你无需删除空行,直接评论以获取最佳展示效果</span>
</div>
</div>
<halo:comment group="content.halo.run" kind="SinglePage" th:attr="name='links'" colorScheme="document.documentElement.getAttribute('data-theme')" />
</div>
<!--/* 评论组件 */-->
<th:block
th:replace="~{modules/comment :: comment(group = 'content.halo.run',
kind = 'SinglePage',
name = 'links')}"/>
</div>
</main>

View File

@ -0,0 +1,151 @@
<th:block th:fragment="content-links(htmlType)">
<th:block th:with="groups = ${linkFinder.groupBy()}">
<div class="flink" id="banners">
<div class="banners-title">
<div class="banners-title-small">[[${theme.config.link.smallTitle}]]</div>
<div class="banners-title-big">[[${theme.config.link.bigTitle}]]</div>
</div>
<div class="banner-button-group">
<a class="banner-button secondary" data-pjax-state="" onclick="travelling()">
<i class="haofont hao-icon-paper-plane1"></i>
<span class="banner-button-text">随机访问</span>
</a>
<a class="banner-button" href="#post-comment" rel="external nofollow">
<i class="iconfont icon-link"></i>
<span class="banner-button-text">申请友链</span>
</a>
</div>
<div class="tags-group-all nowrapMove">
<div class="tags-group-wrapper">
<th:block th:each="group : ${groups}">
<th:block th:each="link,iterStat : ${group.links}" th:if="${group.links.size > 2}">
<div class="tags-group-icon-pair" th:if="${iterStat.even}">
<a class="tags-group-icon" target="_blank" th:href="${linkOdd.spec.url}"
th:title="${linkOdd.spec.displayName}"
th:with="linkOdd = ${group.links.get(iterStat.index - 1)}">
<img th:src="@{${linkOdd.spec.logo}}" th:title="${linkOdd.spec.displayName}">
</a>
<a class="tags-group-icon" target="_blank" th:href="${linkEven.spec.url}"
th:title="${linkEven.spec.displayName}" th:with="linkEven = ${link}">
<img th:src="@{${linkEven.spec.logo}}" th:title="${linkEven.spec.displayName}">
</a>
</div>
</th:block>
</th:block>
</div>
</div>
</div>
<!--钓鱼-->
<th:block th:if="${not #lists.isEmpty(groups) && theme.config.fcircle.linksRandomFriendsEnable}">
<div class="title-h2-a">
<div class="title-h2-a-left">
<h2 style="padding-top:0;margin:.6rem 0 .6rem">🎣 钓鱼</h2>
<a class="random-post-start" href="javascript:fetchRandomPost();">
<i class="haofont hao-icon-arrow-rotate-right"></i>
</a>
</div>
<div th:if="${not #strings.isEmpty(theme.config.link.fcircleUrl)}" class="title-h2-a-right">
<a class="random-post-all" th:href="${theme.config.link.fcircleUrl}" data-pjax-state="">查看鱼塘</a>
</div>
</div>
<div id="random-post"></div>
<script type="text/javascript">
var fdataUser = {
apiurl: [[${ theme.config.fcircle.apiurl }]],
defaultFish: 500,
hungryFish: 500,
}
</script>
<script th:src="${assets_link + '/libs/moments/random-friends-post.js'}"></script>
</th:block>
<div class="flink" id="article-container">
<th:block th:each="group,iterStat : ${groups}">
<h2 th:if="${not #lists.isEmpty(group.spec.displayName)}">
<a class="headerlink" th:href="'#'+${group.spec.displayName}+'-'+${group.links.size}"
th:title="${group.spec.displayName}+ '('+${group.links.size}+')'"></a>
[[${group.spec.displayName}]] ([[${group.links.size}]])
</h2>
<div class="flink-desc">[[${group.spec.description}]]</div>
<!-- 第一个,使用卡片展示 -->
<div th:if="${#strings.equals(group.spec.displayStyle,'beautify') && not #lists.isEmpty(group.spec.displayStyle)}"
class="site-card-group">
<div class="site-card" th:each="link : ${group.links}">
<span th:if="${not #lists.isEmpty(link.spec.label)}"
th:style="'background-color:' + ${link.spec.labelColor}"
class="site-card-tag">[[${link.spec.label}]]</span>
<a class="img" target="_blank" th:href="${link.spec.url}" th:title="${link.spec.displayName}">
<img class="flink-avatar" style="pointer-events: none;" th:alt="${link.spec.displayName}"
th:src="@{${#strings.isEmpty(link.spec.siteshot) ? link.spec.logo : link.spec.siteshot}}">
</a>
<a class="info cf-friends-link" target="_blank" th:href="${link.spec.url}"
th:title="${link.spec.displayName}">
<div class="site-card-avatar">
<img class="flink-avatar cf-friends-avatar" th:alt="${link.spec.displayName}"
th:src="${link.spec.logo}">
</div>
<div class="site-card-text">
<span class="title cf-friends-name" th:text="${link.spec.displayName}"></span>
<span class="desc" th:text="${link.spec.description}"
th:title="${link.spec.description}"></span>
</div>
</a>
</div>
</div>
<div class="flink-list"
th:if="${#strings.equals(group.spec.displayStyle,'default') && not #lists.isEmpty(group.spec.displayStyle)}">
<div class="flink-list-item" th:each="link : ${group.links}">
<span th:if="${not #lists.isEmpty(link.spec.label)}"
th:style="'background-color:' + ${link.spec.labelColor}"
class="site-card-tag">[[${link.spec.label}]]</span>
<a class="cf-friends-link" rel="external nofollow" target="_blank" th:href="${link.spec.url}"
th:title="${link.spec.displayName}">
<img class="flink-avatar cf-friends-avatar" th:alt="${link.spec.displayName}"
th:src="${link.spec.logo}">
<div class="flink-item-info">
<span class="flink-item-name cf-friends-name" th:text="${link.spec.displayName}"></span>
<span class="flink-item-desc" th:text="${link.spec.description}"
th:title="${link.spec.description}"></span>
<img th:src="${link.spec.logo}" class="entered loaded">
</div>
</a>
</div>
</div>
<div class="flink-list mini"
th:if="${#strings.equals(group.spec.displayStyle,'deprecated') && not #lists.isEmpty(group.spec.displayStyle)}">
<div class="flink-list-item" th:each="link : ${group.links}">
<a class="cf-friends-link" rel="external nofollow" target="_blank" th:href="${link.spec.url}"
th:title="${link.spec.displayName}">
<img class="flink-avatar cf-friends-avatar entered loaded" th:src="${link.spec.logo}"
th:alt="${link.spec.displayName}">
<div class="img-alt is-center">[[${link.spec.displayName}]]</div>
<div class="flink-item-info">
<span class="flink-item-name cf-friends-name">[[${link.spec.displayName}]]</span>
<span class="flink-item-desc"
th:title="${link.spec.description}">[[${link.spec.description}]]</span>
</div>
</a>
</div>
</div>
</th:block>
<th:block th:if="${htmlType == 'page'}" th:utext="${singlePage.content.content}">
</th:block>
</div>
</th:block>
</th:block>

View File

@ -0,0 +1,21 @@
<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<th:block th:fragment="comment(group, kind, name)">
<th:block
th:if="${theme.config.comments.twikooEnable && #strings.equals(theme.config.comments.use, 'Twikoo') && not #strings.isEmpty(theme.config.comments.twikoos.envId)}">
<div th:replace="~{modules/twikoo :: twikoo}"></div>
</th:block>
<!-- 已知问题 PJAX 下comment 首次请求会出错。当前的临时解决办法是使用 js 重试 -->
<div id="post-comment"
th:if="${pluginFinder.available('PluginCommentWidget') && #strings.equals(theme.config.comments.use, 'commentWidget')}">
<div class="comment-head">
<div class="comment-headline"><i class="iconfont icon-comment-alt"></i> <span>评论</span></div>
<div class="comment-privacy"><a href="/privacy">隐私政策</a></div>
<div class="comment-tips" id="comment-tips">
<span>你无需删除空行,直接评论以获取最佳展示效果</span>
</div>
</div>
<halo:comment th:attr="name=${name},kind=${kind},group=${group}" colorScheme="document.documentElement.getAttribute('data-theme')"/>
</div>
</th:block>
</html>

View File

@ -232,7 +232,7 @@
var GLOBAL_CONFIG = {
// 页面类型 index,page,post,tag,category
htmlType: [[${ htmlType }]],
postTitle: [[${ htmlType == 'post' ? post.spec.title : ''}]],
postTitle: [[${ htmlType == 'post' ? post.spec.title : htmlType == 'page' ? singlePage.spec.title : ''}]],
isanchor: true,
isPost: [[${htmlType == 'post'}]],
isHome: [[${ htmlType == 'index'}]],
@ -295,6 +295,10 @@
if (GLOBAL_CONFIG.postTitle != '')
title = GLOBAL_CONFIG.postTitle
break;
case 'page':
if (GLOBAL_CONFIG.postTitle != '')
title = GLOBAL_CONFIG.postTitle
break;
case 'archive':
title = '归档'
break;

View File

@ -211,6 +211,7 @@
// 页脚友链
addFriendLinksInFooter: function () {
var linksUrl = '[[${theme.config.link.linksUrl}]]'
var fetchUrl = [[${theme.config.footer.footer_group.fetchUrl}]]
fetch(fetchUrl)
.then(res => res.json())
@ -222,7 +223,7 @@
var item = randomFriendLinks[i]
htmlText += `<a class='footer-item' href='${item.link}' target="_blank" rel="noopener nofollow">${item.name}</a>`;
}
htmlText += `<a class='footer-item' href='/links'>更多</a>`
htmlText += `<a class='footer-item' href='${linksUrl}'>更多</a>`
document.getElementById("friend-links-in-footer").innerHTML = htmlText;
})
}

View File

@ -70,23 +70,11 @@
</div>
<script>heo.reflashEssayWaterFall();</script>
<hr/>
<!-- 评论模块 -->
<!--/* 评论组件 */-->
<th:block
th:if="${theme.config.comments.twikooEnable && #strings.equals(theme.config.comments.use, 'Twikoo') && not #strings.isEmpty(theme.config.comments.twikoos.envId)}">
<div th:replace="~{modules/twikoo :: twikoo}"></div>
</th:block>
<div id="post-comment"
th:if="${pluginFinder.available('PluginCommentWidget') && #strings.equals(theme.config.comments.use, 'commentWidget')}">
<div class="comment-head">
<div class="comment-headline"><i class="iconfont icon-comment-alt"></i> <span>评论</span></div>
<div class="comment-privacy"><a href="/privacy">隐私政策</a></div>
<div class="comment-tips" id="comment-tips">
<span>你无需删除空行,直接评论以获取最佳展示效果</span>
</div>
</div>
<halo:comment group="content.halo.run" kind="SinglePage" th:attr="name='moments'"
colorScheme="document.documentElement.getAttribute('data-theme')"/>
</div>
th:replace="~{modules/comment :: comment(group = 'content.halo.run',
kind = 'SinglePage',
name = 'moments')}"/>
</div>

View File

@ -13,23 +13,12 @@
<div id="page">
<div id="article-container" th:utext="${singlePage.content.content}"></div>
<hr>
<!-- 评论模块 -->
<!--/* 评论组件 */-->
<th:block
th:if="${singlePage.spec.allowComment && theme.config.comments.twikooEnable && #strings.equals(theme.config.comments.use, 'Twikoo') && not #strings.isEmpty(theme.config.comments.twikoos.envId)}">
<div th:replace="~{modules/twikoo :: twikoo}"></div>
</th:block>
<div id="post-comment"
th:if="${singlePage.spec.allowComment && pluginFinder.available('PluginCommentWidget') && #strings.equals(theme.config.comments.use, 'commentWidget')}">
<div class="comment-head">
<div class="comment-headline"><i class="iconfont icon-comment-alt"></i> <span>评论</span></div>
<div class="comment-privacy"><a href="/privacy">隐私政策</a></div>
<div class="comment-tips" id="comment-tips">
<span>你无需删除空行,直接评论以获取最佳展示效果</span>
</div>
</div>
<halo:comment group="content.halo.run" kind="SinglePage"
th:attr="name=${singlePage.metadata.name}" colorScheme="document.documentElement.getAttribute('data-theme')" />
</div>
th:replace="~{modules/comment :: comment(group = 'content.halo.run',
kind = 'SinglePage',
name = ${singlePage.metadata.name})}"/>
</div>
<!-- 侧栏 -->

33
templates/page_links.html Normal file
View File

@ -0,0 +1,33 @@
<!DOCTYPE html>
<html lang="en" th:replace="~{modules/layouts/layout :: layout(content = ~{::content}, htmlType = 'page')}"
xmlns:th="http://www.thymeleaf.org">
<th:block th:fragment="content">
<div class="page" id="body-wrap">
<header class="not-top-img" id="page-header">
<nav th:replace="~{modules/nav :: nav(title = null)}"></nav>
<link rel="stylesheet" type="text/css" th:href="${assets_link + '/zhheo/heo-fcircle3.css'}">
</header>
<main class="layout hide-aside" id="content-inner">
<div id="page">
<th:block th:replace="~{macro/content-links :: content-links(${htmlType})}" />
<hr/>
<!--/* 评论组件 */-->
<th:block
th:replace="~{modules/comment :: comment(group = 'content.halo.run',
kind = 'SinglePage',
name = ${singlePage.metadata.name})}"/>
</div>
</main>
<!-- 底部 -->
<footer th:replace="~{modules/footer :: footer}"></footer>
</div>
</th:block>
</html>

View File

@ -272,22 +272,11 @@
</div>
</div>
<hr>
<!-- 评论模块 -->
<!--/* 评论组件 */-->
<th:block
th:if="${post.spec.allowComment && theme.config.comments.twikooEnable && #strings.equals(theme.config.comments.use, 'Twikoo') && not #strings.isEmpty(theme.config.comments.twikoos.envId)}">
<div th:replace="~{modules/twikoo :: twikoo}"></div>
</th:block>
<div id="post-comment"
th:if="${post.spec.allowComment && pluginFinder.available('PluginCommentWidget') && #strings.equals(theme.config.comments.use, 'commentWidget')}">
<div class="comment-head">
<div class="comment-headline"><i class="iconfont icon-comment-alt"></i> <span>评论</span></div>
<div class="comment-privacy"><a href="/privacy">隐私政策</a></div>
<div class="comment-tips" id="comment-tips">
<span>你无需删除空行,直接评论以获取最佳展示效果</span>
</div>
</div>
<halo:comment group="content.halo.run" kind="Post" th:attr="name=${post.metadata.name}" colorScheme="document.documentElement.getAttribute('data-theme')" />
</div>
th:replace="~{modules/comment :: comment(group = 'content.halo.run',
kind = 'Post',
name = ${post.metadata.name})}"/>
</div>

View File

@ -9,6 +9,10 @@ spec:
website: https://liuzhihang.com
customTemplates:
page:
- name: 友情链接页面模版
description: 支持可预设文本的友链
screenshot:
file: page_links.html
- name: 关于页面模版
description: 关于页面
screenshot: