Skip to content
Browse files

Add comments.

  • Loading branch information...
1 parent 52e2791 commit 96894c6263bccb163ae0bd7f8191f1b79d4f4440 @eric eric committed Aug 9, 2008
Showing with 9 additions and 3 deletions.
  1. +9 −3 lib/gistr.rb
View
12 lib/gistr.rb
@@ -16,10 +16,16 @@ def gist_code
return @gist_code if @gist_code
js = open("http://gist.github.com/#{@gist_id}.js").read
+
+ # Unescape the js into HTML
code = js.scan(/document.write\('([^']*)'/).flatten.last.gsub("\\\n", "\n")
h = Hpricot(code)
+ # Remove the <pre> tag.
+ #
+ # Tumblr wrap lines at of HTML at times and having the additional
+ # whitespace in a <pre> is very undesirable.
h.search('pre').each do |pre|
pre.swap(pre.inner_html)
end
@@ -30,11 +36,11 @@ def gist_code
private
def post_to_tumblr(email, password, title, body)
Net::HTTP.start("www.tumblr.com") do |http|
- req = Net::HTTP::Post.new "/api/write"
+ req = Net::HTTP::Post.new("/api/write")
req.set_form_data :email => email, :password => password,
- :title => title, :body => body
+ :title => title, :body => body, :format => 'html'
- http.request req
+ http.request(req)
end
end
end

0 comments on commit 96894c6

Please sign in to comment.
Something went wrong with that request. Please try again.