给tag search结果添加了分页。
|
@ -15,6 +15,7 @@ class BidsController < ApplicationController
|
|||
@bids = @bids.like(params[:name]) if params[:name].present?
|
||||
@bid_count = @bids.count
|
||||
@bid_pages = Paginator.new @bid_count, @limit, params['page']
|
||||
|
||||
@offset ||= @bid_pages.reverse_offset
|
||||
#@bids = @bids.offset(@offset).limit(@limit).all.reverse
|
||||
unless @offset == 0
|
||||
|
|
|
@ -7,6 +7,7 @@ class TagsController < ApplicationController
|
|||
include UsersHelper
|
||||
include BidsHelper
|
||||
include ActsAsTaggableOn::TagsHelper
|
||||
helper :projects
|
||||
|
||||
$selected_tags = Array.new
|
||||
$related_tags = Array.new
|
||||
|
@ -21,23 +22,56 @@ class TagsController < ApplicationController
|
|||
@users_tags_num = User.tag_counts.size
|
||||
@bids_tags_num = Bid.tag_counts.size
|
||||
|
||||
@issues_results = get_issues_by_tag($selected_tags)
|
||||
@projects_results = get_projects_by_tag($selected_tags)
|
||||
@users_results = get_users_by_tag($selected_tags)
|
||||
@bids_results = get_bids_by_tag($selected_tags)
|
||||
# 这里为了提高系统的响应速度 把搜索结果放到case中去了
|
||||
@users_results = nil
|
||||
@projects_results = nil
|
||||
@issues_results = nil
|
||||
@bids_results = nil
|
||||
@obj_pages = nil
|
||||
|
||||
@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
|
||||
|
@ -83,4 +117,12 @@ class TagsController < ApplicationController
|
|||
|
||||
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
|
||||
|
||||
end
|
||||
|
|
|
@ -99,7 +99,9 @@ class User < Principal
|
|||
acts_as_taggable
|
||||
scope :by_join_date, order("created_at DESC")
|
||||
############################# added by liuping 关注
|
||||
acts_as_watchable
|
||||
acts_as_watchable
|
||||
has_one :user_extensions
|
||||
## end
|
||||
|
||||
attr_accessor :password, :password_confirmation
|
||||
attr_accessor :last_before_login_on
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
class UserExtensions < ActiveRecord::Base
|
||||
belongs_to :user
|
||||
attr_accessible :user_id,:birthday,:brief_introduction,:gender,:location,:occupation,:work_experience,:zip_code
|
||||
#this method was used to update the table user_extensions
|
||||
def update_user_extensions(birthday=nil,brief_introduction=nil,
|
||||
|
|
|
@ -5,8 +5,6 @@
|
|||
|
||||
<h3 style="padding-left: 10px;"><%= l(:label_my_account)%></h3>
|
||||
|
||||
|
||||
|
||||
<fieldset class="box" style="margin:10px;">
|
||||
<fieldset class="collapsible collapsed" style="width:800px;margin-left: 10px;">
|
||||
<legend onclick="toggleFieldset(this);">
|
||||
|
@ -70,6 +68,15 @@
|
|||
<div>
|
||||
<%= render :partial => 'users/preferences' %></div>
|
||||
</fieldset>
|
||||
<!-- added by william -->
|
||||
<fieldset class="collapsible collapsed" style="width:800px;margin-left: 10px;">
|
||||
<legend onclick="toggleFieldset(this);">
|
||||
<%= l(:label_user_extensions)%>
|
||||
</legend>
|
||||
<div>
|
||||
<%= render :partial => 'users/user_extensions' %></div>
|
||||
</fieldset>
|
||||
<!-- end -->
|
||||
<%= submit_tag l(:button_save) %>
|
||||
</fieldset>
|
||||
<% end %>
|
||||
|
|
|
@ -25,7 +25,7 @@
|
|||
<!-- <p class="pagination"><%= pagination_links_full @project_pages%></p> -->
|
||||
<div class="pagination">
|
||||
<ul>
|
||||
<%= pagination_links_full @project_pages%>
|
||||
<%= pagination_links_full @project_pages %>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<% if related_tags %>
|
||||
<ul>
|
||||
<ul style="list-style-type: none">
|
||||
<% for rt in related_tags %>
|
||||
<li>
|
||||
<%= link_to image_tag("/images/sidebar/add.png"),:action => "add_tag",:remote => true,:tag => rt,:show_flag => show_flag %>
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<% if selected_tags %>
|
||||
<ul>
|
||||
<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 %>
|
||||
|
|
|
@ -11,3 +11,8 @@
|
|||
<% end %>
|
||||
<% end %>
|
||||
</div>
|
||||
<div class="pagination" style="float:right;">
|
||||
<ul>
|
||||
<%= pagination_links_full @obj_pages %>
|
||||
<ul>
|
||||
</div>
|
|
@ -12,3 +12,8 @@
|
|||
|
||||
<% end %>
|
||||
</div>
|
||||
<div class="pagination" style="float:right;">
|
||||
<ul>
|
||||
<%= pagination_links_full @obj_pages %>
|
||||
<ul>
|
||||
</div>
|
||||
|
|
|
@ -11,6 +11,10 @@
|
|||
</div>
|
||||
<div class="line_under"></div>
|
||||
<% end %>
|
||||
|
||||
<% end %>
|
||||
</div>
|
||||
<div class="pagination" style="float:right;">
|
||||
<ul>
|
||||
<%= pagination_links_full @obj_pages %>
|
||||
<ul>
|
||||
</div>
|
|
@ -12,3 +12,8 @@
|
|||
<% end %>
|
||||
<% end %>
|
||||
</div>
|
||||
<div class="pagination" style="float:right;">
|
||||
<ul>
|
||||
<%= pagination_links_full @obj_pages %>
|
||||
<ul>
|
||||
</div>
|
|
@ -41,7 +41,7 @@
|
|||
<%= form_for "tag_for_save",:remote=>true,:url=>tag_path,
|
||||
:update => "tags_show",
|
||||
:complete => '$("#put-tag-form").hide();' do |f| %>
|
||||
<%= f.text_field :name ,:id => "name",:size=>"28",:require=>true,:maxlength => 25,:minlength=>1 %>
|
||||
<%= f.text_field :name ,:id => "name",:size=>"28",:require=>true,:maxlength => Setting.tags_max_length,:minlength=>Setting.tags_min_length %>
|
||||
<%= f.text_field :object_id,:value=> obj.id,:style=>"display:none"%>
|
||||
<%= f.text_field :object_flag,:value=> object_flag,:style=>"display:none"%>
|
||||
<%= f.submit "add"%>
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
<% case %>
|
||||
<% when show_flag == '1' %>
|
||||
<strong><%=l(:label_user)%><strong>
|
||||
<%= render :partial => "show_users",:locals => {:users_results => users_results }%>
|
||||
<%= render :partial => "show_users",:locals => {:users_results => users_results}%>
|
||||
<% when show_flag == '2'%>
|
||||
<strong><%=l(:label_project)%></strong>
|
||||
<%= render :partial => "show_projects",:locals => {:projects_results => projects_results }%>
|
||||
|
@ -12,7 +12,7 @@
|
|||
<%= render :partial => "show_issues",:locals => {:issues_results => issues_results }%>
|
||||
<% when show_flag == '4'%>
|
||||
<strong><%= l(:label_requirement)%></strong>
|
||||
<%= render :partial => "show_bids",:locals => {:bids_results => bids_results }%>
|
||||
<%= 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 }%>
|
||||
|
|
|
@ -1,10 +1,11 @@
|
|||
<% content_for :sidebar do %>
|
||||
<div>
|
||||
<strong>Selected Tags</strong>
|
||||
<h3><strong>Selected Tags</strong></h3>
|
||||
<div id="selected_tags">
|
||||
<%= render :partial => "selected_tags",:locals => {:selected_tags => $selected_tags,:show_flag => @obj_flag}%>
|
||||
</div>
|
||||
<strong>Related Tags</strong>
|
||||
|
||||
<h3><strong>Related Tags</strong></h3>
|
||||
<div id="related_tags">
|
||||
<%= render :partial => "related_tags",:locals => {:related_tags => $related_tags,:show_flag => @obj_flag }%>
|
||||
</div>
|
||||
|
@ -13,7 +14,7 @@
|
|||
<% content_for :content do %>
|
||||
<div>
|
||||
<h3><strong>Search Results</strong></h3>
|
||||
<div id="filter-menu" align="right">
|
||||
<div align="right">
|
||||
<%= l(:label_tags_numbers) %>
|
||||
<%= l(:label_issue_plural) %>(<%= @issues_tags_num %>)|
|
||||
<%= l(:label_project_plural) %>(<%= @projects_tags_num %>)|
|
||||
|
|
|
@ -0,0 +1,26 @@
|
|||
<%= labelled_fields_for :user_extensions, @user.user_extensions do |user_extension| %>
|
||||
|
||||
<p style="width:400px;padding-left: 26px;">
|
||||
<%= user_extension.text_field :birthday %>
|
||||
</p>
|
||||
<p style="width:400px;">
|
||||
<%= user_extension.select :gender, [[l(:label_boy), '1'], [l(:label_girl), '0']] %>
|
||||
</p>
|
||||
|
||||
<p style="width:400px;padding-left: 26px;">
|
||||
<%= user_extension.text_area :brief_introduction %>(少于250字)
|
||||
</p>
|
||||
<p style="width:400px;padding-left: 26px;">
|
||||
<%= user_extension.text_field :location %>
|
||||
</p>
|
||||
<p style="width:400px;padding-left: 26px;">
|
||||
<%= user_extension.text_field :occupation %>
|
||||
</p>
|
||||
<p style="width:400px;padding-left: 26px;">
|
||||
<%= user_extension.text_field :work_experience %>
|
||||
</p>
|
||||
<p style="width:400px;padding-left: 26px;">
|
||||
<%= user_extension.text_field :zip_code %>
|
||||
</p>
|
||||
|
||||
<% end %>
|
|
@ -1173,6 +1173,18 @@ zh:
|
|||
label_tags_bid_description: 需求描述
|
||||
label_tags_issue_description: 问题描述
|
||||
label_tags_all_objects: 所有
|
||||
|
||||
label_user_extensions: 其他信息
|
||||
label_boy: 男
|
||||
label_girl: 女
|
||||
field_gender: 性别
|
||||
field_birthday: 生日
|
||||
field_brief_introduction: 个人简介
|
||||
field_location: 现住址
|
||||
field_occupation: 学校/公司
|
||||
field_work_experience: 工作经验(年)
|
||||
field_zip_code: 邮编
|
||||
|
||||
#fq
|
||||
button_leave_meassge: 留言
|
||||
label_leave_message_to: 给用户 %{name}留言
|
||||
|
|
|
@ -234,12 +234,12 @@ non_working_week_days:
|
|||
show_tags_length:
|
||||
format: int
|
||||
default: 5
|
||||
show_tags_length:
|
||||
format: int
|
||||
default: 5
|
||||
tags_min_length:
|
||||
format: int
|
||||
default: 1
|
||||
tags_max_length:
|
||||
format: int
|
||||
default: 25
|
||||
default: 13
|
||||
tags_show_search_results:
|
||||
format: int
|
||||
default: 5
|
Before Width: | Height: | Size: 2.8 KiB After Width: | Height: | Size: 2.8 KiB |
Before Width: | Height: | Size: 2.8 KiB After Width: | Height: | Size: 2.8 KiB |
Before Width: | Height: | Size: 2.8 KiB After Width: | Height: | Size: 2.8 KiB |
Before Width: | Height: | Size: 2.8 KiB After Width: | Height: | Size: 2.8 KiB |
|
@ -251,6 +251,7 @@ a
|
|||
font-size: 11px;
|
||||
border-radius:3px;
|
||||
-moz-border-radius:3px;
|
||||
|
||||
-webkit-border-radius:3px;
|
||||
-o-border-radius:3px;
|
||||
-ms-border-radius:3px;
|
||||
|
@ -1070,7 +1071,9 @@ pre,code,.line-code
|
|||
}
|
||||
|
||||
|
||||
|
||||
div.project_tag_info a.root {
|
||||
font-size: 1.5em;
|
||||
}
|
||||
|
||||
div.wiki-description {
|
||||
/*word-break; break-all;
|
||||
|
|