diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb
index 23fd401fd..3a28e4b72 100644
--- a/app/helpers/application_helper.rb
+++ b/app/helpers/application_helper.rb
@@ -3296,6 +3296,14 @@ def strip_html(text,len=0,endss="...")
return ss
end
+def message_content content
+ content = (strip_html content).strip
+ if content.gsub(" ", "") == ""
+ content = "[非文本消息]"
+ end
+ content
+end
+
def get_hw_index(hw,is_teacher)
if is_teacher
homeworks = hw.course.homework_commons.order("created_at asc")
diff --git a/app/views/layouts/_show_messages_list.html.erb b/app/views/layouts/_show_messages_list.html.erb
index ba31c4379..0829b9c42 100644
--- a/app/views/layouts/_show_messages_list.html.erb
+++ b/app/views/layouts/_show_messages_list.html.erb
@@ -5,7 +5,7 @@
<% messages.each do |ma| %>
<% if ma.class == SystemMessage %>
- - Trustie平台 发布新消息:<%= ma.subject.blank? ? (ma.content.nil? ? ma.description.html_safe : ma.content.html_safe) : ma.subject%>
+ - Trustie平台 发布新消息:<%= ma.subject.blank? ? (ma.content.nil? ? message_content(ma.description) : message_content(ma.content)) : ma.subject%>
<% elsif ma.class == CourseMessage %>
<% if ma.course_message_type == "News" %>
- <%=ma.course_message.author.show_name %> 发布了通知:<%= ma.course_message.title%>
@@ -50,18 +50,18 @@
<% elsif ma.course_message_type == "Poll" %>
- "><%=ma.course_message.user.show_name %> 发布了问卷:<%= ma.course_message.polls_name.nil? ? "未命名问卷" : ma.course_message.polls_name%>
<% elsif ma.course_message_type == "Message" %>
- <% content = ma.course_message.parent_id.nil? ? ma.course_message.subject : ma.course_message.content.html_safe %>
+ <% content = ma.course_message.parent_id.nil? ? ma.course_message.subject : message_content(ma.course_message.content) %>
<% href = board_message_path(ma.course_message.board_id, ma.course_message.parent_id ? ma.course_message.parent_id : ma.course_message.id) %>
- <%= content%>"><%=ma.course_message.author.show_name %> <%= ma.course_message.parent_id.nil? ? "发布了班级帖子:" : "评论了班级帖子:" %><%= content%>
<% elsif ma.course_message_type == "StudentWorksScore" %>
- - <%= ma.status == 0 ? "评阅了您的作品:" : "重新评阅了您的作品:" %><%= ma.content.html_safe if !ma.content.nil?%>"><%=ma.course_message.reviewer_role == 3 ? '匿名用户' : ma.course_message.user.show_name+"老师" %> <%= ma.status == 0 ? "评阅了您的作品:" : "重新评阅了您的作品:" %><%= ma.content.html_safe if !ma.content.nil?%>
+ - <%= ma.status == 0 ? "评阅了您的作品:" : "重新评阅了您的作品:" %><%= message_content(ma.content) if !ma.content.nil?%>"><%=ma.course_message.reviewer_role == 3 ? '匿名用户' : ma.course_message.user.show_name+"老师" %> <%= ma.status == 0 ? "评阅了您的作品:" : "重新评阅了您的作品:" %><%= message_content(ma.content) if !ma.content.nil?%>
<% elsif ma.course_message_type == "JournalsForMessage" %>
<% if ma.course_message.jour_type == 'Course' %>
- - <%=ma.course_message.user.show_name %> 在班级中留言了:<%= ma.course_message.notes.html_safe%>
+ - <%=ma.course_message.user.show_name %> 在班级中留言了:<%= message_content(ma.course_message.notes)%>
<% elsif ma.course_message.jour_type == 'HomeworkCommon' %>
- - <%=ma.course_message.user.show_name %> <%=ma.course_message.m_parent_id.nil? ? '回复了您的作业:' : '在作业中回复了您:' %><%= ma.course_message.notes.html_safe%>
+ - <%=ma.course_message.user.show_name %> <%=ma.course_message.m_parent_id.nil? ? '回复了您的作业:' : '在作业中回复了您:' %><%= message_content(ma.course_message.notes)%>
<% else %>
- - <%=ma.course_message.user.show_name %><%=ma.course_message.user.allowed_to?(:as_teacher, ma.course) ? '老师' : '同学' %> 回复了作品评论:<%= ma.course_message.notes%>
+ - <%=ma.course_message.user.show_name %><%=ma.course_message.user.allowed_to?(:as_teacher, ma.course) ? '老师' : '同学' %> 回复了作品评论:<%= message_content(ma.course_message.notes)%>
<% end %>
<% elsif ma.course_message_type == "StudentWork" && !ma.course_message.homework_common.nil? && !User.current.allowed_to?(:as_teacher, ma.course_message.homework_common.course) %>
- <%=ma.course_message.homework_common.user.show_name %>老师 发布的作业:<%=ma.course_message.homework_common.name %>,由于迟交作业,您及您的作品都不能参与该作业的匿评
@@ -112,11 +112,11 @@
<% end %>
<% elsif ma.class == MemoMessage %>
<% if ma.memo_type == "Memo" %>
- - <%= ma.memo.parent_id.nil? ? ma.memo.subject : ma.memo.content.html_safe%>"><%=ma.memo.author.show_name %> <%= ma.memo.parent_id.nil? ? "在贴吧发布帖子:" : "回复了贴吧帖子:" %><%= ma.memo.parent_id.nil? ? ma.memo.subject : ma.memo.content.html_safe%>
+ - <%= ma.memo.parent_id.nil? ? ma.memo.subject : message_content(ma.memo.content)%>"><%=ma.memo.author.show_name %> <%= ma.memo.parent_id.nil? ? "在贴吧发布帖子:" : "回复了贴吧帖子:" %><%= ma.memo.parent_id.nil? ? ma.memo.subject : message_content(ma.memo.content)%>
<% end %>
<% elsif ma.class == UserFeedbackMessage %>
<% if ma.journals_for_message_type == "JournalsForMessage" %>
- - <%= ma.journals_for_message.notes.gsub("
","").gsub("
","").gsub("
","").html_safe%>"><%=ma.journals_for_message.user.show_name %> <%= ma.journals_for_message.reply_id == 0 ? "给你留言了:" : "回复了你的留言:" %><%= ma.journals_for_message.notes.gsub("","").gsub("
","").gsub("
","").html_safe%>
+ - <%= message_content(ma.journals_for_message.notes)%>"><%=ma.journals_for_message.user.show_name %> <%= ma.journals_for_message.reply_id == 0 || ma.journals_for_message.reply_id.nil? ? "给你留言了:" : "回复了你的留言:" %><%= message_content(ma.journals_for_message.notes)%>
<% end %>
<% elsif ma.class == OrgMessage %>
<% if ma.message_type == 'ApplySubdomain' %>
diff --git a/app/views/users/_join_course_course_message.html.erb b/app/views/users/_join_course_course_message.html.erb
index 01ebb5cf9..d0718c11e 100644
--- a/app/views/users/_join_course_course_message.html.erb
+++ b/app/views/users/_join_course_course_message.html.erb
@@ -18,7 +18,7 @@
真实姓名:<%= User.find(ma.course_message_id).realname %>
申请课程:<%= Course.find(ma.course_id).name%>
课程描述:
- <%= Course.find(ma.course_id).description.html_safe %>
+ <%= Course.find(ma.course_id).description.html_safe if Course.find(ma.course_id).description %>
申请职位:<%= ma.content == '9' ? "教师" : "教辅"%>
-
diff --git a/app/views/users/_user_message_course.html.erb b/app/views/users/_user_message_course.html.erb
index f48ce7010..065cb0b27 100644
--- a/app/views/users/_user_message_course.html.erb
+++ b/app/views/users/_user_message_course.html.erb
@@ -309,7 +309,7 @@
<% else %>
-
- <%= link_to ma.course_message.content.html_safe, board_message_path(ma.course_message.board_id, ma.course_message.parent_id),
+ <%= link_to message_content(ma.course_message.content), board_message_path(ma.course_message.board_id, ma.course_message.parent_id),
:class => "#{ma.viewed==0 ? "newsBlack" : "newsGrey"}", :target => '_blank' %>
@@ -348,7 +348,7 @@
-
<% unless ma.content.nil? %>
- <%= link_to ma.content.html_safe, student_work_index_path(:homework => ma.course_message.student_work.homework_common_id),
+ <%= link_to message_content(ma.content), student_work_index_path(:homework => ma.course_message.student_work.homework_common_id),
:class =>"#{ma.viewed == 0 ? "newsBlack" : "newsGrey"}", :target => '_blank' %>
@@ -387,7 +387,7 @@
">在班级中留言了:
-
- <%= link_to ma.course_message.notes.html_safe, course_feedback_path(:id => ma.course_id),
+ <%= link_to message_content(ma.course_message.notes), course_feedback_path(:id => ma.course_id),
:class => "#{ma.viewed == 0 ? "newsBlack" : "newsGrey"}", :target => '_blank' %>
@@ -414,7 +414,7 @@
-
- <%= link_to ma.course_message.notes.html_safe, homework_common_index_url_in_org( ma.course_id),
+ <%= link_to message_content(ma.course_message.notes), homework_common_index_url_in_org( ma.course_id),
:class => "#{ma.viewed == 0 ? "newsBlack" : "newsGrey"}", :target => '_blank' %>
@@ -437,7 +437,7 @@
">回复了作品评论:
-
- <%= link_to ma.course_message.notes, student_work_index_path(:homework => ma.course_message.jour.student_work.homework_common_id,:show_work_id => ma.course_message.jour.student_work_id), :class => "#{ma.viewed == 0 ? "newsBlack" : "newsGrey"}", :target => '_blank' %>
+ <%= link_to message_content(ma.course_message.notes), student_work_index_path(:homework => ma.course_message.jour.student_work.homework_common_id,:show_work_id => ma.course_message.jour.student_work_id), :class => "#{ma.viewed == 0 ? "newsBlack" : "newsGrey"}", :target => '_blank' %>
diff --git a/app/views/users/_user_message_forum.html.erb b/app/views/users/_user_message_forum.html.erb
index e0111276a..4757aa401 100644
--- a/app/views/users/_user_message_forum.html.erb
+++ b/app/views/users/_user_message_forum.html.erb
@@ -17,7 +17,7 @@
<% else %>
-
- <%= link_to ma.memo.content.html_safe, forum_memo_path(ma.memo.forum_id, ma.memo.parent_id ? ma.memo.parent_id: ma.memo.id), :class =>"#{ma.viewed == 0 ? "newsBlack" : "newsGrey"}", :target => '_blank' %>
+ <%= link_to message_content(ma.memo.content), forum_memo_path(ma.memo.forum_id, ma.memo.parent_id ? ma.memo.parent_id: ma.memo.id), :class =>"#{ma.viewed == 0 ? "newsBlack" : "newsGrey"}", :target => '_blank' %>
diff --git a/app/views/users/_user_message_system.html.erb b/app/views/users/_user_message_system.html.erb
index a7e48f456..13967dce1 100644
--- a/app/views/users/_user_message_system.html.erb
+++ b/app/views/users/_user_message_system.html.erb
@@ -10,7 +10,7 @@
【系统消息】
-
- <%= link_to ma.subject.blank? ? (ma.content.nil? ? ma.description.html_safe : ma.content.html_safe) : ma.subject, user_system_messages_path(User.current),
+ <%= link_to ma.subject.blank? ? (ma.content.nil? ? message_content(ma.description) : message_content(ma.content)) : ma.subject, user_system_messages_path(User.current),
:id => "content_link_#{ma.id}", :target => '_blank' %>
diff --git a/app/views/users/_user_message_userfeedaback.html.erb b/app/views/users/_user_message_userfeedaback.html.erb
index 3af623813..1c33d9de4 100644
--- a/app/views/users/_user_message_userfeedaback.html.erb
+++ b/app/views/users/_user_message_userfeedaback.html.erb
@@ -9,7 +9,7 @@
"><%= ma.journals_for_message.reply_id == 0 ? "给你留言了:" : "回复了你的留言:" %>
-
- <%= link_to ma.journals_for_message.notes.gsub("
","").gsub("
","").gsub("
","").html_safe, feedback_path(ma.journals_for_message.jour_id), :class =>"#{ma.viewed == 0 ? "newsBlack" : "newsGrey"}", :target => '_blank'%>
+ <%= link_to message_content(ma.journals_for_message.notes), feedback_path(ma.journals_for_message.jour_id), :class =>"#{ma.viewed == 0 ? "newsBlack" : "newsGrey"}", :target => '_blank'%>