Activity Streams with com_activities
24 May 2012 by israelAs the web becomes more social, a new and interesting way to follow people across the Internet has emerged. Termed as “Activity Streams”, it is popularized by sites like Facebook, Twitter, and other social websites, Activity Streams has now become an essential part of “the Social Web”.
So what are “Activity Streams”?
On the surface, it looks like a simple record of actions performed by people on the Internet. But what makes it interesting is the philosophy behind it. Activity Streams is rooted to a concept called Activity Theory.
We may not be able to discuss the theory in detail , but I am quite certain that Activity Theory may drive the future of the social web. The concept is also very relevant to Open Source communities such as Nooku, as it explores the psychology behind collaboration, motivation and productivity.
Philosophy aside, the technology behind Activity Streams is also evolving. As more and more websites use it, a standard is being developed which will allow Activity Streams to be syndicated in its own protocol instead of using RSS or Atom. To know more about the Activity Streams Standard, read the Draft and the Wiki.
Where does Nooku come into play?
To easily integrate Activity Streams in your Nooku application, a new Nooku Component is here at your service – com_activities. By using this, logging user actions in your Nooku component and rendering Activity Streams can be effortless.
How do you use com_activities in your component? Check out this code:
class ComArticlesControllerArticle extends ComDefaultControllerDefault
{
protected function _initialize(KConfig $config)
{
$config->append(array(
'behaviors' => array(
'com://admin/activities.controller.behavior.loggable',
)
));
parent::_initialize($config);
}
}
In your controller, simply add the “loggable” controller behavior from com_activities. By default, the loggable behavior is triggered on controller actions: add, edit and delete.
When the behavior is triggered, it logs the user(actor), the action(verb), the item in which the action was performed(object), the link to the object(target), and some metadata e.g. when the action was performed, and which application was used.
When viewing the activity stream, these records are constructed together to form a meaningful sentence like “This User has performed this Action on this Object on this Date”.
The behavior is also flexible, you can configure it to track only certain actions such as after login, or after logout as demonstrated in this code:
$config->append(array(
'behaviors' => array(
$this->getService('com://admin/activities.controller.behavior.loggable',
array(
'title_column' => 'name',
'actions' => array('after.login', 'after.logout')
))),
));
Aside from the HTML view, com_activities can also output the JSON format that follows the emerging Activity Streams standard. To do this, just append format=json in the URL e.g
index.php?com_activities&view=activities&format=json.
Using Nooku’s RESTful architecture, you can syndicate your component’s activity stream without additional effort.
Coming Soon in Nooku 12.2
As the web evolves, Activity Streams can become an integral part of user driven websites. By using Nooku with com_activities, developers can easily integrate it to their applications. It’s a powerful feature and it’s so easy to implement in Nooku.
Check the code of com_activities in the Nooku Components trunk or see it in action in Nooku Server’s. To view , look for “Activity Logs” under the Tools menu or check out the dashboard which shows the activities in a AJAX overlay. Coming to you in 12.2. Excited ? So are we !
Happy Coding!

