Sha256: ae090e9f27608eda54a8d7c85d5952940e8df353dab67ebe31319e2228f57122

Contents?: true

Size: 1.36 KB

Versions: 3

Compression:

Stored size: 1.36 KB

Contents

module Features
  
  # ---------------------------------------------------------------------------
  # paginate top features
  get "/features/:page" do
    page = params[:page] ? params[:page].to_i : 1
        
puts @filter.inspect
        
    @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
puts "Setting #{session[:filter].inspect}"        
    @features = Wackamole::Feature.paginate_tops( @filter.to_conds )
    erb :"features/filter.js", :layout => false
  end  
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
wackamole-0.0.6 lib/controllers/features.rb
wackamole-0.0.5 lib/controllers/features.rb
wackamole-0.0.4 lib/controllers/features.rb