diff --git a/app/controllers/favorites_controller.rb b/app/controllers/favorites_controller.rb index c90c8e5fe..10d7853ff 100644 --- a/app/controllers/favorites_controller.rb +++ b/app/controllers/favorites_controller.rb @@ -4,6 +4,8 @@ class FavoritesController < ApplicationController def index if params[:tags] redirect_to(posts_path(:tags => params[:tags])) + elsif request.format == Mime::JS + list_favorited_users else @favorite_set = PostSets::Favorite.new(CurrentUser.user, params[:page], params) end @@ -22,4 +24,9 @@ class FavoritesController < ApplicationController @post = Post.find(params[:id]) @post.remove_favorite!(CurrentUser.user) end + + def list_favorited_users + @post = Post.find(params[:post_id]) + render :action => "list_favorited_users" + end end diff --git a/app/models/post.rb b/app/models/post.rb index bd8e52676..880164cf1 100644 --- a/app/models/post.rb +++ b/app/models/post.rb @@ -543,6 +543,10 @@ class Post < ActiveRecord::Base def favorited_user_ids fav_string.scan(/\d+/) end + + def favorited_users + favorited_user_ids.map {|id| User.find_by_id(id)} + end end module UploaderMethods diff --git a/app/views/favorites/_favorited_users_list.html.erb b/app/views/favorites/_favorited_users_list.html.erb new file mode 100644 index 000000000..5ac0ef596 --- /dev/null +++ b/app/views/favorites/_favorited_users_list.html.erb @@ -0,0 +1 @@ +
<%= post.favorited_users.reverse_each.map{|user| link_to_user(user)}.join(", ").html_safe %> \ No newline at end of file diff --git a/app/views/favorites/list_favorited_users.js.erb b/app/views/favorites/list_favorited_users.js.erb new file mode 100644 index 000000000..f6529cadb --- /dev/null +++ b/app/views/favorites/list_favorited_users.js.erb @@ -0,0 +1 @@ +$("span#favlist-for-post-<%= @post.id %>").html("<%= j(render(:partial => "favorites/favorited_users_list", :locals => { :post => @post }))%>"); \ No newline at end of file diff --git a/app/views/posts/partials/show/_information.html.erb b/app/views/posts/partials/show/_information.html.erb index 0685ed7cc..c95d411e6 100644 --- a/app/views/posts/partials/show/_information.html.erb +++ b/app/views/posts/partials/show/_information.html.erb @@ -14,7 +14,7 @@
  • Source: <%= post_source_tag(post) %>
  • Rating: <%= post.pretty_rating %>
  • Score: <%= post.score %> <% if CurrentUser.is_privileged? %>(vote <%= link_to "up", post_votes_path(:post_id => post.id, :score => "up"), :remote => true, :method => :post %>/<%= link_to "down", post_votes_path(:post_id => post.id, :score => "down"), :remote => true, :method => :post %>)<% end %>
  • -
  • Favorites: <%= post.fav_count %>
  • +
  • Favorites: <%= post.fav_count %> <% if CurrentUser.is_privileged? && post.fav_count > 0 %><%= link_to "»".html_safe, favorites_path(:post_id => post.id), :remote => true %><% end %>
  • Status: <% if post.is_pending? %>