From 5c5d2121937d30d59597953b2e2caef12b13478a Mon Sep 17 00:00:00 2001 From: yuanke <249218296@qq.com> Date: Fri, 22 Apr 2016 13:52:33 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8D=9A=E5=AE=A2=E5=88=97=E8=A1=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/blogs_controller.rb | 34 +++++-- app/views/blogs/_article.html.erb | 118 +++++++++++++---------- app/views/blogs/_article_list.html.erb | 2 +- app/views/blogs/index.js.erb | 1 + app/views/layouts/new_base_user.html.erb | 2 +- public/javascripts/homework.js | 6 ++ public/stylesheets/new_user.css | 21 ++-- 7 files changed, 117 insertions(+), 67 deletions(-) diff --git a/app/controllers/blogs_controller.rb b/app/controllers/blogs_controller.rb index dcdb4846c..8a725dcca 100644 --- a/app/controllers/blogs_controller.rb +++ b/app/controllers/blogs_controller.rb @@ -1,24 +1,44 @@ class BlogsController < ApplicationController before_filter :find_blog,:except => [:index,:create,:new,:set_homepage, :cancel_homepage] before_filter :find_user + include PraiseTreadHelper + def index @article = BlogComment.new - @order, @b_sort = params[:order] || 1, params[:sort] || "desc" - - sort_name = @order == 1 ? "created_on" : "" + @order, @b_sort,@type = params[:order] || 1, params[:sort] || 2, params[:type] || 1 + #确定 sort_type + if @order.to_i == @type.to_i + @b_sort = @b_sort.to_i == 1 ? 2 : 1 + else + @b_sort = 1 + end - @topics = @user.blog.articles.reorder("#{BlogComment.table_name}.sticky desc,#{BlogComment.table_name}.#{sort_name} #{@b_sort}") + sort_name = "updated_on" - #分页 + sort_type = @b_sort == 1 ? "desc" : "asc" - @topics = paginateHelper @topics,10 - @page = (params['page'] || 1).to_i - 1 + @topics = @user.blog.articles.reorder("#{BlogComment.table_name}.sticky desc,#{BlogComment.table_name}.#{sort_name} #{sort_type}") + #根据 赞+回复数排序 + if @order.to_i == 2 + @type = 2 + @b_sort == 1 ? @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| 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) } + else + @type = 1 + 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 respond_to do |format| + format.js format.html {render :layout=>'new_base_user'} end end diff --git a/app/views/blogs/_article.html.erb b/app/views/blogs/_article.html.erb index 7b8ccb5d3..4b733c0f9 100644 --- a/app/views/blogs/_article.html.erb +++ b/app/views/blogs/_article.html.erb @@ -1,56 +1,70 @@ -
-

博客列表

-
- 排序: +
+
+
+

博客列表

+
+ 排序: + <%= 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, :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, :type => @type, :sort => @b_sort, :order => 2 }, :class => "sortTxt", :remote => true %> + <% if @type.to_i == 2 %> + <%= 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 %> - - <%= link_to "时间", user_blog_sort_blog_path(:sort => @score, :order => 1, :search => " "), :class => "sortTxt", :remote => true %> - <% if @order == 1 %> - <%= link_to "", user_blog_sort_blog_path(:sort => @score, :order => 1, :search => " "), :class => "#{@score == 'desc' ? 'sortupbtn' : 'sortdownbtn'} ", :remote => true %> - <% end %> - - <%= link_to "人气", user_blog_sort_blog_path(:sort => @score, :order => 2, :search => " "), :class => "sortTxt", :remote => true %> - <% if @order == 2 %> - <%= link_to "", user_blog_sort_blog_path(:sort => @score, :order => 2, :search => " "), :class => "#{@score == 'desc' ? 'sortupbtn' : 'sortdownbtn'} ", :remote => true %> - <% end %> - -
-
-
- <% topics.each do |activity| %> -
    -
  • - <% if activity.parent_id.nil? %> - <%= link_to activity.title.to_s.html_safe, user_blog_blog_comment_path(:user_id=>activity.author_id, :blog_id=>activity.blog.id,:id=>activity), :class=> "c_red ml10" %> - <% else %> - <%= link_to activity.title.subject.to_s.html_safe, user_blog_blog_comment_path(:user_id=>activity.author_id, :blog_id=>activity.blog.id,:id=>activity), :class=> "c_red ml10"%> - <% end %> - <% if activity.blog.homepage_id and activity.id == activity.blog.homepage_id %> - [已设为首页] - <% end %> -
  • - <% count=0 %> - <% if activity.parent %> - <% count=activity.parent.children.count%> - <% else %> - <% count=activity.children.count%> - <% end %> -
  • - 发帖时间:<%= format_time(activity.created_on) %> - 更新时间:<%= format_time(activity.updated_on) %> -

    - <%= count>0 ? "(#{count})" : "" %> - 回复 - | - <%= get_praise_num(activity) > 0 ? "(#{get_praise_num(activity)})" : "" %> - -

    -
  • +
    +
+
+ <% topics.each do |activity| %> +
    +
  • + <% if activity.parent_id.nil? %> + <%= link_to activity.title.to_s.html_safe, user_blog_blog_comment_path(:user_id=>activity.author_id, :blog_id=>activity.blog.id,:id=>activity), :class=> "list-title fl" %> + <% else %> + <%= link_to activity.title.subject.to_s.html_safe, user_blog_blog_comment_path(:user_id=>activity.author_id, :blog_id=>activity.blog.id,:id=>activity), :class=> "list-title fl"%> + <% end %> + <% if activity.blog.homepage_id and activity.id == activity.blog.homepage_id %> + [已设为首页] + <% end %> +
    +
  • + <% count=0 %> + <% if activity.parent %> + <% count=activity.parent.children.count%> + <% else %> + <% count=activity.children.count%> + <% end %> +
  • + 发帖时间:<%= format_time(activity.created_on) %> + 更新时间:<%= format_time(activity.updated_on) %> +

    + <%= 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 %> +
- - <% end %> - +
-
+ \ No newline at end of file diff --git a/app/views/blogs/_article_list.html.erb b/app/views/blogs/_article_list.html.erb index af9fc1c0f..c52fa017e 100644 --- a/app/views/blogs/_article_list.html.erb +++ b/app/views/blogs/_article_list.html.erb @@ -38,7 +38,7 @@
-
+
<%= @user.name%>的博客
diff --git a/app/views/blogs/index.js.erb b/app/views/blogs/index.js.erb index e69de29bb..6c8835f6f 100644 --- a/app/views/blogs/index.js.erb +++ b/app/views/blogs/index.js.erb @@ -0,0 +1 @@ +$("#blog-list").html('<%= escape_javascript( render :partial => 'blogs/article', :locals => {:topics => @topics} ) %>'); \ 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 f3bd827a4..4e1064b7f 100644 --- a/app/views/layouts/new_base_user.html.erb +++ b/app/views/layouts/new_base_user.html.erb @@ -7,7 +7,7 @@ <%= csrf_meta_tag %> <%= favicon %> - <%= stylesheet_link_tag 'jquery/jquery-ui-1.9.2', 'share','new_user', 'user_leftside','prettify','users','application',:media => 'all' %> + <%= stylesheet_link_tag 'jquery/jquery-ui-1.9.2', 'share','new_user', 'user_leftside','prettify','users',:media => 'all' %> <%= stylesheet_link_tag 'rtl', :media => 'all' if l(:direction) == 'rtl' %> <%= javascript_heads %> <%= javascript_include_tag "bootstrap","avatars","new_user",'attachments','prettify'%> diff --git a/public/javascripts/homework.js b/public/javascripts/homework.js index 7aed347b0..e2268ca3b 100644 --- a/public/javascripts/homework.js +++ b/public/javascripts/homework.js @@ -22,6 +22,8 @@ $(function(){ }; var test_program = function(cb){ + $('#test-program-btn').hide() + var homework_id = $('#test-program-btn').attr('data-homework-id'); var student_work_id = $('#test-program-btn').attr('data-student-work-id'); var src = $('#program-src').val(); @@ -29,6 +31,7 @@ $(function(){ var is_test = $('input[name=is_test]').val(); if(!valid_form()){ + $('#test-program-btn').show() return; } /* @@ -83,12 +86,14 @@ $(function(){ if (r) { $(".HomeWorkCon form").submit(); } + $('#test-program-btn').show() return; } //2 超时 -2 编译错误 测试结束 if (data.status == 2 || data.status == -2 || tSeq >= tCount ){ if (typeof cb == 'function') {cb(data); return;} + $('#test-program-btn').show() return; } @@ -100,6 +105,7 @@ $(function(){ } else { alert("对不起,服务器繁忙请稍后再试!"); } + $('#test-program-btn').show() return; }); }; diff --git a/public/stylesheets/new_user.css b/public/stylesheets/new_user.css index 141205078..8f72b0a52 100644 --- a/public/stylesheets/new_user.css +++ b/public/stylesheets/new_user.css @@ -1499,18 +1499,19 @@ a:hover.Blue-btn{ background:#3598db; color:#fff;} .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;} +/*.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;} -.sortTxt{ color:#000;} -.sortTxt:hover{ color:#28be6c;} +.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;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;} -a.list-title{ font-size:14px; font-weight: bold; color:#000;white-space:nowrap; overflow:hidden; text-overflow:ellipsis; display:block; width:708px;} +.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;} @@ -1531,4 +1532,12 @@ a.messages-title{font-size:14px; font-weight: bold; color:#000;white-space:nowra a:hover.messages-title{ color:#269ac9;} .massages-content{ width:710px; color:#424242; max-height:65px; overflow:hidden; margin:10px 0;margin-left:15px; line-height:1.9;} .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;} \ No newline at end of file +.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;} + +/****翻页***/ +ul.wlist{ float:right; border-bottom:none; height:30px; margin-top:20px; } +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;} \ No newline at end of file