On Supporting Activity Streams in Drupal
A couple of days ago I wrote a post about the importance of de-centralised social networks in general and the role Drupal can play, in particular. I also indicated that one of the first things we would like to look at here at Istos is providing support for Activity Streams in Drupal. In this post we briefly look at Activity Streams and discuss some of the issues for adding support in Drupal.
I should add that these blog posts serve as a means for us to collect together thoughts and put ideas down in writing - as everything is pretty much at the reasoning / planning stages things may not be described in the best possible way (i.e. they might be quite wrong!).
Activity Streams is a standard to describe and syndicate social activities. It started out of the DISO project and now is part of the set of standards promoted by OStatus to support de-centralised social networks.
As one can see from the front page of the Activity Streams website is has garnered wide support with big names like Facebook, Google Buzz and MySpace amongst the organisations that put out Activity Streams of their users activities.
The basic format of an activity in the stream follows a simple "Actor Verb Object (Target)" structure. As in: Ronald posted a Post on his Blog, John tagged a Picture on Flickr, Angelo followed Andrea on Twitter... you get the idea.
The technical implementation of Activity Streams is made up of two parts, essentially:
1. A few more tags on to the Atom format to represent Verbs and Objects
2. A list of Verbs and Objects that seem to cover a wide range of situations.
A few of them:
Verbs: Add Friend, Favorite, Follow, Like, Join
Objects: Article, Audio, Bookmark, Comment, File, Folder, Group
Drupal and Activity Streams
Ok, so far so good. That is what Activity Streams are. There is a bunch of Verbs and Objects and users perform actions that get mapped to these "phrases" and the whole thing is presented as an Atom feed for others to pick-up and use as they like. Simple, right?
Well, kind of.
The interesting part is the mapping. Drupal, as many like to say, is a box of Legos. You can do pretty much whatever you like. So what exactly is an Adding a Friend activity? Or a Follow, Like, etc. Also when does it count and when not? If I post a photo in an Article content type I may not want that in the "official" activity stream but a photo in a User Photo Gallery content type should count towards the activity stream.
Drupal's own Activity module actually allows us to define phrases by putting together tokens supplied by Drupal and our own terminology. In its fantastically Drupalish way it offers a lot of flexibility and allows you to do just about what you like. As long as the end result makes sense to us, our users and the application's context we are good to go.
Supporting Activity Streams, however, means bringing some order to this scenario. Firstly, we must use the exact terminology supported or else our stream won't be very useful. Secondly, this can't be turned into a tedious process for website owners. The ideal end result should be you install module, turn it on and hey presto you have activity streams.
Adding some educated guesses to the mix
Our current thinking is that an Activity Streams module should essentially do three things in order to figure out what streams to create.
1. Sniff around your site and figure out what functionality there is (e.g. fivestar, voting, following, picture uploading, flags, etc) and based on that output the appropriate activities. It would have to be aware of what popular modules / fields / Drupal actions mean in an Activity Streams context and "know" how to represent those actions when it gets switched on.
2. Allow you to map actions it has not discovered to proper Activity Streams verbs and objects. For example, it would be sensible to provide an interface where activities created by the Activity module are made available to be mapped on to the Activity Streams standard.
3. Allow you to adjust and refine the sum of the two actions above. It may have guessed a few things wrong or it may be that you already have activities to represent some of the actions that the module discovered on its own so you need to flatten those out to just one thing, etc.
There are almost certainly a few more things we haven't thought of here, but hopefully this is a good start. Let us know what you think - in the meantime we will be looking at getting together some code that takes care of a few basic scenarios like commenting, posting a photo, etc.