class PackagesController < ApplicationController def index @packages = Package.includes(:screenshots) if params[:query] @packages = @packages.text_search(params[:query]) end if params[:search] logger.debug "Searching for #{params[:search]}" @packages = @packages.general_search(params[:search]) 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 end def list index @packages = @packages.paginate(page: params[:page], per_page: 6) render 'packages/index-list.slim' end def grid index @packages = @packages.paginate(page: params[:page], per_page: 24) render 'packages/index-grid.slim' end def details @package = Package.find_by(name: params[:name]) end def with_screenshots # TODO end def without_screenshots # TODO end def moderate # TODO end def upload # TODO raise "name not given" unless params[:name] @package = Package.find_by(name: params[:name]) end def upload_image "uploaded" end end