Created
December 7, 2011 16:22
-
-
Save timhodson/1443436 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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