主页页面设为主页或取消首页后跳转至主页列表、已设为主页的始终显示在前方
This commit is contained in:
parent
bebff7b24a
commit
85f489eb97
|
@ -6,7 +6,12 @@ class HomepagesController < ApplicationController
|
|||
@b_sort = params[:sort] || 1
|
||||
@b_sort = @b_sort.to_i == 1 ? 2 : 1
|
||||
sort_type = @b_sort == 1 ? "asc" : "desc"
|
||||
@articles = @user.homepage.article_homepages.reorder("updated_at #{sort_type}")
|
||||
if @user.base_homepage.nil?
|
||||
@articles = @user.homepage.article_homepages.reorder("updated_at #{sort_type}")
|
||||
else
|
||||
@articles = @user.homepage.article_homepages.where("id != #{@user.base_homepage.id}").reorder("updated_at #{sort_type}").all
|
||||
@articles.insert(0, @user.base_homepage) unless @user.base_homepage.nil?
|
||||
end
|
||||
@limit = 20
|
||||
@is_remote = true
|
||||
@atta_count = @articles.count
|
||||
|
@ -30,14 +35,19 @@ class HomepagesController < ApplicationController
|
|||
def set_homepage
|
||||
@homepage = Homepage.find(params[:id])
|
||||
@homepage.update_attribute(:article_id, params[:article_id])
|
||||
@articles = @user.homepage.article_homepages.reorder("updated_at desc")
|
||||
if @user.base_homepage.nil?
|
||||
@articles = @user.homepage.article_homepages.reorder("updated_at desc")
|
||||
else
|
||||
@articles = @user.homepage.article_homepages.where("id != #{@user.base_homepage.id}").reorder("updated_at desc").all
|
||||
@articles.insert(0, @user.base_homepage) unless @user.base_homepage.nil?
|
||||
end
|
||||
@limit = 20
|
||||
@is_remote = true
|
||||
@atta_count = @articles.count
|
||||
@atta_pages = Paginator.new @atta_count, @limit, 1
|
||||
@articles = paginateHelper @articles,@limit
|
||||
if params[:show]
|
||||
redirect_to homepage_user_path(@user.id)
|
||||
redirect_to user_homepages_path(:user_id => @user.id)
|
||||
return
|
||||
else
|
||||
respond_to do |format|
|
||||
|
@ -49,14 +59,19 @@ class HomepagesController < ApplicationController
|
|||
def cancel_homepage
|
||||
@homepage = Homepage.find(params[:id])
|
||||
@homepage.update_attribute(:article_id, nil)
|
||||
@articles = @user.homepage.article_homepages.reorder("updated_at desc")
|
||||
if @user.base_homepage.nil?
|
||||
@articles = @user.homepage.article_homepages.reorder("updated_at desc")
|
||||
else
|
||||
@articles = @user.homepage.article_homepages.where("id != #{@user.base_homepage.id}").reorder("updated_at desc").all
|
||||
@articles.insert(0, @user.base_homepage) unless @user.base_homepage.nil?
|
||||
end
|
||||
@limit = 20
|
||||
@is_remote = true
|
||||
@atta_count = @articles.count
|
||||
@atta_pages = Paginator.new @atta_count, @limit, 1
|
||||
@articles = paginateHelper @articles,@limit
|
||||
if params[:show]
|
||||
redirect_to user_homepage_article_homepage_path(:user_id=>@user.id, :homepage_id=>@homepage.id,:id=>params[:article_id].to_i)
|
||||
redirect_to user_homepages_path(:user_id => @user.id)
|
||||
return
|
||||
else
|
||||
respond_to do |format|
|
||||
|
|
|
@ -8,8 +8,8 @@
|
|||
<div class="cl"></div>
|
||||
<div class="category">
|
||||
<span class="grayTxt">排序:</span>
|
||||
<%= link_to "时间", {:controller => 'homepages', :action => 'index', :id =>@user, :sort => @b_sort}, :class => "sortTxt", :remote => true %>
|
||||
<%= link_to "", {:controller => 'homepages', :action => 'index', :id =>@user, :sort => @b_sort}, :class => "#{@b_sort.to_i == 1 ? 'sortupbtn' : 'sortdownbtn'} ", :remote => true %>
|
||||
<%= link_to "时间", {:controller => 'homepages', :action => 'index', :user_id =>@user.id, :sort => @b_sort}, :class => "sortTxt", :remote => true %>
|
||||
<%= link_to "", {:controller => 'homepages', :action => 'index', :user_id =>@user.id, :sort => @b_sort}, :class => "#{@b_sort.to_i == 1 ? 'sortupbtn' : 'sortdownbtn'} ", :remote => true %>
|
||||
<div class="cl"></div>
|
||||
</div>
|
||||
<div class="bloglistbox">
|
||||
|
|
|
@ -36,7 +36,7 @@
|
|||
<li>地区 : </li>
|
||||
<li>邮件通知 : </li>
|
||||
<!--<li>个人签名 : </li>-->
|
||||
<li>个人简介 : </li>
|
||||
<li>个人主页 : </li>
|
||||
<li> </li>
|
||||
</ul>
|
||||
<ul class="setting_right ">
|
||||
|
|
Loading…
Reference in New Issue