2 var md5 = $$(this).app.require("vendor/couchapp/lib/md5");
4 // TODO this can be cleaned up with docForm?
5 // it still needs the workflow to edit an existing profile
6 var name = $("input[name=userCtxName]",this).val();
8 rand : Math.random().toString(),
9 nickname : $("input[name=nickname]",this).val(),
10 email : $("input[name=email]",this).val(),
11 url : $("input[name=url]",this).val()
16 newProfile.gravatar_url = 'http://www.gravatar.com/avatar/'+md5.hex(newProfile.email || newProfile.rand)+'.jpg?s=40&d=identicon';
19 // store the user profile on the user account document
20 $.couch.userDb(function(db) {
21 var userDocId = "org.couchdb.user:"+name;
22 db.openDoc(userDocId, {
23 success : function(userDoc) {
24 userDoc["couch.app.profile"] = newProfile;
26 success : function() {
27 newProfile.name = userDoc.name;
28 $$(widget).profile = newProfile;
29 widget.trigger("profileReady", [newProfile]);