OccupyMosaic

OccupyMosaic is a site originally developed after the May Day 2012 day of action to show a visual narrative of the events that happened that day.

The site uses a crawler to scrape data from the Twitter API, as well as photo and video services associated with Twitter (Twitpic, Yfrog, Vimeo, Youtube, etc).  Curators can collect media that has been tweeted on certain hash tags and display them in a chronological stream of photos.  Photos that have been retweeted or reposted appear larger.

To get up and running quickly, I coded the site using Sinatra on MongoDB – a technology stack I’ve found very effective for getting applications off the ground quickly.

Sinatra is a minimalist Ruby framework – unlike Rails, which generates a file structure for each project and has strict naming conventions, Sinatra projects only require the ‘sinatra’ gem – all other architectural choices are left to the user.  The base of a Sinatra application is a collection of routes used to define a REST API.  You can use the templating language of your choice to render views for a web client – OccupyMosaic uses Haml.

MongoDB is a NoSQL document-based data store.  Unlike SQL databases, which represent objects as one or more rows spread across tables, Mongo stores an object as a document in BSON (a variant of JSON with support for binary data).  This obviates the need for complex Object-Relational-Mapping (ORM) plugins and, since there is no schema required, allows objects of with differing attributes to be stored in the same collection.  This makes it very easy to quickly gather data from web api’s – you don’t even need to define a schema before you start collecting the data – you can just run an HTTP request at an API, take the resulting data and stash it in a Mongo collection, knowing that all of its attributes and nested arrays will be available for querying or reformatting later. Mongo uses Javascript as its query language, and commands are defined as JSON documents, which will translate 1-to-1 as hashes, dictionaries or associative arrays in the programming language of your choice.

The project behind OccupyMosaic is “The People’s Mosaic” and the source code is freely available (MIT License) on github:

The People’s Mosaic

It’s under active development, with new features being added regularly.  Feel free to check it out – you can run it on a local deployment for your own research or deploy it to any webserver that supports Sinatra and MongoDB.

(Posted by Tom Gillis, OWS Tech Ops)