From 29115bca3ae1fd2d81303e523b56584ab8cd9c23 Mon Sep 17 00:00:00 2001 From: yuanke <249218296@qq.com> Date: Wed, 20 Apr 2016 16:12:20 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8D=9A=E5=AE=A2=E5=88=97=E8=A1=A8=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/admin_controller.rb | 7 +- app/controllers/blogs_controller.rb | 7 + app/views/blogs/_article.html.erb | 258 ++++------------------- app/views/blogs/_article_list.html.erb | 37 +--- app/views/blogs/index.html.erb | 2 +- app/views/layouts/new_base_user.html.erb | 2 +- public/images/liststyle.png | Bin 0 -> 19559 bytes public/stylesheets/new_user.css | 35 +++ 8 files changed, 88 insertions(+), 260 deletions(-) create mode 100644 public/images/liststyle.png diff --git a/app/controllers/admin_controller.rb b/app/controllers/admin_controller.rb index 906194951..e6e0ec087 100644 --- a/app/controllers/admin_controller.rb +++ b/app/controllers/admin_controller.rb @@ -600,10 +600,11 @@ class AdminController < ApplicationController #设置个空的数组 以便paginateHelper来分页 @code_work_tests = [] - @code_work_tests[tCount-1] = {} - + if tCount >= 1 + @code_work_tests[tCount-1] = {} + end @code_work_tests = paginateHelper @code_work_tests,30 - @page = (params['page'] || 1).to_i - 1 #1111111111 + @page = (params['page'] || 1).to_i - 1 #取出需要的那一页数据 tStart = @page*30 diff --git a/app/controllers/blogs_controller.rb b/app/controllers/blogs_controller.rb index 7a226f50d..8ee153456 100644 --- a/app/controllers/blogs_controller.rb +++ b/app/controllers/blogs_controller.rb @@ -3,6 +3,13 @@ class BlogsController < ApplicationController before_filter :find_user def index @article = BlogComment.new + + @topics = @user.blog.articles.reorder("#{BlogComment.table_name}.sticky desc,#{BlogComment.table_name}.updated_on desc") + + #分页 + @topics = paginateHelper @topics,10 + @page = (params['page'] || 1).to_i - 1 + respond_to do |format| format.html {render :layout=>'new_base_user'} end diff --git a/app/views/blogs/_article.html.erb b/app/views/blogs/_article.html.erb index edbce26d3..cfc43ca47 100644 --- a/app/views/blogs/_article.html.erb +++ b/app/views/blogs/_article.html.erb @@ -1,226 +1,46 @@ -
-
-
- <%= link_to image_tag(url_to_avatar(activity.author), :width => "50", :height => "50"), user_path(activity.author_id,:host=>Setting.host_user), :alt => "用户头像" %> -
-
- <% if activity.author.id == User.current.id || User.current.admin? %> - - <%end%> -
- <% if activity.try(:author).try(:realname) == ' ' %> - <%= link_to activity.try(:author), user_path(activity.author_id,:host=>Setting.host_user), :class => "newsBlue mr15" %> - <% else %> - <%= link_to activity.try(:author).try(:realname), user_path(activity.author_id,:host=>Setting.host_user), :class => "newsBlue mr15" %> - <% end %> - TO - <%= link_to activity.blog.name+" | 博客", user_blogs_path(:user_id=>activity.author_id,:host=>Setting.host_user), :class => "newsBlue ml15 mr5"%> - <% if activity.blog.homepage_id and activity.id == activity.blog.homepage_id %> - 已设为首页 - <% end %> -
-
- - <% if activity.sticky == 1%> - 置顶 - <% end%> - <% if activity.locked%> -        - <% end%> -
-
- 发帖时间:<%= format_time(activity.created_on) %> -
-
- 更新时间:<%= format_time(activity.updated_on) %> -
-
- <% if activity.parent_id.nil? %> - <% content= activity.content%> - <% else %> - <% content= activity.parent.content%> - <% end %> - <%=render :partial =>"users/intro_content", :locals=>{:user_activity_id =>user_activity_id, :content=>content} %> - -
- - - -
-
- <%= render :partial=>"attachments/activity_attach", :locals=>{:activity => activity} %> -
- -
+
+

博客列表

+
+ 排序: + 时间 + 人气
- <% count=0 %> - <% if activity.parent %> - <% count=activity.parent.children.count%> - <% else %> - <% count=activity.children.count%> - <% end %> -
-
-
回复 - <%= count>0 ? "(#{count})" : "" %> - - <% if activity.author == User.current %> - - <% else %> - <%=render :partial=> "praise_tread/praise", :locals => {:activity=>activity, :user_activity_id=>user_activity_id,:type=>"activity"}%> - <% end %> - -
-
<%#=format_date(activity.updated_on)%>
- <%if count > 3 %> - - <% end %> -
- - <% activity= activity.parent ? activity.parent : activity%> - <% replies_all_i = 0 %> - <% if count > 0 %> -
-
    - <% activity.children.reorder("created_on desc").each do |reply|%> - - <% replies_all_i=replies_all_i+1 %> -
  • -
    - <%= link_to image_tag(url_to_avatar(reply.author), :width => "33", :height => "33"), user_path(reply.author_id,:host=>Setting.host_user), :alt => "用户头像" %> -
    -
    -
    - <% if reply.try(:author).try(:realname) == ' ' %> - <%= link_to reply.try(:author), user_path(reply.author_id,:host=>Setting.host_user), :class => "newsBlue mr10 f14" %> - <% else %> - <%= link_to reply.try(:author).try(:realname), user_path(reply.author_id,:host=>Setting.host_user), :class => "newsBlue mr10 f14" %> - <% end %> - <%= format_time(reply.created_on) %> - - <% if reply.author == User.current %> - - <% else %> - <%=render :partial=> "praise_tread/praise", :locals => {:activity=>reply, :user_activity_id=>reply.id,:type=>"reply"}%> - <% end %> - -
    -
    - <%= reply.content.html_safe %> -
    -
    -
    -
  • +
    + <% 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 %> -
    -
    - <% end %> - - <% if !activity.locked? %> -
    -
    <%= link_to image_tag(url_to_avatar(User.current), :width => "33", :height => "33"), user_path(activity.author_id), :alt => "用户头像" %>
    -
    -
    - <%= form_for('new_form',:url => {:controller=>'blog_comments',:action => 'reply', :id => activity.id, :blog_id => activity.blog.id, :user_id => activity.author_id},:method => "post",:remote=>true) do |f|%> - - - - - -
    - - -
    -

    - <% 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 %> +
- diff --git a/app/views/blogs/_article_list.html.erb b/app/views/blogs/_article_list.html.erb index f3fd1aa61..af9fc1c0f 100644 --- a/app/views/blogs/_article_list.html.erb +++ b/app/views/blogs/_article_list.html.erb @@ -51,44 +51,9 @@ <% end %> <% if topics%> - <% topics.each do |topic| %> - - <% if topic %> - <%= render :partial => 'blogs/article', :locals => {:activity => topic, :user_activity_id => topic.id} %> - <% end %> - <% end %> - - <%# if topics.count == 10 %> - - <%# end %> + <%= render :partial => 'blogs/article', :locals => {:topics => topics} %> <% end%>
-