This commit is contained in:
cxt 2015-12-11 14:59:13 +08:00
commit a3715051b1
19 changed files with 191 additions and 51 deletions

View File

@ -118,7 +118,7 @@ class MyController < ApplicationController
@user.safe_attributes = params[:user]
@user.pref.attributes = params[:pref]
@user.pref[:no_self_notified] = (params[:no_self_notified] == '1')
@user.login = params[:login]
#@user.login = params[:login]
unless @user.user_extensions.nil?
if @user.user_extensions.identity == 2
@user.firstname = params[:enterprise_name]

View File

@ -161,7 +161,7 @@ class WelcomeController < ApplicationController
query: @name,
type:"most_fields",
operator: "or",
fields: ['login', 'firstname','lastname','name','description^0.5','filename']
fields: ['login', 'firstname','lastname','name','description^0.5','filename','subject','content^0.5']
}
},
highlight: {
@ -173,10 +173,12 @@ class WelcomeController < ApplicationController
lastname: {},
name:{},
description:{},
filename:{}
filename:{},
subject:{},
content:{}
}
}
},[User,Course,Attachment,Project] ).page(params[:page] || 1).per(20).results
},[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'
@ -185,6 +187,8 @@ class WelcomeController < ApplicationController
@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: {
@ -192,7 +196,7 @@ class WelcomeController < ApplicationController
query: @name,
type:"most_fields",
operator: "or",
fields: ['login', 'firstname','lastname','name','description^0.5','filename']
fields: ['login', 'firstname','lastname','name','description^0.5','filename','subject','content^0.5']
}
},
highlight: {
@ -204,10 +208,12 @@ class WelcomeController < ApplicationController
lastname: {},
name:{},
description:{},
filename:{}
filename:{},
subject:{},
content:{}
}
}
},[User,Course,Attachment,Project] ).page(params[:page] || 1).per(20).results
},[User,Course,Attachment,Project,Memo] ).page(params[:page] || 1).per(20).results
end
@ -216,13 +222,14 @@ class WelcomeController < ApplicationController
@course_count = Course.search(@name).results.total
@attach_count = Attachment.search(@name).results.total
@project_count = Project.search(@name).results.total
@memo_count = Memo.search(@name).results.total
@total_count = Elasticsearch::Model.search({
query: {
multi_match: {
query: @name,
type:"most_fields",
operator: "or",
fields: ['login', 'firstname','lastname','name','description^0.5','filename']
fields: ['login', 'firstname','lastname','name','description^0.5','filename','subject','content^0.5']
}
},
highlight: {
@ -234,10 +241,12 @@ class WelcomeController < ApplicationController
lastname: {},
name:{},
description:{},
filename:{}
filename:{},
subject:{},
content:{}
}
}
},[User,Course,Attachment,Project] ).results.total
},[User,Course,Attachment,Project,Memo] ).results.total
# search_type = params[:search_type].to_sym unless search_condition.blank?
# search_by = params[:search_by]
#

View File

@ -46,7 +46,7 @@ class Attachment < ActiveRecord::Base
settings index: { number_of_shards: 5 } do
mappings dynamic: 'false' do
indexes :filename, analyzer: 'smartcn',index_options: 'offsets'
indexes :downloads, analyzer: 'smartcn',index_options: 'offsets'
indexes :downloads, index:"not_analyzed",index_options: 'offsets'
end
end

View File

@ -16,7 +16,7 @@ class Course < ActiveRecord::Base
mappings dynamic: 'false' do
indexes :name, analyzer: 'smartcn',index_options: 'offsets'
indexes :description, analyzer: 'smartcn',index_options: 'offsets'
indexes :updated_at, analyzer: 'smartcn',index_options: 'offsets',type:"date"
indexes :updated_at, index:"not_analyzed",type:"date"
end
end

View File

@ -1,7 +1,9 @@
require 'elasticsearch/model'
class Memo < ActiveRecord::Base
include Redmine::SafeAttributes
include UserScoreHelper
include ApplicationHelper
include Elasticsearch::Model
belongs_to :forum
has_many_kindeditor_assets :assets, :dependent => :destroy
belongs_to :author, :class_name => "User", :foreign_key => 'author_id'
@ -12,6 +14,18 @@ class Memo < ActiveRecord::Base
validates_length_of :content, maximum: 30000
validate :cannot_reply_to_locked_topic, :on => :create
#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 :subject, analyzer: 'smartcn',index_options: 'offsets'
indexes :content, analyzer: 'smartcn',index_options: 'offsets'
indexes :updated_at,index:"not_analyzed" ,type:'date'
end
end
acts_as_tree :counter_cache => :replies_count, :order => "#{Memo.table_name}.created_at ASC"
acts_as_attachable
has_many :user_score_details, :class_name => 'UserScoreDetails',:as => :score_changeable_obj
@ -47,9 +61,9 @@ class Memo < ActiveRecord::Base
"parent_id",
"replies_count"
after_create :add_author_as_watcher, :reset_counters!, :send_mail, :send_message
# after_update :update_memos_forum
after_destroy :reset_counters!,:delete_kindeditor_assets#,:down_user_score -- 公共区发帖暂不计入得分
after_create :add_author_as_watcher, :reset_counters!, :send_mail, :send_message,:create_memo_ealasticsearch_index
after_update :update_memo_ealasticsearch_index
after_destroy :reset_counters!,:delete_kindeditor_assets,:delete_memo_ealasticsearch_index#,:down_user_score -- 公共区发帖暂不计入得分,
# after_create :send_notification
# after_save :plusParentAndForum
# after_destroy :minusParentAndForum
@ -57,6 +71,36 @@ class Memo < ActiveRecord::Base
# scope :visible, lambda { |*args|
# includes(:forum => ).where()
# }
scope :indexable,lambda {
where('parent_id is null')
}
def self.search(query)
__elasticsearch__.search(
{
query: {
multi_match: {
query: query,
type:"most_fields",
operator: "or",
fields: ['subject','content^0.5']
}
},
sort: {
_score:{order: "desc" },
updated_at:{order: "desc" }
},
highlight: {
pre_tags: ['<span class="c_red">'],
post_tags: ['</span>'],
fields: {
subject: {},
content: {}
}
}
}
)
end
def send_mail
Mailer.run.forum_message_added(self) if Setting.notified_events.include?('forum_message_added')
@ -203,6 +247,22 @@ class Memo < ActiveRecord::Base
# Author lizanle
# Description 从硬盘上删除资源
def delete_kindeditor_assets
delete_kindeditor_assets_from_disk self.id,OwnerTypeHelper::MEMO
delete_kindeditor_assets_from_disk self.id,OwnerTypeHelper::MEMO
end
def create_memo_ealasticsearch_index
if self.parent_id.nil?
self.__elasticsearch__.index_document
end
end
def update_memo_ealasticsearch_index
if self.parent_id.nil?
self.__elasticsearch__.update_document
end
end
def delete_memo_ealasticsearch_index
if self.parent_id.nil?
self.__elasticsearch__.delete_document
end
end
end

View File

@ -39,7 +39,7 @@ class Project < ActiveRecord::Base
mappings dynamic: 'false' do
indexes :name, analyzer: 'smartcn',index_options: 'offsets'
indexes :description, analyzer: 'smartcn',index_options: 'offsets'
indexes :updated_on, analyzer: 'smartcn',index_options: 'offsets', type:'date'
indexes :updated_on, index:"not_analyzed", type:'date'
end
end

View File

@ -35,7 +35,7 @@ class User < Principal
indexes :login, analyzer: 'smartcn',index_options: 'offsets'
indexes :firstname, analyzer: 'smartcn',index_options: 'offsets'
indexes :lastname, analyzer: 'smartcn',index_options: 'offsets'
indexes :last_login_on, analyzer: 'smartcn',index_options: 'offsets',type: 'date'
indexes :last_login_on, index:"not_analyzed",type: 'date'
end
end

View File

@ -30,7 +30,7 @@
<li>&nbsp;&nbsp;</li>
</ul>
<ul class="setting_right ">
<li><%= f.text_field :login,:no_label=>true, :required => true, :nh_required=>"1", :name => "login",:class=>"w210"%></li>
<li><%= f.text_field :login,:no_label=>true, :required => true, :nh_required=>"1",:disabled=>'disabled', :name => "login",:class=>"w210"%></li>
<li><%= f.text_field :mail,:no_label=>true, :required => true,:nh_required=>"1",:class=>"w210"%></li>
<li>

View File

@ -1,18 +1,19 @@
<%= javascript_include_tag "/assets/kindeditor/kindeditor",'/assets/kindeditor/pasteimg' %>
<li>
<label><span class="c_red">*</span>&nbsp;<%= l(:field_title) %>&nbsp;&nbsp;</label>
<input type="text" name="news[title]" class="hwork_input_news" id="news_title" width="576px" onblur="regexTitle();" maxlength="60" placeholder="60个字符以内" value="<%= is_new ? '' : @news.title %>">
<label style="float: left"><span class="c_red">*</span>&nbsp;<%= l(:field_title) %>&nbsp;&nbsp;</label>
<input type="text" name="news[title]" class="hwork_input_news fl" id="news_title" width="576px" onblur="regexTitle();" maxlength="60" placeholder="60个字符以内" value="<%= is_new ? '' : @news.title %>">
<div class="cl"></div>
<p id="title_notice_span" class="ml55"></p>
</li>
<li class="mb10">
<% if is_new %>
<%= hidden_field_tag :asset_id,params[:asset_id],:required => false,:style => 'display:none' %>
<label class="fl" ><span class="c_red">*</span>&nbsp;<%= l(:field_description) %>&nbsp;&nbsp;</label>
<%= f.kindeditor :description,:width=>'91%',:editor_id=>'project_news_description_editor' %>
<%= f.kindeditor :description,:width=>'90%',:editor_id=>'project_news_description_editor' %>
<p id="description_notice_span" class="ml55"></p>
<% else %>
<label class="fl" ><span class="c_red">*</span>&nbsp;<%= l(:field_description) %>&nbsp;&nbsp;</label>
<%= f.kindeditor :description,:width=>'91%', :editor_id=>'project_news_description_editor', :owner_id => @news.id, :owner_type => OwnerTypeHelper::NEWS %>
<%= f.kindeditor :description,:width=>'90%', :editor_id=>'project_news_description_editor', :owner_id => @news.id, :owner_type => OwnerTypeHelper::NEWS %>
<p id="description_notice_span" class="ml55"></p>
<% end %>

View File

@ -45,12 +45,12 @@
</li>
<li class="homepageNewsContent fl"><a href="javascript:void(0);" class="newsGrey">
<% if !User.current.allowed_to?(:as_teacher, ma.course_message.course) && cur_user_works_for_homework(ma.course_message).nil? %>
<%= link_to "作业题" + ma.course_message.name, new_student_work_path(:homework => ma.course_message.id),
<%= link_to "作业题:" + ma.course_message.name, new_student_work_path(:homework => ma.course_message.id),
:class =>"#{ma.viewed == 0 ? "newsBlack" : "newsGrey"}",
:onmouseover =>"message_titile_show($(this),event)",
:onmouseout => "message_titile_hide($(this))" %>
<% else %>
<%= link_to "作业题" + ma.course_message.name, student_work_index_path(:homework => ma.course_message.id),
<%= link_to "作业题:" + ma.course_message.name, student_work_index_path(:homework => ma.course_message.id),
:class => "#{ma.viewed == 0 ? "newsBlack" : "newsGrey"}",
:onmouseover => "message_titile_show($(this),event)",
:onmouseout => "message_titile_hide($(this))" %>
@ -103,7 +103,7 @@
user_path(ma.course_message.user), :class => "newsBlue homepageNewsPublisher", :title => "#{ma.course_message.user.lastname + ma.course_message.user.firstname}老师" %>
<span class="<%= ma.viewed == 0 ? "homepageNewsTypeNotRead fl":"homepageNewsType fl" %>">发布的作业:</span></li>
<li class="homepageHomeworkContent fl">
<%= link_to "作业题" + ma.course_message.name, student_work_index_path(:homework => ma.course_message.id),
<%= link_to "作业题:" + ma.course_message.name, student_work_index_path(:homework => ma.course_message.id),
:class => "#{ma.viewed == 0 ? "newsBlack" : "newsGrey"}",
:onmouseover => "message_titile_show($(this),event)",
:onmouseout => "message_titile_hide($(this))" %>
@ -142,7 +142,7 @@
<span class="<%= ma.viewed == 0 ? "homepageNewsTypeNotRead fl" : "homepageNewsType fl" %>">启动了作业匿评:</span>
</li>
<li class="homepageNewsContent fl">
<%= link_to "作业题" + ma.course_message.name, student_work_index_path(:homework => ma.course_message.id), :class => "#{ma.viewed == 0 ? "newsBlack" : "newsGrey"}",
<%= link_to "作业题:" + ma.course_message.name, student_work_index_path(:homework => ma.course_message.id), :class => "#{ma.viewed == 0 ? "newsBlack" : "newsGrey"}",
:onmouseover => "message_titile_show($(this),event)",
:onmouseout => "message_titile_hide($(this))" %>
</li>
@ -173,19 +173,25 @@
<%=link_to ma.course_message.user.lastname + ma.course_message.user.firstname + "老师",
user_path(ma.course_message.user), :class => "newsBlue homepageNewsPublisher" %><span class="<%= ma.viewed == 0 ? "homepageNewsTypeNotRead fl":"homepageNewsType fl" %>">关闭了作业匿评:</span></li>
<li class="homepageNewsContent fl">
<%= link_to "作业题" + ma.course_message.name, student_work_index_path(:homework => ma.course_message.id), :class =>"#{ma.viewed == 0 ? "newsBlack" : "newsGrey"}",
<%= link_to "作业题:" + ma.course_message.name, student_work_index_path(:homework => ma.course_message.id), :class =>"#{ma.viewed == 0 ? "newsBlack" : "newsGrey"}",
:onmouseover =>"message_titile_show($(this),event)",
:onmouseout => "message_titile_hide($(this))"%>
</li>
<div style="display: none" class="message_title_red system_message_style">
<p>
<%= User.current.lastname + User.current.firstname %><%= User.current.allowed_to?(:as_teacher,ma.course_message.course) ? '老师':'同学'%>您好!
<%= User.current.eql?(ma.course_message.user)?"您":(ma.course_message.user.lastname + ma.course_message.user.firstname+"老师") %>关闭了匿评,作业详情如下:
该作业已经被关闭了匿评。作业信息如下:
</p>
<ul class="ul_grey">
<li>课程名称:<%= ma.course_message.course.name %>(<%= ma.course_message.course.time.to_s + '年'+ ma.course_message.course.term %>)</li>
<li>作业标题:<%= ma.course_message.name %></li>
</ul>
<p></p>
<p class="c_red">注缺省情况下系统将在作业提交截止日期后14天自动关闭匿评。</p>
<p></p>
<% if User.current.allowed_to?(:as_teacher,ma.course_message.course)%>
<p>祝您的教学活动高效、顺利、愉快!</p>
<% end %>
</div>
<li class="homepageNewsTime fl"><%= time_tag(ma.created_at).html_safe %> </li>
</ul>
@ -202,7 +208,7 @@
<span class="<%= ma.viewed == 0 ? "homepageNewsTypeNotRead fl" : "homepageNewsType fl" %>">启动作业匿评失败</span>
</li>
<li class="homepageNewsContent fl">
<%= link_to "作业题目:" + ma.course_message.name, student_work_index_path(:homework => ma.course_message.id), :class => "#{ma.viewed == 0 ? "newsBlack" : "newsGrey"}",
<%= link_to truncate(ma.course_message.name,:length=>25)+'(失败原因提交作品的人数低于2人)', student_work_index_path(:homework => ma.course_message.id), :class => "#{ma.viewed == 0 ? "c_red" : "newsGrey "}",
:onmouseover => "message_titile_show($(this),event)",
:onmouseout => "message_titile_hide($(this))" %>
</li>
@ -213,7 +219,6 @@
</p>
<ul class="ul_normal_color">
<li>失败原因:<span style="color:red;">提交作品的人数低于2人</span></li>
<li>课程名称:<%= ma.course_message.course.name %>(<%= ma.course_message.course.time.to_s + '年' + ma.course_message.course.term %>)</li>
<li>作业标题:<span style="color:Red;"><%= ma.course_message.name %></span></li>
<li>提交截止:<span style="color:Red;"><%= ma.course_message.end_time%>&nbsp;&nbsp;23:59</span></li>
@ -385,7 +390,7 @@
<span class="<%= ma.viewed == 0 ? "homepageNewsTypeNotRead fl":"homepageNewsType fl" %>">发布的作业:</span>
</li>
<li class="homepageHomeworkContent fl"><a href="javascript:void(0);" class="newsGrey">
<%= link_to "作业题" + ma.course_message.homework_common.name, student_work_index_path(:homework => ma.course_message.homework_common_id),
<%= link_to "作业题:" + ma.course_message.homework_common.name, student_work_index_path(:homework => ma.course_message.homework_common_id),
:class => "#{ma.viewed==0 ? "newsBlack" : "newsGrey"}",
:onmouseover => "message_titile_show($(this),event)",
:onmouseout => "message_titile_hide($(this))" %></a>

View File

@ -16,3 +16,5 @@ $('#ajax-modal').before("<a href='javascript:void(0)' onclick='closePopUp();' st
$('#ajax-modal').parent().css("top","").css("left","");
$('#ajax-modal').parent().addClass("popbox").addClass("resourceUploadPopup");
$('#ajax-modal').css("padding-left","16px").css("padding-bottom","16px");
var val = $("#search_course_input").val();
$("#search_course_input").val("").focus().val(val);

View File

@ -12,3 +12,6 @@ $('#ajax-modal').before("<a href='javascript:void(0)' onclick='closePopUp();' st
$('#ajax-modal').parent().css("top","").css("left","");
$('#ajax-modal').parent().addClass("resourceUploadPopup").addClass("popbox")
$('#ajax-modal').css("padding-left","16px").css("padding-bottom","16px");
//$("#search_project_input").focus();
var val = $("#search_project_input").val();
$("#search_project_input").val("").focus().val(val);

View File

@ -361,12 +361,11 @@
if(user_id === '<%= User.current.id%>') {
res_name = line.children().eq(1).children().attr('title');
res_link = line.children().eq(1).html();
line.children().eq(1).html('<%= form_tag(url_for(:controller => 'users',:action => 'rename_resource',:method => 'post',:remote=>true,:id=>@user.id),:id=>"res_name_form" ) do%>' +
line.children().eq(1).html(
'<input name="res_name" id="res_name" ' +
'style="height: 2em;line-height: 2em;overflow: hidden;" onblur="restore();" ' +
'style="height: 2em;line-height: 2em;overflow: hidden;" onblur="restore();" onkeypress="if(event.keyCode==13){event.preventDefault();this.blur();}" ' +
'value="'+res_name+
'"/> <input type="hidden" id ="res_id" name="res_id" value="'+id+'"/>'+
'<% end %>');
'"/> <input type="hidden" id ="res_id" name="res_id" value="'+id+'"/>');
$("#res_name").focus();
$("html,body").animate({scrollTop:$("#res_name").offset().top},1000)
}else{
@ -382,6 +381,8 @@
return str.slice(0, i + 1);
}
//恢复编辑状态到链接状态
//如果当前是编辑状态,任何的不在输入框里的单击右键事件都需要将编辑状态变回链接状态
//如果是编辑状态,且做了修改,那么久要进行修改,并且将修改值经过处理替换到页面显示
@ -395,22 +396,22 @@
if( name && name != res_name.trim()){
if(confirm('确定修改为 '+name)){
$.post(
'<%=rename_resource_user_path(@user) %>',
"res_name="+$('#res_name').val()+"&res_id="+$("#res_id").val(),
function (data){
if(data != 'fail'){//修改成功,那么将链接恢复,并且将链接的显示内容改变。链接可以不变
$.ajax({
url: '<%=rename_resource_user_path(@user) %>'+ "?res_name="+$('#res_name').val() + "&res_id=" + $("#res_id").val(),
type:'get',
success:function (data)
{
if (data != 'fail') {//修改成功,那么将链接恢复,并且将链接的显示内容改变。链接可以不变
last_line.children().eq(1).html(res_link);
last_line.children().eq(1).children().attr('title',name);
last_line.children().eq(1).children().attr('href',data);
last_line.children().eq(1).children().html(name.length > 17? name.substring(0,17)+'...' : name);
}else{
last_line.children().eq(1).children().attr('title', name);
last_line.children().eq(1).children().attr('href', data);
last_line.children().eq(1).children().html(name.length > 17 ? name.substring(0, 17) + '...' : name);
} else {
last_line.children().eq(1).html(res_link);
res_link = null; //如果修改失败恢复之后将res_link置空
}
},
'text'
);
}
} );
}else{
last_line.children().eq(1).html(res_link);
res_link = null; //如果没有做修改恢复之后将res_link置空

View File

@ -72,6 +72,22 @@
</li>
<div class="cl"></div>
</ul>
<% when 'memo'%>
<ul class="searchContent">
<li class="fl">
</li>
<li class="fl searchContentDes">
<ul class="fl">
<li class="f16 mb5"><a href="<%= forum_memo_path(:forum_id=>item.forum_id,:id=>item.id)%>" class="fontGrey3 fl"><%= item.try(:highlight).try(:subject) ? item.highlight.subject[0].html_safe : item.subject %></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="fontGrey3 mb5"><%= item.try(:highlight).try(:content) ? item.highlight.content[0].html_safe : item.content.html_safe%></li>
<li class="f12 fontGrey2"><span class="mr30">发帖人:<%= item.author_id ? User.find(item.author_id).login : '无' %></span><span class="mr30">创建时间:<%= format_date( item.created_at) %></span></li>
</ul>
</li>
<div class="cl"></div>
</ul>
<%end %>
<% end %>
<div class="pageRoll">

View File

@ -0,0 +1,24 @@
<% unless memos.nil? || memos.empty?%>
<% memos.each do |memo|%>
<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(memo.author_id)), :width => "75", :height => "75",:class=>'searchCourseImage'), forum_memo_path(:forum_id=>memo.forum_id,:id=>memo.id), :alt => "贴吧图片" %>
</li>
<li class="fl searchContentDes">
<ul class="fl">
<li class="f16 mb5"><a href="<%= forum_memo_path(:forum_id=>memo.forum_id,:id=>memo.id)%>" class="fontGrey3 fl"><%= memo.try(:highlight).try(:subject) ? memo.highlight.subject[0].html_safe : memo.subject %></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="fontGrey3 mb5"><%= memo.try(:highlight).try(:content) ? memo.highlight.content[0].html_safe : memo.content.html_safe%></li>
<li class="f12 fontGrey2"><span class="mr30">发帖人:<%= memo.author_id ? User.find(memo.author_id).login : '无' %></span><span class="mr30">创建时间:<%= format_date( memo.created_at) %></span></li>
</ul>
</li>
<div class="cl"></div>
</ul>
<% end %>
<div class="pageRoll">
<%= paginate memos,:params => {:controller => 'welcome', :action => 'search',:search_type=>'memo'}%>
</div>
<% end %>

View File

@ -3,7 +3,7 @@
function g(o){return document.getElementById(o);}
function HoverLi(n){
//如果有N个标签,就将i<=N;
for(var i=1;i<=5;i++){
for(var i=1;i<=6;i++){
g('searchBaner_'+i).className='searchBannerNormal';
g('searchContent_'+i).className='undis';g('searchNum_'+i).className="numRed";
g('searchType_'+i).className="fontGrey2 f14";
@ -28,6 +28,8 @@
search('attachment')
}else if(n == 5){
search('project')
}else if(n == 6){
search('memo')
}
}
@ -56,6 +58,10 @@
}else if('<%= @search_type%>' == 'project'){
HoverLi(5)
$("#searchContent_5").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})%>');
}
})
//如果要做成点击后再转到请将<li>中的onmouseover 改成 onclick;
@ -76,6 +82,7 @@
<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>
<div class="cl"></div>
</ul>
<ul id="searchTips" style="display:none;">
@ -94,6 +101,9 @@
</div>
<div id="searchContent_5" class="undis">
</div>
<div id="searchContent_6" class="undis">
</div>
</div>
</div>

View File

@ -9,5 +9,7 @@ $("#searchContent_3").html('<%= escape_javascript(render :partial => 'search_cou
$("#searchContent_5").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})%>');
<% when 'memo'%>
$("#searchContent_6").html('<%= escape_javascript(render :partial => 'search_memo_results',:locals => {:memos=>@memos})%>');
<%else%>
<%end %>

View File

@ -489,7 +489,7 @@ RedmineApp::Application.routes.draw do
post "add_exist_file_to_course"
post "add_exist_file_to_project"
get 'resource_preview'
post 'rename_resource'
get 'rename_resource'
get 'search_user_project'
get 'user_resource_type'
get 'user_ref_resource_search'

View File

@ -28,4 +28,11 @@ namespace :importer do
ENV['BATCH']='1000'
Rake::Task["elasticsearch:import:model"].invoke
end
task :importmemo do
ENV['CLASS']='Memo'
ENV['SCOPE']='indexable'
ENV['FORCE']='y'
ENV['BATCH']='1000'
Rake::Task["elasticsearch:import:model"].invoke
end
end