Skip to content

Commit

Permalink
Finished implementing comments timeline and feed [#10 state:resolved]
Browse files Browse the repository at this point in the history
  • Loading branch information
dima767 committed Sep 16, 2008
1 parent 371917e commit e8fcf89
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 5 deletions.
34 changes: 29 additions & 5 deletions grails-app/controllers/CommentController.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,37 @@ class CommentController {
def allowedMethods = [feed: 'GET', list: 'GET']

def list = {
params.order = 'desc'
def total = Comment.count()
def comments = Comment.listOrderByDateCreated(params)
[comments: comments, paginatingController: controllerName, paginatingAction: actionName, total: total]
withComments {
[comments: it, paginatingController: controllerName, paginatingAction: actionName, total: Comment.count()]
}
}

def feed = {
//TODO
withComments {comments ->
render(feedType: "atom") {
title = "Grails Crowd project comments"
description = "Comments across all projects registered on Grails Crowd"
link = createLink(controller: "comment", action: "feed")

comments.each() {comment ->
entry {
title = "A comment for project ${comment.project.name} has been submitted on ${g.niceDate(date:comment.dateCreated)}"
link = createLink(controller: "grailsProject", action: "viewProject", id: comment.project.id)
author = comment.member.displayName
publishedDate = comment.dateCreated
content {
comment.body?.encodeAsTextile()
}
}
}
} //render
} //withComments
}

private withComments(callable) {
params.order = 'desc'
def comments = Comment.listOrderByDateCreated(params)
callable(comments)
}

}
1 change: 1 addition & 0 deletions grails-app/views/comment/list.gsp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
<head>
<title>Comments timeline</title>
<meta name="layout" content="grailscrowd" />
<feed:meta kind="atom" version="1.0" controller="comment" action="feed" />
</head>


Expand Down

0 comments on commit e8fcf89

Please sign in to comment.