From 1da8288fe769938953b36b4551f181980b8b6c3e Mon Sep 17 00:00:00 2001
From: yuanke <249218296@qq.com>
Date: Fri, 29 Apr 2016 13:42:58 +0800
Subject: [PATCH] =?UTF-8?q?=E5=88=97=E8=A1=A8=E6=98=BE=E7=A4=BA=E4=BF=AE?=
=?UTF-8?q?=E6=94=B9?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
app/controllers/blogs_controller.rb | 5 +-
app/controllers/boards_controller.rb | 5 +-
app/controllers/news_controller.rb | 37 +++++++++++-
app/controllers/users_controller.rb | 2 +-
app/helpers/application_helper.rb | 23 ++++++++
app/views/blogs/_article.html.erb | 16 +++---
app/views/forums/_show_topics.html.erb | 17 +++---
app/views/news/_course_news_detail.html.erb | 37 +-----------
app/views/news/index.js.erb | 2 +-
app/views/users/_course_boardlist.html.erb | 16 +++---
app/views/users/_course_newslist.html.erb | 64 +++++++++++++++++++++
app/views/users/_intro_content_ex.html.erb | 17 ++----
app/views/users/_project_boardlist.html.erb | 16 +++---
app/views/users/_user_course_list.html.erb | 21 ++++---
app/views/users/_user_project_list.html.erb | 16 +++---
public/javascripts/application.js | 16 ++++++
public/stylesheets/courses.css | 2 +-
public/stylesheets/new_user.css | 11 ++--
public/stylesheets/project.css | 2 +-
19 files changed, 217 insertions(+), 108 deletions(-)
create mode 100644 app/views/users/_course_newslist.html.erb
diff --git a/app/controllers/blogs_controller.rb b/app/controllers/blogs_controller.rb
index 63b0da009..6bb90afe1 100644
--- a/app/controllers/blogs_controller.rb
+++ b/app/controllers/blogs_controller.rb
@@ -24,8 +24,9 @@ class BlogsController < ApplicationController
#根据 赞+回复数排序
if @order.to_i == 2
@type = 2
- @b_sort == 1 ? @topics = @topics.sort{|x,y| get_praise_num(x) + (x.parent ? x.parent.children.count : x.children.count) <=> get_praise_num(y) + (y.parent ? y.parent.children.count : y.children.count) } : @topics = @topics.sort{|x,y| get_praise_num(y) + (y.parent ? y.parent.children.count : y.children.count) <=> get_praise_num(x) + (x.parent ? x.parent.children.count : x.children.count) }
- @topics = @topics.sort{|x,y| y.sticky <=> x.sticky}
+ @b_sort == 1 ? @topics = @topics.sort{|x,y| get_praise_num(x) + (x.parent ? x.parent.children.count : x.children.count) <=> get_praise_num(y) + (y.parent ? y.parent.children.count : y.children.count) } : @topics = @topics.sort{|x,y| get_praise_num(y) + (y.parent ? y.parent.children.count : y.children.count) <=> get_praise_num(x) + (x.parent ? x.parent.children.count : x.children.count) }
+
+ @topics = sort_by_sticky @topics
else
@type = 1
end
diff --git a/app/controllers/boards_controller.rb b/app/controllers/boards_controller.rb
index 2e499ea1d..0bccdd139 100644
--- a/app/controllers/boards_controller.rb
+++ b/app/controllers/boards_controller.rb
@@ -103,7 +103,6 @@ class BoardsController < ApplicationController
@topic_count = @board ? @board.topics.count : 0
if @project
if @board
- limit = 10;
@topic_count = @board.topics.count();
@topic_pages = 0#(params[:page] ? params[:page].to_i + 1 : 0) *10
@topics = @board.topics.reorder("#{Message.table_name}.sticky DESC, COALESCE(last_replies_messages.created_on, #{Message.table_name}.created_on) #{sort_type}").
@@ -126,13 +125,13 @@ class BoardsController < ApplicationController
if @order.to_i == 2
@type = 2
@b_sort == 1 ? @topics = @topics.sort{|x,y| get_praise_num(x) + (x.parent ? x.parent.children.count : x.children.count) <=> get_praise_num(y) + (y.parent ? y.parent.children.count : y.children.count) } : @topics = @topics.sort{|x,y| get_praise_num(y) + (y.parent ? y.parent.children.count : y.children.count) <=> get_praise_num(x) + (x.parent ? x.parent.children.count : x.children.count) }
- @topics = @topics.sort{|x,y| y.sticky <=> x.sticky}
+ @topics = sort_by_sticky @topics
else
@type = 1
end
#分页
- @limit = 10
+ @limit = 15
@is_remote = true
@atta_count = @topics.count
@atta_pages = Paginator.new @atta_count, @limit, params['page'] || 1
diff --git a/app/controllers/news_controller.rb b/app/controllers/news_controller.rb
index f45e1dbd7..d8e83de80 100644
--- a/app/controllers/news_controller.rb
+++ b/app/controllers/news_controller.rb
@@ -70,25 +70,56 @@ class NewsController < ApplicationController
end
elsif @course
if (User.current.admin? || @course.is_public == 1 || (@course.is_public == 0 && User.current.member_of_course?(@course)))
+ @order, @b_sort,@type = params[:order] || 1, params[:sort] || 1, params[:type] || 1
+
+ #确定 sort_type 1升序 2 降序
+ if @order.to_i == @type.to_i
+ @b_sort = @b_sort.to_i == 1 ? 2 : 1
+ else
+ @b_sort = 2
+ end
+
+ sort_name = "created_on"
+
+ sort_type = @b_sort == 1 ? "asc" : "desc"
+
scope = @course ? @course.news.course_visible : News.course_visible
news_arr = scope.map{|news| news.id}
@page = params[:page] ? params[:page].to_i + 1 : 0
- news_page = @page *10
+ news_page = 0 #@page *10
@news_count = scope.count
@is_new = params[:is_new]
@q = params[:subject]
if params[:subject].nil? || params[:subject].blank?
- scope_order = scope.reorder("#{News.table_name}.sticky DESC, #{News.table_name}.created_on DESC").limit(10).offset(news_page).includes(:author,:course).all()
+ scope_order = scope.reorder("#{News.table_name}.sticky DESC, #{News.table_name}.#{sort_name} #{sort_type}").offset(news_page).includes(:author,:course).all()
#all(:include => [:author, :course],
#:order => "#{News.table_name}.sticky DESC, #{News.table_name}.created_on DESC").limit(10).offset(news_page)
else
- scope_order = scope.where("#{News.table_name}.title like '#{'%' << params[:subject].to_s << '%'}'").reorder("#{News.table_name}.sticky DESC, #{News.table_name}.created_on DESC").limit(10).offset(news_page).includes(:author,:course).all()
+ scope_order = scope.where("#{News.table_name}.title like '#{'%' << params[:subject].to_s << '%'}'").reorder("#{News.table_name}.sticky DESC, #{News.table_name}.#{sort_name} #{sort_type}").offset(news_page).includes(:author,:course).all()
#.all(:include => [:author, :course],:order => "#{News.table_name}.sticky DESC, #{News.table_name}.created_on DESC")
end
+ #根据 赞+回复数排序
+ if @order.to_i == 2
+ @type = 2
+ @b_sort == 1 ? scope_order = scope_order.sort{|x,y| get_praise_num(x) + x.comments.count <=> get_praise_num(y) + y.comments.count } : scope_order = scope_order.sort{|x,y| get_praise_num(y) + y.comments.count <=> get_praise_num(x) + x.comments.count }
+ scope_order = sort_by_sticky scope_order
+ else
+ @type = 1
+ end
+
@newss = scope_order
+
+ #分页
+ @limit = 15
+ @is_remote = true
+ @atta_count = @newss.count
+ @atta_pages = Paginator.new @atta_count, @limit, params['page'] || 1
+ @offset ||= @atta_pages.offset
+ @newss = paginateHelper @newss,@limit
+
#@newss = paginateHelper scope_order,10
respond_to do |format|
format.html {
diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb
index 774a8dabd..554afdb20 100644
--- a/app/controllers/users_controller.rb
+++ b/app/controllers/users_controller.rb
@@ -2855,7 +2855,7 @@ class UsersController < ApplicationController
@c_sort = 2
end
- sort_name = "updated_at"
+ sort_name = "created_at"
sort_type = @c_sort == 1 ? "asc" : "desc"
if @user.courses.visible.count > 0
diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb
index d7c72b805..57faf739d 100644
--- a/app/helpers/application_helper.rb
+++ b/app/helpers/application_helper.rb
@@ -3065,3 +3065,26 @@ def host_with_protocol
return Setting.protocol + "://" + Setting.host_name
end
+#将有置顶属性的提到数组前面
+def sort_by_sticky topics
+ tmpTopics = []
+ tmpIndex = 0
+ topics.each do |topic|
+ if topic.sticky == 1
+ tmpTopics[tmpIndex] = topic
+ tmpIndex = tmpIndex + 1
+ end
+ end
+
+ topics.each do |topic|
+ if topic.sticky == 0
+ tmpTopics[tmpIndex] = topic
+ tmpIndex = tmpIndex + 1
+ end
+ end
+
+ topics = tmpTopics
+
+ return topics
+end
+
diff --git a/app/views/blogs/_article.html.erb b/app/views/blogs/_article.html.erb
index ec6a6c7b5..ea494d0f9 100644
--- a/app/views/blogs/_article.html.erb
+++ b/app/views/blogs/_article.html.erb
@@ -66,11 +66,13 @@
\ No newline at end of file
diff --git a/app/views/forums/_show_topics.html.erb b/app/views/forums/_show_topics.html.erb
index dc3a20482..93df27e42 100644
--- a/app/views/forums/_show_topics.html.erb
+++ b/app/views/forums/_show_topics.html.erb
@@ -7,7 +7,15 @@
<%= link_to image_tag(url_to_avatar(topic.author), :width => 50,:height => 50,:alt => '贴吧图片'), user_path(topic.author) if topic.author%>
-
+
+
+
+ <%= link_to (topic.replies_count), forum_memo_path(topic.forum, topic),:target =>'_blank',:class=>'linkGrey2' %>
+
<%= get_praise_num(topic)%>
+
+
<%= topic.content.html_safe%>
@@ -16,12 +24,7 @@
<%= format_date(topic.last_reply.created_at)%>
<% end%>
-
更新时间:<%= format_date(topic.updated_at)%>
-
-
-
- <%= link_to (topic.replies_count), forum_memo_path(topic.forum, topic),:target =>'_blank',:class=>'linkGrey2' %>
-
<%= get_praise_num(topic)%>
+
更新时间:<%= format_date(topic.updated_at)%>
diff --git a/app/views/news/_course_news_detail.html.erb b/app/views/news/_course_news_detail.html.erb
index bd3215fb3..e20177536 100644
--- a/app/views/news/_course_news_detail.html.erb
+++ b/app/views/news/_course_news_detail.html.erb
@@ -4,41 +4,6 @@
<% end %>
<% if newss%>
- <% newss.each do |news| %>
-
- <% if news %>
- <%= render :partial => 'users/course_news', :locals => {:activity => news, :user_activity_id => news.id} %>
- <% end %>
- <% end %>
-
- <% if newss.count == 10 %>
- <%= link_to "点击展开更多",news_index_path(:course_id => @course.id ,:page => page),:id => "show_more_course_news",:remote => "true",:class => "loadMore mt10 f_grey"%>
- <% end %>
+ <%= render :partial => 'users/course_newslist', :locals => {:topics => newss} %>
<% end%>
diff --git a/app/views/news/index.js.erb b/app/views/news/index.js.erb
index d2cac877c..c5d5c84aa 100644
--- a/app/views/news/index.js.erb
+++ b/app/views/news/index.js.erb
@@ -1,5 +1,5 @@
<% if @project %>
$("#show_more_project_news").replaceWith("<%= escape_javascript(render :partial => 'project_news_detail', :locals=>{ :all_news=>@newss,:page => @page})%>");
<% else %>
- $("#show_more_course_news").replaceWith("<%= escape_javascript( render :partial => 'course_news_detail', :locals =>{:newss => @newss, :page => @page} )%>");
+ $("#course-newslist").replaceWith('<%= escape_javascript( render :partial => 'users/course_newslist', :locals => {:topics => @newss}) %>');
<% end %>
\ No newline at end of file
diff --git a/app/views/users/_course_boardlist.html.erb b/app/views/users/_course_boardlist.html.erb
index 2a00d69bf..d41d630ce 100644
--- a/app/views/users/_course_boardlist.html.erb
+++ b/app/views/users/_course_boardlist.html.erb
@@ -68,11 +68,13 @@
\ No newline at end of file
diff --git a/app/views/users/_course_newslist.html.erb b/app/views/users/_course_newslist.html.erb
new file mode 100644
index 000000000..5df06b16f
--- /dev/null
+++ b/app/views/users/_course_newslist.html.erb
@@ -0,0 +1,64 @@
+
+
+
+
通知列表
+
+
排序:
+ <%= link_to "时间", {:controller => 'news', :action => 'index', :type => @type, :sort => @b_sort, :order => 1 }, :class => "sortTxt", :remote => true %>
+ <% if @type.to_i == 1 %>
+ <%= link_to "", {:controller => 'news', :action => 'index', :type => @type, :sort => @b_sort, :order => 1 }, :class => "#{@b_sort.to_i == 1 ? 'sortupbtn' : 'sortdownbtn'} ", :remote => true %>
+ <% end %>
+ <%= link_to "人气", {:controller => 'news', :action => 'index', :type => @type, :sort => @b_sort, :order => 2 }, :class => "sortTxt", :remote => true %>
+ <% if @type.to_i == 2 %>
+ <%= link_to "", {:controller => 'news', :action => 'index', :type => @type, :sort => @b_sort, :order => 2 }, :class => "#{@b_sort.to_i == 1 ? 'sortupbtn' : 'sortdownbtn'} ", :remote => true %>
+ <% end %>
+
+
+
+ <% topics.each do |activity| %>
+
+
+ <%= link_to activity.title.to_s, news_path(activity), :class => "list-title fl" %>
+ <% if activity.sticky == 1 %>
+
顶
+ <% end%>
+ <% u = User.where("id=?",activity.author_id).first%>
+
+ 发布者: <%=(u.try(:realname) != " " ? u.lastname + u.firstname : u.try(:login)) %>
+
+
+
+
+
<%=render :partial =>"users/intro_content_ex", :locals=>{:user_activity_id =>activity.id, :content=>activity.description, :maxheight=>54} %>
+
+
+
发布时间:<%= format_time(activity.created_on) %>
+
更新时间:<%= format_time(CourseActivity.where("course_act_type='#{activity.class}' and course_act_id =#{activity.id}").first.updated_at) %>
+ <% count=0 %>
+ <% count=activity.comments.count %>
+
<%= count>0 ? "#{count}" : "0" %>回复|<%= get_praise_num(activity) > 0 ? "#{get_praise_num(activity)}" : "0" %>赞
+
+
+
+ <% end %>
+
+
+ <%= pagination_links_full @atta_pages, @atta_count, :per_page_links => false, :remote => @is_remote, :flag => true %>
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/views/users/_intro_content_ex.html.erb b/app/views/users/_intro_content_ex.html.erb
index d667845d0..ae88fc6ac 100644
--- a/app/views/users/_intro_content_ex.html.erb
+++ b/app/views/users/_intro_content_ex.html.erb
@@ -4,21 +4,14 @@
\ No newline at end of file
diff --git a/app/views/users/_project_boardlist.html.erb b/app/views/users/_project_boardlist.html.erb
index 9d25b7bd5..a36020e3d 100644
--- a/app/views/users/_project_boardlist.html.erb
+++ b/app/views/users/_project_boardlist.html.erb
@@ -68,11 +68,13 @@
\ No newline at end of file
diff --git a/app/views/users/_user_course_list.html.erb b/app/views/users/_user_course_list.html.erb
index 8d45510a1..610c16293 100644
--- a/app/views/users/_user_course_list.html.erb
+++ b/app/views/users/_user_course_list.html.erb
@@ -18,7 +18,7 @@
-
- <%= link_to course.name+"("+current_time_and_term_short(course)+")", course_path(course.id,:host=>Setting.host_course), :class => "course-title fl #{course_endTime_timeout?(course) ? 'c_dark_grey' : ''}",
+ <%= link_to course.name+"("+current_time_and_term_short(course)+")", course_path(course.id,:host=>Setting.host_course), :class => "list-title fl #{course_endTime_timeout?(course) ? 'c_dark_grey' : ''}",
:style => 'color:#000',:id => "show_course_#{course.id}", :target => '_blank', :title => (course.is_public? ? "公开课程:":"私有课程:")+course.name+"("+current_time_and_term(course)+")"%>
<% teacher = User.where("id=?",course.tea_id).first%>
@@ -30,6 +30,9 @@
开课学期: <%= current_time_and_term course %>
+
+ 创建时间:<%= format_time(course.created_at) %>
+
<% if User.current.admin? || User.current.allowed_to?(:as_teacher,@course) %>
<% homework_num = course.homework_commons.count %>
<% else %>
@@ -51,11 +54,13 @@
\ No newline at end of file
diff --git a/app/views/users/_user_project_list.html.erb b/app/views/users/_user_project_list.html.erb
index 73bdc900a..030e62d1d 100644
--- a/app/views/users/_user_project_list.html.erb
+++ b/app/views/users/_user_project_list.html.erb
@@ -43,11 +43,13 @@
\ No newline at end of file
diff --git a/public/javascripts/application.js b/public/javascripts/application.js
index 9c3afd48b..31807b8d0 100644
--- a/public/javascripts/application.js
+++ b/public/javascripts/application.js
@@ -1238,3 +1238,19 @@ function expand_reply(container,btnid){
target.eq(2).show();
}
}
+
+//by yk 列表描述将文字和起来去掉空格多于100就显示省略号
+function description_showwords_ellipsis(id){
+ var str = "";
+ $("#intro_content_"+id).each(function () {
+ str = str + $(this).text();
+ });
+
+ if(str.length > 100){
+ str = str.substring(0,100)+"...";
+ }
+
+ $("#intro_content_"+id).html(str);
+ $("#intro_content_"+id).show();
+
+}
diff --git a/public/stylesheets/courses.css b/public/stylesheets/courses.css
index 3ec30ae51..c10f2b9cb 100644
--- a/public/stylesheets/courses.css
+++ b/public/stylesheets/courses.css
@@ -1311,7 +1311,7 @@ a:hover.Blue-btn{ background:#3598db; color:#fff;}
a{text-decoration:none}
.listbox{ width:730px; background-color:#fff; border:1px solid #ddd; padding:10px; }
/*.bloglistbox{ min-height:690px;}*/
-.list-h2{ font-size:16px; font-weight:bold; color:#000; border-bottom:2px solid #269ac9; padding-bottom:5px;}
+.list-h2{ font-size:16px; font-weight:bold; color:#000; padding-bottom:5px;}
.category{ padding:10px 0; border-bottom:1px solid #ddd;}
.category a,.category span{ float:left; margin-right:5px;}
.grayTxt{ color:#9093a6;}
diff --git a/public/stylesheets/new_user.css b/public/stylesheets/new_user.css
index 1e24c34f4..51e8ebe9b 100644
--- a/public/stylesheets/new_user.css
+++ b/public/stylesheets/new_user.css
@@ -845,14 +845,14 @@ a.sortArrowActiveU {background:url(images/post_image_list.png) -17px -20px no-re
.postDetailBanner {height:30px; width:720px; border-bottom:1px solid #efefef;}
.postDetailRow {width:720px; border-bottom:1px solid #efefef; padding:15px 0;}
.postDetailPortrait {width:50px; height:50px; float:left; margin-right:15px;}
-.postDetailWrap {width:580px; float:left;}
-.postDetailTitle {width:580px; max-width:580px; margin-bottom:5px;}
+.postDetailWrap {width:655px; float:left;}
+.postDetailTitle {width:570px; max-width:570px; margin-bottom:5px;}
.postDetailDes {width:580px; max-width:580px; margin-bottom:6px; color:#888888;display:block;overflow:hidden;word-break:keep-all;text-overflow:ellipsis;}
.postDetailDes p,div,em{word-break: break-all;word-wrap: break-word;}
.homepagePostIntro p,.homepagePostIntro div,.homepagePostIntro em, .homepagePostIntro span{text-align: justify; text-justify:inter-ideograph; word-break: normal !important; word-wrap: break-word !important; line-height: 18px !important;}
.postDetailCreater {color:#888888; font-size:12px; float:left; margin-right:25px;}
.postDetailDate {color:#888888; font-size:12px; float:left;}
-.postDetailReply { margin-top:28px; color:#888888; float:right;display: inline}
+.postDetailReply { color:#888888; float:right;display: inline}
.disablePostLikeIcon {background:url(images/post_image_list.png) 0px -42px no-repeat ;float:right; padding-left:18px; padding-right: 5px; -moz-transition :all 0s linear 0s; -webkit-transition :all 0s linear 0s; -o-transition:all 0s linear 0s; transition:all 0s linear 0s;}
a.postReplyIcon {background:url(images/post_image_list.png) -40px 2px no-repeat; width:18px; height:18px; float:left; -moz-transition :all 0s linear 0s; -webkit-transition :all 0s linear 0s; -o-transition:all 0s linear 0s; transition:all 0s linear 0s;}
a.postReplyIcon:hover {background:url(images/post_image_list.png) -40px -29px no-repeat; -moz-transition :all 0s linear 0s; -webkit-transition :all 0s linear 0s; -o-transition:all 0s linear 0s; transition:all 0s linear 0s;}
@@ -1508,7 +1508,7 @@ a:hover.Blue-btn{ background:#3598db; color:#fff;}
a{text-decoration:none}
.listbox{ width:730px; background-color:#fff; border:1px solid #ddd; padding:10px; }
/*.bloglistbox{ min-height:690px;}*/
-.list-h2{ font-size:16px; font-weight:bold; color:#000; border-bottom:2px solid #269ac9; padding-bottom:5px;}
+.list-h2{ font-size:16px; font-weight:bold; color:#000; padding-bottom:5px;}
.category{ padding:10px 0; border-bottom:1px solid #ddd;}
.category a,.category span{ float:left; margin-right:5px;}
.grayTxt{ color:#9093a6;}
@@ -1533,6 +1533,7 @@ a.pages-big{ width:50px;}
a.course-title{ font-size:14px; font-weight: bold; color:#000;white-space:nowrap; overflow:hidden; text-overflow:ellipsis; display:block; width:590px;}
a:hover.course-title{ color:#269ac9;}
+
/*通知列表界面样式*/
a.messages-title{font-size:14px; font-weight: bold; color:#000;white-space:nowrap; overflow:hidden; text-overflow:ellipsis; display:block; max-width:630px;}
a:hover.messages-title{ color:#269ac9;}
@@ -1546,4 +1547,4 @@ ul.wlist li{float: left;}
ul.wlist li a{ border:1px solid #15bccf; padding: 1px 4px 1px 4px; margin-left:3px;}
ul.wlist li a:hover{ background:#15bccf; color:#fff; text-decoration:none;}
/*.wlist_select { background-color:#64bdd9; color:#fff; padding: 1px 5px 0px 5px; margin-left:3px;margin-top: -2px; border:1px solid #64bdd9;}*/
-.wlist_select a{background-color: #64bdd9;cursor: default;}
+.wlist_select a{background-color: #64bdd9;cursor: default;}
diff --git a/public/stylesheets/project.css b/public/stylesheets/project.css
index ebedb1c30..713b959f5 100644
--- a/public/stylesheets/project.css
+++ b/public/stylesheets/project.css
@@ -1209,7 +1209,7 @@ a.chooseActive {background-color:#269ac9; color:#ffffff;}
a{text-decoration:none}
.listbox{ width:730px; background-color:#fff; border:1px solid #ddd; padding:10px; }
/*.bloglistbox{ min-height:690px;}*/
-.list-h2{ font-size:16px; font-weight:bold; color:#000; border-bottom:2px solid #269ac9; padding-bottom:5px;}
+.list-h2{ font-size:16px; font-weight:bold; color:#000; padding-bottom:5px;}
.category{ padding:10px 0; border-bottom:1px solid #ddd;}
.category a,.category span{ float:left; margin-right:5px;}
.grayTxt{ color:#9093a6;}