- Moved creation of activities urls for blog/discussions from the REST api to the client side

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@9992 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Michael Ru
2008-07-23 13:37:41 +00:00
parent e3c9b02d37
commit f11972f381
23 changed files with 91 additions and 104 deletions

View File

@@ -3,12 +3,12 @@
<#assign username = firstName + " " + lastName>
</#if>
<entry xmlns='http://www.w3.org/2005/Atom'>
<title>New blog post: ${title!'unknown'}</title>
<title>New blog post: ${postTitle!'unknown'}</title>
<link rel="alternate" type="text/html" href="${(browsePostUrl!'')?replace("&", "&amp;")}" />
<id>${id}</id>
<updated>${xmldate(date)}</updated>
<summary type="html">
<![CDATA[${username} added blog post <a href="${(browsePostUrl!'')}">${title!'unknown'}</a>.]]>
<![CDATA[${username} added blog post <a href="${(browsePostUrl!'')}">${postTitle!'unknown'}</a>.]]>
</summary>
<author>
<name>${userId!""}</name>

View File

@@ -3,9 +3,9 @@
<#assign username = firstName + " " + lastName>
</#if>
<item>
<title>New blog post: ${title!"unknown"}</title>
<title>New blog post: ${postTitle!"unknown"}</title>
<link>${(browsePostUrl!'')?replace("&", "&amp;")}</link>
<guid>${id}</guid>
<description>${username} added blog post ${title!'unknown'}.</description>
<description>${username} added blog post ${postTitle!'unknown'}.</description>
</item>

View File

@@ -3,12 +3,12 @@
<#assign username = firstName + " " + lastName>
</#if>
<entry xmlns='http://www.w3.org/2005/Atom'>
<title>Blog post deleted: ${title!'unknown'}</title>
<title>Blog post deleted: ${postTitle!'unknown'}</title>
<link rel="alternate" type="text/html" href="${(browsePostListUrl!'')?replace("&", "&amp;")}" />
<id>${id}</id>
<updated>${xmldate(date)}</updated>
<summary type="html">
<![CDATA[${username} deleted blog post ${title}.]]>
<![CDATA[${username} deleted blog post ${postTitle}.]]>
</summary>
<author>
<name>${userId!""}</name>

View File

@@ -3,9 +3,8 @@
<#assign username = firstName + " " + lastName>
</#if>
<item>
<title>Blog post deleted: ${title!"unknown"}</title>
<link>${(browsePostListURL!'')?replace("&", "&amp;")}</link>
<title>Blog post deleted: ${postTitle!"unknown"}</title>
<guid>${id}</guid>
<description>${username} deleted blog post ${title}.</description>
<description>${username} deleted blog post ${postTitle}.</description>
</item>

View File

@@ -3,12 +3,12 @@
<#assign username = firstName + " " + lastName>
</#if>
<entry xmlns='http://www.w3.org/2005/Atom'>
<title>Blog post updated: ${title!'unknown'}</title>
<title>Blog post updated: ${postTitle!'unknown'}</title>
<link rel="alternate" type="text/html" href="${(browsePostUrl!'')?replace("&", "&amp;")}" />
<id>${id}</id>
<updated>${xmldate(date)}</updated>
<summary type="html">
<![CDATA[${username} updated blog post <a href="${(browsePostUrl!'')}">${title}</a>.]]>
<![CDATA[${username} updated blog post <a href="${(browsePostUrl!'')}">${postTitle}</a>.]]>
</summary>
<author>
<name>${userId!""}</name>

View File

@@ -3,9 +3,9 @@
<#assign username = firstName + " " + lastName>
</#if>
<item>
<title>Blog post updated: ${title!"unknown"}</title>
<title>Blog post updated: ${postTitle!"unknown"}</title>
<link>${(browsePostUrl!'')?replace("&", "&amp;")}</link>
<guid>${id}</guid>
<description>${username} updated blog post ${title}.</description>
<description>${username} updated blog post ${postTitle}.</description>
</item>

View File

@@ -3,12 +3,12 @@
<#assign username = firstName + " " + lastName>
</#if>
<entry xmlns='http://www.w3.org/2005/Atom'>
<title>New discussion: ${title!'unknown'}</title>
<title>New discussion: ${topicTitle!'unknown'}</title>
<link rel="alternate" type="text/html" href="${(browseTopicUrl!'')?replace("&", "&amp;")}" />
<id>${id}</id>
<updated>${xmldate(date)}</updated>
<summary type="html">
<![CDATA[${username} added topic <a href="${(browseTopicUrl!'')}">${title!'unknown'}</a>.]]>
<![CDATA[${username} added topic <a href="${(browseTopicUrl!'')}">${topicTitle!'unknown'}</a>.]]>
</summary>
<author>
<name>${userId!""}</name>

View File

@@ -3,9 +3,9 @@
<#assign username = firstName + " " + lastName>
</#if>
<item>
<title>New discussion: ${title!"unknown"}</title>
<title>New discussion: ${topicTitle!"unknown"}</title>
<link>${(browseTopicUrl!'')?replace("&", "&amp;")}</link>
<guid>${id}</guid>
<description>${username} added topic ${title!'unknown'}.</description>
<description>${username} added topic ${topicTitle!'unknown'}.</description>
</item>

View File

@@ -3,12 +3,11 @@
<#assign username = firstName + " " + lastName>
</#if>
<entry xmlns='http://www.w3.org/2005/Atom'>
<title>Discussion topic deleted: ${title!'unknown'}</title>
<link rel="alternate" type="text/html" href="${(browseTopicListUrl!'')?replace("&", "&amp;")}" />
<title>Discussion topic deleted: ${topicTitle!'unknown'}</title>
<id>${id}</id>
<updated>${xmldate(date)}</updated>
<summary type="html">
<![CDATA[${username} deleted topic ${title!'unknown'}.]]>
<![CDATA[${username} deleted topic ${topicTitle!'unknown'}.]]>
</summary>
<author>
<name>${userId!""}</name>

View File

@@ -3,9 +3,8 @@
<#assign username = firstName + " " + lastName>
</#if>
<item>
<title>Discussion topic deleted: ${title!"unknown"}</title>
<link>${(browseTopicListURL!'')?replace("&", "&amp;")}</link>
<title>Discussion topic deleted: ${topicTitle!"unknown"}</title>
<guid>${id}</guid>
<description>${username} deleted topic ${title!'unknown'}.</description>
<description>${username} deleted topic ${topicTitle!'unknown'}.</description>
</item>

View File

@@ -3,12 +3,12 @@
<#assign username = firstName + " " + lastName>
</#if>
<entry xmlns='http://www.w3.org/2005/Atom'>
<title>Discussion topic updated: ${title!'unknown'}</title>
<title>Discussion topic updated: ${topicTitle!'unknown'}</title>
<link rel="alternate" type="text/html" href="${(browseTopicUrl!'')?replace("&", "&amp;")}" />
<id>${id}</id>
<updated>${xmldate(date)}</updated>
<summary type="html">
<![CDATA[${username} updated topic <a href="${(browseTopicUrl!'')}">${title!'unknown'}</a>.]]>
<![CDATA[${username} updated topic <a href="${(browseTopicUrl!'')}">${topicTitle!'unknown'}</a>.]]>
</summary>
<author>
<name>${userId!""}</name>

View File

@@ -3,9 +3,9 @@
<#assign username = firstName + " " + lastName>
</#if>
<item>
<title>Discussion topic updated: ${title!"unknown"}</title>
<title>Discussion topic updated: ${topicTitle!"unknown"}</title>
<link>${(browseTopicUrl!'')?replace("&", "&amp;")}</link>
<guid>${id}</guid>
<description>${username} updated topic '${title!'unknown'}'.</description>
<description>${username} updated topic '${topicTitle!'unknown'}'.</description>
</item>

View File

@@ -3,12 +3,12 @@
<#assign username = firstName + " " + lastName>
</#if>
<entry xmlns='http://www.w3.org/2005/Atom'>
<title>Reply added: ${title!'unknown'}</title>
<title>Reply added: ${topicTitle!'unknown'}</title>
<link rel="alternate" type="text/html" href="${(browseTopicUrl!'')?replace("&", "&amp;")}" />
<id>${id}</id>
<updated>${xmldate(date)}</updated>
<summary type="html">
<![CDATA[${username} added a reply to topic <a href="${(browseTopicUrl!'')}">${title!'unknown'}</a>.]]>
<![CDATA[${username} added a reply to topic <a href="${(browseTopicUrl!'')}">${topicTitle!'unknown'}</a>.]]>
</summary>
<author>
<name>${userId!""}</name>

View File

@@ -3,9 +3,9 @@
<#assign username = firstName + " " + lastName>
</#if>
<item>
<title>Reply added: ${title!"unknown"}</title>
<title>Reply added: ${topicTitle!"unknown"}</title>
<link>${(browseTopicUrl!'')?replace("&", "&amp;")}</link>
<guid>${id}</guid>
<description>${username} added a reply to topic '${title!'unknown'}'.</description>
<description>${username} added a reply to topic '${topicTitle!'unknown'}'.</description>
</item>

View File

@@ -3,12 +3,12 @@
<#assign username = firstName + " " + lastName>
</#if>
<entry xmlns='http://www.w3.org/2005/Atom'>
<title>Reply updated: ${title!'unknown'}</title>
<title>Reply updated: ${topicTitle!'unknown'}</title>
<link rel="alternate" type="text/html" href="${(browseTopicUrl!'')?replace("&", "&amp;")}" />
<id>${id}</id>
<updated>${xmldate(date)}</updated>
<summary type="html">
<![CDATA[${username} updated a reply of topic <a href="${(browseTopicUrl!'')}">${title!'unknown'}</a>.]]>
<![CDATA[${username} updated a reply of topic <a href="${(browseTopicUrl!'')}">${topicTitle!'unknown'}</a>.]]>
</summary>
<author>
<name>${userId!""}</name>

View File

@@ -3,9 +3,9 @@
<#assign username = firstName + " " + lastName>
</#if>
<item>
<title>Reply updated: ${title!"unknown"}</title>
<title>Reply updated: ${topicTitle!"unknown"}</title>
<link>${(browseTopicUrl!'')?replace("&", "&amp;")}</link>
<guid>${id}</guid>
<description>${username} updated a reply of topic '${title!'unknown'}'.</description>
<description>${username} updated a reply of topic '${topicTitle!'unknown'}'.</description>
</item>

View File

@@ -1,4 +1,5 @@
<import resource="classpath:alfresco/templates/webscripts/org/alfresco/repository/requestutils.lib.js">
<import resource="classpath:alfresco/templates/webscripts/org/alfresco/repository/blogs/blogpost.lib.js">
/**
* Deletes a blog post node.
@@ -25,20 +26,19 @@ function main()
return;
}
var item = getBlogPostData(node);
var title = node.properties.title;
var tags = node.properties.tags;
deleteBlogPost(node);
// post an activitiy item, but only if we got a site
if (url.templateArgs.site != null)
if (args["site"] != undefined && args["container"] != undefined && ! item.isDraft)
{
var browsePostListUrl = '/share/page/site/' + url.templateArgs.site + '/blog-postlist?container=' + url.templateArgs.container;
var data = {
title: title,
browsePostListUrl: browsePostListUrl
postTitle: title
}
activities.postActivity("org.alfresco.blog.post-deleted", url.templateArgs.site, url.templateArgs.container, jsonUtils.toJSONString(data));
activities.postActivity("org.alfresco.blog.post-deleted", args["site"], args["container"], jsonUtils.toJSONString(data));
}
}

View File

@@ -76,15 +76,15 @@ function main()
model.item = getBlogPostData(node);
// post an activitiy item, but only if we got a site
if (url.templateArgs.site != null && ! model.item.isDraft)
if (json.has("site") && json.has("container") && json.has("browsePostUrl") && ! model.item.isDraft)
{
var browsePostUrl = '/share/page/site/' + url.templateArgs.site + '/blog-topicview?container=' + url.templateArgs.container + '&postId=' + node.name;
var browsePostUrl = "" + json.get("browsePostUrl");
browsePostUrl = browsePostUrl.replace("{post.name}", model.item.node.properties.name);
var data = {
title: node.properties.title,
postTitle: model.item.node.properties.title,
browsePostUrl: browsePostUrl
}
activities.postActivity("org.alfresco.blog.post-updated", url.templateArgs.site, url.templateArgs.container, jsonUtils.toJSONString(data));
activities.postActivity("org.alfresco.blog.post-updated", json.get("site"), json.get("container"), jsonUtils.toJSONString(data));
}
}

View File

@@ -74,27 +74,27 @@ function createBlogPost(blogNode)
function main()
{
// get requested node
var node = getRequestNode();
if (status.getCode() != status.STATUS_OK)
{
return;
}
ensureTagScope(node);
var post = createBlogPost(node);
model.item = getBlogPostData(post);
// post an activitiy item, but only if we got a site
if (url.templateArgs.site != null && ! model.item.isDraft)
// get requested node
var node = getRequestNode();
if (status.getCode() != status.STATUS_OK)
{
var browsePostUrl = '/share/page/site/' + url.templateArgs.site + '/blog-postview?container=' + url.templateArgs.container + '&postId=' + post.name;
return;
}
ensureTagScope(node);
var post = createBlogPost(node);
model.item = getBlogPostData(post);
if (json.has("site") && json.has("container") && json.has("browsePostUrl") && ! model.item.isDraft)
{
var browsePostUrl = "" + json.get("browsePostUrl");
browsePostUrl = browsePostUrl.replace("{post.name}", model.item.node.properties.name);
var data = {
title: post.properties.title,
browsePostUrl: browsePostUrl
postTitle: model.item.node.properties.title,
browsePostUrl: browsePostUrl
}
activities.postActivity("org.alfresco.blog.post-created", url.templateArgs.site, url.templateArgs.container, jsonUtils.toJSONString(data));
activities.postActivity("org.alfresco.blog.post-created", json.get("site"), json.get("container"), jsonUtils.toJSONString(data));
}
}

View File

@@ -78,18 +78,17 @@ function main()
model.postData = getTopicPostData(topicPost);
// post an activitiy item, but only if we got a site
if (url.templateArgs.site != null)
// create an activity entry
if (json.has("site") && json.has("container") && json.has("browseTopicUrl"))
{
var browseTopicUrl = '/share/page/site/' + url.templateArgs.site + '/discussions-postview?container=' + url.templateArgs.container +
+ '&path=' + url.templateArgs.path + '&postId=' + topicPost.name;
var browseTopicUrl = "" + json.get("browseTopicUrl");
browseTopicUrl = browseTopicUrl.replace("{post.name}", model.postData.topic.name);
var data = {
title: model.postData.post.properties.title,
topicTitle: model.postData.post.properties.title,
browseTopicUrl: browseTopicUrl
}
activities.postActivity("org.alfresco.discussions.post-created", url.templateArgs.site, url.templateArgs.container, jsonUtils.toJSONString(data));
}
activities.postActivity("org.alfresco.discussions.post-created", json.get("site"), json.get("container"), jsonUtils.toJSONString(data));
}
}
main();

View File

@@ -75,20 +75,17 @@ function main()
model.postData = createPostReply(node);
// add an activity item
if (json.has("site"))
if (json.has("site") && json.has("container") && json.has("browseTopicUrl"))
{
// fetch the topic (and with it the root post
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") : '';
var browseTopicUrl = '/share/page/site/' + site + '/discussions-topicview?container=' + container +
+ '&path=' + path + '&postId=' + topicData.topic.name;
var topicData = getTopicPostData(model.postData.post.parent);
var browseTopicUrl = json.get("browseTopicUrl");
browseTopicUrl = browseTopicUrl.replace("{post.name}", topicData.topic.name);
var data = {
title: topicData.post.properties.title,
topicTitle: topicData.post.properties.title,
browseTopicUrl: browseTopicUrl
}
activities.postActivity("org.alfresco.discussions.reply-created", site, container, jsonUtils.toJSONString(data));
activities.postActivity("org.alfresco.discussions.reply-created", json.get("site"), json.get("container"), jsonUtils.toJSONString(data));
}
}

View File

@@ -10,7 +10,7 @@ function deleteTopicPost(topicNode)
{
// fetch the topic info as we need to get the title for the post for the activity
var data = getTopicPostData(topicNode);
var title = data.post.properties.title;
var topicTitle = data.post.properties.title;
// we simply delete the complete topic
var nodeRef = topicNode.nodeRef;
@@ -23,15 +23,12 @@ function deleteTopicPost(topicNode)
model.message = "Node " + nodeRef + " deleted";
// post an activitiy item, but only if we got a site
if (url.templateArgs.site != null)
if (args["site"] != undefined && args["container"] != undefined)
{
var browseTopicListUrl = '/share/page/site/' + url.templateArgs.site + '/discussions-topiclist?container=' + url.templateArgs.container +
+ '&path=' + url.templateArgs.path;
var data = {
browseTopicListUrl: browseTopicListUrl,
title: title
topicTitle: topicTitle
}
activities.postActivity("org.alfresco.discussions.post-deleted", url.templateArgs.site, url.templateArgs.container, jsonUtils.toJSONString(data));
activities.postActivity("org.alfresco.discussions.post-deleted", args["site"], args["container"], jsonUtils.toJSONString(data));
}
}

View File

@@ -97,20 +97,16 @@ function main()
model.postData = getReplyPostData(postNode);
// add an activity item
if (json.has("site"))
if (json.has("site") && json.has("container") && json.has("browseTopicUrl"))
{
// fetch the topic (and with it the root post
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") : '';
var browseTopicUrl = '/share/page/site/' + site + '/discussions-topicview?container=' + container +
+ '&path=' + path + '&postId=' + topicData.topic.name;
var topicData = getTopicPostData(model.postData.post.parent);
var browseTopicUrl = "" + json.get("browseTopicUrl");
browseTopicUrl = browseTopicUrl.replace("{post.name}", topicData.topic.name);
var data = {
title: topicData.post.properties.title,
topicTitle: topicData.post.properties.title,
browseTopicUrl: browseTopicUrl
}
activities.postActivity("org.alfresco.discussions.reply-updated", site, container, jsonUtils.toJSONString(data));
activities.postActivity("org.alfresco.discussions.reply-updated", json.get("site"), json.get("container"), jsonUtils.toJSONString(data));
}
}
else
@@ -120,16 +116,17 @@ function main()
//model.topicpost = getTopicPostData(node);
model.postData = getTopicPostDataFromTopicAndPosts(topicNode, nodes);
// post an activitiy item, but only if we got a site
if (url.templateArgs.site != null)
// add an activity item
if (json.has("site") && json.has("container") && json.has("browseTopicUrl"))
{
var browseTopicUrl = '/share/page/site/' + url.templateArgs.site + '/discussions-topicview?container=' + url.templateArgs.container +
+ '&path=' + url.templateArgs.path + '&postId=' + model.postData.topic.name;
var topicData = getTopicPostData(model.postData.post.parent);
var browseTopicUrl = "" + json.get("browseTopicUrl");
browseTopicUrl = browseTopicUrl.replace("{post.name}", topicData.topic.name);
var data = {
title: model.postData.post.properties.title,
topicTitle: topicData.post.properties.title,
browseTopicUrl: browseTopicUrl
}
activities.postActivity("org.alfresco.discussions.post-updated", url.templateArgs.site, url.templateArgs.container, jsonUtils.toJSONString(data));
activities.postActivity("org.alfresco.discussions.post-updated", json.get("site"), json.get("container"), jsonUtils.toJSONString(data));
}
}
}