mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-31 17:39:05 +00:00
- 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
This commit is contained in:
@@ -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 />
|
||||
</@gen.pagedResults>
|
||||
|
||||
|
@@ -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 />
|
||||
</@gen.pagedResults>
|
||||
|
@@ -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 />
|
||||
</@gen.pagedResults>
|
||||
|
@@ -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 />
|
||||
</@gen.pagedResults>
|
||||
|
||||
|
@@ -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));
|
||||
|
@@ -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 />
|
||||
}
|
@@ -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}",
|
||||
</#if>
|
||||
"username" : "${person.properties["cm:userName"]}",
|
||||
"firstName" : "${person.properties["cm:firstName"]}",
|
||||
"lastName" : "${person.properties["cm:lastName"]}"
|
||||
},
|
||||
</#macro>
|
||||
|
||||
This template renders a post.
|
||||
<#macro renderTags tags>
|
||||
[<#list tags as x>"${x?j_string}"<#if x_has_next>, </#if></#list>]
|
||||
</#macro>
|
||||
|
||||
-->
|
||||
<#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}",
|
||||
</#if>
|
||||
<#elseif contentFormat == "textDigest">
|
||||
<#assign croppedTextContent=cropContent(post.properties.content, maxTextLength)>
|
||||
"content" : "${croppedTextContent?j_string}",
|
||||
<#else>
|
||||
<#-- no content returned -->
|
||||
</#if>
|
||||
</#macro>
|
||||
|
||||
<#macro postJSON postData>
|
||||
{
|
||||
<@postDataJSON refNode=post post=post/>
|
||||
<@postDataJSON postData=postData />
|
||||
}
|
||||
</#macro>
|
||||
|
||||
<#-- 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 />
|
||||
</#if>
|
||||
|
||||
<#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" />
|
||||
</#if>
|
||||
"tags" : <@renderTags tags=postData.tags />,
|
||||
</#if>
|
||||
|
||||
<#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')'")}",
|
||||
</#if>
|
||||
</#macro>
|
||||
|
||||
<@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}",
|
||||
</#if>
|
||||
<#elseif contentFormat == "textDigest">
|
||||
<#assign croppedTextContent=cropContent(post.properties.content, maxTextLength)>
|
||||
"content" : "${croppedTextContent?j_string}",
|
||||
<#else>
|
||||
<#-- no content returned -->
|
||||
</#if>
|
||||
</#macro>
|
||||
|
||||
|
||||
<#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')'")}",
|
||||
</#if>
|
||||
<@addContent post=post />
|
||||
"replyCount" : <#if post.sourceAssocs["cm:references"]??>${post.sourceAssocs["cm:references"]?size?c}<#else>0</#if>,
|
||||
"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>
|
||||
<#if postData.author??>
|
||||
<@renderPerson person=postData.author fieldName="author" />
|
||||
<#else>
|
||||
"author" : {
|
||||
"username" : "${post.properties["cm:creator"]}"
|
||||
},
|
||||
</#if>
|
||||
<@addContent post=post />
|
||||
"replyCount" : <#if post.sourceAssocs["cm:references"]??>${post.sourceAssocs["cm:references"]?size?c}<#else>0</#if>,
|
||||
"permissions" : { "edit": true, "delete" : true, "reply" : true }
|
||||
</#macro>
|
||||
|
||||
|
||||
<#-- 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 />
|
||||
</#if>
|
||||
<@postDataJSON postData=data />
|
||||
<#if data.children?exists>
|
||||
, "children": <@repliesRootJSON children=data.children />
|
||||
</#if>
|
||||
}
|
||||
</#macro>
|
||||
|
||||
<#macro repliesRootJSON children>
|
||||
[
|
||||
<#list children as child>
|
||||
<@repliesJSON data=child/>
|
||||
<#if child_has_next>,</#if>
|
||||
</#list>
|
||||
<#list children as child>
|
||||
<@repliesJSON data=child/>
|
||||
<#if child_has_next>,</#if>
|
||||
</#list>
|
||||
]
|
||||
</#macro>
|
||||
|
@@ -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)
|
||||
|
@@ -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") : '';
|
||||
|
@@ -1,4 +1,4 @@
|
||||
<#import "../post.lib.ftl" as postLib />
|
||||
{
|
||||
"item" : <@postLib.postJSON post=post />
|
||||
}
|
||||
"item": <@postLib.postJSON postData=postData />
|
||||
}
|
@@ -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
|
||||
{
|
||||
|
@@ -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 />
|
||||
</#if>
|
||||
"item": <@postLib.postJSON postData=postData />
|
||||
}
|
@@ -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));
|
||||
|
@@ -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 />
|
||||
</#if>
|
||||
"item": <@postLib.postJSON postData=postData />
|
||||
}
|
@@ -1,23 +0,0 @@
|
||||
<#import "post.lib.ftl" as postLib/>
|
||||
|
||||
<#macro renderTags tags>
|
||||
[<#list tags as x>"${x?j_string}"<#if x_has_next>, </#if></#list>]
|
||||
</#macro>
|
||||
|
||||
<#--
|
||||
|
||||
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')'")}",
|
||||
</#if>
|
||||
"tags" : <@renderTags tags=item.tags />,
|
||||
<@postLib.postDataJSON refNode=item.topic post=item.post />
|
||||
}
|
||||
</#macro>
|
@@ -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;
|
||||
}
|
||||
|
Reference in New Issue
Block a user