- <% comments.each do |comment| %>
-
-
-
- <%= link_to image_tag(url_to_avatar(comment.creator_user), :width => 33, :height => 33, :alt => "用户头像"), user_url_in_org(comment.creator_user.id) %>
-
-
- <%= render :partial => 'users/message_contents', :locals => {:comment => comment}%>
-
- <% if !comment.content_detail.blank? %>
-
-
-
-
-
-
- <%= link_to(
- l(:button_reply),
- {:controller => 'org_document_comments',:action => 'quote',:user_id=>comment.creator_id, :id => comment.id},
- :remote => true,
- :method => 'get',
- :title => l(:button_reply)) %>
-
-
- <% if comment.creator_user == User.current %>
- <%= link_to(
- l(:button_delete),
- {:controller => 'org_document_comments',:action => 'delete_reply', :id => comment.id},
- :method => :delete,
- :id => "delete_reply_#{comment.id}",
- :class => 'fr mr20 undis',
- :data => {:confirm => l(:text_are_you_sure)},
- :title => l(:button_delete)) %>
- <% end %>
-
-
-
-
-
- <% end %>
-
-
-
- <% end %>
-
+ <%# comments = all_replies %>
+
+ <%= render :partial => "document_show_replies" %>
<%# end %>
diff --git a/app/views/org_document_comments/show.js.erb b/app/views/org_document_comments/show.js.erb
new file mode 100644
index 000000000..f164d10ec
--- /dev/null
+++ b/app/views/org_document_comments/show.js.erb
@@ -0,0 +1 @@
+$("#more_document_replies").replaceWith("<%= escape_javascript(render :partial => 'org_document_comments/document_show_replies')%>");
\ No newline at end of file
From d407b5ab10956191c1329954b1a72630a4c42cb6 Mon Sep 17 00:00:00 2001
From: yuanke <249218296@qq.com>
Date: Sun, 9 Oct 2016 10:35:43 +0800
Subject: [PATCH 07/48] =?UTF-8?q?=E6=90=9C=E7=B4=A2=E4=B8=AD=E5=8A=A0?=
=?UTF-8?q?=E5=85=A5=E8=AF=BE=E7=A8=8B?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
app/controllers/welcome_controller.rb | 15 ++++---
app/models/syllabus.rb | 28 +++++++++++++
app/views/layouts/_logined_header.html.erb | 2 +-
.../welcome/_search_syllabus_results.html.erb | 11 +++++
app/views/welcome/search.html.erb | 42 +++++++++++--------
5 files changed, 75 insertions(+), 23 deletions(-)
create mode 100644 app/views/welcome/_search_syllabus_results.html.erb
diff --git a/app/controllers/welcome_controller.rb b/app/controllers/welcome_controller.rb
index 1508fc871..1d8f95779 100644
--- a/app/controllers/welcome_controller.rb
+++ b/app/controllers/welcome_controller.rb
@@ -161,7 +161,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: {
@@ -171,6 +171,7 @@ class WelcomeController < ApplicationController
login: {},
firstname: {},
lastname: {},
+ title:{},
name:{},
description:{},
filename:{},
@@ -181,6 +182,8 @@ class WelcomeController < ApplicationController
},[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 'syllabus'
+ @syllabuses = Syllabus.search(@name).page(params[:page] || 1).per(20)
when 'project'
@projects = Project.search(@name).page(params[:page] || 1).per(20).results
when 'course'
@@ -196,7 +199,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: {
@@ -206,6 +209,7 @@ class WelcomeController < ApplicationController
login: {},
firstname: {},
lastname: {},
+ title:{},
name:{},
description:{},
filename:{},
@@ -213,12 +217,12 @@ class WelcomeController < ApplicationController
content:{}
}
}
- },[User,Course,Attachment,Project,Memo] ).page(params[:page] || 1).per(20).results
+ },[User,Syllabus,Course,Attachment,Project,Memo] ).page(params[:page] || 1).per(20).results
end
@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 +233,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 +243,7 @@ class WelcomeController < ApplicationController
login: {},
firstname: {},
lastname: {},
+ title:{},
name:{},
description:{},
filename:{},
diff --git a/app/models/syllabus.rb b/app/models/syllabus.rb
index f72463503..2f69ce5c4 100644
--- a/app/models/syllabus.rb
+++ b/app/models/syllabus.rb
@@ -57,4 +57,32 @@ class Syllabus < ActiveRecord::Base
jfm.save
jfm
end
+
+ def self.search(query)
+ __elasticsearch__.search(
+ {
+ query: {
+ multi_match: {
+ query: query,
+ type:"most_fields",
+ operator: "or",
+ fields: ['title', 'description^0.5']
+ }
+ },
+ sort: {
+ _score:{order: "desc" },
+ updated_at:{order:"desc"}
+
+ },
+ highlight: {
+ pre_tags: ['
'],
+ post_tags: [' '],
+ fields: {
+ title: {},
+ description: {}
+ }
+ }
+ }
+ )
+ end
end
diff --git a/app/views/layouts/_logined_header.html.erb b/app/views/layouts/_logined_header.html.erb
index cda8e8be5..5f350dd65 100644
--- a/app/views/layouts/_logined_header.html.erb
+++ b/app/views/layouts/_logined_header.html.erb
@@ -47,7 +47,7 @@
<% name = name%>
<%= form_tag({controller: :welcome, action: :search },:class=>'navHomepageSearchBox', method: :get) do %>
-
" id="navHomepageSearchInput" class="navHomepageSearchInput" placeholder="请输入关键词搜索公开的班级、项目、用户、资源以及帖子"/>
+
" id="navHomepageSearchInput" class="navHomepageSearchInput" placeholder="请输入关键词搜索公开的课程、班级、项目、用户、资源以及帖子"/>
diff --git a/app/views/welcome/_search_syllabus_results.html.erb b/app/views/welcome/_search_syllabus_results.html.erb
new file mode 100644
index 000000000..6dd9b382a
--- /dev/null
+++ b/app/views/welcome/_search_syllabus_results.html.erb
@@ -0,0 +1,11 @@
+<% unless syllabuses.nil? || syllabuses.empty?%>
+ <% syllabuses.each do |syllabus|%>
+
+ <%= syllabus.title %> 课程课程
+ 创建者:<%=syllabus.user.login+"("+syllabus.user.show_name+")"%> 教师团队:<%=syllabus.syllabus_member.count%> 班级:<%=syllabus.courses.count%> 更新时间:<%=format(syllabus.updated_at)%> 单位:<%=syllabus.user.user_extensions.occupation.present? ? syllabus.user.user_extensions.occupation:'' %>
+
+ <% end %>
+
+<% end %>
\ No newline at end of file
diff --git a/app/views/welcome/search.html.erb b/app/views/welcome/search.html.erb
index 15491c1c0..d167920e9 100644
--- a/app/views/welcome/search.html.erb
+++ b/app/views/welcome/search.html.erb
@@ -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})%>');
}
})
//如果要做成点击后再转到请将
中的onmouseover 改成 onclick;
@@ -79,10 +84,11 @@
@@ -97,13 +103,15 @@
-
+
+
+