Created
October 24, 2011 18:57
-
-
Save lilyszajn/1309818 to your computer and use it in GitHub Desktop.
High Five Ruby app with jquery
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 'rubygems' | |
require 'sinatra' | |
require 'open-uri' | |
get "/highFive.jsonp" do | |
content_type :jsonp | |
open("http://www.itpcakemix.com/project/HI5SON!!").read | |
end | |
get "/" do | |
<<-CRAZYKAT | |
<html> | |
<head> | |
<title></title> | |
<script src="http://code.jquery.com/jquery-1.4.2.min.js" ></script> | |
<script> | |
var apikey = "2794b427c3570f8b21835f18368f407a" | |
var photoid = "results.doc.photoid" | |
var flickrUrl = "http://api.flickr.com/services/rest/?method=flickr.photos.getSizes&api_key="+ apikey+"&photo_id="+ "photoid" +"&format=json&jsoncallback=?" | |
$(window).load(function () { | |
/*$.getJSONP("/~lrs372/highFive/highFive.jsonp", function(data)){ | |
for( var i = 0; i < data.rows.length){ | |
var photoid = data.rows[i].doc.photoid; | |
$.getJSON(flickrUrl, function(data) { | |
result = data.rows[0]; }) | |
// console.log(data.sizes.size[3].source); | |
console.log(data); | |
//console.log(results.doc) | |
addy = data.sizes.size[3].source | |
$('#photos').html('<img src = "' + addy + '"/>'); | |
}); | |
}*/ | |
/*}); | |
$.getJSON(flickrUrl, function(data){ | |
result = data.rows[0]; }) | |
// console.log(data.sizes.size[3].source); | |
console.log(data); | |
//console.log(results.doc) | |
//var results = data.rows; | |
// for(i data.rows) */ | |
addy = data.sizes.size[3].source | |
$('#photos').html('<img src = "' + addy + '"/>'); | |
}); | |
}); */ | |
</script> | |
</head> | |
<body> | |
<h1>Results</h1> | |
<div id="photos"> | |
</div> | |
</body> | |
</html> | |
CRAZYKAT | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment