添加写project_status和user_status两表的方法,

在关注中写这2个表,
重构了tag的过滤方法,
拿掉了user_extension.rb.
This commit is contained in:
william 2013-08-27 11:27:25 +08:00
parent c7beefa556
commit 0c22d409fc
24 changed files with 222 additions and 161 deletions

View File

@ -14,71 +14,28 @@ class TagsController < ApplicationController
$selected_tags = Array.new
$related_tags = Array.new
@@numbers = Setting.tags_show_search_results
def index
$selected_tags = []
$related_tags = []
$selected_tags << params[:q]
@issues_tags_num = Issue.tag_counts.size
@projects_tags_num = Project.tag_counts.size
@users_tags_num = User.tag_counts.size
@bids_tags_num = Bid.tag_counts.size
# 这里为了提高系统的响应速度 把搜索结果放到case中去了
@users_results = nil
@projects_results = nil
@issues_results = nil
@bids_results = nil
@obj_pages = nil
@users_tags_num,@projects_tags_num,@issues_tags_num,@bids_tags_num = get_tags_size
@obj_id = params[:obj_id]
@obj_flag = params[:object_flag]
@numbers = Setting.tags_show_search_results
case @obj_flag
when '1' then
@users_results = get_users_by_tag($selected_tags)
@obj = User.find_by_id(@obj_id)
@offset, @limit = api_offset_and_limit({:limit => @numbers})
@project_count = @users_results.count
@obj_pages = Paginator.new @project_count, @limit, params['page']
@offset ||= @obj_pages.offset
@users_results = @users_results.offset(@offset).limit(@limit).all
when '2' then
@projects_results = get_projects_by_tag($selected_tags)
@obj = Project.find_by_id(@obj_id)
@offset, @limit = api_offset_and_limit({:limit => @numbers})
@project_count = @projects_results.count
@obj_pages = Paginator.new @project_count, @limit, params['page']
@offset ||= @obj_pages.offset
@projects_results = @projects_results.offset(@offset).limit(@limit).order('lft').all
when '3' then
@issues_results = get_issues_by_tag($selected_tags)
@obj = Issue.find_by_id(@obj_id)
@offset, @limit = api_offset_and_limit({:limit => @numbers})
@project_count = @issues_results.count
@obj_pages = Paginator.new @project_count, @limit, params['page']
@offset ||= @obj_pages.offset
@issues_results = @issues_results.offset(@offset).limit(@limit).all
when '4'
@bids_results = get_bids_by_tag($selected_tags)
@obj = Bid.find_by_id(@obj_id)
@offset, @limit = api_offset_and_limit({:limit => @numbers})
@project_count = @bids_results.count
@obj_pages = Paginator.new @project_count, @limit, params['page']
@offset ||= @obj_pages.offset
@bids_results = @bids_results.offset(@offset).limit(@limit).all
else
@obj = nil
end
# 获取搜索结果
@obj,@obj_pages,@users_results,
@projects_results,
@issues_results,
@bids_results,
@obj_pages = refresh_results(@obj_id,@obj_flag)
# 这里是做tag推荐用的 用来生产推荐的tag
unless @obj.nil?
@tags = @obj.tag_list
$selected_tags.each do |i|
@ -91,35 +48,44 @@ class TagsController < ApplicationController
end
# 增加已选的tag
def add_tag
@tag = params[:tag]
@show_flag = params[:show_flag]
$selected_tags << @tag
$related_tags.delete(@tag)
@obj_pages = nil
@numbers = Setting.tags_show_search_results
# # 获取搜索结果
# @obj,@obj_pages,@users_results,
# @projects_results,
# @issues_results,
# @bids_results,
# @obj_pages = refresh_results(@obj_id,@show_flag)
# @issues_results = get_issues_by_tag($selected_tags)
# @projects_results = get_projects_by_tag($selected_tags)
# @users_results = get_users_by_tag($selected_tags)
case @show_flag
when '1' then
@users_results = get_users_by_tag($selected_tags)
@obj = User.find_by_id(@obj_id)
@offset, @limit = api_offset_and_limit({:limit => @numbers})
@offset, @limit = api_offset_and_limit({:limit => @@numbers})
@project_count = @users_results.count
@obj_pages = Paginator.new @project_count, @limit, params['page']
@offset ||= @obj_pages.offset
@users_results = @users_results.offset(@offset).limit(@limit).all
when '2' then
@projects_results = get_projects_by_tag($selected_tags)
@obj = Project.find_by_id(@obj_id)
@offset, @limit = api_offset_and_limit({:limit => @numbers})
@offset, @limit = api_offset_and_limit({:limit => @@numbers})
@project_count = @projects_results.count
@obj_pages = Paginator.new @project_count, @limit, params['page']
@offset ||= @obj_pages.offset
@projects_results = @projects_results.offset(@offset).limit(@limit).order('lft').all
@ -127,44 +93,49 @@ class TagsController < ApplicationController
@issues_results = get_issues_by_tag($selected_tags)
@obj = Issue.find_by_id(@obj_id)
@offset, @limit = api_offset_and_limit({:limit => @numbers})
@offset, @limit = api_offset_and_limit({:limit => @@numbers})
@project_count = @issues_results.count
@obj_pages = Paginator.new @project_count, @limit, params['page']
@offset ||= @obj_pages.offset
@issues_results = @issues_results.offset(@offset).limit(@limit).all
when '4'
when '4' then
@bids_results = get_bids_by_tag($selected_tags)
@obj = Bid.find_by_id(@obj_id)
@offset, @limit = api_offset_and_limit({:limit => @numbers})
@offset, @limit = api_offset_and_limit({:limit => @@numbers})
@project_count = @bids_results.count
@obj_pages = Paginator.new @project_count, @limit, params['page']
@offset ||= @obj_pages.offset
@bids_results = @bids_results.offset(@offset).limit(@limit).all
@bids_results = @bids_results.offset(@offset).limit(@limit)
else
@obj = nil
@obj = nil
end
end
# 删除已选tag
def delete_tag
@tag = params[:tag]
@show_flag = params[:show_flag]
$related_tags << @tag
$selected_tags.delete(@tag)
@obj_pages = nil
@numbers = Setting.tags_show_search_results
# @issues_results = get_issues_by_tag($selected_tags)
# @projects_results = get_projects_by_tag($selected_tags)
# @users_results = get_users_by_tag($selected_tags)
case @show_flag
when '1' then
@users_results = get_users_by_tag($selected_tags)
@obj = User.find_by_id(@obj_id)
@offset, @limit = api_offset_and_limit({:limit => @numbers})
@offset, @limit = api_offset_and_limit({:limit => @@numbers})
@project_count = @users_results.count
@obj_pages = Paginator.new @project_count, @limit, params['page']
@offset ||= @obj_pages.offset
@ -173,7 +144,7 @@ class TagsController < ApplicationController
@projects_results = get_projects_by_tag($selected_tags)
@obj = Project.find_by_id(@obj_id)
@offset, @limit = api_offset_and_limit({:limit => @numbers})
@offset, @limit = api_offset_and_limit({:limit => @@numbers})
@project_count = @projects_results.count
@obj_pages = Paginator.new @project_count, @limit, params['page']
@offset ||= @obj_pages.offset
@ -183,20 +154,26 @@ class TagsController < ApplicationController
@issues_results = get_issues_by_tag($selected_tags)
@obj = Issue.find_by_id(@obj_id)
@offset, @limit = api_offset_and_limit({:limit => @numbers})
@offset, @limit = api_offset_and_limit({:limit => @@numbers})
@project_count = @issues_results.count
@obj_pages = Paginator.new @project_count, @limit, params['page']
@offset ||= @obj_pages.offset
@issues_results = @issues_results.offset(@offset).limit(@limit).all
when '4'
@bids_results = get_bids_by_tag($selected_tags)
@obj_pages,@bids_results = for_pagination(get_bids_by_tag($selected_tags))
# @bids_results = get_bids_by_tag($selected_tags)
@obj = Bid.find_by_id(@obj_id)
#
# @offset, @limit = api_offset_and_limit({:limit => @@numbers})
# @project_count = @bids_results.count
# @obj_pages = Paginator.new @project_count, @limit, params['page']
# @offset ||= @obj_pages.offset
# @bids_results = @bids_results.offset(@offset).limit(@limit).all
@offset, @limit = api_offset_and_limit({:limit => @numbers})
@project_count = @bids_results.count
@obj_pages = Paginator.new @project_count, @limit, params['page']
@offset ||= @obj_pages.offset
@bids_results = @bids_results.offset(@offset).limit(@limit).all
else
@obj = nil
@ -209,22 +186,13 @@ class TagsController < ApplicationController
def show_all
@tags = ActsAsTaggableOn::Tag.find(:all)
end
def for_pagination(results)
@offset, @limit = api_offset_and_limit({:limit => 2})
@project_count = results.count
@obj_pages = Paginator.new @project_count, @limit, params['page']
@offset ||= @obj_pages.offset
results = results.offset(@offset).limit(@limit).order('lft').all
end
#完全从数据库删除tag
def delete
if params[:q]
@tag = ActsAsTaggableOn::Tag.find_by_id(params[:q])
@tag.delete
@tag.delete
@taggings = ActsAsTaggableOn::Tagging.find_all_by_tag_id(@tag.id)
@taggings.each do |tagging|
tagging.delete
end
@ -238,4 +206,51 @@ private
end
# 这里用来刷新搜索结果的区域
# 函数的返回值 前2字段用来处理获取其他tag和分页 另外4个返回值为过滤结果
def refresh_results(obj_id,obj_flag)
@users_results = nil
@projects_results = nil
@issues_results = nil
@bids_results = nil
@obj_pages = nil
@obj = nil
# 这里为了提高系统的响应速度 把搜索结果放到case中去了
case obj_flag
when '1' then
@obj = User.find_by_id(obj_id)
@obj_pages,@users_results = for_pagination(get_users_by_tag($selected_tags))
when '2' then
@obj = Project.find_by_id(obj_id)
@obj_pages,@projects_results = for_pagination(get_projects_by_tag($selected_tags))
when '3' then
@obj = Issue.find_by_id(obj_id)
@obj_pages,@issues_results = for_pagination(get_issues_by_tag($selected_tags))
when '4' then
@obj_pages,@bids_results = for_pagination(get_bids_by_tag($selected_tags))
@obj = Bid.find_by_id(obj_id)
else
@obj = nil
end
return @obj,@obj_pages,@users_results,@projects_results,@issues_results,@bids_results
end
def for_pagination(results)
@offset, @limit = api_offset_and_limit({:limit => 3}) # 设置每页显示的个数
@results_count = results.count
@obj_pages = Paginator.new @results_count, @limit, params['page']
@offset ||= @obj_pages.offset
results = results.offset(@offset).limit(@limit).all # 这里默认设置为按时间排序
return @obj_pages,results
end
#获取有某类对象的tag总数
def get_tags_size
@issues_tags_num = Issue.tag_counts.size
@projects_tags_num = Project.tag_counts.size
@users_tags_num = User.tag_counts.size
@bids_tags_num = Bid.tag_counts.size
return @users_tags_num,@projects_tags_num,@issues_tags_num,@bids_tags_num
end
end

View File

@ -14,10 +14,8 @@
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
class WatchersController < ApplicationController
before_filter :require_login, :find_watchables, :only => [:watch, :unwatch]
def watch
set_watcher(@watchables, User.current, true)
end
@ -86,7 +84,7 @@ class WatchersController < ApplicationController
end
rescue
render_404
end
end
def find_watchables
klass = Object.const_get(params[:object_type].camelcase) rescue nil
@ -100,7 +98,27 @@ class WatchersController < ApplicationController
def set_watcher(watchables, user, watching)
watchables.each do |watchable|
watchable.set_watcher(user, watching)
@user = watchable # added by william
# @user = watchable # added by william
if watching
# 修改 user和project的状态
if watchable.instance_of?(User)
#写user_statuses表
watchable.user_status.update_watchers_count(1)
elsif watchable.instance_of?(Project)
#写project_statuese表
watchable.project_status.update_watchers_count(1)
end
else
# 修改 user和project的状态
if watchable.instance_of?(User)
#写user_statuses表
watchable.user_status.update_watchers_count(-1)
elsif watchable.instance_of?(Project)
#写project_statuese表 :project_status
watchable.project_status.update_watchers_count(-1)
end
end
end
respond_to do |format|
format.html { redirect_to_referer_or {render :text => (watching ? 'Watcher added.' : 'Watcher removed.'), :layout => true}}

View File

@ -34,7 +34,7 @@ module BidsHelper
# this method is used to get all projects that tagged one tag
# added by william
def get_bids_by_tag(tag_name)
Bid.tagged_with(tag_name)
Bid.tagged_with(tag_name).order('updated_on desc')
end
end

View File

@ -33,7 +33,7 @@ module GroupsHelper
s = content_tag('div', principals_check_box_tags('user_ids[]', principals), :id => 'principals')
links = pagination_links_full(principal_pages, principal_count, :per_page_links => false) {|text, parameters, options|
links = pagination_links_full(principal_pages, principal_count, :per_page_links => false){|text, parameters, options|
link_to text, autocomplete_for_user_group_path(group, parameters.merge(:q => params[:q], :format => 'js')), :remote => true
}

View File

@ -377,7 +377,7 @@ module IssuesHelper
# this method is used to get all projects that tagged one tag
# added by william
def get_issues_by_tag(tag_name)
Issue.tagged_with(tag_name)
Issue.tagged_with(tag_name).order('updated_on desc')
end
end

View File

@ -21,7 +21,7 @@ module MembersHelper
def render_principals_for_new_members(project)
scope = Principal.active.sorted.not_member_of(project).like(params[:q])
principal_count = scope.count
principal_pages = Redmine::Pagination::Paginator.new principal_count, 10, params['page']#by young
principal_pages = Redmine::Pagination::Paginator.new principal_count, 10, params['page'] #by young
principals = scope.offset(principal_pages.offset).limit(principal_pages.per_page).all
s = content_tag('div', principals_check_box_tags('membership[user_ids][]', principals), :id => 'principals')

View File

@ -85,7 +85,7 @@ module ProjectsHelper
# this method is used to get all projects that tagged one tag
# added by william
def get_projects_by_tag(tag_name)
Project.tagged_with(tag_name)
Project.tagged_with(tag_name).order('updated_on desc')
end
end

View File

@ -58,7 +58,7 @@ module UsersHelper
# this method is used to get all projects that tagged one tag
# added by william
def get_users_by_tag(tag_name)
User.tagged_with(tag_name)
User.tagged_with(tag_name).order('updated_on desc')
end
# added by fq

View File

@ -56,6 +56,8 @@ class Project < ActiveRecord::Base
# end
#ADDED BY NIE
has_many :project_infos, :dependent => :destroy
has_one :project_status, :class_name => "ProjectStatus", :dependent => :destroy
#end
has_one :wiki, :dependent => :destroy
# Custom field for the project issues
@ -81,10 +83,10 @@ class Project < ActiveRecord::Base
:url => Proc.new {|o| {:controller => 'projects', :action => 'show', :id => o}},
:author => nil
############################added by william
acts_as_taggable
scope :by_join_date, order("created_at DESC")
acts_as_taggable
scope :by_join_date, order("created_on DESC")
###################added by liuping 关注
acts_as_watchable
acts_as_watchable
attr_protected :status

View File

@ -0,0 +1,21 @@
class ProjectStatus < ActiveRecord::Base
attr_accessible :changesets_count, :watchers_count, :project_id
belongs_to :projects
belongs_to :watchers
belongs_to :changesets
validates_presence_of :project_id
validates_uniqueness_of :project_id
# 更新字段 watchers_count 加1 这里没有做用户是否存在的匹配
# 负责这个表的聂同学 是在新建用户时就新建了该表的记录
# 但是 如果超级用户删除其他用户的话会造成读取错误 这里是遗漏点
# 删除用户时 此表创建人员未作相应删除动作
def update_watchers_count(num)
if self.watchers_count >= 0
self.update_attribute(:watchers_count, self.watchers_count.to_i + num)
end
end
end

View File

@ -89,6 +89,7 @@ class User < Principal
######added by nie
has_many :project_infos, :dependent => :destroy
has_one :user_status, :dependent => :destroy
#####
scope :logged, lambda { where("#{User.table_name}.status <> #{STATUS_ANONYMOUS}") }
@ -99,10 +100,10 @@ class User < Principal
acts_as_customizable
############################added by william
acts_as_taggable
scope :by_join_date, order("created_at DESC")
scope :by_join_date, order("created_on DESC")
############################# added by liuping 关注
acts_as_watchable
has_one :user_extensions
acts_as_watchable
has_one :user_extensions,:dependent => :destroy
## end
attr_accessor :password, :password_confirmation

View File

@ -1,11 +0,0 @@
class UserExtension < ActiveRecord::Base
attr_accessible :birthday, :brief_introduction, :fans_num, :finish_project_num, :follow_num, :gender, :good_num, :location, :occupation, :publish_requirement_num, :user_id, :work_experience, :zip_code
belongs_to :user
validate :validate_user
def validate_user
errors.add :user_id, :invalid if user.nil? || !user.active? || User.current != user_id
end
end

20
app/models/user_status.rb Normal file
View File

@ -0,0 +1,20 @@
class UserStatus < ActiveRecord::Base
attr_accessible :changesets_count, :user_id, :watchers_count
belongs_to :users
belongs_to :watchers
belongs_to :changesets
validates_presence_of :user_id
validates_uniqueness_of :user_id
# 更新字段 watchers_count 加1 这里没有做用户是否存在的匹配
# 负责这个表的聂同学 是在新建用户时就新建了该表的记录
# 但是 如果超级用户删除其他用户的话会造成读取错误 这里是遗漏点
# 删除用户时 此表创建人员未作相应删除动作
def update_watchers_count(num)
if self.watchers_count >= 0
self.update_attribute(:watchers_count, self.watchers_count.to_i + num)
end
end
end

View File

@ -69,7 +69,7 @@
<%= render :partial => 'users/preferences' %></div>
</fieldset>
<!-- added by william -->
<fieldset class="collapsible collapsed" style="width:800px;margin-left: 10px;display: none;">
<fieldset class="collapsible collapsed" style="width:800px;margin-left: 10px;display: none">
<legend onclick="toggleFieldset(this);">
<%= l(:label_user_extensions)%>
</legend>

View File

@ -6,10 +6,7 @@
<span id="tag">
<%= rt %>
</span>
<% @issue_size = Issue.tagged_with("#{rt}").size %>
<% @project_size = Project.tagged_with(rt).size %>
<% @user_size = User.tagged_with("#{rt}").size %>
(<%= @user_size + @project_size + @issue_size %>)
<%= render :partial => 'sidebar_tags',:locals => {:show_flag => show_flag,:sg => rt }%>
</li>
<% end %>
</ul>

View File

@ -2,12 +2,10 @@
<ul style="list-style-type: none">
<% for sg in selected_tags %>
<li>
<%= link_to image_tag("/images/sidebar/minus.png"),:action => "delete_tag",:remote=>true,:tag => sg,:show_flag => show_flag %>
<%= link_to image_tag("/images/sidebar/minus.png"),:action => "delete_tag",
:remote=>true,:tag => sg,:show_flag => show_flag %>
<span id="tag"><%= sg %> </span>
<% @issue_size = Issue.tagged_with("#{sg}").size %>
<% @project_size = Project.tagged_with(sg).size %>
<% @user_size = User.tagged_with("#{sg}").size %>
(<%= @user_size + @project_size + @issue_size %>)
<%= render :partial => 'sidebar_tags',:locals => {:show_flag => show_flag,:sg => sg }%>
</li>
<% end %>
</ul>

View File

@ -6,6 +6,7 @@
<strong><%= l(:label_tags_bid) %>:<%= link_to "#{bid.name}",:controller => "bids",:action => "show",:id => bid.id %></strong>
<br />
<strong><%= l(:label_tags_bid_description) %>:</strong><%= bid.description %>
<%= bid.updated_on %>
</p>
<div class="line_under"></div>
<% end %>

View File

@ -39,7 +39,5 @@
<% else %>
<div><%= l(:label_tags_no) %></div>
<% end %>
<% end %>

View File

@ -15,16 +15,14 @@
<%= render :partial => "show_bids",:locals => {:bids_results => bids_results}%>
<% else %>
<strong><%= l(:label_tags_all_objects)%></strong>
<!-- 这里为显示搜有过滤结果预留了默认设置 -->
<%= render :partial => "show_issues",:locals => {:issues_results => issues_results }%>
<%= render :partial => "show_users",:locals => {:users_results => users_results }%>
<%= render :partial => "show_projects",:locals => {:projects_results => projects_results }%>
<%= render :partial => "show_bids",:locals => {:bids_results => bids_results}%>
<% end %>
<% else %>
<span>no data.</span>
<% end %>
</ul>
<div class="pagination" style="float:right;">
<ul>
<%= pagination_links_full @obj_pages %>
<ul>
</div>

View File

@ -4,6 +4,7 @@ $('#related_tags').html('<%= j(render :partial => "related_tags",
:locals => {:related_tags => $related_tags ,:show_flag => @show_flag })%>')
$('#show_results').html('<%= j(render :partial => "tag_search_results",:locals => {:issues_results => @issues_results,
:projects_results => @projects_results,:users_results => @users_results,:bids_results => @bids_results ,:show_flag => @show_flag })%>')
:projects_results => @projects_results,:users_results => @users_results,
:bids_results => @bids_results ,:show_flag => @show_flag,:obj_pages => @obj_pages })%>')

View File

@ -4,5 +4,7 @@ $('#related_tags').html('<%= j(render :partial => "related_tags",
:locals => {:related_tags => $related_tags,:show_flag => @show_flag })%>')
$('#show_results').html('<%= j(render :partial => "tag_search_results",:locals => {:issues_results => @issues_results,
:projects_results => @projects_results,:users_results => @users_results,:bids_results => @bids_results ,:show_flag => @show_flag })%>')
:projects_results => @projects_results,:users_results => @users_results,
:bids_results => @bids_results ,:show_flag => @show_flag ,:obj_pages => @obj_pages })%>')

View File

@ -1,14 +1,14 @@
<% content_for :sidebar do %>
<div>
<h3><strong><%= l(:label_tags_selected) %></strong></h3>
<div id="selected_tags">
<%= render :partial => "selected_tags",:locals => {:selected_tags => $selected_tags,:show_flag => @obj_flag}%>
</div>
<h3><strong><%= l(:label_tags_related) %></strong></h3>
<div id="related_tags">
<%= render :partial => "related_tags",:locals => {:related_tags => $related_tags,:show_flag => @obj_flag }%>
</div>
<h3><strong><%= l(:label_tags_selected) %></strong></h3>
<div id="selected_tags">
<%= render :partial => "selected_tags",:locals => {:selected_tags => $selected_tags,:show_flag => @obj_flag}%>
</div>
<h3><strong><%= l(:label_tags_related) %></strong></h3>
<div id="related_tags">
<%= render :partial => "related_tags",:locals => {:related_tags => $related_tags,:show_flag => @obj_flag }%>
</div>
</div>
<% end %>
<% content_for :content do %>
@ -16,15 +16,18 @@
<h3><strong><%= l(:label_tags_search_result) %></strong></h3>
<div align="right">
<%= l(:label_tags_numbers) %>
<%= l(:label_issue_plural) %>(<%= @issues_tags_num %>)|
<%= l(:label_issue_plural) %>(<%= @issues_tags_num %>)|
<%= l(:label_project_plural) %>(<%= @projects_tags_num %>)|
<%= l(:label_user_plural) %>(<%= @users_tags_num %>)|
<%= l(:label_tags_call)%>(<%= @bids_tags_num %>)
</div>
<div id="show_results">
<%= render :partial => "tag_search_results",:locals => {:issues_results => @issues_results,
:projects_results => @projects_results,:users_results => @users_results ,:bids_results=>@bids_results,:show_flag => @obj_flag}%>
</div>
<div id="show_results">
<%= render :partial => "tag_search_results",:locals => {:issues_results => @issues_results,
:projects_results => @projects_results,:users_results => @users_results ,
:bids_results=>@bids_results,:show_flag => @obj_flag}%>
</div>
</div>
<%= render :partial => "pagination",:locals => {:obj_pages => @obj_pages}%>
<% end %>

View File

@ -5,7 +5,7 @@
<div id="show_all_tags">
<% for tag in @tags %>
<span id="tag" class="tag<%= tag.id %>">
<%= link_to tag.name,:remote=>true,:action=>"delete",:q => tag.id%>
<%= link_to tag.name,:remote=>true,:action=>"delete",:q => tag.id,:confirm => "Are you Sure?"%>
</span>
<% end %>
<% end %>

View File

@ -1,5 +1,2 @@
<% selector = ".#{watcher_css(watched)}" %>
$("<%= selector %>").each(function(){$(this).replaceWith("<%= escape_javascript watcher_link(watched, user) %>")});
$('#fans_num').html('<%= j(render :partial => "/watchers/fans_num",:locals => {:fans_num => get_fans_num(@user) }
) %>');