From 88b76c94c74f44c7d4a6d232b1a644664ced563f Mon Sep 17 00:00:00 2001 From: Michael Ru Date: Tue, 22 Jul 2008 10:24:53 +0000 Subject: [PATCH] - improved search bar - discussions now show real user names and avatars (wip) git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@9969 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261 --- .../forum/forum-posts-hot.get.json.ftl | 5 +- .../forum/forum-posts-mine.get.json.ftl | 4 +- .../forum/forum-posts-new.get.json.ftl | 4 +- .../forum/forum-posts.get.json.ftl | 5 +- .../discussions/forum/forum-posts.post.js | 4 +- .../forum/forum-posts.post.json.ftl | 6 +- .../repository/discussions/post.lib.ftl | 153 ++++++++++-------- .../posts/forum-post-replies.get.js | 3 +- .../posts/forum-post-replies.post.js | 6 +- .../posts/forum-post-replies.post.json.ftl | 4 +- .../discussions/posts/forum-post.get.js | 4 +- .../discussions/posts/forum-post.get.json.ftl | 9 +- .../discussions/posts/forum-post.put.js | 10 +- .../discussions/posts/forum-post.put.json.ftl | 9 +- .../repository/discussions/topicpost.lib.ftl | 23 --- .../repository/discussions/topicpost.lib.js | 27 +++- 16 files changed, 140 insertions(+), 136 deletions(-) delete mode 100644 config/alfresco/templates/webscripts/org/alfresco/repository/discussions/topicpost.lib.ftl diff --git a/config/alfresco/templates/webscripts/org/alfresco/repository/discussions/forum/forum-posts-hot.get.json.ftl b/config/alfresco/templates/webscripts/org/alfresco/repository/discussions/forum/forum-posts-hot.get.json.ftl index 43a17d7777..55bbde4085 100644 --- a/config/alfresco/templates/webscripts/org/alfresco/repository/discussions/forum/forum-posts-hot.get.json.ftl +++ b/config/alfresco/templates/webscripts/org/alfresco/repository/discussions/forum/forum-posts-hot.get.json.ftl @@ -1,5 +1,6 @@ -<#import "../topicpost.lib.ftl" as topicpostLib/> +<#import "../post.lib.ftl" as postLib/> <#import "../../generic-paged-results.lib.ftl" as gen/> <@gen.pagedResults data=data ; item> - <@topicpostLib.topicpostJSON item=item /> + <@postLib.postJSON postData=item /> + diff --git a/config/alfresco/templates/webscripts/org/alfresco/repository/discussions/forum/forum-posts-mine.get.json.ftl b/config/alfresco/templates/webscripts/org/alfresco/repository/discussions/forum/forum-posts-mine.get.json.ftl index 43a17d7777..f940739f6c 100644 --- a/config/alfresco/templates/webscripts/org/alfresco/repository/discussions/forum/forum-posts-mine.get.json.ftl +++ b/config/alfresco/templates/webscripts/org/alfresco/repository/discussions/forum/forum-posts-mine.get.json.ftl @@ -1,5 +1,5 @@ -<#import "../topicpost.lib.ftl" as topicpostLib/> +<#import "../post.lib.ftl" as postLib/> <#import "../../generic-paged-results.lib.ftl" as gen/> <@gen.pagedResults data=data ; item> - <@topicpostLib.topicpostJSON item=item /> + <@postLib.postJSON postData=item /> diff --git a/config/alfresco/templates/webscripts/org/alfresco/repository/discussions/forum/forum-posts-new.get.json.ftl b/config/alfresco/templates/webscripts/org/alfresco/repository/discussions/forum/forum-posts-new.get.json.ftl index 43a17d7777..f940739f6c 100644 --- a/config/alfresco/templates/webscripts/org/alfresco/repository/discussions/forum/forum-posts-new.get.json.ftl +++ b/config/alfresco/templates/webscripts/org/alfresco/repository/discussions/forum/forum-posts-new.get.json.ftl @@ -1,5 +1,5 @@ -<#import "../topicpost.lib.ftl" as topicpostLib/> +<#import "../post.lib.ftl" as postLib/> <#import "../../generic-paged-results.lib.ftl" as gen/> <@gen.pagedResults data=data ; item> - <@topicpostLib.topicpostJSON item=item /> + <@postLib.postJSON postData=item /> diff --git a/config/alfresco/templates/webscripts/org/alfresco/repository/discussions/forum/forum-posts.get.json.ftl b/config/alfresco/templates/webscripts/org/alfresco/repository/discussions/forum/forum-posts.get.json.ftl index 43a17d7777..55bbde4085 100644 --- a/config/alfresco/templates/webscripts/org/alfresco/repository/discussions/forum/forum-posts.get.json.ftl +++ b/config/alfresco/templates/webscripts/org/alfresco/repository/discussions/forum/forum-posts.get.json.ftl @@ -1,5 +1,6 @@ -<#import "../topicpost.lib.ftl" as topicpostLib/> +<#import "../post.lib.ftl" as postLib/> <#import "../../generic-paged-results.lib.ftl" as gen/> <@gen.pagedResults data=data ; item> - <@topicpostLib.topicpostJSON item=item /> + <@postLib.postJSON postData=item /> + diff --git a/config/alfresco/templates/webscripts/org/alfresco/repository/discussions/forum/forum-posts.post.js b/config/alfresco/templates/webscripts/org/alfresco/repository/discussions/forum/forum-posts.post.js index 97c9b5a333..93ee49c2d9 100644 --- a/config/alfresco/templates/webscripts/org/alfresco/repository/discussions/forum/forum-posts.post.js +++ b/config/alfresco/templates/webscripts/org/alfresco/repository/discussions/forum/forum-posts.post.js @@ -76,7 +76,7 @@ function main() var topicPost = createPost(node); - model.topicpost = getTopicPostData(topicPost); + model.postData = getTopicPostData(topicPost); // post an activitiy item, but only if we got a site if (url.templateArgs.site != null) @@ -84,7 +84,7 @@ function main() var browseTopicUrl = '/page/site/' + url.templateArgs.site + '/discussions-postview?container=' + url.templateArgs.container + + '&path=' + url.templateArgs.path + '&postId=' + topicPost.name; var data = { - title: model.topicpost.post.properties.title, + title: model.postData.post.properties.title, browseTopicUrl: browseTopicUrl } activities.postActivity("org.alfresco.discussions.post-created", url.templateArgs.site, url.templateArgs.container, jsonUtils.toJSONString(data)); diff --git a/config/alfresco/templates/webscripts/org/alfresco/repository/discussions/forum/forum-posts.post.json.ftl b/config/alfresco/templates/webscripts/org/alfresco/repository/discussions/forum/forum-posts.post.json.ftl index d6babedd8c..a3cd1be869 100644 --- a/config/alfresco/templates/webscripts/org/alfresco/repository/discussions/forum/forum-posts.post.json.ftl +++ b/config/alfresco/templates/webscripts/org/alfresco/repository/discussions/forum/forum-posts.post.json.ftl @@ -1,4 +1,4 @@ -<#import "../topicpost.lib.ftl" as topicpostLib/> +<#import "../post.lib.ftl" as postLib /> { - "item" : <@topicpostLib.topicpostJSON item=topicpost/> -} + "item": <@postLib.postJSON postData=postData /> +} \ No newline at end of file diff --git a/config/alfresco/templates/webscripts/org/alfresco/repository/discussions/post.lib.ftl b/config/alfresco/templates/webscripts/org/alfresco/repository/discussions/post.lib.ftl index a2f66b5206..11d6da31e3 100644 --- a/config/alfresco/templates/webscripts/org/alfresco/repository/discussions/post.lib.ftl +++ b/config/alfresco/templates/webscripts/org/alfresco/repository/discussions/post.lib.ftl @@ -1,89 +1,108 @@ -<#-- +<#-- Renders a person object. --> +<#macro renderPerson person fieldName> + "${fieldName}" : { + <#if person.assocs["cm:avatar"]??> + "avatarRef" : "${person.assocs["cm:avatar"][0].nodeRef?string}", + + "username" : "${person.properties["cm:userName"]}", + "firstName" : "${person.properties["cm:firstName"]}", + "lastName" : "${person.properties["cm:lastName"]}" + }, + - This template renders a post. +<#macro renderTags tags> +[<#list tags as x>"${x?j_string}"<#if x_has_next>, ] + ---> -<#macro postJSON post> +<#macro addContent post> + <#assign maxTextLength=512> + <#if (! contentFormat??) || contentFormat == "" || contentFormat == "full"> + "content" : "${post.content?j_string}", + <#elseif contentFormat == "htmlDigest"> + <#if (post.content?length > maxTextLength)> + "content" : "${post.content?substring(0, maxTextLength)?j_string}", + <#else> + "content" : "${post.content?j_string}", + + <#elseif contentFormat == "textDigest"> + <#assign croppedTextContent=cropContent(post.properties.content, maxTextLength)> + "content" : "${croppedTextContent?j_string}", + <#else> + <#-- no content returned --> + + + +<#macro postJSON postData> { - <@postDataJSON refNode=post post=post/> + <@postDataJSON postData=postData /> } -<#-- Adds a modified date property if the creation date and modification - date differ of more 1 minute. ---> +<#macro postDataJSON postData> + <#-- which node should be used for urls? which for the post data? --> + <#if postData.isTopicPost> + <#assign refNode=postData.topic /> + <#else> + <#assign refNode=postData.post /> + + + <#assign post=postData.post /> -<#-- + <#-- render topic post only data first --> + <#if postData.isTopicPost> + "name" : "${postData.topic.name?js_string}", + "totalReplyCount" : ${postData.totalReplyCount?c}, + <#if postData.lastReply??> + "lastReplyOn" : "${postData.lastReply.properties.created?string("MMM dd yyyy HH:mm:ss 'GMT'Z '('zzz')'")}", + <@renderPerson person=postData.lastReplyBy fieldName="lastReplyBy" /> + + "tags" : <@renderTags tags=postData.tags />, + -<#macro addModifiedDate post> -<#assign min_difference=60000> -<#if post.properties.modified?? && post.properties.modified.time < 100000000 > - <#- - && ((post.properties.modified.getTime() - post.properties.created.getTime()) < min_difference)> - -> - "modifiedOn" : "${post.properties.modified?string("MMM dd yyyy HH:mm:ss 'GMT'Z '('zzz')'")}", - - - -<@addModifiedDate post=post /> - ---> - -<#macro addContent post> - <#assign maxTextLength=512> - <#if (! contentFormat??) || contentFormat == "" || contentFormat == "full"> - "content" : "${post.content?j_string}", - <#elseif contentFormat == "htmlDigest"> - <#if (post.content?length > maxTextLength)> - "content" : "${post.content?substring(0, maxTextLength)?j_string}", - <#else> - "content" : "${post.content?j_string}", - - <#elseif contentFormat == "textDigest"> - <#assign croppedTextContent=cropContent(post.properties.content, maxTextLength)> - "content" : "${croppedTextContent?j_string}", - <#else> - <#-- no content returned --> - - - - -<#macro postDataJSON refNode post> - <#-- data using refNode which might be the topic or the post node --> - "url" : "/forum/post/node/${refNode.nodeRef.storeRef.protocol}/${refNode.nodeRef.storeRef.identifier}/${refNode.nodeRef.id}", - "repliesUrl" : "/forum/post/node/${refNode.nodeRef.storeRef.protocol}/${refNode.nodeRef.storeRef.identifier}/${refNode.nodeRef.id}/replies", - "nodeRef" : "${refNode.nodeRef?j_string}", - <#-- normal data, the post node will used to fetch it --> - "title" : "${(post.properties.title!"")?j_string}", - "createdOn" : "${post.properties.created?string("MMM dd yyyy HH:mm:ss 'GMT'Z '('zzz')'")}", - "modifiedOn" : "${post.properties.modified?string("MMM dd yyyy HH:mm:ss 'GMT'Z '('zzz')'")}", - "author" : "${post.properties.creator?j_string}", - "isUpdated" : ${post.hasAspect("cm:contentupdated")?string}, - <#if (post.hasAspect("cm:contentupdated"))> - "updatedOn" : "${post.properties["cm:contentupdatedate"]?string("MMM dd yyyy HH:mm:ss 'GMT'Z '('zzz')'")}", - - <@addContent post=post /> - "replyCount" : <#if post.sourceAssocs["cm:references"]??>${post.sourceAssocs["cm:references"]?size?c}<#else>0, - "permissions" : { "edit": true, "delete" : true, "reply" : true } + <#-- data using refNode which might be the topic or the post node --> + "url" : "/forum/post/node/${refNode.nodeRef.storeRef.protocol}/${refNode.nodeRef.storeRef.identifier}/${refNode.nodeRef.id}", + "repliesUrl" : "/forum/post/node/${refNode.nodeRef.storeRef.protocol}/${refNode.nodeRef.storeRef.identifier}/${refNode.nodeRef.id}/replies", + "nodeRef" : "${refNode.nodeRef?j_string}", + + <#-- normal data, the post node will used to fetch it --> + "title" : "${(post.properties.title!"")?j_string}", + "createdOn" : "${post.properties.created?string("MMM dd yyyy HH:mm:ss 'GMT'Z '('zzz')'")}", + "modifiedOn" : "${post.properties.modified?string("MMM dd yyyy HH:mm:ss 'GMT'Z '('zzz')'")}", + "isUpdated" : ${post.hasAspect("cm:contentupdated")?string}, + <#if (post.hasAspect("cm:contentupdated"))> + "updatedOn" : "${post.properties["cm:contentupdatedate"]?string("MMM dd yyyy HH:mm:ss 'GMT'Z '('zzz')'")}", + + <#if postData.author??> + <@renderPerson person=postData.author fieldName="author" /> + <#else> + "author" : { + "username" : "${post.properties["cm:creator"]}" + }, + + <@addContent post=post /> + "replyCount" : <#if post.sourceAssocs["cm:references"]??>${post.sourceAssocs["cm:references"]?size?c}<#else>0, + "permissions" : { "edit": true, "delete" : true, "reply" : true } <#-- Renders replies. - The difference is to a normal post is that the children might be - added inline in the returned JSON. + The difference is to a normal post is that the children might be + added inline in the returned JSON. --> <#macro repliesJSON data> { - <@postDataJSON refNode=data.post post=data.post /> - <#if data.children?exists> - , "children": <@repliesRootJSON children=data.children /> - + <@postDataJSON postData=data /> + <#if data.children?exists> + , "children": <@repliesRootJSON children=data.children /> + } <#macro repliesRootJSON children> [ - <#list children as child> - <@repliesJSON data=child/> - <#if child_has_next>, - + <#list children as child> + <@repliesJSON data=child/> + <#if child_has_next>, + ] diff --git a/config/alfresco/templates/webscripts/org/alfresco/repository/discussions/posts/forum-post-replies.get.js b/config/alfresco/templates/webscripts/org/alfresco/repository/discussions/posts/forum-post-replies.get.js index ded1e3b701..6c0ef29711 100644 --- a/config/alfresco/templates/webscripts/org/alfresco/repository/discussions/posts/forum-post-replies.get.js +++ b/config/alfresco/templates/webscripts/org/alfresco/repository/discussions/posts/forum-post-replies.get.js @@ -25,8 +25,7 @@ function getRepliesForPost(post) function getReplyDataRecursive(post, levels) { // encapsulates the data: node, childCount, children - var data = new Object(); - data.post = post; + var data = getReplyPostData(post); var children = getRepliesForPost(post); data.childCount = children.length; if (levels > 1) diff --git a/config/alfresco/templates/webscripts/org/alfresco/repository/discussions/posts/forum-post-replies.post.js b/config/alfresco/templates/webscripts/org/alfresco/repository/discussions/posts/forum-post-replies.post.js index 986efafaa8..4a3a7f9b5e 100644 --- a/config/alfresco/templates/webscripts/org/alfresco/repository/discussions/posts/forum-post-replies.post.js +++ b/config/alfresco/templates/webscripts/org/alfresco/repository/discussions/posts/forum-post-replies.post.js @@ -32,7 +32,7 @@ function createPostReplyImpl(topicNode, parentPostNode) postNode.createAssociation(parentPostNode, "cm:references"); postNode.save(); // probably not necessary here - return postNode; + return getReplyPostData(postNode); } /** @@ -72,13 +72,13 @@ function main() return; } - model.post = createPostReply(node); + model.postData = createPostReply(node); // add an activity item if (json.has("site")) { // fetch the topic (and with it the root post - var topicData = getTopicPostData(model.post.parent); + var topicData = getTopicPostData(model.postData.post.parent); var site = json.get("site"); var container = json.get("container"); var path = json.has("path") ? json.get("path") : ''; diff --git a/config/alfresco/templates/webscripts/org/alfresco/repository/discussions/posts/forum-post-replies.post.json.ftl b/config/alfresco/templates/webscripts/org/alfresco/repository/discussions/posts/forum-post-replies.post.json.ftl index 14dc4b4c6c..a3cd1be869 100644 --- a/config/alfresco/templates/webscripts/org/alfresco/repository/discussions/posts/forum-post-replies.post.json.ftl +++ b/config/alfresco/templates/webscripts/org/alfresco/repository/discussions/posts/forum-post-replies.post.json.ftl @@ -1,4 +1,4 @@ <#import "../post.lib.ftl" as postLib /> { - "item" : <@postLib.postJSON post=post /> -} + "item": <@postLib.postJSON postData=postData /> +} \ No newline at end of file diff --git a/config/alfresco/templates/webscripts/org/alfresco/repository/discussions/posts/forum-post.get.js b/config/alfresco/templates/webscripts/org/alfresco/repository/discussions/posts/forum-post.get.js index 0f9340b650..2bd9b90ad5 100644 --- a/config/alfresco/templates/webscripts/org/alfresco/repository/discussions/posts/forum-post.get.js +++ b/config/alfresco/templates/webscripts/org/alfresco/repository/discussions/posts/forum-post.get.js @@ -10,11 +10,11 @@ function fetchPostData(node) // only in the first case we fetch all information (as returned by forum/.../posts) if (node.type == "{http://www.alfresco.org/model/forum/1.0}topic") { - model.topicpost = getTopicPostData(node); + model.postData = getTopicPostData(node); } else if (node.type == "{http://www.alfresco.org/model/forum/1.0}post") { - model.post = node; + model.postData = getReplyPostData(node); } else { diff --git a/config/alfresco/templates/webscripts/org/alfresco/repository/discussions/posts/forum-post.get.json.ftl b/config/alfresco/templates/webscripts/org/alfresco/repository/discussions/posts/forum-post.get.json.ftl index 21c91f42a2..a3cd1be869 100644 --- a/config/alfresco/templates/webscripts/org/alfresco/repository/discussions/posts/forum-post.get.json.ftl +++ b/config/alfresco/templates/webscripts/org/alfresco/repository/discussions/posts/forum-post.get.json.ftl @@ -1,9 +1,4 @@ +<#import "../post.lib.ftl" as postLib /> { - <#if topicpost??> - <#import "../topicpost.lib.ftl" as topicpostLib /> - "item": <@topicpostLib.topicpostJSON item=topicpost /> - <#else> - <#import "../post.lib.ftl" as postLib /> - "item": <@postLib.postJSON post=post /> - + "item": <@postLib.postJSON postData=postData /> } \ No newline at end of file diff --git a/config/alfresco/templates/webscripts/org/alfresco/repository/discussions/posts/forum-post.put.js b/config/alfresco/templates/webscripts/org/alfresco/repository/discussions/posts/forum-post.put.js index 9e53166f8a..ca59525244 100644 --- a/config/alfresco/templates/webscripts/org/alfresco/repository/discussions/posts/forum-post.put.js +++ b/config/alfresco/templates/webscripts/org/alfresco/repository/discussions/posts/forum-post.put.js @@ -94,13 +94,13 @@ function main() // do another lucene search in case of a topic post if (topicNode == null) { - model.post = node; + model.postData = getReplyPostData(postNode); // add an activity item if (json.has("site")) { // fetch the topic (and with it the root post - var topicData = getTopicPostData(model.post.parent); + var topicData = getTopicPostData(model.postData.post.parent); var site = json.get("site"); var container = json.get("container"); var path = json.has("path") ? json.get("path") : ''; @@ -118,15 +118,15 @@ function main() // we will do the search here as we have to reuse the lucene result later // See above, use getTopicPostDataFromTopicAndPosts instead of getTopicPostData //model.topicpost = getTopicPostData(node); - model.topicpost = getTopicPostDataFromTopicAndPosts(topicNode, nodes); + model.postData = getTopicPostDataFromTopicAndPosts(topicNode, nodes); // post an activitiy item, but only if we got a site if (url.templateArgs.site != null) { var browseTopicUrl = '/page/site/' + url.templateArgs.site + '/discussions-topicview?container=' + url.templateArgs.container + - + '&path=' + url.templateArgs.path + '&postId=' + model.topicpost.topic.name; + + '&path=' + url.templateArgs.path + '&postId=' + model.postData.topic.name; var data = { - title: model.topicpost.post.properties.title, + title: model.postData.post.properties.title, browseTopicUrl: browseTopicUrl } activities.postActivity("org.alfresco.discussions.post-updated", url.templateArgs.site, url.templateArgs.container, jsonUtils.toJSONString(data)); diff --git a/config/alfresco/templates/webscripts/org/alfresco/repository/discussions/posts/forum-post.put.json.ftl b/config/alfresco/templates/webscripts/org/alfresco/repository/discussions/posts/forum-post.put.json.ftl index 21c91f42a2..a3cd1be869 100644 --- a/config/alfresco/templates/webscripts/org/alfresco/repository/discussions/posts/forum-post.put.json.ftl +++ b/config/alfresco/templates/webscripts/org/alfresco/repository/discussions/posts/forum-post.put.json.ftl @@ -1,9 +1,4 @@ +<#import "../post.lib.ftl" as postLib /> { - <#if topicpost??> - <#import "../topicpost.lib.ftl" as topicpostLib /> - "item": <@topicpostLib.topicpostJSON item=topicpost /> - <#else> - <#import "../post.lib.ftl" as postLib /> - "item": <@postLib.postJSON post=post /> - + "item": <@postLib.postJSON postData=postData /> } \ No newline at end of file diff --git a/config/alfresco/templates/webscripts/org/alfresco/repository/discussions/topicpost.lib.ftl b/config/alfresco/templates/webscripts/org/alfresco/repository/discussions/topicpost.lib.ftl deleted file mode 100644 index 156f880812..0000000000 --- a/config/alfresco/templates/webscripts/org/alfresco/repository/discussions/topicpost.lib.ftl +++ /dev/null @@ -1,23 +0,0 @@ -<#import "post.lib.ftl" as postLib/> - -<#macro renderTags tags> -[<#list tags as x>"${x?j_string}"<#if x_has_next>, ] - - -<#-- - - This template renders a post. - ---> -<#macro topicpostJSON item> -{ - "name" : "${item.topic.name?js_string}", - "totalReplyCount" : ${item.totalReplyCount?c}, - <#if item.lastReply??> - "lastReplyBy" : "${item.lastReply.properties.creator}", - "lastReplyOn" : "${item.lastReply.properties.created?string("MMM dd yyyy HH:mm:ss 'GMT'Z '('zzz')'")}", - - "tags" : <@renderTags tags=item.tags />, - <@postLib.postDataJSON refNode=item.topic post=item.post /> -} - \ No newline at end of file diff --git a/config/alfresco/templates/webscripts/org/alfresco/repository/discussions/topicpost.lib.js b/config/alfresco/templates/webscripts/org/alfresco/repository/discussions/topicpost.lib.js index d9e273ce77..7f0535dfe3 100644 --- a/config/alfresco/templates/webscripts/org/alfresco/repository/discussions/topicpost.lib.js +++ b/config/alfresco/templates/webscripts/org/alfresco/repository/discussions/topicpost.lib.js @@ -42,10 +42,8 @@ function getOrderedPosts(topic) } /* - * This method encapsulates a topic object into a JavaScript object with the following properties - * node: The topic node - * content: The topic text - * replyCount: The number of replies + * Returns a JavaScript object that is used by the freemarker template + * to render a topic post */ function getTopicPostData(topicNode) { @@ -55,6 +53,10 @@ function getTopicPostData(topicNode) return getTopicPostDataFromTopicAndPosts(topicNode, posts); } +/* + * Returns a JavaScript object that is used by the freemarker template + * to render a topic post + */ function getTopicPostDataFromTopicAndPosts(topicNode, posts) { // check the first post (which is the main post) @@ -64,16 +66,19 @@ function getTopicPostDataFromTopicAndPosts(topicNode, posts) return; } - var item = new Object(); + var item = {}; // fetch the data + item.isTopicPost = true; item.topic = topicNode; item.post = posts[0]; + item.author = people.getPerson(item.post.properties["cm:creator"]); item.totalReplyCount = posts.length - 1; // in case of replies, find the last reply if (posts.length > 1) { item.lastReply = posts[posts.length - 1]; + item.lastReplyBy = people.getPerson(item.lastReply.properties["cm:creator"]); } // tags @@ -88,3 +93,15 @@ function getTopicPostDataFromTopicAndPosts(topicNode, posts) return item; } + +/** + * Returns the data object that is used by the freemarker template to render a reply post + */ +function getReplyPostData(post) +{ + var item = {}; + item.isTopicPost = false; + item.post = post; + item.author = people.getPerson(item.post.properties["cm:creator"]); + return item; +}