Collage is a Framework for Live Collages
Collage brings together many public APIs, along with a method of presenting media within a limitless two-dimesional space to create memorable and meaningful experiences. It's a mixture between Big Surface, Giant Quadtree, and a public API library.
For plain JavaScript applications, use the dist/collage.js,
which will inject the Collage module object to the global scope (i.e. it creates window.collage). You can also use this file as an AMD or CommonJS module. If you use bower, you can install collage with bower install collage
.
Depending on which loaders you use, you will need to include these in your HTML doc, before starting the collage:
<!-- Youtube Iframe API -->
<script src="//www.youtube.com/iframe_api"></script>
<!-- Twitter API -->
<script src="//platform.twitter.com/widgets.js"></script>
<!-- Facebook API -->
<div id="fb-root"></div>
<script>
(function(d, s, id) {
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) return;
js = d.createElement(s); js.id = id;
js.src = "//connect.facebook.net/en_US/all.js#xfbml=1";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));
</script>
These are referred to as loader
s in the codebase.
- Facebook (like boxes)
- Reddit (images and embeds)
- Youtube
- Flickr
- Google News
- Google Plus
- Twitter (currently broken due to auth changes)
- NY Times (requires a reverse-proxy due to lack of CORS headers)
Check the loader configurations for how to query them for content.
Collage extends Big Surface, all API methods that are available for Big
Surface is also available for Collage. In the API collage
refers to the module object and collageInstance
refers to a
Collage instance which is created via collage.create
.
Constructor function which returns a new Collage instance. The container is the element which will contain the collage.
Loads the media from the given loaderName according to the loaderConfig and assigns the loaded media to the tagName.
var collageInstance = collage.create(document.body);
collageInstance.load('some fb content', 'facebook', {
minLikes: 200,
query: 'popcorn'
}).then(function(){
// Wait for the loading to be finished, then
// start the collage (filling the center) and set the active tags
collageInstance.start('some fb content');
collageInstance.speed(8);
});
Loads the media from the given loaderName : loaderConfig mapping and assigns the loaded media to the tagName.
var collageInstance = collage.create(document.body);
collageInstance.load('my content', {
facebook: [
{
minLikes: 200,
query: 'popcorn'
},
{
ids: ["110452248983275"]
}
],
twitter: [
{ query: 'popcorn' },
{ query: 'caramel' }
]
}).then(function(){
// Wait for the loading to be finished, then
// start the collage (filling the center) and set the active tags
collageInstance.start('my content');
collageInstance.speed(8);
});
Starts the transform loop of the collage (allows for movement) and optionally sets the active tags to the given arguments.
Brings the collage movement to a halt within the given time duration (or immediately if none provided).
Resumes collage movement to the state it was in previous to a pause
call. If a duration
is provided, the speed will tween to the limit within the given time period.
Sets the given tags as the 'active' tags which media for the collage will be pulled from.
Adds the given element(s) to the given tag(s).
Removes the given element(s) from the given tag(s).
Gets the elements for the given tag names.
Inserts an element directly in the collage surface at left, top (in pixels). If show is set to true, the element is placed visibly, otherwise hidden.
A map of available loaders which you can extend during run-time.
Fills the visible center of the screen with elements.
Loaders are where you get the content for the collage from. The content from the loaders are associated with one or more tags, which the collage will use to populate itself with.
Adds like boxes for facebook pages to the collage
query
: a search query (not required if providing ids)ids
: an array of page ids to load (not required if providing a query)limit
(default 3): max number of results from query searchwidth
(default 400): width of the like boxheight
(default 600): height of the like boxminLikes
(default 0): minimum number of likes for results of the query searchshowFaces
(default true): whether to show faces in the like boxshowStream
(default true): whether to show the page stream in the like boxshowHeader
(default false): whether to show a 'like our page' header in the like box
var collageInstance = collage.create(document.body);
collageInstance.load('some fb content', 'facebook', {
minLikes: 200,
query: 'one man one woman'
}).then(function(){ // wait for the first batch to complete loading
collageInstance.load('more fb content', {
facebook: [{
minLikes: 200,
query: 'popcorn'
},
{
ids: ["110452248983275"]
}]
}).then(function(){
// Wait for the loading to be finished, then
// start the collage (filling the center) and set the active tags
collageInstance.start('some fb content', 'more fb content');
collageInstance.speed(8);
});
});
Adds images or reddit embeds to the collage
type
default "photos", can be "embed" or "photos"sort
default "top", can be "confidence", "top", "new", "hot", "controversial", "old", "random"subreddit
default "all"limit
default 20time
default "all", can be "hour", "day", "week", "month", "year", "all"nsfw
default "false"minComments
default 0minScore
default 0width
default 500, width of the embed boxheight
default 600, height of the embed box
collageInstance.load('reddit popcorn', {
reddit: [
{
query: "popcorn site:imgur.com subreddit:funny",
limit: "10"
},
{
type: "embed",
query: "popcorn"
}]
}).then(function(){
// Wait for the loading to be finished, then
// start the collage (filling the center) and set the active tags
collageInstance.start('reddit popcorn');
collageInstance.speed(8);
});
Choose one:
query
a search query for tweetsids
an array of tweet idsid
a single tweet id
collageInstance.load('popcorn', {
twitter: [
{ query: "popcorn"}
],
}).then(function(){
// Wait for the loading to be finished, then
// start the collage (filling the center) and set the active tags
collageInstance.start('popcorn');
collageInstance.speed(8);
});
Adds youtube videos to the collage
Choose one:
query
a string to search Youtube withvideoId
a singe video id to loadvideoIds
an array of video ids to load
Optional parameters:
mute
default falseloop
default falseautoplay
default falsecallback
continuousPlay
default false. This option determines if the video pauses when it goes out of view or not.startTime
default 0duration
default "short"key
Google api api keywidth
default 1060height
default 650
collageInstance.load('popcorn', {
youtube: [
{
query: "popcorn",
mute: true,
loop: true
},
{
videoId: 'abcdefgh',
mute: true,
autoplay: true,
loop: true,
startTime: 108
}
]
}).then(function(){
// Wait for the loading to be finished, then
// start the collage (filling the center) and set the active tags
collageInstance.start('popcorn');
collageInstance.speed(8);
});
Adds images from Flickr to the collage
tags
the search query for tags to loadsort
default "relevance"count
default 20license
default "1,2,3,4,5,6,7,8" see Flickr APIapiKey
tagMode
default "all"isCommons
default falsecontentType
default 1 (photos)
collageInstance.load('popcorn', {
flickr: [
{
tags: "popcorn",
sort: "interestingness-desc"
}
],
}).then(function(){
// Wait for the loading to be finished, then
// start the collage (filling the center) and set the active tags
collageInstance.start('popcorn');
collageInstance.speed(8);
});
Adds news articles from Google News to the collage.
The loader only accepts a string query.
collageInstance.load('popcorn', {
googleNews: ["popcorn"]
}).then(function(){
// Wait for the loading to be finished, then
// start the collage (filling the center) and set the active tags
collageInstance.start('popcorn');
collageInstance.speed(8);
});
Adds posts from Google Plus to the collage.
The loader only accepts a string query.
collageInstance.load('popcorn', {
googlePlus: ["popcorn"]
}).then(function(){
// Wait for the loading to be finished, then
// start the collage (filling the center) and set the active tags
collageInstance.start('popcorn');
collageInstance.speed(8);
});
Adds news articles from the NY Times API. The api endpoint must be proxied locally, since it doesn't allow for JSONP calls to be made.
Choose one:
query
A live query to make to the NY Time apidata
A pre-recorded JSON object to use instead of doing a query
collageInstance.load('popcorn', {
nyTimes: [{
query: "popcorn+nytd_des_facet%3A%5BHate+Crimes%5D"
}]
}).then(function(){
// Wait for the loading to be finished, then
// start the collage (filling the center) and set the active tags
collageInstance.start('popcorn');
collageInstance.speed(8);
});
Adds an iframe to the collage. Becareful, this is a particularly expensive thing to add, because it embed an entire site in the collage.
url
width
height
collageInstance.load('popcorn', {
iframe: [{
url: "http://en.wikipedia.org/wiki/Popcorn",
width: 800,
height: 600
}]
}).then(function(){
// Wait for the loading to be finished, then
// start the collage (filling the center) and set the active tags
collageInstance.start('popcorn');
collageInstance.speed(8);
});
Adds a single image to the collage.
The loader only accepts a string src.
collageInstance.load('popcorn', {
image: ["http://www.popcorn.com/popcorn.jpg"]
}).then(function(){
// Wait for the loading to be finished, then
// start the collage (filling the center) and set the active tags
collageInstance.start('popcorn');
collageInstance.speed(8);
});
This project uses boilerplate-gulp. Run 'gulp dev' to develop and have incremental builds, continuous testing, etc. Run 'gulp' to run regenerate the dist files.