forked from oesmith/puffing-billy
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* `em-http-client` has issues with large gzip responses - stripping gzip headers for now as a workaround. * Fix issue with UTF8/BINARY encodings in responses. * Add Tumblr API example.
- Loading branch information
Showing
6 changed files
with
80 additions
and
16 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#!/usr/bin/env ruby | ||
require 'billy' | ||
Billy::Proxy.new.start(false) |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<!doctype html> | ||
<body> | ||
<h1>Latest news</h1> | ||
<div id="news"></div> | ||
|
||
<script type='text/javascript' src='http://code.jquery.com/jquery-1.8.2.min.js'></script> | ||
<script type='text/javascript'> | ||
$(function () { | ||
var url = 'http://blog.howmanyleft.co.uk/api/read/json?callback=?&type=text&num=3&filter=text'; | ||
$.getJSON(url, function (data) { | ||
$.each(data.posts, function (idx, post) { | ||
var title = post['regular-title']; | ||
var href = post['url-with-slug']; | ||
var body = post['regular-body']; | ||
$('#news').append( | ||
'<h3><a href="' + href + '">' + title + '</a></h3>' + | ||
'<p>' + body + '</p>'); | ||
}); | ||
}); | ||
}) | ||
</script> | ||
</body> |
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
require 'spec_helper' | ||
|
||
describe 'Tumblr API example', :type => :request, :js => true do | ||
before do | ||
proxy.stub('http://blog.howmanyleft.co.uk/api/read/json').and_return( | ||
:jsonp => { | ||
:posts => [ | ||
{ | ||
'regular-title' => 'News Item 1', | ||
'url-with-slug' => 'http://example.com/news/1', | ||
'regular-body' => 'News item 1 content here' | ||
}, | ||
{ | ||
'regular-title' => 'News Item 2', | ||
'url-with-slug' => 'http://example.com/news/2', | ||
'regular-body' => 'News item 2 content here' | ||
} | ||
] | ||
}) | ||
end | ||
|
||
it 'should show news stories', :js => true do | ||
visit '/tumblr_api.html' | ||
page.should have_link('News Item 1', :href => 'http://example.com/news/1') | ||
page.should have_content('News item 1 content here') | ||
page.should have_link('News Item 2', :href => 'http://example.com/news/2') | ||
page.should have_content('News item 2 content here') | ||
end | ||
end | ||
|