Skip to content

Instantly share code, notes, and snippets.

@zombor
Created June 8, 2010 13:58
Show Gist options
  • Save zombor/430043 to your computer and use it in GitHub Desktop.
Save zombor/430043 to your computer and use it in GitHub Desktop.
module Picombo
module Stache
class User_View < Mustache
self.template = File.open(Picombo::Core.find_file('views', 'user/view', true, 'mustache').shift).read
@user = nil
def initialize
Picombo::Head.add_js('js/jquery.js')
Picombo::Head.add_js('js/effects.js')
end
def user=(user)
@user = user
end
def user
@user
end
def primary_photo
{
:photo_url => @user.primary_photo,
:alt => @user.username
}
end
def feed_posts
@user.feed_posts
end
def friends
friends = []
@user.friends.each do |friend|
friends << {
:username => friend.username,
:image => friend.primary_photo
}
end
friends
end
def photos
photos = []
@user.images.each do |photo|
photos << {
:photo_url => photo.remote_path,
:alt => @user.username
}
end
photos
end
def vote_count
@user.ratings.length
end
def is_friend?
return false if ! Picombo::Auth.logged_in?
Picombo::Auth.instance.user.friends.include?(@user)
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment