Sha256: b9524a10ecac8da21213e9d7cd2c661a9bade9c9806a3d9953a940c5910f55b3
Contents?: true
Size: 1.75 KB
Versions: 1
Compression:
Stored size: 1.75 KB
Contents
require 'json' module Collections # --------------------------------------------------------------------------- # Paginate on a collection get "/cltn/:page" do @back_url = "/explore/back" @page = params[:page].to_i || 1 @title = title_for( session[:path_names] ) load_cltn( params[:page].to_i ) erb :cltn_list end # --------------------------------------------------------------------------- post "/cltn_refresh/:page" do selected_cols = params[:cols].keys.sort session[:selected_cols] = selected_cols load_cltn( params[:page].to_i ) erb :cltn_update_js, :layout => false end # --------------------------------------------------------------------------- # BOZO !! Validation.... post "/cltn_search" do json = params[:search].gsub( /'/, "\"" ) if json.empty? @query = {} @sort = {} else tokens = json.split( "|" ) @query = JSON.parse( tokens.shift ) @sort = tokens.empty? ? [] : JSON.parse( tokens.first ) end session[:query_params] = [@query, @sort] load_cltn erb :cltn_update_js, :layout => false end # =========================================================================== helpers do def load_cltn( page=1 ) query_params = session[:query_params] || [{},[]] @query = [query_params.first.to_json, query_params.last.to_json].join(",") @page = page path_names = session[:path_names] path_ids = session[:path_ids] @cltn = options.connection.paginate_cltn( path_names, query_params, @page, 15 ) @cols = @cltn.first.keys.sort @selected_cols = session[:selected_cols] || @cols[0...5] end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
mongo3-0.0.2 | lib/controllers/collections.rb |