fixed archive bug, make it have page and category

This commit is contained in:
Rueshyna 2013-02-20 10:18:28 +08:00 committed by chris
parent 9cf8c2b72b
commit 4e151690e9
2 changed files with 85 additions and 55 deletions

View File

@ -1,47 +1,81 @@
class Panel::Archive::FrontEnd::ArchiveFilesController < OrbitWidgetController class Panel::Archive::FrontEnd::ArchiveFilesController < OrbitWidgetController
def initialize def initialize
super super
@app_title = 'archive_files' @app_title = 'archive_files'
end end
def index def index
@item = Page.find(params[:page_id])
@item = Page.find(params[:page_id]) @title = @item.title
if !@item.frontend_data_count.blank?
@title = @item.title @page_num = @item.frontend_data_count
else
if @item.frontend_data_count @page_num = 1
@page_num = @item.frontend_data_count end
else
@page_num = 0 date_now = Time.now
end @archive_file_categorys = ArchiveFileCategory.all
date_now = Time.now # @archive_files = ArchiveFile.where( :is_hidden => false ).desc(:is_top).page(params[:page]).per(@page_num)
@archive_file_categorys = ArchiveFileCategory.all if !params[:category_id].blank? && !params[:tag_id].blank?
@tag = ArchiveTag.find(params[:tag_id]) rescue nil
# @archive_files = ArchiveFile.where( :is_hidden => false ).desc(:is_top).page(params[:page]).per(@page_num) @tag = ArchiveTag.where(key: params[:tag_id])[0] unless @tag
@archive_files = @tag.archive_files.can_display.desc( :is_top ).page( params[:page_main] ).per(@page_num)
if !params[:category_id].blank? @archive_files = @archive_files.can_display.where(:archive_file_category_id => params[:category_id]).desc( :is_top ).page( params[:page_main] ).per(@page_num)
@archive_files = ArchiveFile.all.can_display.any_in(:archive_file_category_id => params[:category_id]).merge(ArchiveFileCategory.excludes('disable' => true)).desc( :is_top ).page( params[:page_main] ).per(@page_num)
@current_category = ArchiveFileCategory.from_id(params[:category_id]) rescue nil @current_category = ArchiveFileCategory.from_id(params[:category_id]) rescue nil
elsif !params[:tag_id].blank?
@tag = ArchiveTag.find(params[:tag_id]) rescue nil elsif !params[:category_id].blank?
@tag = ArchiveTag.where(key: params[:tag_id])[0] unless @tag @archive_files = ArchiveFile.can_display.where(:archive_file_category_id => params[:category_id]).desc( :is_top ).page( params[:page_main] ).per(@page_num)
@archive_files = @tag.archive_files.can_display.desc( :is_top ).page( params[:page_main] ).per(@page_num) @current_category = ArchiveFileCategory.from_id(params[:category_id]) rescue nil
elsif !params[:tag_id].blank?
get_categorys @tag = ArchiveTag.find(params[:tag_id]) rescue nil
else @tag = ArchiveTag.where(key: params[:tag_id])[0] unless @tag
@archive_files = ArchiveFile.all.can_display.merge(ArchiveFileCategory.excludes('disable' => true)).desc( :is_top ).page( params[:page_main] ).per(@page_num) @archive_files = @tag.archive_files.can_display.desc( :is_top ).page( params[:page_main] ).per(@page_num)
else
get_categorys @archive_files = ArchiveFile.can_display.desc( :is_top ).page( params[:page_main] ).per(@page_num)
end end
end get_categorys
end
def get_categorys
@archive_file_categorys = ArchiveFileCategory.excludes('disable' => true) def show
end @item = Page.find(params[:page_id])
@title = @item.title
end @archive_file = ArchiveFile.find(params[:id])
get_categorys
end
protected
def reload_archive_files
@item = Page.find(params[:page_id])
@title = @item.title
if @item.frontend_data_count
@page_num = @item.frontend_data_count
else
@page_num = 0
end
date_now = Time.now
@archive_file_categorys = ArchiveFileCategory.all
# @archive_files = ArchiveFile.where( :is_hidden => false ).desc(:is_top).page(params[:page]).per(@page_num)
if !params[:category_id].blank?
@archive_files = ArchiveFile.can_display.where(:archive_file_category_id => params[:category_id]).desc( :is_top ).page( params[:page_main] ).per(@page_num)
@current_category = ArchiveFileCategory.from_id(params[:category_id]) rescue nil
elsif !params[:tag_id].blank?
@tag = ArchiveTag.find(params[:tag_id]) rescue nil
@tag = ArchiveTag.where(key: params[:tag_id])[0] unless @tag
@archive_files = @tag.archive_files.can_display.desc( :is_top ).page( params[:page_main] ).per(@page_num)
else
@archive_files = ArchiveFile.can_display.desc( :is_top ).page( params[:page_main] ).per(@page_num)
end
get_categorys
end
def get_categorys
@archive_file_categorys = ArchiveFileCategory.excludes('disabled' => true)
end
end

View File

@ -1,17 +1,13 @@
Rails.application.routes.draw do Rails.application.routes.draw do
namespace :panel do namespace :panel do
namespace :archive do namespace :archive do
namespace :back_end do namespace :back_end do
resources :archive_files do resources :archive_files
collection do resources :archive_file_categorys
get 'delete'
end
end
resources :archive_file_categorys
resources :tags resources :tags
end end
namespace :front_end do namespace :front_end do
match "archive_files" => "archive_files#index"
resources :archive_files resources :archive_files
end end
namespace :widget do namespace :widget do
@ -19,5 +15,5 @@ Rails.application.routes.draw do
end end
end end
end end
match "/appfront/*path" => redirect("/panel/*path") match "/appfront/*path" => redirect("/panel/*path")
end end