diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 6df35b7..4aad64c 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -89,6 +89,17 @@ def service_icon(service, link = nil) end end + def room_name(nickname) + Room.ff_name(:auth => auth, :room => nickname) + end + + def room_picture(nickname, size = 'small') + name = Room.ff_name(:auth => auth, :room => nickname) + image_url = Room.picture_url(:auth => auth, :room => nickname, :size => size) + url = Room.ff_url(:auth => auth, :room => nickname) + link_to(image_tag(image_url, :alt => h(name), :title => h(name), :size => image_size(25, 25)), url) + end + def room(room) link_to(h(room.name), :controller => 'entry', :action => 'list', :room => u(room.nickname)) end @@ -103,8 +114,9 @@ def user_picture(nickname, size = 'small') if nickname == auth.name name = SELF_LABEL end - url = User.picture_url(:auth => auth, :user => nickname, :size => size) - link_to(image_tag(url, :alt => h(name), :title => h(name), :size => image_size(25, 25)), :controller => 'entry', :action => 'list', :user => u(nickname || user_id)) + image_url = User.picture_url(:auth => auth, :user => nickname, :size => size) + url = User.ff_url(:auth => auth, :user => nickname) + link_to(image_tag(image_url, :alt => h(name), :title => h(name), :size => image_size(25, 25)), url) end def user(user) diff --git a/app/helpers/entry_helper.rb b/app/helpers/entry_helper.rb index 62a5b40..6a10200 100644 --- a/app/helpers/entry_helper.rb +++ b/app/helpers/entry_helper.rb @@ -496,7 +496,6 @@ def page_links(opt = {}) if opt[:with_bottom] links << menu_link(menu_label('bottom', '8'), '#bottom', :accesskey => '8') end - links << menu_link(menu_label('members'), '#members') if ctx.room_for links << menu_link(icon_tag(:next), list_opt(ctx.link_opt(:start => start + num, :num => num)), :accesskey => '6') { !no_page } str = links.join(' ') if ctx.updated diff --git a/app/models/room.rb b/app/models/room.rb index b8b3244..187fe24 100644 --- a/app/models/room.rb +++ b/app/models/room.rb @@ -5,6 +5,42 @@ class Room < Hash include HashUtils class << self + def ff_id(arg) + auth = arg[:auth] + room = arg[:room] + ff_profile(auth, room)['id'] + end + + def ff_name(arg) + auth = arg[:auth] + room = arg[:room] + ff_profile(auth, room)['name'] + end + + def ff_url(arg) + auth = arg[:auth] + room = arg[:room] + ff_profile(auth, room)['url'] + end + + def status(arg) + auth = arg[:auth] + room = arg[:room] + ff_profile(auth, room)['status'] + end + + def description(arg) + auth = arg[:auth] + room = arg[:room] + ff_profile(auth, room)['description'] + end + + def picture_url(arg) + room = arg[:room] + size = arg[:size] || 'small' + ff_picture_url(room, size) + end + def members(arg) auth = arg[:auth] room = arg[:room] @@ -13,8 +49,14 @@ def members(arg) private + def ff_picture_url(room, size = 'small') + (@picture_url_cache ||= {})[room] ||= + ff_client.get_room_picture_url(room, size) + end + def ff_profile(auth, room) - ff_client.get_room_profile(auth.name, auth.remote_key, room) + (@profile_cache ||= {})[[auth.name, room]] ||= + ff_client.get_room_profile(auth.name, auth.remote_key, room) end def sort_by_name(lists) diff --git a/app/models/user.rb b/app/models/user.rb index 7696aad..0bd1e32 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -40,6 +40,12 @@ def ff_name(arg) ff_profile(auth, user)['name'] end + def ff_url(arg) + auth = arg[:auth] + user = arg[:user] + ff_profile(auth, user)['profileUrl'] + end + def status(arg) auth = arg[:auth] user = arg[:user] @@ -80,7 +86,7 @@ def subscriptions(arg) def ff_picture_url(user, size = 'small') (@picture_url_cache ||= {})[user] ||= - ff_client.get_picture_url(user, size) + ff_client.get_user_picture_url(user, size) end def ff_profile(auth, user) diff --git a/app/views/entry/_room.html.erb b/app/views/entry/_room.html.erb new file mode 100644 index 0000000..f853075 --- /dev/null +++ b/app/views/entry/_room.html.erb @@ -0,0 +1,2 @@ +

<%= room_picture(room) %> <%= h(room_name(room)) %>

+

<%= member_links(room) %>

diff --git a/app/views/entry/list.html.erb b/app/views/entry/list.html.erb index 0fb8778..8ad9b42 100644 --- a/app/views/entry/list.html.erb +++ b/app/views/entry/list.html.erb @@ -24,6 +24,9 @@ <%- if ctx.user_for -%> <%= render :partial => 'profile', :locals => {:user => ctx.user_for} %> <%- end -%> + <%- if ctx.room_for -%> + <%= render :partial => 'room', :locals => {:room => ctx.room_for} %> + <%- end -%> <%- if ctx.list -%>

<%= list_links %>

<%- end -%> @@ -51,10 +54,3 @@ <%- end -%>

<%= page_links(:with_top => true) %>

-<%- if ctx.room and ctx.room != '*' -%> -
-

- <%= h(ctx.room)%> members:
- <%= member_links(ctx.room) %> -

-<%- end -%> diff --git a/lib/ff.rb b/lib/ff.rb index 8f65c53..f5fb9b4 100644 --- a/lib/ff.rb +++ b/lib/ff.rb @@ -104,10 +104,15 @@ def validate(name, remote_key) end # size: small, medium, or large. - def get_picture_url(name, size = 'small') + def get_user_picture_url(name, size = 'small') "http://friendfeed.com/#{name}/picture?size=#{size}" end + # size: small, medium, or large. + def get_room_picture_url(name, size = 'small') + "http://friendfeed.com/rooms/#{name}/picture?size=#{size}" + end + def get_profile(name, remote_key, user = nil) uri = uri("user/#{user || name}/profile") client_sync(uri, name, remote_key) do |client|