Skip to content

Commit

Permalink
Sets gravatar hash and sets current user
Browse files Browse the repository at this point in the history
Signed-off-by: Akash Manohar J <akash@akash.im>
  • Loading branch information
HashNuke committed Mar 31, 2012
1 parent 41b02b8 commit ce28aef
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
10 changes: 10 additions & 0 deletions app/assets/javascripts/backbone/kandan.js.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,18 @@ window.Kandan =
Kandan.initTabs()
Kandan.Widgets.initAll()

setCurrentUser: ()->
template = _.template '''
<img src="http://gravatar.com/avatar/<%= gravatar_hash %>?s=25&d=http://bushi.do/images/profile.png"/> <%= name %>
'''
currentUser = Kandan.Helpers.Users.currentUser()
$(".header .user").html template({
gravatar_hash: currentUser.gravatar_hash,
name: "#{currentUser.first_name} #{currentUser.last_name}"
})

init: ->
@setCurrentUser()
channels = new Kandan.Collections.Channels()
channels.fetch({success: (channelsCollection)=>
@initBroadcasterAndSubscribe()
Expand Down
3 changes: 2 additions & 1 deletion app/views/layouts/application.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
:id => current_user.id,
:first_name => current_user.first_name,
:last_name => current_user.last_name,
:auth_token => current_user.authentication_token
:auth_token => current_user.authentication_token,
:gravatar_hash => current_user.gravatar_hash
}
%>
$.data(document, 'current_user', <%= current_user_data.to_json.html_safe %>);
Expand Down

0 comments on commit ce28aef

Please sign in to comment.