47 lines
1.2 KiB
Ruby
47 lines
1.2 KiB
Ruby
class PackagesController < ApplicationController
|
|
def index
|
|
@packages = Package.includes(:screenshots)
|
|
|
|
if params[:query]
|
|
@packages = @packages.text_search(params[:query])
|
|
end
|
|
|
|
# Limit the packages to those that have approved screenshots.
|
|
# Also eager-load the screenshots.
|
|
if params[:show]=='onlywith'
|
|
@packages = @packages.where("screenshots.approved"=>true)
|
|
end
|
|
|
|
if params[:show]=='with'
|
|
@packages = @packages.with_screenshots
|
|
logger.debug 'Limiting packages to those with screenshots'
|
|
elsif params[:show]=='without'
|
|
@packages = @packages.without_screenshots
|
|
logger.debug 'Limiting packages to those without screenshots'
|
|
end
|
|
|
|
# Show packages as list or grid
|
|
if params['view']=='list'
|
|
# List view
|
|
@packages = @packages.paginate(page: params[:page], per_page: 12)
|
|
render 'packages/index-list.slim'
|
|
else
|
|
# Grid view
|
|
@packages = @packages.paginate(page: params[:page], per_page: 24)
|
|
render 'packages/index-grid.slim'
|
|
end
|
|
end
|
|
|
|
def details
|
|
@package = Package.find_by(name: params[:name])
|
|
end
|
|
|
|
def with_screenshots
|
|
end
|
|
|
|
def without_screenshots
|
|
end
|
|
|
|
def moderate
|
|
end
|
|
end
|