Skip to content

Commit

Permalink
Merge pull request #847 from support-project/issue840_display_extend
Browse files Browse the repository at this point in the history
#840 Add display link for user information page
  • Loading branch information
koda-masaru authored Sep 10, 2017
2 parents 6d5075c + b829256 commit 4cd17b9
Show file tree
Hide file tree
Showing 8 changed files with 135 additions and 68 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@ public Boundary activity() throws Exception {
offset = getParam("offset", Integer.class);
}
List<ActivityHistory> list = ActivityLogic.get().getUserPointHistoriese(userId, limit, offset, getUserConfigs());
setSendEscapeHtml(false);
return send(list);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,13 @@
import org.support.project.common.config.Resources;
import org.support.project.common.log.Log;
import org.support.project.common.log.LogFactory;
import org.support.project.common.util.HtmlUtils;
import org.support.project.common.util.StringUtils;
import org.support.project.di.Container;
import org.support.project.di.DI;
import org.support.project.di.Instance;
import org.support.project.knowledge.config.AppConfig;
import org.support.project.knowledge.config.SystemConfig;
import org.support.project.knowledge.dao.ActivitiesDao;
import org.support.project.knowledge.dao.CommentsDao;
import org.support.project.knowledge.dao.PointUserHistoriesDao;
Expand All @@ -27,6 +30,8 @@
import org.support.project.knowledge.vo.UserConfigs;
import org.support.project.ormapping.config.Order;
import org.support.project.web.bean.LoginedUser;
import org.support.project.web.dao.SystemConfigsDao;
import org.support.project.web.entity.SystemConfigsEntity;
import org.support.project.web.logic.DateConvertLogic;

@DI(instance = Instance.Singleton)
Expand Down Expand Up @@ -139,57 +144,94 @@ public List<ContributionPointHistory> getUserPointHistoriesByDate(Integer userId
private String getDisplayDate(Date date, UserConfigs userConfigs) {
return DateConvertLogic.get().convertDate(date, userConfigs.getLocale(), String.valueOf(userConfigs.getTimezoneOffset()));
}

private String getActivityMsg(PointUserHistoriesEntity history, Map<Long, ActivitiesEntity> activities, UserConfigs userConfigs) {
private String convKnowledgeLink(String systemUrl, String target) {
StringBuilder builder = new StringBuilder();
builder.append("<a href=\"");
builder.append(systemUrl);
builder.append("open.knowledge/view/");
builder.append(target);
builder.append("\">#");
builder.append(target);
builder.append("</a>");
return builder.toString();
}
private String convUserLink(String systemUrl, Integer userID, String userName) {
StringBuilder builder = new StringBuilder();
builder.append("<a href=\"");
builder.append(systemUrl);
builder.append("open.account/info/");
builder.append(userID);
builder.append("\">");
builder.append(HtmlUtils.escapeHTML(userName));
builder.append("</a>");
return builder.toString();
}
private String getActivityMsg(PointUserHistoriesEntity history, Map<Long, ActivitiesEntity> activities, UserConfigs userConfigs, String systemUrl) {
Resources resources = Resources.getInstance(userConfigs.getLocale());
ActivitiesEntity activity = activities.get(history.getActivityNo());
if (activity == null) {
return "";
}
if (history.getType() == ActivityProcessor.TYPE_KNOWLEDGE_DO_INSERT) {
return resources.getResource("knowledge.activity.type.11.do.insert", activity.getTarget());
return resources.getResource("knowledge.activity.type.11.do.insert", convKnowledgeLink(systemUrl, activity.getTarget()));
} else if (history.getType() == ActivityProcessor.TYPE_KNOWLEDGE_DO_SHOW) {
return resources.getResource("knowledge.activity.type.21.do.show", activity.getTarget());
return resources.getResource("knowledge.activity.type.21.do.show", convKnowledgeLink(systemUrl, activity.getTarget()));
} else if (history.getType() == ActivityProcessor.TYPE_KNOWLEDGE_SHOWN_BY_OHER) {
return resources.getResource("knowledge.activity.type.22.shown", activity.getTarget(), activity.getUserName());
return resources.getResource("knowledge.activity.type.22.shown", convKnowledgeLink(systemUrl, activity.getTarget()),
convUserLink(systemUrl, activity.getInsertUser(), activity.getUserName()));
} else if (history.getType() == ActivityProcessor.TYPE_KNOWLEDGE_DO_LIKE) {
return resources.getResource("knowledge.activity.type.31.do.like", activity.getTarget(), activity.getUserName());
return resources.getResource("knowledge.activity.type.31.do.like", convKnowledgeLink(systemUrl, activity.getTarget()),
activity.getUserName());
} else if (history.getType() == ActivityProcessor.TYPE_KNOWLEDGE_LIKED_BY_OHER) {
return resources.getResource("knowledge.activity.type.32.liked", activity.getTarget(), activity.getUserName());
return resources.getResource("knowledge.activity.type.32.liked", convKnowledgeLink(systemUrl, activity.getTarget()),
activity.getUserName());
} else if (history.getType() == ActivityProcessor.TYPE_KNOWLEDGE_DO_STOCK) {
return resources.getResource("knowledge.activity.type.41.do.stock", activity.getTarget(), activity.getUserName());
return resources.getResource("knowledge.activity.type.41.do.stock", convKnowledgeLink(systemUrl, activity.getTarget()),
activity.getUserName());
} else if (history.getType() == ActivityProcessor.TYPE_KNOWLEDGE_STOCKED_BY_OHER) {
return resources.getResource("knowledge.activity.type.42.stocked", activity.getTarget(), activity.getUserName());
return resources.getResource("knowledge.activity.type.42.stocked", convKnowledgeLink(systemUrl, activity.getTarget()),
activity.getUserName());
} else if (history.getType() == ActivityProcessor.TYPE_KNOWLEDGE_DO_ANSWER) {
return resources.getResource("knowledge.activity.type.51.do.ansewer", activity.getTarget(), activity.getUserName());
return resources.getResource("knowledge.activity.type.51.do.ansewer", convKnowledgeLink(systemUrl, activity.getTarget()),
activity.getUserName());
} else if (history.getType() == ActivityProcessor.TYPE_KNOWLEDGE_ANSWERD_BY_OHER) {
return resources.getResource("knowledge.activity.type.52.answered", activity.getTarget(), activity.getUserName());
return resources.getResource("knowledge.activity.type.52.answered", convKnowledgeLink(systemUrl, activity.getTarget()),
activity.getUserName());
} else if (history.getType() == ActivityProcessor.TYPE_KNOWLEDGE_DO_JOIN_EVENT) {
return resources.getResource("knowledge.activity.type.61.do.join", activity.getTarget(), activity.getUserName());
return resources.getResource("knowledge.activity.type.61.do.join", convKnowledgeLink(systemUrl, activity.getTarget()),
activity.getUserName());
} else if (history.getType() == ActivityProcessor.TYPE_KNOWLEDGE_JOINED_BY_OHER) {
return resources.getResource("knowledge.activity.type.62.joined", activity.getTarget(), activity.getUserName());
return resources.getResource("knowledge.activity.type.62.joined", convKnowledgeLink(systemUrl, activity.getTarget()),
activity.getUserName());

} else if (history.getType() == ActivityProcessor.TYPE_KNOWLEDGE_DO_POST_PUBLIC) {
return resources.getResource("knowledge.activity.type.101.do.post.public", activity.getTarget(), activity.getUserName());
return resources.getResource("knowledge.activity.type.101.do.post.public", convKnowledgeLink(systemUrl, activity.getTarget()),
activity.getUserName());
} else if (history.getType() == ActivityProcessor.TYPE_KNOWLEDGE_DO_POST_PROTECT) {
return resources.getResource("knowledge.activity.type.111.do.post.protect", activity.getTarget(), activity.getUserName());
return resources.getResource("knowledge.activity.type.111.do.post.protect", convKnowledgeLink(systemUrl, activity.getTarget()),
activity.getUserName());
} else if (history.getType() == ActivityProcessor.TYPE_KNOWLEDGE_DO_POST_PRIVATE) {
return resources.getResource("knowledge.activity.type.121.do.post.private", activity.getTarget(), activity.getUserName());
return resources.getResource("knowledge.activity.type.121.do.post.private", convKnowledgeLink(systemUrl, activity.getTarget()),
activity.getUserName());

} else if (history.getType() >= ActivityProcessor.TYPE_COMMENT_DO_INSERT) {
CommentsEntity comment = CommentsDao.get().selectOnKey(new Long(activity.getTarget()));
if (comment != null) {
if (history.getType() == ActivityProcessor.TYPE_COMMENT_DO_INSERT) {
return resources.getResource("knowledge.activity.type.1011.do.comment.insert", String.valueOf(comment.getKnowledgeId()), activity.getUserName());
return resources.getResource("knowledge.activity.type.1011.do.comment.insert",
convKnowledgeLink(systemUrl, String.valueOf(comment.getKnowledgeId())), activity.getUserName());
} else if (history.getType() == ActivityProcessor.TYPE_COMMENT_DO_LIKE) {
return resources.getResource("knowledge.activity.type.1031.do.comment.like", String.valueOf(comment.getKnowledgeId()), activity.getUserName());
return resources.getResource("knowledge.activity.type.1031.do.comment.like",
convKnowledgeLink(systemUrl, String.valueOf(comment.getKnowledgeId())), activity.getUserName());
} else if (history.getType() == ActivityProcessor.TYPE_COMMENT_LIKED_BY_OHER) {
return resources.getResource("knowledge.activity.type.1032.comment.liked", String.valueOf(comment.getKnowledgeId()), activity.getUserName());
return resources.getResource("knowledge.activity.type.1032.comment.liked",
convKnowledgeLink(systemUrl, String.valueOf(comment.getKnowledgeId())), activity.getUserName());
}
}
}
return "";
}

public List<ActivityHistory> getUserPointHistoriese(Integer userId, int limit, int offset, UserConfigs userConfigs) {
List<PointUserHistoriesEntity> histories = PointUserHistoriesDao.get().selectOnUser(userId, limit, offset, Order.DESC);
List<Long> activityNos = new ArrayList<>();
Expand All @@ -201,9 +243,19 @@ public List<ActivityHistory> getUserPointHistoriese(Integer userId, int limit, i
for (ActivitiesEntity activitiesEntity : activityList) {
activities.put(activitiesEntity.getActivityNo(), activitiesEntity);
}

SystemConfigsDao dao = SystemConfigsDao.get();
SystemConfigsEntity config = dao.selectOnKey(SystemConfig.SYSTEM_URL, AppConfig.get().getSystemName());
StringBuilder builder = new StringBuilder();
if (config != null) {
builder.append(config.getConfigValue());
if (!config.getConfigValue().endsWith("/")) {
builder.append("/");
}
}
List<ActivityHistory> list = new ArrayList<>();
for (PointUserHistoriesEntity history : histories) {
String msg = getActivityMsg(history, activities, userConfigs);
String msg = getActivityMsg(history, activities, userConfigs, builder.toString());
if (StringUtils.isNotEmpty(msg)) {
ActivityHistory activity = new ActivityHistory();
activity.setDate(history.getInsertDatetime());
Expand Down
40 changes: 20 additions & 20 deletions src/main/resources/appresource.properties
Original file line number Diff line number Diff line change
Expand Up @@ -853,23 +853,23 @@ knowledge.maintenance.do.migrate.no.login=Execute maintenance(only administrator
knowledge.maintenance.migrate.title=Database migration
knowledge.maintenance.migrate.message=You can execute database migration. recommend to backup database data.

knowledge.activity.type.11.do.insert=This user posted #{1}
knowledge.activity.type.21.do.show=This user showed #{1}
knowledge.activity.type.22.shown=#{1} was shown by {2}
knowledge.activity.type.31.do.like=This user liked #{1}
knowledge.activity.type.32.liked=#{1} was liked by {2}
knowledge.activity.type.41.do.stock=This user stocked #{1}
knowledge.activity.type.42.stocked=#{1} was stocked by {2}
knowledge.activity.type.51.do.ansewer=This user answered to survey on #{1}
knowledge.activity.type.52.answered=#{1}'s survey was answered by {2}
knowledge.activity.type.61.do.join=This user registration event to #{1}
knowledge.activity.type.62.joined=#{1}'s event was registered by {2}
knowledge.activity.type.101.do.post.public=This user posted #{1} to Public
knowledge.activity.type.111.do.post.protect=This user posted #{1} to Protect
knowledge.activity.type.121.do.post.private=This user posted #{1} to Private
knowledge.activity.type.1011.do.comment.insert=This user posted comment to #{1}
knowledge.activity.type.1031.do.comment.like=This user liked #{1}'s comment
knowledge.activity.type.1032.comment.liked=This user's comment on #{1} was liked by {2}

knowledge.activity.type.13.inserted=#{1} was posted by {2}
knowledge.activity.type.23.shown=#{1} was shown by {2}
knowledge.activity.type.11.do.insert=This user posted {1}
knowledge.activity.type.21.do.show=This user showed {1}
knowledge.activity.type.22.shown={1} was shown by {2}
knowledge.activity.type.31.do.like=This user liked {1}
knowledge.activity.type.32.liked={1} was liked by {2}
knowledge.activity.type.41.do.stock=This user stocked {1}
knowledge.activity.type.42.stocked={1} was stocked by {2}
knowledge.activity.type.51.do.ansewer=This user answered to survey on {1}
knowledge.activity.type.52.answered={1}'s survey was answered by {2}
knowledge.activity.type.61.do.join=This user registration event to {1}
knowledge.activity.type.62.joined={1}'s event was registered by {2}
knowledge.activity.type.101.do.post.public=This user posted {1} to Public
knowledge.activity.type.111.do.post.protect=This user posted {1} to Protect
knowledge.activity.type.121.do.post.private=This user posted {1} to Private
knowledge.activity.type.1011.do.comment.insert=This user posted comment to {1}
knowledge.activity.type.1031.do.comment.like=This user liked {1}'s comment
knowledge.activity.type.1032.comment.liked=This user's comment on {1} was liked by {2}

knowledge.activity.type.13.inserted={1} was posted by {2}
knowledge.activity.type.23.shown={1} was shown by {2}
40 changes: 20 additions & 20 deletions src/main/resources/appresource_ja.properties
Original file line number Diff line number Diff line change
Expand Up @@ -853,25 +853,25 @@ knowledge.maintenance.do.migrate.no.login=メンテナンス管理を実行(管
knowledge.maintenance.migrate.title=Database migration
knowledge.maintenance.migrate.message=DBのマイグレーションを実行します。事前にDBのバックアップを取ることをオススメします。

knowledge.activity.type.11.do.insert=#{1} の記事を投稿しました
knowledge.activity.type.21.do.show=#{1} の記事を参照しました
knowledge.activity.type.22.shown=このユーザが投稿した #{1} の記事を、{2} が参照しました
knowledge.activity.type.31.do.like=#{1} の記事にいいね!を押しました
knowledge.activity.type.32.liked=このユーザが投稿した #{1} の記事を、{2} がいいね!を押しました
knowledge.activity.type.41.do.stock=#{1} の記事をストックしました
knowledge.activity.type.42.stocked=このユーザが投稿した #{1} の記事を、{2} がストックしました
knowledge.activity.type.51.do.ansewer=#{1} のアンケートに回答しました
knowledge.activity.type.52.answered=このユーザが投稿した #{1} の記事のアンケートに、{2} が回答しました
knowledge.activity.type.61.do.join=#{1} のイベントに参加登録しました
knowledge.activity.type.62.joined=このユーザが投稿した #{1} のイベントに、{2} が参加登録しました
knowledge.activity.type.101.do.post.public=#{1} の記事を「公開」で投稿しました
knowledge.activity.type.111.do.post.protect=#{1} の記事を「保護」で投稿しました
knowledge.activity.type.121.do.post.private=#{1} の記事を「非公開」で投稿しました
knowledge.activity.type.1011.do.comment.insert=#{1} の記事にコメントを登録しました
knowledge.activity.type.1031.do.comment.like=#{1} の記事のコメントにいいね!を押しました
knowledge.activity.type.1032.comment.liked=このユーザが投稿した #{1} の記事のコメントに、{2} がいいね!を押しました

knowledge.activity.type.13.inserted=#{1} の記事が、{2} によって投稿されました
knowledge.activity.type.23.shown=#{1} の記事を、{2} が参照しました
knowledge.activity.type.11.do.insert={1} の記事を投稿しました
knowledge.activity.type.21.do.show={1} の記事を参照しました
knowledge.activity.type.22.shown=このユーザが投稿した {1} の記事を、{2} が参照しました
knowledge.activity.type.31.do.like={1} の記事にいいね!を押しました
knowledge.activity.type.32.liked=このユーザが投稿した {1} の記事を、{2} がいいね!を押しました
knowledge.activity.type.41.do.stock={1} の記事をストックしました
knowledge.activity.type.42.stocked=このユーザが投稿した {1} の記事を、{2} がストックしました
knowledge.activity.type.51.do.ansewer={1} のアンケートに回答しました
knowledge.activity.type.52.answered=このユーザが投稿した {1} の記事のアンケートに、{2} が回答しました
knowledge.activity.type.61.do.join={1} のイベントに参加登録しました
knowledge.activity.type.62.joined=このユーザが投稿した {1} のイベントに、{2} が参加登録しました
knowledge.activity.type.101.do.post.public={1} の記事を「公開」で投稿しました
knowledge.activity.type.111.do.post.protect={1} の記事を「保護」で投稿しました
knowledge.activity.type.121.do.post.private={1} の記事を「非公開」で投稿しました
knowledge.activity.type.1011.do.comment.insert={1} の記事にコメントを登録しました
knowledge.activity.type.1031.do.comment.like={1} の記事のコメントにいいね!を押しました
knowledge.activity.type.1032.comment.liked=このユーザが投稿した {1} の記事のコメントに、{2} がいいね!を押しました

knowledge.activity.type.13.inserted={1} の記事が、{2} によって投稿されました
knowledge.activity.type.23.shown={1} の記事を、{2} が参照しました


2 changes: 1 addition & 1 deletion src/main/webapp/WEB-INF/views/open/account/account.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@
<br/><br/>
<div class="list-group" id="activityList">
<a class="list-group-item" v-for="activity in activities">
<h4 class="list-group-item-heading">{{ activity.msg }}</h4>
<h4 class="list-group-item-heading" v-html="activity.msg"></h4>
<p class="list-group-item-text">{{ activity.dispDate }}</p>
</a>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,10 @@
</div>

<div class="item-info">
<i class="fa fa-heart-o" style="margin-left: 5px;"></i>&nbsp;× <%=jspUtil.out("knowledge.point")%>
<a class="text-primary btn-link"
href="<%=request.getContextPath()%>/open.knowledge/likes/<%=jspUtil.out("knowledge.knowledgeId")%><%=jspUtil.out("params")%>">
<i class="fa fa-thumbs-o-up" style="margin-left: 5px;"></i>&nbsp;× <span id="like_count"><%=jspUtil.out("knowledge.likeCount")%></span>
<i class="fa fa-thumbs-o-up"></i>&nbsp;× <span id="like_count"><%=jspUtil.out("knowledge.likeCount")%></span>
</a> &nbsp;
<a class="text-primary btn-link"
href="<%=request.getContextPath()%>/open.knowledge/view/<%=jspUtil.out("knowledge.knowledgeId")%><%=jspUtil.out("params")%>#comments">
Expand Down
Loading

0 comments on commit 4cd17b9

Please sign in to comment.