User:Shashi/Implement Anything

=Implementing a (federated) lastfm/flickr/facebook clone on top of StatusNet=

Some notes.

Introduction
With OStatus, The Tao of social networking freedom is clearer than ever. People own their own servers, then connect them, giving themselves and only themselves complete control over their data. StatusNet already implements everything characteristic of an ideal free software social network service. It's quite wrong to call it a mere microblogging software when it's a lot more than that.

Here are some notes that show how StatusNet can be anything you want without even having the core code edited (i.e to say by developing a set of plugins)

Inspiration
The concept of feathers is taken from the lightweight and extensible tumblogging software Chyrp. Each feather in Chyrp defines the model and view of one kind of a post. For example, a "quote" is a feather whose model part defines the attributes,   and the normal ones  ,   and. The feather can store the data in any manner in the database as long as it implements this sweet little interface.

 object created. */       public function submit;

/**        * Function: update * Handles updating a post. */       public function update($post);

/**        * Function: title * Returns the appropriate string to be treated as a "title" of a post. * If there is no immediate solution, you may use . */       public function title($post);

/**        * Function: excerpt * Returns the appropriate string to be used as an excerpt of a post. */       public function excerpt($post);

/**        * Function: feed_content * Returns the appropriate content for a feed. */       public function feed_content($post); } The view part of a feather in Chyrp is a twig template, forget it for now. The cool part is, there is a feather repository on the Chyrp site, where you can download a feather from, extract it, enable it, and start posting posts of the new feather type (you can upload a new feather you created too!).

A framework Feather plugin
In context of StatusNet, a feather could mean a type of notice, where a notice means not just a micrologging message of 140/more chars but anything, a bunch of data, that ideally is a status update from an "actor" eg. a listen to a song/ a new picture/ a blog post! We now go through the next obvious step: Implementing a feather framework as a StatusNet plugin. Some rough notes on that (step-by-step-going-about-doing-it)


 * 1) Create a plugin called FeatherPlugin which
 * 2) Creates a table called   with   as primary key and   (a varchar) as the 2nd column to store the codename of the feather the notice with the respective   belongs to.
 * 3) Contains some abstract functions that an actual feather plugin should override (like factory functions and other methods that give information about the feather [take the Realtime plugin & Orbit plugin as an example to understand this... Orbit extends Realtime and Realtime handles the common realtime chores])
 * 4) Handles some hooks common to any feather implementation (like StartShowNoticeItem, to call a rendering function if the notice is a feather)
 * 5) Declare a class Feather_object (extends Memcached_DataObject) and add some useful methods, actual feather plgins extend this to get their Model
 * 6) Create a framework of widgets for rendering feathers in HTML and Atom (OStatus too)
 * 7) Create a framework of Action classes and helpers for list/add/modify operations for a feather, actual feathers extend/use this (take care of Ajax wherever possible)

A Lastfm feather as an example
A lastfm plugin, a complete clone of lastfm could be achieved by doing these: (Lastfm specific, not benifiting from FeatherPlugin)
 * 1) Create a plugin LastfmFeatherPlugin extends FeatherPlugin
 * 2) Override the required functions
 * 3) implement Lastfm_Feather extends Feather_object [create a new table to store user_id/timestamp/title/artist/album/tag/year/etc]
 * 4) implements the widgets for HTML and XML
 * 1) implement a scrobbling backend (whoof)
 * 2) generate pages for each artist/album/title
 * 3) define special microsyntax to refer to year/genre/artist/song/album in stats and keep them safely :D [these could be shouts!]
 * 4) statistics generation and so on.

The case of Facebook
The Lastfm example above describes how to implement a Feather plugin, a facebook clone might consist of a set of such feather plugins, roughly the list of feathers to be implemented goes like this: more notes on this:
 * 1) Picture
 * 2) Video
 * 3) Note
 * 4) Link
 * 1) Displaying news feeds for each type of feather
 * 2) An application (apps.facebook.com) api (so not recommended)

Overthinking
(That's the perfect heading I could come up with for this section :D) Well, since the model and view part of a notice are the only important ones while communicating between servers, it makes perfect sense to communicate the model and view of a particular notice to the Subscribing/subscriber servers. i.e to say having an XML representation for each feather so that servers don't _have to_ have the feather plugin installed to display a feather. Storing notice of feather types defined thus (over XML) could be a challenge (Chyrp stores all attributes of a post in a table called post_attributes containing the following colums: post_id(int), attr_name(varchar), value(text)) which is not scalable afaict.

example XML, notice raw Atom: name_of_the_feather http://gitorious.org/statusnet-featherrepo/mainline/name_of_the_feather.xml 

here the feather's model and view is defined at http://gitorious.org/statusnet-featherrepo/mainline/name_of_the_feather.xml (RDF & XSLT maybe?)

for overcoming security concerns with this,there could be a repository of a peer reviewed set of feather definitions for production servers (yeah, right).

DISCLAIMER: I have little or no clue about web semantics and XML, and pretty much everything else i blabber about. Thank you for your patience. ;)

Glossary
g0: hey! what's the correct usage of the word "feather" in Chyrp lingo? is a post a feather of a kind? or is a feather the kind of a post? :D

firemyst: it depends on the bird