mirror of
https://github.com/sismics/docs.git
synced 2025-12-13 17:56:20 +00:00
Closes #42: Gravatar images in comments
This commit is contained in:
@@ -21,6 +21,7 @@ import com.sismics.docs.core.dao.jpa.dto.CommentDto;
|
||||
import com.sismics.docs.core.model.jpa.Comment;
|
||||
import com.sismics.rest.exception.ForbiddenClientException;
|
||||
import com.sismics.rest.util.ValidationUtil;
|
||||
import com.sismics.util.ImageUtil;
|
||||
|
||||
/**
|
||||
* Comment REST resource.
|
||||
@@ -139,6 +140,7 @@ public class CommentResource extends BaseResource {
|
||||
.add("id", commentDto.getId())
|
||||
.add("content", commentDto.getContent())
|
||||
.add("creator", commentDto.getCreatorName())
|
||||
.add("creator_gravatar", ImageUtil.computeGravatar(commentDto.getCreatorEmail()))
|
||||
.add("create_date", commentDto.getCreateTimestamp()));
|
||||
}
|
||||
|
||||
|
||||
@@ -72,15 +72,22 @@
|
||||
<p ng-show="!comments && commentsError">Error loading comments</p>
|
||||
</div>
|
||||
|
||||
<div ng-repeat="comment in comments" style="overflow: hidden">
|
||||
<strong>{{ comment.creator }}</strong>
|
||||
<p>
|
||||
{{ comment.content }}<br />
|
||||
<span class="text-muted">{{ comment.create_date | date: 'yyyy-MM-dd' }}</span>
|
||||
<div ng-repeat="comment in comments" class="media" style="overflow: hidden">
|
||||
<div class="pull-left">
|
||||
<a href="#">
|
||||
<img ng-src="http://www.gravatar.com/avatar/{{ comment.creator_gravatar }}?s=40&d=identicon" class="media-object" />
|
||||
</a>
|
||||
</div>
|
||||
<div class="media-body">
|
||||
<strong>{{ comment.creator }}</strong>
|
||||
<p>
|
||||
{{ comment.content }}<br />
|
||||
<span class="text-muted">{{ comment.create_date | date: 'yyyy-MM-dd' }}</span>
|
||||
<span class="text-muted pull-right btn-link"
|
||||
ng-show="document.writable || userInfo.username == comment.creator"
|
||||
ng-click="deleteComment(comment)">Delete</span>
|
||||
</p>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<form ng-submit="addComment()">
|
||||
|
||||
@@ -127,6 +127,7 @@ public class TestCommentResource extends BaseJerseyTest {
|
||||
Assert.assertEquals(comment2Id, comment.getString("id"));
|
||||
Assert.assertEquals("Comment by comment2", comment.getString("content"));
|
||||
Assert.assertEquals("comment2", comment.getString("creator"));
|
||||
Assert.assertEquals("d6e56c42f61983bba80d370138763420", comment.getString("creator_gravatar"));
|
||||
Assert.assertNotNull(comment.getJsonNumber("create_date"));
|
||||
|
||||
// Delete a comment with comment2
|
||||
|
||||
Reference in New Issue
Block a user