feat: support upvote and comment for moments
This commit is contained in:
+83
-24
@@ -4,42 +4,101 @@
|
||||
th:replace="~{modules/layout :: html(title = |#{page.moments.title} - ${site.title}|, header = null, content = ~{::content}, footer = null)}"
|
||||
>
|
||||
<th:block th:fragment="content">
|
||||
<article
|
||||
class="moment on-list post"
|
||||
th:each="moment,iterStat : ${moments.items}"
|
||||
th:with="content=${moment.spec.content}"
|
||||
th:attr="x-data=|{name:'${moment.metadata.name}',showComment:false}|">
|
||||
<article th:each="moment, stat : ${moments.items}"
|
||||
th:with="
|
||||
name=${moment.metadata.name},
|
||||
content=${moment.spec.content},
|
||||
medium=${content.medium},
|
||||
upvoteCount=${moment.stats.upvote ?: 0},
|
||||
commentCount=${moment.stats.approvedComment ?: 0},
|
||||
commentId=|comment-${name}|,
|
||||
galleryId=|gallery-${stat.index}|,
|
||||
mediaSize=${#lists.size(medium)},
|
||||
mediaGridClass=${mediaSize == 1 ? 'grid-cols-1' : (mediaSize < 5 ? 'grid-cols-2' : 'grid-cols-3')}
|
||||
"
|
||||
class="moment on-list post"
|
||||
th:attr="x-data=|{ name: '${name}', showComment: false }|">
|
||||
|
||||
<header>
|
||||
<div class="post-meta">
|
||||
<time class="post-date" th:text="${#dates.format(moment.spec.releaseTime,'yyyy-MM-dd')}">
|
||||
<time class="post-date"
|
||||
th:text="${#dates.format(moment.spec.releaseTime, 'yyyy-MM-dd')}">
|
||||
Moment CreateTime
|
||||
</time>
|
||||
<span class="post-author" th:with="owner = ${moment.owner}" th:text="${owner.displayName}">
|
||||
<span class="post-author"
|
||||
th:with="owner=${moment.owner}"
|
||||
th:text="${owner.displayName}">
|
||||
Author
|
||||
</span>
|
||||
</div>
|
||||
</header>
|
||||
<div class="post-content" th:utext="${content.html}">Moment Content...</div>
|
||||
<th:block th:with="medium=${moment.spec.content.medium}">
|
||||
<div
|
||||
th:unless="${#lists.isEmpty(moments)}"
|
||||
class="moment-media"
|
||||
th:classappend="${(#lists.size(medium) > 4 ? 'grid-cols-3' : '') + (#lists.size(medium) == 1 ? 'grid-cols-1' :'') + ((#lists.size(medium) > 1 && #lists.size(medium) < 5) ? 'grid-cols-2' :'')}"
|
||||
>
|
||||
<div class="" th:each="media : ${medium}">
|
||||
<a th:class="|glightbox|" th:data-gallery="|gallery${iterStat.count}|" th:href="${media.url}">
|
||||
<img
|
||||
th:if="${#strings.equals(media.type,'PHOTO')}"
|
||||
class="transform-gpu rounded-lg object-cover"
|
||||
th:src="${media.url}"
|
||||
alt="photo"/>
|
||||
|
||||
<div class="post-content" th:utext="${content.html}">
|
||||
Moment Content...
|
||||
</div>
|
||||
|
||||
<th:block th:if="${!#lists.isEmpty(medium)}">
|
||||
<div class="moment-media" th:classappend="${mediaGridClass}">
|
||||
<div th:each="media : ${medium}">
|
||||
<a class="glightbox"
|
||||
th:data-gallery="${galleryId}"
|
||||
th:href="${media.url}">
|
||||
<img th:if="${media.type == 'PHOTO'}"
|
||||
class="transform-gpu rounded-lg object-cover"
|
||||
th:src="${media.url}"
|
||||
alt="photo"/>
|
||||
</a>
|
||||
<div th:if="${#strings.equals(media.type,'VIDEO')}">
|
||||
<video controls th:src="${media.url}"></video>
|
||||
</div>
|
||||
|
||||
<video th:if="${media.type == 'VIDEO'}"
|
||||
controls
|
||||
th:src="${media.url}"></video>
|
||||
</div>
|
||||
</div>
|
||||
</th:block>
|
||||
|
||||
<footer class="moment-footer">
|
||||
<button class="moment-action-btn moment-upvote-btn"
|
||||
th:attr="data-name=${name},data-count=${upvoteCount}"
|
||||
onclick="handleUpvote(this.dataset.name)">
|
||||
<svg class="icon-regular" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"
|
||||
fill="currentColor" width="16" height="16">
|
||||
<path d="M12 21.35l-1.45-1.32C5.4 15.36 2 12.28 2 8.5 2 5.42 4.42 3 7.5 3c1.74 0 3.41.81 4.5 2.09C13.09 3.81 14.76 3 16.5 3 19.58 3 22 5.42 22 8.5c0 3.78-3.4 6.86-8.55 11.54L12 21.35z"/>
|
||||
</svg>
|
||||
<svg class="icon-pixel" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"
|
||||
width="16" height="16">
|
||||
<path fill="currentColor"
|
||||
d="M9 2H5v2H3v2H1v6h2v2h2v2h2v2h2v2h2v2h2v-2h2v-2h2v-2h2v-2h2v-2h2V6h-2V4h-2V2h-4v2h-2v2h-2V4H9V2zm0 2v2h2v2h2V6h2V4h4v2h2v6h-2v2h-2v2h-2v2h-2v2h-2v-2H9v-2H7v-2H5v-2H3V6h2V4h4z"/>
|
||||
</svg>
|
||||
<span class="upvote-count"
|
||||
th:attr="data-moment-name=${name}"
|
||||
th:text="${upvoteCount}">0</span>
|
||||
</button>
|
||||
|
||||
<button class="moment-action-btn moment-comment-btn"
|
||||
th:attr="data-target=${commentId}"
|
||||
onclick="showComment(this.dataset.target)">
|
||||
<svg class="icon-regular" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"
|
||||
fill="currentColor" width="16" height="16">
|
||||
<path d="M20 2H4c-1.1 0-2 .9-2 2v18l4-4h14c1.1 0 2-.9 2-2V4c0-1.1-.9-2-2-2z"/>
|
||||
</svg>
|
||||
<svg class="icon-pixel" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"
|
||||
width="16" height="16">
|
||||
<path fill="currentColor"
|
||||
d="M22 2H2v14h2V4h16v12h-8v2h-2v2H8v-4H2v2h4v4h4v-2h2v-2h10V2z"/>
|
||||
</svg>
|
||||
<span th:text="${commentCount}">0</span>
|
||||
</button>
|
||||
</footer>
|
||||
<div class="moment-comment-section"
|
||||
th:id="${commentId}"
|
||||
th:attr="data-name=${name}">
|
||||
<th:block th:if="${haloCommentEnabled}"
|
||||
th:replace="~{modules/comment :: comment(
|
||||
group = 'moment.halo.run',
|
||||
kind = 'Moment',
|
||||
name = ${name}
|
||||
)}"/>
|
||||
</div>
|
||||
</article>
|
||||
<nav class="pagination" th:if="${moments.hasPrevious() || moments.hasNext()}">
|
||||
<div class="pagination__buttons">
|
||||
|
||||
Reference in New Issue
Block a user