Skip to content

Instantly share code, notes, and snippets.

@timhodson
Created December 7, 2011 16:22
Show Gist options
  • Save timhodson/1443436 to your computer and use it in GitHub Desktop.
Save timhodson/1443436 to your computer and use it in GitHub Desktop.
require 'sinatra'
require 'kasabi'
get '/' do
dataset = Kasabi::Dataset.new("http://data.kasabi.com/dataset/nasa", :apikey => ENV["KASABI_API_KEY"])
@query = params[:query] || "apollo"
@results = dataset.search_api_client.search(@query)
template =<<-EOL
<html>
<head>
<title>Kasabi</title>
<link rel="stylesheet" href="http://twitter.github.com/bootstrap/1.3.0/bootstrap.min.css">
</head>
<body>
<div class="container">
<h1>Search Results: <%= @query %></h1>
<p>Results of searching the NASA dataset for <%= @query %></p>
<table>
<tr><th>URI</th><th>Title</th><th>Rank</th></tr>
<% @results["results"].each do |hit| %>
<tr>
<td><%= hit["uri"] %></td>
<td><%= hit["title"] %></td>
<td><%= hit["score"] %></td>
</tr>
<% end %>
</table>
</div>
</body>
</html>
EOL
erb template
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment