Sha256: dd862264972711cc42d75616554edc605f69ac55a071718ff2c9dff19694a3d1

Contents?: true

Size: 1.28 KB

Versions: 2

Compression:

Stored size: 1.28 KB

Contents

module Features
  
  # ---------------------------------------------------------------------------
  # paginate top features
  get "/features/:page" do
    page         = params[:page] ? params[:page].to_i : 1        
    @features    = Wackamole::Feature.paginate_tops( @filter.to_conds, page )   
    @search_path = "/features/search"
    @filter_path = "/features/filter"
       
    if request.xhr?
      erb :'features/index.js', :layout => false
    else
      erb :'features/index'
    end
  end
  
  # ---------------------------------------------------------------------------
  # Search - must specify a context ie ses: fred
  post "/features/search" do
    begin      
      @filter.search_terms = params[:search_filter][:search_terms]      
      @features = Wackamole::Feature.paginate_tops( @filter.to_conds )
    rescue => boom
      logger.error boom
      flash[:error] = boom
      @features = [].paginate
    end

    erb :"features/filter.js", :layout => false
  end
    
  # ---------------------------------------------------------------------------
  # Filter
  post "/features/filter" do
    @filter.from_options( params[:filter] )
    session[:filter] = @filter
    @features = Wackamole::Feature.paginate_tops( @filter.to_conds )
    erb :"features/filter.js", :layout => false
  end  
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
wackamole-0.0.8 lib/controllers/features.rb
wackamole-0.0.7 lib/controllers/features.rb