Skip to content

Instantly share code, notes, and snippets.

@ciberch
Created September 10, 2012 19:45
Show Gist options
  • Save ciberch/3693355 to your computer and use it in GitHub Desktop.
Save ciberch/3693355 to your computer and use it in GitHub Desktop.
Activity Backbone Model
var Activity = Backbone.Model.extend({
url : "/activities",
// From activity-streams-mongoose/lib/activityMongoose.js
defaults: {
verb: 'post',
object: null, //ActivityObject
actor: null, //ActivityObject
url: '',
title: '',
content: '',
icon: null, // MediaLinkHash
target: null, //ActivityObject
published: Date.now,
updated: Date.now,
inReplyTo: null, //Activity
provider: null, //ActivityObject
generator: null, //ActivityObject
streams: ['firehose'],
likes: {},
likes_count: 0,
comments: [],
comments_count: 0,
userFriendlyDate: 'No idea when'
},
validate: function(attrs) {
if (! attrs.object) {
return "Object is missing"
}
if (!attrs.object.title) {
return "Title is missing";
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment