From 43c1120b19fccb5d4d5ab1558ae4cb3ed879b531 Mon Sep 17 00:00:00 2001
From: yuanke <249218296@qq.com>
Date: Tue, 26 Apr 2016 15:10:47 +0800
Subject: [PATCH] =?UTF-8?q?=E8=AF=BE=E7=A8=8B=E9=97=AE=E7=AD=94=E5=8C=BA?=
=?UTF-8?q?=20=E9=A1=B9=E7=9B=AE=E8=AE=A8=E8=AE=BA=E5=8C=BA=E5=88=97?=
=?UTF-8?q?=E8=A1=A8?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
app/controllers/blogs_controller.rb | 1 +
app/controllers/boards_controller.rb | 44 +++++++----
app/controllers/users_controller.rb | 2 -
app/views/blogs/_article.html.erb | 14 +++-
app/views/boards/_course_show_detail.html.erb | 40 +---------
.../boards/_project_show_detail.html.erb | 59 +-------------
app/views/boards/show.js.erb | 2 +-
app/views/layouts/new_base_user.html.erb | 60 +++++++--------
app/views/users/_course_boardlist.html.erb | 77 +++++++++++++++++++
app/views/users/_course_message.html.erb | 5 +-
app/views/users/_project_boardlist.html.erb | 77 +++++++++++++++++++
app/views/users/_user_course_list.html.erb | 8 +-
public/stylesheets/courses.css | 28 +++++++
13 files changed, 266 insertions(+), 151 deletions(-)
create mode 100644 app/views/users/_course_boardlist.html.erb
create mode 100644 app/views/users/_project_boardlist.html.erb
diff --git a/app/controllers/blogs_controller.rb b/app/controllers/blogs_controller.rb
index 3305713e7..63b0da009 100644
--- a/app/controllers/blogs_controller.rb
+++ b/app/controllers/blogs_controller.rb
@@ -25,6 +25,7 @@ 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}
else
@type = 1
end
diff --git a/app/controllers/boards_controller.rb b/app/controllers/boards_controller.rb
index a77346d89..124342041 100644
--- a/app/controllers/boards_controller.rb
+++ b/app/controllers/boards_controller.rb
@@ -62,13 +62,24 @@ class BoardsController < ApplicationController
else
render_403
end
-
end
-
end
def show
# 讨论区消息状态更新(已读和未读)
+ @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 = "updated_at"
+
+ sort_type = @b_sort == 1 ? "asc" : "desc"
+
if @project
ForgeMessage.where("user_id =? and project_id =? and viewed =?", User.current.id, @project.id, 0).update_all(:viewed => true)
# 更新@消息为已读
@@ -82,10 +93,10 @@ class BoardsController < ApplicationController
CourseMessage.where("user_id =? and course_id =? and viewed =?", User.current.id, @course.id, 0).update_all(:viewed => true)
end
- sort_init 'updated_on', 'desc'
- sort_update 'created_on' => "#{Message.table_name}.created_on",
- 'replies' => "#{Message.table_name}.replies_count",
- 'updated_on' => "COALESCE(last_replies_messages.created_on, #{Message.table_name}.created_on)"
+ # sort_init 'updated_on', 'desc'
+ # sort_update 'created_on' => "#{Message.table_name}.created_on",
+ # 'replies' => "#{Message.table_name}.replies_count",
+ # 'updated_on' => "COALESCE(last_replies_messages.created_on, #{Message.table_name}.created_on)"
@is_new = params[:is_new]
@topic_count = @board ? @board.topics.count : 0
@@ -93,26 +104,31 @@ class BoardsController < ApplicationController
if @board
limit = 10;
@topic_count = @board.topics.count();
- @topic_pages = (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) desc").
- limit(limit).offset(@topic_pages).includes(:last_reply).
+ @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}").
+ offset(@topic_pages).includes(:last_reply).
preload(:author, {:last_reply => :author}).all();
else
@topics = [];
end
elsif @course
if (@board)
- limit = 10;
@topic_count = @board.topics.count();
- @topic_pages = (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) desc").
- limit(limit).offset(@topic_pages).includes(:last_reply).
- preload(:author, {:last_reply => :author}).all();
+ @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}").offset(@topic_pages).includes(:last_reply).preload(:author, {:last_reply => :author}).all();
else
@topics = [];
end
end
+ #分页
+ @limit = 10
+ @is_remote = true
+ @atta_count = @topics.count
+ @atta_pages = Paginator.new @atta_count, @limit, params['page'] || 1
+ @offset ||= @atta_pages.offset
+ @topics = paginateHelper @topics,@limit
+
@page = params[:page] ? params[:page].to_i + 1 : 0
@message = Message.new(:board => @board)
#modify by nwb
diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb
index 8f80190bf..54b19a3e6 100644
--- a/app/controllers/users_controller.rb
+++ b/app/controllers/users_controller.rb
@@ -2848,7 +2848,6 @@ class UsersController < ApplicationController
def user_courselist
@order, @c_sort,@type = params[:order] || 1, params[:sort] || 1, params[:type] || 1
-
#确定 sort_type
if @order.to_i == @type.to_i
@c_sort = @c_sort.to_i == 1 ? 2 : 1 #1升序 2降序
@@ -2871,7 +2870,6 @@ class UsersController < ApplicationController
@type = 2
@courses.each do |course|
course[:infocount] = (User.current.admin? || User.current.allowed_to?(:as_teacher,course)) ? (course.homework_commons.count + visable_attachemnts_incourse(course).count) : (course.homework_commons.where("publish_time <= '#{Date.today}'").count + visable_attachemnts_incourse(course).count)
- puts course[:infocount]
end
@c_sort == 1 ? (@courses = @courses.sort{|x,y| x[:infocount] <=> y[:infocount] }) : (@courses = @courses.sort{|x,y| y[:infocount] <=> x[:infocount]})
else
diff --git a/app/views/blogs/_article.html.erb b/app/views/blogs/_article.html.erb
index 1b9ef992e..9ec17bf90 100644
--- a/app/views/blogs/_article.html.erb
+++ b/app/views/blogs/_article.html.erb
@@ -4,13 +4,13 @@
排序:
- <%= link_to "时间", {:controller => 'blogs', :action => 'index', :id =>@user.id, :type => @type, :sort => @b_sort, :order => 1 }, :class => "sortTxt", :remote => true %>
+ <%= link_to "时间", {:controller => 'blogs', :action => 'index', :id =>@user, :type => @type, :sort => @b_sort, :order => 1 }, :class => "sortTxt", :remote => true %>
<% if @type.to_i == 1 %>
- <%= link_to "", {:controller => 'blogs', :action => 'index', :id =>@user.id, :type => @type, :sort => @b_sort, :order => 1 }, :class => "#{@b_sort.to_i == 1 ? 'sortupbtn' : 'sortdownbtn'} ", :remote => true %>
+ <%= link_to "", {:controller => 'blogs', :action => 'index', :id =>@user, :type => @type, :sort => @b_sort, :order => 1 }, :class => "#{@b_sort.to_i == 1 ? 'sortupbtn' : 'sortdownbtn'} ", :remote => true %>
<% end %>
- <%= link_to "人气", {:controller => 'blogs', :action => 'index', :id =>@user.id, :type => @type, :sort => @b_sort, :order => 2 }, :class => "sortTxt", :remote => true %>
+ <%= link_to "人气", {:controller => 'blogs', :action => 'index', :id =>@user, :type => @type, :sort => @b_sort, :order => 2 }, :class => "sortTxt", :remote => true %>
<% if @type.to_i == 2 %>
- <%= link_to "", {:controller => 'blogs', :action => 'index', :id =>@user.id, :type => @type, :sort => @b_sort, :order => 2 }, :class => "#{@b_sort.to_i == 1 ? 'sortupbtn' : 'sortdownbtn'} ", :remote => true %>
+ <%= link_to "", {:controller => 'blogs', :action => 'index', :id =>@user, :type => @type, :sort => @b_sort, :order => 2 }, :class => "#{@b_sort.to_i == 1 ? 'sortupbtn' : 'sortdownbtn'} ", :remote => true %>
<% end %>
@@ -27,6 +27,12 @@
<% if activity.blog.homepage_id and activity.id == activity.blog.homepage_id %>
[已设为首页]
<% end %>
+ <% if activity.sticky == 1 %>
+
顶
+ <% end%>
+ <% if activity.locked %>
+
锁
+ <% end %>
<% count=0 %>
diff --git a/app/views/boards/_course_show_detail.html.erb b/app/views/boards/_course_show_detail.html.erb
index d465571c5..64654f517 100644
--- a/app/views/boards/_course_show_detail.html.erb
+++ b/app/views/boards/_course_show_detail.html.erb
@@ -2,41 +2,7 @@
<%= import_ke(enable_at: false, prettify: false) %>
<%= javascript_include_tag "create_kindeditor" %>
<% end %>
-<% if topics %>
- <% topics.each do |topic| %>
-
- <% if topic %>
- <%= render :partial => 'users/course_message', :locals => {:activity => topic, :user_activity_id => topic.id, :is_course => 1, :is_board=>1} %>
- <% end %>
- <% end %>
-
- <% if topics.count == 10 %>
- <%= link_to "点击展开更多",boards_topic_path(@board, :course_id => @board.course.id ,:page => page),:id => "show_more_course_topic",:remote => "true",:class => "loadMore mt10 f_grey"%>
- <% end %>
-<% end%>
+<% if @topics || topics %>
+ <%= render :partial => 'users/course_boardlist', :locals => {:topics => @topics ? @topics: topics , :is_course => 1, :is_board=>1} %>
+<% end %>
\ No newline at end of file
diff --git a/app/views/boards/_project_show_detail.html.erb b/app/views/boards/_project_show_detail.html.erb
index 1d5cc3b75..260fb88c1 100644
--- a/app/views/boards/_project_show_detail.html.erb
+++ b/app/views/boards/_project_show_detail.html.erb
@@ -2,60 +2,7 @@
<%= import_ke(enable_at: false, prettify: false) %>
<%= javascript_include_tag "create_kindeditor" %>
<% end %>
-
-<% if topics%>
- <% topics.each do |topic| %>
-
- <% if topic %>
- <%= render :partial => 'users/project_message', :locals => {:activity => topic, :user_activity_id => topic.id,:is_course=>1,:is_board=>1} %>
- <% end %>
- <% end %>
-
- <% if topics.count == 10 %>
-
- <%= link_to "点击展开更多", boards_topic_path(@board, :project_id => @board.project.id ,:page => page), :id => "show_more_project_topic",:remote => "true",:class => "loadMore mt10 f_grey"%>
- <% end %>
-<% end%>
-
-
+<%if @topics || topics %>
+ <%= render :partial => 'users/project_boardlist', :locals => {:topics => @topics ? @topics: topics , :is_course => 1, :is_board=>1} %>
+<% end %>
\ No newline at end of file
diff --git a/app/views/boards/show.js.erb b/app/views/boards/show.js.erb
index c9208fd2c..c842197c7 100644
--- a/app/views/boards/show.js.erb
+++ b/app/views/boards/show.js.erb
@@ -1,5 +1,5 @@
<% if @course %>
- $("#show_more_course_topic").replaceWith("<%= escape_javascript( render :partial => 'boards/course_show_detail',:locals => {:topics => @topics, :page => @page} )%>");
+ <%= render :partial => 'users/course_boardlist', :locals => {:topics => @topics, :is_course => 1, :is_board=>1} %>
<% else %>
$("#show_more_project_topic").replaceWith("<%= escape_javascript( render :partial => 'boards/project_show_detail',:locals => {:topics => @topics, :page => @page} )%>");
<% end %>
\ No newline at end of file
diff --git a/app/views/layouts/new_base_user.html.erb b/app/views/layouts/new_base_user.html.erb
index 0d40bb946..6fb880ed8 100644
--- a/app/views/layouts/new_base_user.html.erb
+++ b/app/views/layouts/new_base_user.html.erb
@@ -105,13 +105,13 @@
<%= image_tag(url_to_avatar(@user),width:"78", height: "78", :id=>'nh_user_tx') %>
<% if User.current.logged?%>
- <% if is_current_user%>
-
- <% end %>
+ <% if is_current_user%>
+
+ <% end %>
<% end%>
@@ -189,7 +189,8 @@
<% unvisiable = hidden_courses && hidden_courses.value == "1"%>
<% if !unvisiable %>
\ No newline at end of file
diff --git a/app/views/users/_project_boardlist.html.erb b/app/views/users/_project_boardlist.html.erb
new file mode 100644
index 000000000..a48001fdc
--- /dev/null
+++ b/app/views/users/_project_boardlist.html.erb
@@ -0,0 +1,77 @@
+
+
+
+
讨论区列表
+
+
排序:
+ <%= link_to "时间", {:controller => 'boards', :action => 'index', :type => @type, :sort => @b_sort, :order => 1 }, :class => "sortTxt", :remote => true %>
+ <% if @type.to_i == 1 %>
+ <%= link_to "", {:controller => 'boards', :action => 'index', :type => @type, :sort => @b_sort, :order => 1 }, :class => "#{@b_sort.to_i == 1 ? 'sortupbtn' : 'sortdownbtn'} ", :remote => true %>
+ <% end %>
+ <%= link_to "人气", {:controller => 'boards', :action => 'index', :type => @type, :sort => @b_sort, :order => 2 }, :class => "sortTxt", :remote => true %>
+ <% if @type.to_i == 2 %>
+ <%= link_to "", {:controller => 'boards', :action => 'index', :type => @type, :sort => @b_sort, :order => 2 }, :class => "#{@b_sort.to_i == 1 ? 'sortupbtn' : 'sortdownbtn'} ", :remote => true %>
+ <% end %>
+
+
+
+ <% topics.each do |activity| %>
+
+
+ <% if activity.parent_id.nil? %>
+ <%= link_to activity.subject.to_s.html_safe, board_message_path(activity.board_id, activity), :class=> "list-title fl" %>
+ <% else %>
+ <%= link_to activity.parent.subject.to_s.html_safe, board_message_path(activity.board_id, activity), :class=> "list-title f1" %>
+ <% end %>
+ <% if activity.sticky == 1 %>
+
顶
+ <% end%>
+ <% if activity.locked %>
+
锁
+ <% end %>
+
+ <%= activity.project.name.to_s %>
+
+
+
+
+ <% if activity.parent_id.nil? %>
+ <% content = activity.content %>
+ <% else %>
+ <% content = activity.parent.content %>
+ <% end %>
+
<%=render :partial =>"users/intro_content", :locals=>{:user_activity_id =>activity.id, :content=>content} %>
+
+
+
发帖时间:<%= 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 %>
+ <% if activity.parent %>
+ <% count=activity.parent.children.count%>
+ <% else %>
+ <% count=activity.children.count%>
+ <% end %>
+
<%= count>0 ? "(#{count})" : "" %>回复|<%= get_praise_num(activity) > 0 ? "(#{get_praise_num(activity)})" : "" %>赞
+
+
+
+ <% 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/_user_course_list.html.erb b/app/views/users/_user_course_list.html.erb
index 0a3ac5e5a..fa326264e 100644
--- a/app/views/users/_user_course_list.html.erb
+++ b/app/views/users/_user_course_list.html.erb
@@ -2,13 +2,13 @@
课程列表
排序:
- <%= link_to "时间", {:controller => 'users', :action => 'user_courselist', :id =>@user.id, :type => @type, :sort => @c_sort, :order => 1 }, :class => "sortTxt", :remote => true %>
+ <%= link_to "时间", {:controller => 'users', :action => 'user_courselist', :id =>@user, :type => @type, :sort => @c_sort, :order => 1 }, :class => "sortTxt", :remote => true %>
<% if @type.to_i == 1 %>
- <%= link_to "", {:controller => 'users', :action => 'user_courselist', :id =>@user.id, :type => @type, :sort => @c_sort, :order => 1 }, :class => "#{@c_sort.to_i == 1 ? 'sortupbtn' : 'sortdownbtn'} ", :remote => true %>
+ <%= link_to "", {:controller => 'users', :action => 'user_courselist', :id =>@user, :type => @type, :sort => @c_sort, :order => 1 }, :class => "#{@c_sort.to_i == 1 ? 'sortupbtn' : 'sortdownbtn'} ", :remote => true %>
<% end %>
- <%= link_to "人气", {:controller => 'users', :action => 'user_courselist', :id =>@user.id, :type => @type, :sort => @c_sort, :order => 2 }, :class => "sortTxt", :remote => true %>
+ <%= link_to "人气", {:controller => 'users', :action => 'user_courselist', :id =>@user, :type => @type, :sort => @c_sort, :order => 2 }, :class => "sortTxt", :remote => true %>
<% if @type.to_i == 2 %>
- <%= link_to "", {:controller => 'users', :action => 'user_courselist', :id =>@user.id, :type => @type, :sort => @c_sort, :order => 2 }, :class => "#{@c_sort.to_i == 1 ? 'sortupbtn' : 'sortdownbtn'} ", :remote => true %>
+ <%= link_to "", {:controller => 'users', :action => 'user_courselist', :id =>@user, :type => @type, :sort => @c_sort, :order => 2 }, :class => "#{@c_sort.to_i == 1 ? 'sortupbtn' : 'sortdownbtn'} ", :remote => true %>
<% end %>
diff --git a/public/stylesheets/courses.css b/public/stylesheets/courses.css
index d58d951d0..6349e4faa 100644
--- a/public/stylesheets/courses.css
+++ b/public/stylesheets/courses.css
@@ -1306,3 +1306,31 @@ a:hover.Blue-btn{ background:#3598db; color:#fff;}
.box-con{ width:450px; margin:0 auto; text-align:center;}
.box-con-a{ width:170px; margin:0 auto; margin-top:10px;}
/*--------------------------------------*/
+
+/*博客列表界面样式*/
+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;}
+.category{ padding:10px 0; border-bottom:1px solid #ddd;}
+.category a,.category span{ float:left; margin-right:5px;}
+.grayTxt{ color:#9093a6;}
+.category a.sortTxt{ color:#9093a6;}
+.category .sortTxt:hover{ color:#28be6c;}
+a.sortupbtn{ background: url(../images/liststyle.png) 0 3px no-repeat; width:12px; height:17px; display:block; margin-right:10px; cursor:pointer;}
+a.sortdownbtn{ background: url(../images/liststyle.png) 0 -12px no-repeat; width:12px; height:17px; display:block;margin-right:10px;cursor:pointer; }
+.item_list{ display:block; width:5px; height:5px;-webkit-border-radius: 25px;border-radius:25px; background-color:#adadad; margin:10px 10px 0 0;}
+.list-file a.list-title{ font-size:14px; font-weight: bold; color:#000;white-space:nowrap; overflow:hidden; text-overflow:ellipsis; display:block; max-width:635px;}
+a:hover.list-title{ color:#269ac9;}
+.c_red{ font-weight:normal; font-size:12px;}
+.list-file{ padding:10px 0; border-bottom:1px dashed #ddd;}
+.list-file li{ line-height:1.9;}
+.list-info span{ margin-left:5px;}
+.pages a{ display:block; border:1px solid #d1d1d1; color:#000; float:left; width:30px; text-align:center; padding:3px 0; line-height:1.9; margin-right:5px; }
+.pages a:hover{ background-color:#269ac9; color:#fff;}
+a.pages-big{ width:50px;}
+.pages .active{ background-color:#269ac9; color:#fff;}
+.pages{width:330px; margin:20px auto 10px;}
+
+.red-cir-btn{ background:#e74c3c; padding:1px 5px; -moz-border-radius:2px; -webkit-border-radius:2px; border-radius:2px; color:#fff; font-weight:normal;font-size:12px;}
+.green-cir-btn{ background:#28be6c; padding:1px 5px; -moz-border-radius:2px; -webkit-border-radius:2px; border-radius:2px; color:#fff; font-weight:normal;font-size:12px;}