2024-05-07 15:14:20 +08:00

34 lines
2.5 KiB
HTML

<div xmlns:th="https://www.thymeleaf.org"
th:fragment="widget (sidebar)"
th:class="'card widget recent-comments ' + ${sidebar.hide}"
th:with="num = ${#strings.isEmpty(theme.config.sidebar.recent_comments_num)? 5 : T(java.lang.Integer).parseInt(theme.config.sidebar.recent_comments_num)}, comments = ${commentFinder.list(null,1,num)}, isEmpty = ${#lists.isEmpty(comments)}">
<div class="card-title">
<i th:class="${#strings.defaultString(sidebar.icon, 'ri-message-2-line') + ' card-title-label'}"></i><span th:text="${#strings.defaultString(sidebar.title, '最新评论')}"></span>
</div>
<div th:if="${isEmpty}" class="card-empty">暂无评论</div>
<div th:unless="${isEmpty}" class="card-content">
<ul class="widget-comment">
<li class="item" th:each="comment : ${comments}">
<div class="user"
th:with="
emailHash = ${comment.spec.owner.annotations != null ? comment.spec.owner.annotations['email-hash'] : ''},
userA = ${comment.owner.avatar},
img = ${#strings.isEmpty(userA) && !#strings.isEmpty(emailHash) ? theme.config.basic_info.providerMirror+'/avatar/'+emailHash : userA}">
<img width="35" height="35" th:unless="${#strings.isEmpty(img)}" class="avatar" th:src="${img}"
th:alt="${comment.owner.displayName}">
<div th:if="${#strings.isEmpty(img)}" class="no-avatar">
<span class="avatar-info">[[${#strings.substring(comment.owner.displayName, 0, 1)}]]</span>
</div>
<div class="info">
<div class="author">[[${comment.owner.displayName}]]</div>
<span class="date">[[${#temporals.format(comment.spec.creationTime, 'yyyy-MM-dd')}]]</span>
</div>
</div>
<div class="reply"
th:with="url = ${comment.spec.subjectRef.kind == 'SinglePage'?(comment.spec.subjectRef.name == theme.config.page_config.link_comment_id?'/links':singlePageFinder.getByName(comment.spec.subjectRef.name).status.permalink):(comment.spec.subjectRef.kind == 'Post'?postFinder.getByName(comment.spec.subjectRef.name).status.permalink:comment.spec.subjectRef.kind == 'Moment'?'/moments':'')}">
<a th:href="@{${url}}+'#comment-wrapper'" class="link">[[${comment.spec.content}]]</a>
</div>
</li>
</ul>
</div>
</div>