diff --git a/src/main/scala/app/IssuesController.scala b/src/main/scala/app/IssuesController.scala index 65dcf51..8c0c0f9 100644 --- a/src/main/scala/app/IssuesController.scala +++ b/src/main/scala/app/IssuesController.scala @@ -69,10 +69,15 @@ val issueId = params("issueId").toInt val content = params("content") // TODO input check - saveComment(owner, repository, context.loginAccount.get.userName, issueId, content) - contentType = formats("json") - org.json4s.jackson.Serialization.write(Map("content" -> content)) + saveComment(owner, repository, context.loginAccount.get.userName, issueId, content) map { + model => org.json4s.jackson.Serialization.write( + Map("commentedUserName" -> model.commentedUserName, + "registeredDate" -> view.helpers.datetime(model.registeredDate), + "content" -> view.Markdown.toHtml( + model.content, getRepository(owner, repository, baseUrl).get, false, true, true) + )) + } getOrElse "" }) } \ No newline at end of file diff --git a/src/main/scala/service/IssuesService.scala b/src/main/scala/service/IssuesService.scala index 67f23b0..161e82b 100644 --- a/src/main/scala/service/IssuesService.scala +++ b/src/main/scala/service/IssuesService.scala @@ -53,13 +53,15 @@ def saveComment(owner: String, repository: String, loginUser: String, issueId: Int, content: String) = - IssueComments.autoInc insert ( - owner, - repository, - issueId, - loginUser, - content, - currentDate, - currentDate) + Query(IssueComments) filter { + _.commentId is ( IssueComments.autoInc insert ( + owner, + repository, + issueId, + loginUser, + content, + currentDate, + currentDate) ).bind + } firstOption } \ No newline at end of file diff --git a/src/main/twirl/issues/issue.scala.html b/src/main/twirl/issues/issue.scala.html index 5e50d43..191e3a1 100644 --- a/src/main/twirl/issues/issue.scala.html +++ b/src/main/twirl/issues/issue.scala.html @@ -48,7 +48,14 @@ content : $('#content').val() }, function(data){ - $('#comment-area').html(data.content); + var div = $('
').addClass('box') + .append($('
').addClass('box-header-small') + .append($('').attr('href', '@path/@repository.owner').text(data.commentedUserName)) + .append(' commented') + .append($('').addClass('pull-right').text(data.registeredDate))) + .append($('
').addClass('box-content').attr('style', 'background-color: #f5f5f5;').html(data.content)); + $('#comment-area').append(div); + $('#content').val(''); }); }); });