Sha256: efa412bd6ef6d86a537c752f5e34d1cbef144d497f5fa47e7a1ecf3f1c37931c
Contents?: true
Size: 1.31 KB
Versions: 3
Compression:
Stored size: 1.31 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 two query instances. # BooksSearch = Picky::Client.new :host => 'localhost', :port => 8080, :path => '/books' set :static, true set :public_folder, File.dirname(__FILE__) set :views, File.expand_path('views', File.dirname(__FILE__)) # Root, the search interface. # get '/' do @query = params[:q] haml :'/search' end # For full results, you get the ids from the picky server # and then populate the result with models (rendered, even). # get '/search/full' do results = BooksSearch.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 # For live results, you'd actually go directly to the search server without taking the detour. # get '/search/live' do BooksSearch.search_unparsed params[:query], :offset => params[:offset] end helpers do def js path "<script src='javascripts/#{path}.js' type='text/javascript'></script>" end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
picky-generators-4.12.1 | prototypes/client/sinatra/app.rb |
picky-generators-4.12.0 | prototypes/client/sinatra/app.rb |
picky-generators-4.11.3 | prototypes/client/sinatra/app.rb |