2
0
mirror of https://github.com/moebooru/moebooru synced 2025-08-22 01:47:48 +00:00
moebooru/app/helpers/avatar_helper.rb
petopeto 30ff4fccd3 --HG--
branch : moe
extra : convert_revision : svn%3A2d28d66d-8d94-df11-8c86-00306ef368cb/trunk/moe%405
2010-04-20 23:05:11 +00:00

31 lines
1.1 KiB
Ruby

module AvatarHelper
# id is an identifier for the object referencing this avatar; it's passed down
# to the javascripts to implement blacklisting "click again to open".
def avatar(user, id, html_options = {})
@shown_avatars ||= {}
@posts_to_send ||= []
#if not @shown_avatars[user] then
@shown_avatars[user] = true
@posts_to_send << user.avatar_post
img = image_tag(user.avatar_url + "?" + user.avatar_timestamp.tv_sec.to_s,
{:class => "avatar", :width => user.avatar_width, :height => user.avatar_height}.merge(html_options))
link_to(img,
{ :controller => "post", :action => "show", :id => user.avatar_post.id.to_s },
:class => "ca" + user.avatar_post.id.to_s,
:onclick => %{return Post.check_avatar_blacklist(#{user.avatar_post.id.to_s}, #{id});})
#end
end
def avatar_init
return "" if not defined?(@posts_to_send)
ret = ""
@posts_to_send.uniq.each do |post|
ret << %{Post.register(#{ post.to_json })\n}
end
ret << %{Post.init_blacklisted()}
ret
end
end