Skip to content

Commit

Permalink
评论区显示昵称
Browse files Browse the repository at this point in the history
  • Loading branch information
adlered committed Nov 6, 2024
1 parent 302d3c5 commit 7fc37f3
Show file tree
Hide file tree
Showing 7 changed files with 11 additions and 6 deletions.
2 changes: 2 additions & 0 deletions src/main/java/org/b3log/symphony/event/CommentNotifier.java
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ public void action(final Event<JSONObject> event) {
commenter = userQueryService.getAnonymousUser();
}
final String commenterName = commenter.optString(User.USER_NAME);
final String commenterNickName = commenter.optString(UserExt.USER_NICKNAME);

// 0. Data channel (WebSocket)
final JSONObject chData = JSONs.clone(originalComment);
Expand Down Expand Up @@ -203,6 +204,7 @@ public void action(final Event<JSONObject> event) {


chData.put(Comment.COMMENT_T_AUTHOR_NAME, commenterName);
chData.put("commentAuthorNickName", commenterNickName);
chData.put(Comment.COMMENT_T_AUTHOR_THUMBNAIL_URL, avatarQueryService.getAvatarURLByUser(commenter, "48"));


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,7 @@ public void showArticleApi(final RequestContext context) {
article.put(Article.ARTICLE_T_AUTHOR_NAME, author.optString(User.USER_NAME));
article.put(Article.ARTICLE_T_AUTHOR_URL, author.optString(User.USER_URL));
article.put(Article.ARTICLE_T_AUTHOR_INTRO, author.optString(UserExt.USER_INTRO));
article.put("articleAuthorNickName", author.optString(UserExt.USER_NICKNAME));

String metal = cloudService.getEnabledMetal(articleAuthorId);
if (!metal.equals("{}")) {
Expand Down Expand Up @@ -1059,6 +1060,7 @@ public void showArticle(final RequestContext context) {
article.put(Article.ARTICLE_T_AUTHOR_NAME, author.optString(User.USER_NAME));
article.put(Article.ARTICLE_T_AUTHOR_URL, author.optString(User.USER_URL));
article.put(Article.ARTICLE_T_AUTHOR_INTRO, author.optString(UserExt.USER_INTRO));
article.put("articleAuthorNickName", author.optString(UserExt.USER_NICKNAME));

String metal = cloudService.getEnabledMetal(articleAuthorId);
if (!metal.equals("{}")&&Article.ARTICLE_ANONYMOUS_C_ANONYMOUS!=article.optInt(Article.ARTICLE_ANONYMOUS)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -867,6 +867,7 @@ private void organizeComment(final JSONObject comment) throws RepositoryExceptio
}
comment.put(Comment.COMMENT_T_COMMENTER, author);
comment.put(Comment.COMMENT_T_AUTHOR_NAME, author.optString(User.USER_NAME));
comment.put("commentAuthorNickName", author.optString(UserExt.USER_NICKNAME));
comment.put(Comment.COMMENT_T_AUTHOR_URL, author.optString(User.USER_URL));
final String thumbnailURL = avatarQueryService.getAvatarURLByUser(author, "48");
comment.put(Comment.COMMENT_T_AUTHOR_THUMBNAIL_URL, thumbnailURL);
Expand Down
4 changes: 2 additions & 2 deletions src/main/resources/skins/classic/article.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@
<a rel="author" href="${servePath}/member/${article.articleAuthorName}"
class="article__stats article__stats--a tooltipped tooltipped-e"
aria-label="${article.oId?number?number_to_datetime}">
<span class="article__cnt">${article.articleAuthorName}</span>
<span class="article__cnt"><#if article.articleAuthorNickName != "">${article.articleAuthorNickName}<#else>${article.articleAuthorName}</#if></span>
<time>${article.timeAgo}</time>
<#if 0 == article.articleAuthor.userUAStatus>
<span id="articltVia" class="via" data-ua="${article.articleUA}"></span>
Expand Down Expand Up @@ -355,7 +355,7 @@
<a rel="nofollow"
href="${servePath}/member/${comment.commentAuthorName}"
class="ft-gray"><span
class="ft-gray">${comment.commentAuthorName}</span></a>
class="ft-gray"><#if comment.commentAuthorNickName != "">${comment.commentAuthorNickName} (${comment.commentAuthorName})<#else>${comment.commentAuthorName}</#if></span></a>
<span class="ft-fade">• ${comment.timeAgo}</span>

<#if comment.rewardedCnt gt 0>
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/skins/classic/common/comment.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
<div class="comment-get-comment list"></div>
<div class="fn-clear comment-info">
<span class="fn-left ft-smaller">
<a rel="nofollow" href="${servePath}/member/${comment.commentAuthorName}" class="ft-gray"><span class="ft-gray">${comment.commentAuthorName}</span></a>
<a rel="nofollow" href="${servePath}/member/${comment.commentAuthorName}" class="ft-gray"><span class="ft-gray"><#if comment.commentAuthorNickName != "">${comment.commentAuthorNickName} (${comment.commentAuthorName})<#else>${comment.commentAuthorName}</#if></span></a>
<#list comment.sysMetal?eval as metal>
<img title="${metal.description}" src="https://fishpi.cn/gen?ver=0.1&scale=0.79&txt=${metal.name}&${metal.attr}"/>
</#list>
Expand Down
4 changes: 2 additions & 2 deletions src/main/resources/skins/mobile/article.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@
title="${article.articleAuthorName}"><div class="avatar" style="background-image:url('${article.articleAuthorThumbnailURL48}')"></div></a>
<div class="article-params">
<a rel="author" href="${servePath}/member/${article.articleAuthorName}" class="ft-gray"
title="${article.articleAuthorName}"><strong>${article.articleAuthorName}</strong></a>
title="${article.articleAuthorName}"><strong><#if article.articleAuthorNickName != "">${article.articleAuthorNickName}<#else>${article.articleAuthorName}</#if></strong></a>
<span class="ft-gray">
<#if article.articleCity != "">
&nbsp;&nbsp;
Expand Down Expand Up @@ -270,7 +270,7 @@
<div class="fn-flex-1">
<div class="fn-clear comment-info ft-smaller">
<span class="fn-left">
<a rel="nofollow" href="${servePath}/member/${comment.commentAuthorName}" class="ft-gray"><span class="ft-gray">${comment.commentAuthorName}</span></a>
<a rel="nofollow" href="${servePath}/member/${comment.commentAuthorName}" class="ft-gray"><span class="ft-gray"><#if comment.commentAuthorNickName != "">${comment.commentAuthorNickName} (${comment.commentAuthorName})<#else>${comment.commentAuthorName}</#if></span></a>
<span class="ft-fade">• ${comment.timeAgo}</span>

<#if comment.rewardedCnt gt 0>
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/skins/mobile/common/comment.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
<div class="comment-get-comment list"></div>
<div class="fn-clear comment-info">
<span class="fn-left ft-smaller">
<a rel="nofollow" href="${servePath}/member/${comment.commentAuthorName}" class="ft-gray"><span class="ft-gray">${comment.commentAuthorName}</span></a>
<a rel="nofollow" href="${servePath}/member/${comment.commentAuthorName}" class="ft-gray"><span class="ft-gray"><#if comment.commentAuthorNickName != "">${comment.commentAuthorNickName} (${comment.commentAuthorName})<#else>${comment.commentAuthorName}</#if></span></a>
<#list comment.sysMetal?eval as metal>
<img title="${metal.description}" src="https://fishpi.cn/gen?ver=0.1&scale=0.79&txt=${metal.name}&${metal.attr}"/>
</#list>
Expand Down

0 comments on commit 7fc37f3

Please sign in to comment.