Merge branch 'develop' of https://git.trustie.net/jacknudt/trustieforge into develop

This commit is contained in:
cxt 2016-10-13 14:25:36 +08:00
commit f56fc5a44d
14 changed files with 298 additions and 115 deletions

View File

@ -112,7 +112,7 @@ module Mobile
# end
if reply_type == nil || reply_type == 0
homework_common = HomeworkCommon.find(params[:id])
feedback = HomeworkCommon.add_homework_jour(current_user, params[:content], params[:id])
feedback = HomeworkCommon.add_homework_jour(current_user, params[:content], params[:id], params[:id])
if (feedback.errors.empty?)
homework_common.update_column(:updated_at, Time.now)
result = 2
@ -124,7 +124,7 @@ module Mobile
homework_common = HomeworkCommon.find reply.jour_id
options = {:notes => params[:content], :reply_id => reply.user_id,:user_id => current_user.id,:m_parent_id => params[:id].to_i,:m_reply_id => params[:id].to_i}
feedback = HomeworkCommon.add_homework_jour(current_user, params[:content], reply.jour_id, options)
feedback = HomeworkCommon.add_homework_jour(current_user, params[:content], reply.jour_id, reply.jour_id, options)
if (feedback.errors.empty?)
homework_common.update_column(:updated_at, Time.now)
result = 2
@ -189,6 +189,7 @@ module Mobile
reply.content = params[:content]
reply.parent_id = params[:id]
reply.subject = "RE: #{topic.subject}"
reply.root_id = topic.id
if message.children << reply
result = 2
update_id = topic.id
@ -224,6 +225,7 @@ module Mobile
:m_parent_id => parent_id,
:m_reply_id => reply_id,
:reply_id => reply_user_id,
:root_id => jour.id,
:notes => content,
:is_readed => false}
jfm = jour.user.add_jour(nil, nil, nil, options)
@ -278,6 +280,7 @@ module Mobile
blogComment.blog = blog.blog
blogComment.content = params[:content]
blogComment.title = "RE: #{blog.title}"
blogComment.root_id = blog.id
if blog.children << blogComment
result = 2
update_id = blog.id
@ -293,6 +296,7 @@ module Mobile
parent = BlogComment.find params[:id]
blogComment.parent_id = params[:id] #被回复的回复
blogComment.reply_id = parent.author.id #被回复者id
blogComment.root_id = blog.id
if parent.children << blogComment
result = 2

View File

@ -25,8 +25,10 @@ module Mobile
elsif ac.act_type == "News"
ac.nil? || ac.act.nil? ? 0 : ac.act.comments.count
elsif ac.act_type == "Message" || ac.act_type == "BlogComment" || ac.act_type == "JournalsForMessage"
all_comments = []
ac.nil? || ac.act.nil? ? 0 : get_all_children(all_comments, ac.act).count
className = ac.act_type.classify.constantize
# all_comments = []
# ac.nil? || ac.act.nil? ? 0 : get_all_children(all_comments, ac.act).count
ac.nil? || ac.act.nil? ? 0 : className.where("root_id = #{ac.act.id}").count
elsif ac.act_type == "Issue"
ac.nil? || ac.act.nil? ? 0 : ac.act.journals.where("notes is not null and notes != ''").count
end

View File

@ -153,72 +153,10 @@ class WelcomeController < ApplicationController
def search
@name = params[:q]
@search_type = params[:search_type]
case params[:search_type]
when 'all'
@alls = Elasticsearch::Model.search({
query: {
multi_match: {
query: @name,
type:"most_fields",
operator: "or",
fields: ['login', 'firstname','lastname','name','description^0.5','filename','subject','content^0.5']
}
},
highlight: {
pre_tags: ['<span class="c_red">'],
post_tags: ['</span>'],
fields: {
login: {},
firstname: {},
lastname: {},
name:{},
description:{},
filename:{},
subject:{},
content:{}
}
}
},[User,Course,Attachment,Project,Memo] ).page(params[:page] || 1).per(20).results
when 'user'
@users = User.search(@name).page(params[:page] || 1).per(20)
when 'project'
@projects = Project.search(@name).page(params[:page] || 1).per(20).results
when 'course'
@courses = Course.search(@name).page(params[:page] || 1).per(20).results
when 'attachment'
@attachments = Attachment.search(@name).page(params[:page] || 1).per(20).results
when 'memo'
@memos = Memo.search(@name).page(params[:page] || 1).per(20).results
else
@alls = Elasticsearch::Model.search({
query: {
multi_match: {
query: @name,
type:"most_fields",
operator: "or",
fields: ['login', 'firstname','lastname','name','description^0.5','filename','subject','content^0.5']
}
},
highlight: {
pre_tags: ['<span class="c_red">'],
post_tags: ['</span>'],
fields: {
login: {},
firstname: {},
lastname: {},
name:{},
description:{},
filename:{},
subject:{},
content:{}
}
}
},[User,Course,Attachment,Project,Memo] ).page(params[:page] || 1).per(20).results
end
page = (params[:page] || 1).to_i
@users_count = User.search(@name).results.total
@syllabus_count = Syllabus.search(@name).results.total
@course_count = Course.search(@name).results.total
@attach_count = Attachment.search(@name).results.total
@project_count = Project.search(@name).results.total
@ -229,7 +167,7 @@ class WelcomeController < ApplicationController
query: @name,
type:"most_fields",
operator: "or",
fields: ['login', 'firstname','lastname','name','description^0.5','filename','subject','content^0.5']
fields: ['login', 'firstname','lastname','title','name','description^0.5','filename','subject','content^0.5']
}
},
highlight: {
@ -239,6 +177,7 @@ class WelcomeController < ApplicationController
login: {},
firstname: {},
lastname: {},
title:{},
name:{},
description:{},
filename:{},
@ -246,7 +185,110 @@ class WelcomeController < ApplicationController
content:{}
}
}
},[User,Course,Attachment,Project,Memo] ).results.total
},[User,Syllabus,Course,Attachment,Project,Memo] ).results.total
case params[:search_type]
when 'all'
if (page-1)*20 >= @total_count
page = 1
params[:page] = "1"
end
@alls = Elasticsearch::Model.search({
query: {
multi_match: {
query: @name,
type:"most_fields",
operator: "or",
fields: ['login', 'firstname','lastname','title','name','description^0.5','filename','subject','content^0.5']
}
},
highlight: {
pre_tags: ['<span class="c_red">'],
post_tags: ['</span>'],
fields: {
login: {},
firstname: {},
lastname: {},
title:{},
name:{},
description:{},
filename:{},
subject:{},
content:{}
}
}
},[User,Syllabus,Course,Attachment,Project,Memo] ).page(page).per(20).results
when 'user'
if (page-1)*20 >= @users_count
page = 1
params[:page] = "1"
end
@users = User.search(@name).page(page).per(20)
when 'syllabus'
if (page-1)*20 >= @syllabus_count
page = 1
params[:page] = "1"
end
@syllabuses = Syllabus.search(@name).page(page).per(20).results
when 'project'
if (page-1)*20 >= @project_count
page = 1
end
@projects = Project.search(@name).page(page).per(20).results
when 'course'
if (page-1)*20 >= @course_count
page = 1
params[:page] = "1"
end
@courses = Course.search(@name).page(page).per(20).results
when 'attachment'
if (page-1)*20 >= @attach_count
page = 1
params[:page] = "1"
end
@attachments = Attachment.search(@name).page(page).per(20).results
when 'memo'
if (page-1)*20 >= @memo_count
page = 1
params[:page] = "1"
end
@memos = Memo.search(@name).page(page).per(20).results
else
if (page-1)*20 >= @total_count
page = 1
params[:page] = "1"
end
@alls = Elasticsearch::Model.search({
query: {
multi_match: {
query: @name,
type:"most_fields",
operator: "or",
fields: ['login', 'firstname','lastname','title','name','description^0.5','filename','subject','content^0.5']
}
},
highlight: {
pre_tags: ['<span class="c_red">'],
post_tags: ['</span>'],
fields: {
login: {},
firstname: {},
lastname: {},
title:{},
name:{},
description:{},
filename:{},
subject:{},
content:{}
}
}
},[User,Syllabus,Course,Attachment,Project,Memo] ).page(page).per(20).results
end
# search_type = params[:search_type].to_sym unless search_condition.blank?
# search_by = params[:search_by]
#

View File

@ -2,6 +2,18 @@
class Syllabus < ActiveRecord::Base
include Redmine::SafeAttributes
include ApplicationHelper
#elasticsearch
include Elasticsearch::Model
#elasticsearch kaminari init
Kaminari::Hooks.init
Elasticsearch::Model::Response::Response.__send__ :include, Elasticsearch::Model::Response::Pagination::Kaminari
settings index: { number_of_shards: 5 } do
mappings dynamic: 'false' do
indexes :title, analyzer: 'smartcn',index_options: 'offsets'
indexes :description, analyzer: 'smartcn',index_options: 'offsets'
indexes :updated_at, index:"not_analyzed", type:'date'
end
end
acts_as_taggable
acts_as_attachable
has_many_kindeditor_assets :assets, :dependent => :destroy
@ -17,6 +29,12 @@ class Syllabus < ActiveRecord::Base
validates :title, :user_id, presence: true
after_update :update_syllabus_ealasticsearch_index
after_create :create_syllabus_ealasticsearch_index
before_destroy :delete_syllabus_ealasticsearch_index
scope :indexable,lambda { where(nil) }#用于elastic建索引的scope
scope :like, lambda {|arg|
if arg.blank?
where(nil)
@ -57,4 +75,55 @@ class Syllabus < ActiveRecord::Base
jfm.save
jfm
end
def create_syllabus_ealasticsearch_index
return if Rails.env.development?
self.__elasticsearch__.index_document
end
def update_syllabus_ealasticsearch_index
return if Rails.env.development?
begin
self.__elasticsearch__.update_document
rescue => e
self.__elasticsearch__.index_document
end
end
def delete_syllabus_ealasticsearch_index
return if Rails.env.development?
begin
self.__elasticsearch__.delete_document
rescue => e
end
end
def self.search(query)
__elasticsearch__.search(
{
query: {
multi_match: {
query: query,
type:"most_fields",
operator: "or",
fields: ['title']
}
},
sort: {
_score:{order: "desc" },
updated_at:{order:"desc"}
},
highlight: {
pre_tags: ['<span class="c_red">'],
post_tags: ['</span>'],
fields: {
title: {},
description: {}
}
}
}
)
end
end

View File

@ -431,6 +431,12 @@ class User < Principal
name = lastname + firstname
name.empty? || name.nil? ? login : name
end
def show_occupation
if self.user_extensions && self.user_extensions.school
self.user_extensions.school.name
end
end
## end
def get_at_show_name

View File

@ -51,7 +51,7 @@
<% name = name%>
<%= form_tag({controller: :welcome, action: :search },:class=>'navHomepageSearchBox', method: :get) do %>
<input type="text" name="q" value="<%= name.nil? ? "" : name%>" id="navHomepageSearchInput" class="navHomepageSearchInput" placeholder="请输入关键词搜索公开的班级、项目、用户、资源以及帖子"/>
<input type="text" name="q" value="<%= name.nil? ? "" : name%>" id="navHomepageSearchInput" class="navHomepageSearchInput" placeholder="请输入关键词搜索公开的课程、班级、项目、用户、资源以及帖子"/>
<input type="hidden" name="search_type" id="type" value="all"/>
<input type="text" style="display: none;"/>
<a href="javascript:void(0);" class="homepageSearchIcon" onclick="search_in_header($(this));"></a>

View File

@ -16,15 +16,31 @@
<div class="mt5 fl"><%= image_tag("search_icon_03.png", :width=>"8", :height=>"16" ,:class=>"fl") %><span class="searchTag"><%= get_user_identity(User.find(item.id).user_extensions.identity) %></span></div>
<div class="cl"></div>
</li>
<li class="fontGrey3 mb5"><%= User.find(item.id).user_extensions && User.find(item.id).user_extensions.brief_introduction.present? ? User.find(item.id).user_extensions.brief_introduction : '这位童鞋很懒,什么也没有留下~'%></li>
<% user = User.find(item.id)%>
<li class="fontGrey3 mb5"><%= user.user_extensions && user.user_extensions.brief_introduction.present? ? user.user_extensions.brief_introduction : '这位童鞋很懒,什么也没有留下~'%></li>
<li class="f12 fontGrey2">
<span class="mr30">加入时间:<%= format_date( User.find(item.id).created_on)%></span><span class="mr30">
最后登录时间:<%= format_date( User.find(item.id).last_login_on)%></span><span class="mr30">
<%= User.find(item.id).user_extensions.occupation.present? ? '单位:'+User.find(item.id).user_extensions.occupation : ''%></span></li>
<span class="mr30">加入时间:<%= format_date( user.created_on)%></span><span class="mr30">
最后登录时间:<%= format_date( user.last_login_on)%></span><span class="mr30">
<%=user.show_occupation.nil? ? "": "单位:"+user.show_occupation %></span></li>
</ul>
</li>
<div class="cl"></div>
</ul>
<% when 'syllabus'%>
<ul class="searchContent w968">
<li class="f16 mb5 fontGrey3">
<a href="<%= syllabus_path(item.id)%>" class="fontGrey3 fl"><%= item.try(:highlight).try(:title) ? item.highlight.title[0].html_safe : item.title %>课程</a>
<div class="mt5 fl"><%= image_tag("search_icon_03.png", :width=>"8", :height=>"16" ,:class=>"fl") %><span class="searchTag">课程</span></div><div class="cl"></div></li>
<li class="f12 fontGrey2">
<% user = User.find(item.user_id)%>
<% syllabus = Syllabus.find(item.id) %>
<span class="mr30">创建者:<%=user.login+"("+user.show_name+")"%></span>
<span class="mr30">教师团队:<%=syllabus.syllabus_members.count%></span>
<span class="mr30">班级:<%=syllabus.courses.count%></span>
<span class="mr30">更新时间:<%=format_date(item.updated_at)%></span>
<span class="mr30"><%=user.show_occupation.nil? ? "": "单位:"+user.show_occupation %></span>
</li>
</ul>
<% when 'course'%>
<ul class="searchContent">
<li class="fl">
@ -38,10 +54,11 @@
</li>
<li class="fontGrey3 mb5"><%= item.try(:highlight).try(:description) ? item.highlight.description[0].html_safe : item.description %></li>
<li class="f12 fontGrey2">
<span class="mr30">教师:<%= User.find(item.tea_id).realname %></span>
<% user = User.find(item.tea_id)%>
<span class="mr30">教师:<%= user.realname %></span>
<span class="mr30">授课时间:<%= item.time.to_s + item.term%></span>
<span class="mr30">更新时间:<%= format_date(item.updated_at)%></span>
<span class="mr30"><%= User.find(item.tea_id).user_extensions.occupation.present? ? '单位:'+User.find(item.tea_id).user_extensions.occupation : ''%></span></li>
<span class="mr30"><%=user.show_occupation.nil? ? "": "单位:"+user.show_occupation %></span></li>
</ul>
</li>
<div class="cl"></div>
@ -56,7 +73,8 @@
<div class="mt5 fl"><%= image_tag("search_icon_03.png", :width=>"8", :height=>"16" ,:class=>"fl") %><span class="searchTag">资源</span></div>
<div class="cl"></div>
</li>
<li class="f12 fontGrey2"><span class="mr30">发布者:<%= User.find(item.author_id).login%><%= User.find(item.author_id).realname%></span>
<% user = User.find(item.author_id)%>
<li class="f12 fontGrey2"><span class="mr30">发布者:<%= user.login%><%= user.realname%></span>
<!--<span class="mr30">职称:<%#= get_technical_title User.find(item.author_id) %></span>-->
<span class="mr30">发布时间:<%= format_date(item.created_on)%></span>
<span class="mr30">下载次数:<%= item.downloads%>次</span>

View File

@ -10,7 +10,8 @@
<div class="mt5 fl"><%= image_tag("search_icon_03.png", :width=>"8", :height=>"16" ,:class=>"fl") %><span class="searchTag">资源</span></div>
<div class="cl"></div>
</li>
<li class="f12 fontGrey2"><span class="mr30">发布者:<%= User.find(attachment.author_id).login%><%= User.find(attachment.author_id).realname%></span>
<% user = User.find(attachment.author_id)%>
<li class="f12 fontGrey2"><span class="mr30">发布者:<%= user.login%><%= user.realname%></span>
<!--<span class="mr30">职称:<%#= get_technical_title User.find(attachment.author_id) %></span>-->
<span class="mr30">发布时间:<%= format_date(attachment.created_on)%></span>
<span class="mr30">下载次数:<%= attachment.downloads%>次</span>
@ -21,6 +22,6 @@
</ul>
<% end %>
<div class="pageRoll">
<!%= paginate attachments,:params => {:controller => 'welcome', :action => 'search',:search_type=>'attachment'}%>
<%= paginate attachments,:params => {:controller => 'welcome', :action => 'search',:search_type=>'attachment'}%>
</div>
<% end %>

View File

@ -13,10 +13,11 @@
</li>
<li class="fontGrey3 mb5"><%= course.try(:highlight).try(:description) ? course.highlight.description[0].html_safe : (course.description.present? ? course.description : '暂时没有该班级描述') %></li>
<li class="f12 fontGrey2">
<span class="mr30">教师:<%= User.find(course.tea_id).realname %></span>
<% user = User.find(course.tea_id)%>
<span class="mr30">教师:<%= user.realname %></span>
<span class="mr30">授课时间:<%= course.time.to_s + course.term%></span>
<span class="mr30">更新时间:<%= format_date(course.updated_at)%></span>
<span class="mr30"><%= User.find(course.tea_id).user_extensions.occupation.present? ? '单位:'+User.find(course.tea_id).user_extensions.occupation : ''%></span></li>
<span class="mr30"><%=user.show_occupation.nil? ? "": "单位:"+user.show_occupation %></span></li>
</ul>
</li>
<div class="cl"></div>

View File

@ -0,0 +1,22 @@
<% unless syllabuses.nil? || syllabuses.empty?%>
<% syllabuses.each do |item|%>
<ul class="searchContent w968">
<li class="f16 mb5 fontGrey3">
<!--<a href="<%#= syllabus_path(syllabus.id)%>" class="fontGrey3 fl"><span class="c_red"><%#= syllabus.title %></span>课程</a>-->
<a href="<%= syllabus_path(item.id)%>" class="fontGrey3 fl"><%= item.try(:highlight).try(:title) ? item.highlight.title[0].html_safe : item.title %>课程</a>
<div class="mt5 fl"><%= image_tag("search_icon_03.png", :width=>"8", :height=>"16" ,:class=>"fl") %><span class="searchTag">课程</span></div><div class="cl"></div></li>
<li class="f12 fontGrey2">
<% user = User.find(item.user_id)%>
<% syllabus = Syllabus.find(item.id) %>
<span class="mr30">创建者:<%=user.login+"("+user.show_name+")"%></span>
<span class="mr30">教师团队:<%=syllabus.syllabus_members.count%></span>
<span class="mr30">班级:<%=syllabus.courses.count%></span>
<span class="mr30">更新时间:<%=format_date(syllabus.updated_at)%></span>
<span class="mr30"><%=user.show_occupation.nil? ? "": "单位:"+user.show_occupation %></span>
</li>
</ul>
<% end %>
<div class="pageRoll">
<%= paginate syllabuses,:params => {:controller => 'welcome', :action => 'search',:search_type=>'syllabus'}%>
</div>
<% end %>

View File

@ -1,20 +1,21 @@
<% unless users.nil? || users.empty?%>
<% users.each do |user|%>
<% users.each do |item|%>
<ul class="searchContent">
<li class="fl">
<!--<img src="images/homepageImage.jpg" alt="个人图片" width="75" height="75" class="searchCourseImage" />-->
<%= link_to image_tag(url_to_avatar(User.find(user.id)), :width => "75", :height => "75",:class=>'searchCourseImage'), user_path(user.id), :alt => "用户头像" %>
<% user = User.find(item.id)%>
<%= link_to image_tag(url_to_avatar(user), :width => "75", :height => "75",:class=>'searchCourseImage'), user_path(user.id), :alt => "用户头像" %>
</li>
<li class="fl searchContentDes">
<ul class="fl">
<li class="f16 mb5"><a href="<%= user_path(user.id)%>" class="fontGrey3 fl"><%= user.try(:highlight).try(:login) ? user.highlight.login[0].html_safe : user.login %>(<%= user.try(:highlight).try(:lastname) ? user.highlight.lastname[0].html_safe : user.lastname%><%= user.try(:highlight).try(:firstname) ? user.highlight.firstname[0].html_safe : user.firstname %>)</a>
<div class="mt5 fl"><%= image_tag("search_icon_03.png", :width=>"8", :height=>"16" ,:class=>"fl") %><span class="searchTag"><%= get_user_identity(User.find(user.id).user_extensions.identity) %></span></div>
<li class="f16 mb5"><a href="<%= user_path(user.id)%>" class="fontGrey3 fl"><%= item.try(:highlight).try(:login) ? item.highlight.login[0].html_safe : user.login %>(<%= item.try(:highlight).try(:lastname) ? item.highlight.lastname[0].html_safe : user.lastname%><%= item.try(:highlight).try(:firstname) ? item.highlight.firstname[0].html_safe : user.firstname %>)</a>
<div class="mt5 fl"><%= image_tag("search_icon_03.png", :width=>"8", :height=>"16" ,:class=>"fl") %><span class="searchTag"><%= get_user_identity(user.user_extensions.identity) %></span></div>
<div class="cl"></div>
</li>
<li class="fontGrey3 mb5"><%= User.find(user.id).user_extensions && User.find(user.id).user_extensions.brief_introduction.present? ? User.find(user.id).user_extensions.brief_introduction : '这位童鞋很懒,什么也没有留下~'%></li>
<li class="f12 fontGrey2"><span class="mr30">加入时间:<%= format_date( User.find(user.id).created_on)%></span><span class="mr30">
最后登录时间:<%= format_date( User.find(user.id).last_login_on)%></span><span class="mr30">
<%= User.find(user.id).user_extensions.occupation.present? ? '单位:'+User.find(user.id).user_extensions.occupation : ''%></span></li>
<li class="fontGrey3 mb5"><%= user.user_extensions && user.user_extensions.brief_introduction.present? ? user.user_extensions.brief_introduction : '这位童鞋很懒,什么也没有留下~'%></li>
<li class="f12 fontGrey2"><span class="mr30">加入时间:<%= format_date( user.created_on)%></span><span class="mr30">
最后登录时间:<%= format_date( user.last_login_on)%></span><span class="mr30">
<%=user.show_occupation.nil? ? "": "单位:"+user.show_occupation %></span></li>
</ul>
</li>
<div class="cl"></div>

View File

@ -3,7 +3,7 @@
function g(o){return document.getElementById(o);}
function HoverLi(n){
//如果有N个标签,就将i<=N;
for(var i=1;i<=6;i++){
for(var i=1;i<=7;i++){
g('searchBaner_'+i).className='searchBannerNormal';
g('searchContent_'+i).className='undis';g('searchNum_'+i).className="numRed";
g('searchType_'+i).className="fontGrey2 f14";
@ -23,12 +23,14 @@
//$("#searchContent_2").html('<%#= escape_javascript(render :partial => 'search_user_results',:locals => {:users=>@users})%>');
search('user')
}else if(n == 3){
search('course')
search('syllabus')
}else if(n == 4){
search('attachment')
search('course')
}else if(n == 5){
search('project')
search('attachment')
}else if(n == 6){
search('project')
}else if(n == 7){
search('memo')
}
}
@ -49,19 +51,22 @@
}else if('<%= @search_type%>' == 'user'){
HoverLi(2)
$("#searchContent_2").html('<%= escape_javascript(render :partial => 'search_user_results',:locals => {:users=>@users})%>');
}else if('<%= @search_type%>' == 'course'){
}else if('<%= @search_type%>' == 'syllabus'){
HoverLi(3)
$("#searchContent_3").html('<%= escape_javascript(render :partial => 'search_course_results',:locals => {:courses=>@courses})%>');
}else if('<%= @search_type%>' == 'attachment'){
$("#searchContent_3").html('<%= escape_javascript(render :partial => 'search_syllabus_results',:locals => {:syllabuses=>@syllabuses})%>');
}else if('<%= @search_type%>' == 'course'){
HoverLi(4)
$("#searchContent_4").html('<%= escape_javascript(render :partial => 'search_attachment_results',:locals => {:attachments=>@attachments})%>');
}else if('<%= @search_type%>' == 'project'){
$("#searchContent_4").html('<%= escape_javascript(render :partial => 'search_course_results',:locals => {:courses=>@courses})%>');
}else if('<%= @search_type%>' == 'attachment'){
HoverLi(5)
$("#searchContent_5").html('<%= escape_javascript(render :partial => 'search_project_results',:locals => {:projects=>@projects})%>');
$("#searchContent_5").html('<%= escape_javascript(render :partial => 'search_attachment_results',:locals => {:attachments=>@attachments})%>');
}else if('<%= @search_type%>' == 'project'){
HoverLi(6)
$("#searchContent_6").html('<%= escape_javascript(render :partial => 'search_project_results',:locals => {:projects=>@projects})%>');
}else if('<%= @search_type%>' == 'memo')
{
HoverLi(6)
$("#searchContent_6").html('<%= escape_javascript(render :partial => 'search_memo_results',:locals => {:memos=>@memos})%>');
HoverLi(7)
$("#searchContent_7").html('<%= escape_javascript(render :partial => 'search_memo_results',:locals => {:memos=>@memos})%>');
}
})
//如果要做成点击后再转到请将<li>中的onmouseover 改成 onclick;
@ -79,10 +84,11 @@
<ul id="searchBanner">
<li id="searchBaner_1" class="searchBannerActive" onclick="HoverLi(1);on_click_search(1);"><a href="javascript:void(0);" id="searchType_1" class="fontGrey3 f14">全部<span style="font-weight:normal;"><font id="searchNum_1" class="c_red">(<%= @total_count%>)</font></span></a></li>
<li id="searchBaner_2" onclick="HoverLi(2);on_click_search(2);"><a href="javascript:void(0);" id="searchType_2" class="fontGrey2 f14">用户<span class="numRed" style="font-weight:normal;"><font id="searchNum_2" class="numRed">(<%= @users_count%>)</font></span></a></li>
<li id="searchBaner_3" onclick="HoverLi(3);on_click_search(3);"><a href="javascript:void(0);" id="searchType_3" class="fontGrey2 f14">班级<span style="font-weight:normal;"><font id="searchNum_3" class="numRed">(<%=@course_count%>)</font></span></a></li>
<li id="searchBaner_4" onclick="HoverLi(4);on_click_search(4);"><a href="javascript:void(0);" id="searchType_4" class="fontGrey2 f14">资源<span class="numRed" style="font-weight:normal;"><font id="searchNum_4" class="numRed">(<%= @attach_count%>)</font></span></a></li>
<li id="searchBaner_5" onclick="HoverLi(5);on_click_search(5);"><a href="javascript:void(0);" id="searchType_5" class="fontGrey2 f14">项目<span class="numRed" style="font-weight:normal;"><font id="searchNum_5" class="numRed">(<%= @project_count%>)</font></span></a></li>
<li id="searchBaner_6" onclick="HoverLi(6);on_click_search(6);"><a href="javascript:void(0);" id="searchType_6" class="fontGrey2 f14">帖子<span class="numRed" style="font-weight:normal;"><font id="searchNum_6" class="numRed">(<%= @memo_count%>)</font></span></a></li>
<li id="searchBaner_3" onclick="HoverLi(3);on_click_search(3);"><a href="javascript:void(0);" id="searchType_3" class="fontGrey2 f14">课程<span style="font-weight:normal;"><font id="searchNum_3" class="numRed">(<%=@syllabus_count%>)</font></span></a></li>
<li id="searchBaner_4" onclick="HoverLi(4);on_click_search(4);"><a href="javascript:void(0);" id="searchType_4" class="fontGrey2 f14">班级<span style="font-weight:normal;"><font id="searchNum_4" class="numRed">(<%=@course_count%>)</font></span></a></li>
<li id="searchBaner_5" onclick="HoverLi(5);on_click_search(5);"><a href="javascript:void(0);" id="searchType_5" class="fontGrey2 f14">资源<span class="numRed" style="font-weight:normal;"><font id="searchNum_5" class="numRed">(<%= @attach_count%>)</font></span></a></li>
<li id="searchBaner_6" onclick="HoverLi(6);on_click_search(6);"><a href="javascript:void(0);" id="searchType_6" class="fontGrey2 f14">项目<span class="numRed" style="font-weight:normal;"><font id="searchNum_6" class="numRed">(<%= @project_count%>)</font></span></a></li>
<li id="searchBaner_7" onclick="HoverLi(7);on_click_search(7);"><a href="javascript:void(0);" id="searchType_7" class="fontGrey2 f14">帖子<span class="numRed" style="font-weight:normal;"><font id="searchNum_7" class="numRed">(<%= @memo_count%>)</font></span></a></li>
<div class="cl"></div>
</ul>
<ul id="searchTips" style="display:none;">
@ -97,13 +103,15 @@
<div id="searchContent_3" class="undis">
</div>
<div id="searchContent_4" class="undis">
</div>
<div id="searchContent_5" class="undis">
</div>
<div id="searchContent_6" class="undis">
</div>
<div id="searchContent_7" class="undis">
</div>
</div>
</div>

View File

@ -3,13 +3,15 @@
$("#searchContent_1").html('<%= escape_javascript(render :partial => 'search_all_results',:locals => {:all_results=> @alls})%>');
<% when 'user'%>
$("#searchContent_2").html('<%= escape_javascript(render :partial => 'search_user_results',:locals => {:users=>@users})%>');
<% when 'syllabus'%>
$("#searchContent_3").html('<%= escape_javascript(render :partial => 'search_syllabus_results',:locals => {:syllabuses=>@syllabuses})%>');
<% when 'course'%>
$("#searchContent_3").html('<%= escape_javascript(render :partial => 'search_course_results',:locals => {:courses=>@courses})%>');
$("#searchContent_4").html('<%= escape_javascript(render :partial => 'search_course_results',:locals => {:courses=>@courses})%>');
<% when 'project'%>
$("#searchContent_5").html('<%= escape_javascript(render :partial => 'search_project_results',:locals => {:projects=>@projects})%>');
$("#searchContent_6").html('<%= escape_javascript(render :partial => 'search_project_results',:locals => {:projects=>@projects})%>');
<% when 'attachment'%>
$("#searchContent_4").html('<%= escape_javascript(render :partial => 'search_attachment_results',:locals => {:attachments=>@attachments})%>');
$("#searchContent_5").html('<%= escape_javascript(render :partial => 'search_attachment_results',:locals => {:attachments=>@attachments})%>');
<% when 'memo'%>
$("#searchContent_6").html('<%= escape_javascript(render :partial => 'search_memo_results',:locals => {:memos=>@memos})%>');
$("#searchContent_7").html('<%= escape_javascript(render :partial => 'search_memo_results',:locals => {:memos=>@memos})%>');
<%else%>
<%end %>

View File

@ -7,9 +7,8 @@ namespace :importer do
ENV['BATCH']='1000'
Rake::Task["elasticsearch:import:model"].execute
end
task :importproject => :environment do
ENV['CLASS']='Project'
task :importsyllabus => :environment do
ENV['CLASS']='Syllabus'
ENV['SCOPE']='indexable'
ENV['FORCE']='y'
ENV['BATCH']='1000'
@ -29,6 +28,14 @@ namespace :importer do
ENV['BATCH']='1000'
Rake::Task["elasticsearch:import:model"].execute
end
task :importproject => :environment do
ENV['CLASS']='Project'
ENV['SCOPE']='indexable'
ENV['FORCE']='y'
ENV['BATCH']='1000'
Rake::Task["elasticsearch:import:model"].execute
end
task :importmemo => :environment do
ENV['CLASS']='Memo'
ENV['SCOPE']='indexable'
@ -38,5 +45,5 @@ namespace :importer do
end
desc "Run all tasks"
task :all => [:importuser,:importproject,:importcourse,:importattachment,:importmemo]
task :all => [:importuser,:importsyllabus,:importcourse,:importattachment,:importproject,:importmemo]
end