Sha256: 1e75e9d9a5cbc7d7ade9c09dbc704a926df473710d01c3e70e0ab1beae738961
Contents?: true
Size: 1.46 KB
Versions: 1
Compression:
Stored size: 1.46 KB
Contents
require 'rubygems' require 'bundler' Bundler.require # Load the "model". # require File.expand_path 'book', File.dirname(__FILE__) set :haml, { :format => :html5 } # Sets up a search instance to the server. # BookSearch = Picky::Client.new :host => 'localhost', :port => 8080, :path => '/books' set :static, true set :public, File.dirname(__FILE__) set :views, File.expand_path('views', File.dirname(__FILE__)) # Root, the search interface. # get '/' do @query = params[:q] haml :'/search' end # Configure. The configuration info page. # get '/configure' do haml :'/configure' end # You get the ids from the picky server and then # populate the result with rendered models. # get '/search/full' do results = BookSearch.search params[:query], :ids => params[:ids], :offset => params[:offset] results.extend Picky::Convenience results.populate_with Book do |book| book.to_s end # # Or use: # results.populate_with Book # # Then: # rendered_entries = results.entries.map do |book| (render each book here) end # ActiveSupport::JSON.encode results end # Normally, you'd actually go directly to the search server without taking the detour. # # We don't parse/reencode the returned json string using search_unparsed. # get '/search/live' do BookSearch.search_unparsed params[:query], :ids => params[:ids], :offset => params[:offset] end helpers do def js path "<script src='javascripts/#{path}.js' type='text/javascript'></script>" end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
picky-generators-2.0.0.pre1 | prototypes/client/sinatra/app.rb |