Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
show room profile at the top of 'room' view. [#48 state:resolved]
  • Loading branch information
nahi committed Mar 2, 2009
1 parent 8e03915 commit 124b6a2
Show file tree
Hide file tree
Showing 7 changed files with 75 additions and 13 deletions.
16 changes: 14 additions & 2 deletions app/helpers/application_helper.rb
Expand Up @@ -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
Expand All @@ -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)
Expand Down
1 change: 0 additions & 1 deletion app/helpers/entry_helper.rb
Expand Up @@ -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
Expand Down
44 changes: 43 additions & 1 deletion app/models/room.rb
Expand Up @@ -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]
Expand All @@ -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)
Expand Down
8 changes: 7 additions & 1 deletion app/models/user.rb
Expand Up @@ -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]
Expand Down Expand Up @@ -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)
Expand Down
2 changes: 2 additions & 0 deletions app/views/entry/_room.html.erb
@@ -0,0 +1,2 @@
<p><%= room_picture(room) %> <%= h(room_name(room)) %></p>
<p><%= member_links(room) %></p>
10 changes: 3 additions & 7 deletions app/views/entry/list.html.erb
Expand Up @@ -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 -%>
<p><%= list_links %></p>
<%- end -%>
Expand Down Expand Up @@ -51,10 +54,3 @@
<%- end -%>
</div>
<p><a name="bottom"></a><%= page_links(:with_top => true) %></p>
<%- if ctx.room and ctx.room != '*' -%>
<hr/>
<p>
<a name="members" id="members"><%= h(ctx.room)%> members:</a><br/>
<%= member_links(ctx.room) %>
</p>
<%- end -%>
7 changes: 6 additions & 1 deletion lib/ff.rb
Expand Up @@ -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|
Expand Down

0 comments on commit 124b6a2

Please sign in to comment.