fix story caching stuff once and for all

This commit is contained in:
joshua stein 2014-03-20 11:41:33 -05:00
parent c09542a80a
commit 4c0aaf7c2e
2 changed files with 10 additions and 6 deletions

View file

@ -114,6 +114,7 @@ class Sponge
end
host = Net::HTTP.new(ip.to_s, uri.port)
host.read_timeout = self.timeout
if self.debug
host.set_debug_output $stdout
end
@ -161,12 +162,10 @@ class Sponge
end
res = nil
Timeout.timeout(self.timeout) do
if method == :post
res = host.post(path, post_data, headers)
else
res = host.get(path, headers)
end
if method == :post
res = host.post(path, post_data, headers)
else
res = host.get(path, headers)
end
if res.get_fields("Set-Cookie")

View file

@ -27,9 +27,14 @@ class StoryCacher
if res.present?
j = JSON.parse(res)
# turn newlines into double newlines, so they become paragraphs
j["text"].gsub!("\n", "\n\n")
while j["text"].match("\n\n\n")
j["text"].gsub!("\n\n\n", "\n\n")
end
return j["text"]
end
rescue => e